リビジョン 374
trunk/src/ProcessManagement/ProcessManagement.sln | ||
---|---|---|
1 |
|
|
2 |
Microsoft Visual Studio Solution File, Format Version 12.00 |
|
3 |
# Visual Studio 2013 |
|
4 |
VisualStudioVersion = 12.0.40629.0 |
|
5 |
MinimumVisualStudioVersion = 10.0.40219.1 |
|
6 |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessManagement", "ProcessManagement\ProcessManagement.csproj", "{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}" |
|
7 |
EndProject |
|
8 |
Global |
|
9 |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
10 |
Debug|Any CPU = Debug|Any CPU |
|
11 |
Debug|Mixed Platforms = Debug|Mixed Platforms |
|
12 |
Debug|x64 = Debug|x64 |
|
13 |
Debug|x86 = Debug|x86 |
|
14 |
Release|Any CPU = Release|Any CPU |
|
15 |
Release|Mixed Platforms = Release|Mixed Platforms |
|
16 |
Release|x64 = Release|x64 |
|
17 |
Release|x86 = Release|x86 |
|
18 |
EndGlobalSection |
|
19 |
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
20 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Debug|Any CPU.ActiveCfg = Debug|x86 |
|
21 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Debug|Any CPU.Build.0 = Debug|x86 |
|
22 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 |
|
23 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Debug|Mixed Platforms.Build.0 = Debug|x86 |
|
24 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Debug|x64.ActiveCfg = Debug|x64 |
|
25 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Debug|x64.Build.0 = Debug|x64 |
|
26 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Debug|x86.ActiveCfg = Debug|x86 |
|
27 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Debug|x86.Build.0 = Debug|x86 |
|
28 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Release|Any CPU.ActiveCfg = Release|x86 |
|
29 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Release|Any CPU.Build.0 = Release|x86 |
|
30 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Release|Mixed Platforms.ActiveCfg = Release|x86 |
|
31 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Release|Mixed Platforms.Build.0 = Release|x86 |
|
32 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Release|x64.ActiveCfg = Release|x86 |
|
33 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Release|x64.Build.0 = Release|x86 |
|
34 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Release|x86.ActiveCfg = Release|x86 |
|
35 |
{BAF227D6-7D1E-4D46-AD17-B93F2C60E41B}.Release|x86.Build.0 = Release|x86 |
|
36 |
EndGlobalSection |
|
37 |
GlobalSection(SolutionProperties) = preSolution |
|
38 |
HideSolutionNode = FALSE |
|
39 |
EndGlobalSection |
|
40 |
EndGlobal |
trunk/src/ProcessManagement/ProcessManagement/DB/Oracle/OracleProcess.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Collections; |
|
4 |
using System.Data; |
|
5 |
using System.Linq; |
|
6 |
using System.Text; |
|
7 |
|
|
8 |
using Oracle.ManagedDataAccess.Client; |
|
9 |
using log4net; |
|
10 |
using log4net.Appender; |
|
11 |
using log4net.Repository.Hierarchy; |
|
12 |
|
|
13 |
using ProcessManagement.DB.Core; |
|
14 |
|
|
15 |
namespace ProcessManagement.DB.Oracle |
|
16 |
{ |
|
17 |
/// <summary> |
|
18 |
/// Oracle使用共通ラッパークラス |
|
19 |
/// </summary> |
|
20 |
public class OracleProcess : ABaseDBProcess |
|
21 |
{ |
|
22 |
#region コンストラクタ |
|
23 |
/// <summary> |
|
24 |
/// コンストラクタ。 |
|
25 |
/// </summary> |
|
26 |
/// <param name="connectionString">接続文字列</param> |
|
27 |
public OracleProcess(String connectionString) |
|
28 |
: base(connectionString) |
|
29 |
{ |
|
30 |
} |
|
31 |
#endregion |
|
32 |
|
|
33 |
#region メソッド |
|
34 |
/// <summary> |
|
35 |
/// Connectionを取得。 |
|
36 |
/// </summary> |
|
37 |
/// <param name="connectionString"></param> |
|
38 |
/// <returns>Connection</returns> |
|
39 |
public override IDbConnection getConnection(String connectionString) |
|
40 |
{ |
|
41 |
return new OracleConnection(connectionString); |
|
42 |
} |
|
43 |
|
|
44 |
#endregion |
|
45 |
} |
|
46 |
} |
trunk/src/ProcessManagement/ProcessManagement/DB/Core/DBCommon.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
|
|
6 |
using log4net; |
|
7 |
using ProcessManagement.Common; |
|
8 |
|
|
9 |
namespace ProcessManagement.DB.Core |
|
10 |
{ |
|
11 |
/// <summary> |
|
12 |
/// データベース共通接続クラス |
|
13 |
/// </summary> |
|
14 |
public class DBCommon |
|
15 |
{ |
|
16 |
#region 定義部 |
|
17 |
/// <summary> |
|
18 |
/// データベース接続共通クラスインスタンスハンドル |
|
19 |
/// </summary> |
|
20 |
private static DBCommon m_instance = new DBCommon(); |
|
21 |
/// <summary> |
|
22 |
/// log4netログを使用する |
|
23 |
/// </summary> |
|
24 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
25 |
#endregion |
|
26 |
|
|
27 |
#region 変数 |
|
28 |
/// <summary> |
|
29 |
/// DB接続情報 |
|
30 |
/// </summary> |
|
31 |
private string m_dbconnectString = string.Empty; |
|
32 |
#endregion |
|
33 |
|
|
34 |
#region コンストラクタ |
|
35 |
/// <summary> |
|
36 |
/// 何もしない |
|
37 |
/// </summary> |
|
38 |
#endregion |
|
39 |
|
|
40 |
#region プロパティ |
|
41 |
/// <summary> |
|
42 |
///インスタンス |
|
43 |
/// </summary> |
|
44 |
public static DBCommon Instance |
|
45 |
{ |
|
46 |
get { return m_instance; } |
|
47 |
} |
|
48 |
/// <summary> |
|
49 |
/// 接続文字列取得 |
|
50 |
/// </summary> |
|
51 |
public string DBConnectString |
|
52 |
{ |
|
53 |
get { return m_dbconnectString; } |
|
54 |
} |
|
55 |
#endregion |
|
56 |
|
|
57 |
#region メソッド |
|
58 |
/// <summary> |
|
59 |
/// 初期化メソッド |
|
60 |
/// </summary> |
|
61 |
public void Initialize() |
|
62 |
{ |
|
63 |
// DB接続情報作成 |
|
64 |
m_dbconnectString = string.Format("User Id={0};", CommonMotions.DFRModel.DBConnect.DBUser); |
|
65 |
m_dbconnectString += string.Format("Password={0};", CommonMotions.DFRModel.DBConnect.Password); |
|
66 |
m_dbconnectString += string.Format("Data Source={0};", CommonMotions.DFRModel.DBConnect.DBDataSource); |
|
67 |
//m_dbconnectString += "Pooling=false"; |
|
68 |
} |
|
69 |
|
|
70 |
#endregion |
|
71 |
} |
|
72 |
} |
trunk/src/ProcessManagement/ProcessManagement/DB/Core/ABaseDBProcess.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Data; |
|
4 |
using System.Linq; |
|
5 |
using System.Text; |
|
6 |
using System.Collections; |
|
7 |
/// Oracle |
|
8 |
using Oracle.ManagedDataAccess.Types; |
|
9 |
using Oracle.ManagedDataAccess.Client; |
|
10 |
|
|
11 |
using log4net; |
|
12 |
using log4net.Appender; |
|
13 |
using log4net.Repository.Hierarchy; |
|
14 |
|
|
15 |
using ProcessManagement.Common; |
|
16 |
|
|
17 |
namespace ProcessManagement.DB.Core |
|
18 |
{ |
|
19 |
/// <summary> |
|
20 |
/// データベース共通抽象クラス |
|
21 |
/// </summary> |
|
22 |
public abstract class ABaseDBProcess : IBaseDB |
|
23 |
{ |
|
24 |
#region ログ定義 |
|
25 |
/// <summary> |
|
26 |
/// log4netログを使用する |
|
27 |
/// </summary> |
|
28 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
29 |
#endregion |
|
30 |
|
|
31 |
#region メンバ変数 |
|
32 |
/// <summary> |
|
33 |
/// DB接続 |
|
34 |
/// </summary> |
|
35 |
protected IDbConnection m_connection = null; |
|
36 |
/// <summary> |
|
37 |
/// 接続有無(true:接続中) |
|
38 |
/// </summary> |
|
39 |
protected bool m_isConnect = false; |
|
40 |
/// <summary> |
|
41 |
/// トランザクション |
|
42 |
/// </summary> |
|
43 |
protected IDbTransaction m_transaction = null; |
|
44 |
/// <summary> |
|
45 |
/// 接続文字列 |
|
46 |
/// </summary> |
|
47 |
protected String m_connectionString = null; |
|
48 |
|
|
49 |
#endregion |
|
50 |
|
|
51 |
#region コンストラクタ |
|
52 |
|
|
53 |
/// <summary> |
|
54 |
/// コンストラクタ |
|
55 |
/// </summary> |
|
56 |
/// <param name="connectionString">接続文字列</param> |
|
57 |
public ABaseDBProcess(String connectionString) |
|
58 |
{ |
|
59 |
//接続文字列セット |
|
60 |
this.m_connectionString = connectionString; |
|
61 |
} |
|
62 |
#endregion |
|
63 |
|
|
64 |
#region プロパティ |
|
65 |
/// <summary> |
|
66 |
/// DCコネクション |
|
67 |
/// </summary> |
|
68 |
public IDbConnection DBConnection |
|
69 |
{ |
|
70 |
get { return m_connection; } |
|
71 |
set { m_connection = value; } |
|
72 |
} |
|
73 |
#endregion |
|
74 |
|
|
75 |
#region プライベートメソッド |
|
76 |
/// <summary> |
|
77 |
/// 接続の確立判断。 |
|
78 |
/// </summary> |
|
79 |
/// <returns>true:接続確立 false:接続無</returns> |
|
80 |
private bool isConnect() |
|
81 |
{ |
|
82 |
//接続されていない場合 |
|
83 |
if (this.m_connection == null || !this.m_isConnect) return false; |
|
84 |
|
|
85 |
return true; |
|
86 |
} |
|
87 |
|
|
88 |
/// <summary> |
|
89 |
/// パラメータの値を取得する |
|
90 |
/// </summary> |
|
91 |
/// <param name="value">値</param> |
|
92 |
/// <returns>パラメータの値</returns> |
|
93 |
protected object getParamValue(object value) |
|
94 |
{ |
|
95 |
if (value != null) return value; |
|
96 |
|
|
97 |
return DBNull.Value; |
|
98 |
} |
|
99 |
#endregion |
|
100 |
|
|
101 |
#region コネクション接続 |
|
102 |
/// <summary> |
|
103 |
/// Connectionを取得。 |
|
104 |
/// </summary> |
|
105 |
/// <param name="connectionString"></param> |
|
106 |
/// <returns>Connectionのオブジェクト</returns> |
|
107 |
public virtual IDbConnection getConnection(String connectionString) |
|
108 |
{ |
|
109 |
return new OracleConnection(connectionString); |
|
110 |
} |
|
111 |
|
|
112 |
#endregion |
|
113 |
|
|
114 |
#region connect |
|
115 |
/// <summary> |
|
116 |
/// コネクト処理。 |
|
117 |
/// </summary> |
|
118 |
public void connect() |
|
119 |
{ |
|
120 |
try |
|
121 |
{ |
|
122 |
//接続有無=無に設定 |
|
123 |
this.m_isConnect = false; |
|
124 |
|
|
125 |
//接続済みの場合 |
|
126 |
if (this.m_connection != null) |
|
127 |
{ |
|
128 |
//接続をClose |
|
129 |
this.m_connection.Close(); |
|
130 |
//初期化 |
|
131 |
this.m_connection = null; |
|
132 |
} |
|
133 |
|
|
134 |
//Connectionを取得 |
|
135 |
this.m_connection = getConnection(m_connectionString); |
|
136 |
|
|
137 |
//Open |
|
138 |
this.m_connection.Open(); |
|
139 |
//接続有無=ありに設定 |
|
140 |
this.m_isConnect = true; |
|
141 |
} |
|
142 |
catch (Exception ex) |
|
143 |
{ |
|
144 |
logger.ErrorFormat("{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, m_connectionString); |
|
145 |
} |
|
146 |
} |
|
147 |
#endregion |
|
148 |
|
|
149 |
#region close |
|
150 |
/// <summary> |
|
151 |
/// クローズ処理。 |
|
152 |
/// </summary> |
|
153 |
/// <returns>true:切断成功 false:接続無</returns> |
|
154 |
public bool close() |
|
155 |
{ |
|
156 |
try |
|
157 |
{ |
|
158 |
//接続が確立されていない場合は処理なし |
|
159 |
if (!isConnect()) return false; |
|
160 |
|
|
161 |
//トランザクションを破棄する |
|
162 |
if (this.m_transaction != null) |
|
163 |
{ |
|
164 |
this.m_transaction.Dispose(); |
|
165 |
this.m_transaction = null; |
|
166 |
} |
|
167 |
|
|
168 |
//接続をClose&破棄する |
|
169 |
if (this.m_connection != null) |
|
170 |
{ |
|
171 |
this.m_connection.Close(); |
|
172 |
this.m_connection.Dispose(); |
|
173 |
this.m_connection = null; |
|
174 |
} |
|
175 |
|
|
176 |
//接続有無なしに設定 |
|
177 |
this.m_isConnect = false; |
|
178 |
|
|
179 |
return true; |
|
180 |
} |
|
181 |
catch (Exception ex) |
|
182 |
{ |
|
183 |
logger.ErrorFormat("{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, m_connectionString); |
|
184 |
return false; |
|
185 |
} |
|
186 |
} |
|
187 |
#endregion |
|
188 |
|
|
189 |
#region begintran |
|
190 |
/// <summary> |
|
191 |
/// トランザクション開始。 |
|
192 |
/// </summary> |
|
193 |
/// <returns>true:開始成功 false:接続無</returns> |
|
194 |
public bool beginTran() |
|
195 |
{ |
|
196 |
try |
|
197 |
{ |
|
198 |
//接続が確立されていない場合、処理なし |
|
199 |
if (!isConnect()) return false; |
|
200 |
|
|
201 |
//トランザクション開始 |
|
202 |
this.m_transaction = m_connection.BeginTransaction(); |
|
203 |
|
|
204 |
return true; |
|
205 |
} |
|
206 |
catch (Exception ex) |
|
207 |
{ |
|
208 |
logger.ErrorFormat("{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, m_connectionString); |
|
209 |
return false; |
|
210 |
} |
|
211 |
} |
|
212 |
#endregion |
|
213 |
|
|
214 |
#region commit |
|
215 |
/// <summary> |
|
216 |
/// コミット。 |
|
217 |
/// </summary> |
|
218 |
/// <returns>true:Commit成功 false:トランザクション無・接続無</returns> |
|
219 |
public bool commit() |
|
220 |
{ |
|
221 |
try |
|
222 |
{ |
|
223 |
//接続が確立されていない場合は処理なし |
|
224 |
if (!isConnect()) return false; |
|
225 |
|
|
226 |
//トランザクションが開始されていない場合、処理なし |
|
227 |
if (this.m_transaction == null) return false; |
|
228 |
|
|
229 |
//コミット |
|
230 |
m_transaction.Commit(); |
|
231 |
|
|
232 |
return true; |
|
233 |
} |
|
234 |
catch (Exception ex) |
|
235 |
{ |
|
236 |
//ログ出力 |
|
237 |
logger.ErrorFormat("{0}:{1}", CommonMotions.GetMethodName(2), ex.Message); |
|
238 |
return false; |
|
239 |
} |
|
240 |
finally |
|
241 |
{ |
|
242 |
//トランザクションを破棄する |
|
243 |
if (this.m_transaction != null) |
|
244 |
{ |
|
245 |
this.m_transaction.Dispose(); |
|
246 |
this.m_transaction = null; |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
#endregion |
|
251 |
|
|
252 |
#region rollback |
|
253 |
/// <summary> |
|
254 |
/// ロールバック。 |
|
255 |
/// </summary> |
|
256 |
/// <returns>true:Rollback成功 false:トランザクション無・接続無</returns> |
|
257 |
public bool rollback() |
|
258 |
{ |
|
259 |
try |
|
260 |
{ |
|
261 |
//接続が確立されていない場合は処理なし |
|
262 |
if (!isConnect()) return false; |
|
263 |
|
|
264 |
//トランザクションが開始されていない場合は処理なし |
|
265 |
if (this.m_transaction == null) return false; |
|
266 |
|
|
267 |
//ロールバック |
|
268 |
this.m_transaction.Rollback(); |
|
269 |
|
|
270 |
return true; |
|
271 |
} |
|
272 |
catch (Exception ex) |
|
273 |
{ |
|
274 |
//ログ出力 |
|
275 |
logger.ErrorFormat("{0}:{1}", CommonMotions.GetMethodName(2), ex.Message); |
|
276 |
return false; |
|
277 |
} |
|
278 |
finally |
|
279 |
{ |
|
280 |
//トランザクションを破棄する |
|
281 |
if (this.m_transaction != null) |
|
282 |
{ |
|
283 |
this.m_transaction.Dispose(); |
|
284 |
this.m_transaction = null; |
|
285 |
} |
|
286 |
} |
|
287 |
} |
|
288 |
#endregion |
|
289 |
|
|
290 |
#region ExecuteReader |
|
291 |
/// <summary> |
|
292 |
/// オラクルフリーSQLリーダー |
|
293 |
/// </summary> |
|
294 |
/// <param name="strSql">検索SQL</param> |
|
295 |
/// <param name="arData">取得データ</param> |
|
296 |
/// <returns>成功時:true 失敗時:false</returns> |
|
297 |
public bool ExecuteReader(string strSql, ref ArrayList arData, bool bconnect = true) |
|
298 |
{ |
|
299 |
//Oracle インターフェース |
|
300 |
OracleCommand oracmd = new OracleCommand(); |
|
301 |
OracleDataReader orareader = null; |
|
302 |
try |
|
303 |
{ |
|
304 |
// 接続 |
|
305 |
if (bconnect) this.connect(); |
|
306 |
|
|
307 |
// OracleCommand・OracleDataReader作成 |
|
308 |
oracmd.Connection = (OracleConnection)m_connection; |
|
309 |
|
|
310 |
// SQLセット |
|
311 |
oracmd.CommandText = strSql; |
|
312 |
|
|
313 |
orareader = oracmd.ExecuteReader(); |
|
314 |
|
|
315 |
int iFeildcnt = oracmd.ExecuteReader().FieldCount; |
|
316 |
// 読込 |
|
317 |
while (orareader.Read()) |
|
318 |
{ |
|
319 |
object[] objwrk = new object[iFeildcnt]; |
|
320 |
|
|
321 |
orareader.GetOracleValues(objwrk); |
|
322 |
|
|
323 |
// null抑制 |
|
324 |
int i = 0; |
|
325 |
foreach (object www in objwrk) |
|
326 |
{ |
|
327 |
objwrk[i++] = www.ToString().Equals("null") ? "" : www; |
|
328 |
} |
|
329 |
|
|
330 |
arData.Add(objwrk); |
|
331 |
|
|
332 |
} |
|
333 |
return true; |
|
334 |
} |
|
335 |
catch (OracleException oraex) |
|
336 |
{ |
|
337 |
logger.ErrorFormat("オラクルエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), oraex.Message, strSql); |
|
338 |
return false; |
|
339 |
} |
|
340 |
catch (Exception ex) |
|
341 |
{ |
|
342 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strSql); |
|
343 |
return false; |
|
344 |
} |
|
345 |
finally |
|
346 |
{ |
|
347 |
if (orareader != null) |
|
348 |
{ |
|
349 |
orareader.Close(); |
|
350 |
orareader.Dispose(); |
|
351 |
orareader = null; |
|
352 |
} |
|
353 |
oracmd.Dispose(); |
|
354 |
oracmd = null; |
|
355 |
|
|
356 |
// 切断 |
|
357 |
if (bconnect) this.close(); |
|
358 |
} |
|
359 |
} |
|
360 |
#endregion |
|
361 |
|
|
362 |
#region ExecuteNonQuery |
|
363 |
/// <summary> |
|
364 |
/// オラクルフリーExecuteNonQuery |
|
365 |
/// </summary> |
|
366 |
/// <param name="strSql">実行SQL</param> |
|
367 |
/// <returns>成功時:true 失敗時:false</returns> |
|
368 |
public bool ExecuteNonQuery(string strSql, bool bconnect = true) |
|
369 |
{ |
|
370 |
//Oracle インターフェース |
|
371 |
OracleCommand oracmd = new OracleCommand(); |
|
372 |
|
|
373 |
try |
|
374 |
{ |
|
375 |
// 接続 |
|
376 |
if (bconnect) this.connect(); |
|
377 |
|
|
378 |
// コネクションセット |
|
379 |
oracmd.Connection = (OracleConnection)m_connection; |
|
380 |
|
|
381 |
// トランザクション |
|
382 |
if (bconnect) |
|
383 |
{ |
|
384 |
if (!this.beginTran()) return false; |
|
385 |
} |
|
386 |
|
|
387 |
// SQLセット |
|
388 |
oracmd.CommandText = strSql; |
|
389 |
//実行 |
|
390 |
if (oracmd.ExecuteNonQuery() == 0) |
|
391 |
{ |
|
392 |
// エラー時rollbackして処理終了 |
|
393 |
if (bconnect) this.rollback(); |
|
394 |
return false; |
|
395 |
} |
|
396 |
// 成功時Commit |
|
397 |
if (bconnect) |
|
398 |
{ |
|
399 |
if (!this.commit()) return false; |
|
400 |
} |
|
401 |
|
|
402 |
return true; |
|
403 |
} |
|
404 |
catch (OracleException oraex) |
|
405 |
{ |
|
406 |
logger.ErrorFormat("オラクルエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), oraex.Message, strSql); |
|
407 |
return false; |
|
408 |
} |
|
409 |
catch (Exception ex) |
|
410 |
{ |
|
411 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strSql); |
|
412 |
return false; |
|
413 |
} |
|
414 |
finally |
|
415 |
{ |
|
416 |
// 切断 |
|
417 |
if (bconnect) this.close(); |
|
418 |
|
|
419 |
oracmd.Dispose(); |
|
420 |
oracmd = null; |
|
421 |
} |
|
422 |
} |
|
423 |
#endregion |
|
424 |
} |
|
425 |
} |
trunk/src/ProcessManagement/ProcessManagement/DB/Core/IBase.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Data; |
|
4 |
using System.Linq; |
|
5 |
using System.Text; |
|
6 |
|
|
7 |
namespace ProcessManagement.DB.Core |
|
8 |
{ |
|
9 |
/// <summary> |
|
10 |
/// データベース共通インターフェースクラス |
|
11 |
/// </summary> |
|
12 |
public interface IBaseDB |
|
13 |
{ |
|
14 |
/// <summary> |
|
15 |
/// コネクト処理。 |
|
16 |
/// </summary> |
|
17 |
void connect(); |
|
18 |
|
|
19 |
/// <summary> |
|
20 |
/// クローズ処理。 |
|
21 |
/// </summary> |
|
22 |
bool close(); |
|
23 |
|
|
24 |
/// <summary> |
|
25 |
/// トランザクション開始。 |
|
26 |
/// </summary> |
|
27 |
bool beginTran(); |
|
28 |
|
|
29 |
/// <summary> |
|
30 |
/// コミット。 |
|
31 |
/// </summary> |
|
32 |
bool commit(); |
|
33 |
|
|
34 |
/// <summary> |
|
35 |
/// ロールバック。 |
|
36 |
/// </summary> |
|
37 |
bool rollback(); |
|
38 |
|
|
39 |
} |
|
40 |
} |
trunk/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOProcessApproval.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Collections; |
|
6 |
|
|
7 |
using log4net; |
|
8 |
using Oracle.ManagedDataAccess.Client; |
|
9 |
|
|
10 |
using ProcessManagement.DB.Oracle; |
|
11 |
using ProcessManagement.DB.Core; |
|
12 |
using ProcessManagement.DataModel; |
|
13 |
|
|
14 |
using ProcessManagement.Common; |
|
15 |
|
|
16 |
namespace ProcessManagement.DB.IOAccess |
|
17 |
{ |
|
18 |
/// <summary> |
|
19 |
/// 承認データアクセスクラス |
|
20 |
/// </summary> |
|
21 |
public class IOProcessApproval : OracleProcess |
|
22 |
{ |
|
23 |
#region 定義部 |
|
24 |
/// <summary> |
|
25 |
/// log4netログを使用する |
|
26 |
/// </summary> |
|
27 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
28 |
#endregion |
|
29 |
|
|
30 |
#region 定数 |
|
31 |
/// <summary> |
|
32 |
/// 承認データフィールド並び |
|
33 |
/// </summary> |
|
34 |
public enum ColumnName |
|
35 |
{ |
|
36 |
ConstructionCode, |
|
37 |
ApprovalCode, |
|
38 |
OrderNo, |
|
39 |
SeqNo, |
|
40 |
PersonCode, |
|
41 |
PetitionApprovalDate, |
|
42 |
ApprovalLimitDates, |
|
43 |
ApprovalStatus, |
|
44 |
InputComment, |
|
45 |
EntryDate, |
|
46 |
UpdateDate |
|
47 |
} |
|
48 |
#endregion |
|
49 |
|
|
50 |
#region コンストラクタ |
|
51 |
/// <summary> |
|
52 |
/// コンストラクタ |
|
53 |
/// </summary> |
|
54 |
/// <param name="ConnectionString"></param> |
|
55 |
public IOProcessApproval() |
|
56 |
: base(DBCommon.Instance.DBConnectString) |
|
57 |
{ |
|
58 |
} |
|
59 |
|
|
60 |
#endregion |
|
61 |
|
|
62 |
#region 承認データ検索文字列作成 |
|
63 |
/// <summary> |
|
64 |
/// 承認データ検索文字列作成 |
|
65 |
/// </summary> |
|
66 |
/// <param name="AddSQLString">検索条件SQL文字列</param> |
|
67 |
/// <param name="data">承認データデータ</param> |
|
68 |
/// <returns>true:成功 false:失敗</returns> |
|
69 |
private string CreateSelectSQL() |
|
70 |
{ |
|
71 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
72 |
string strcmd = "SELECT"; |
|
73 |
strcmd += " ConstructionCode"; |
|
74 |
strcmd += ",ApprovalCode"; |
|
75 |
strcmd += ",OrderNo"; |
|
76 |
strcmd += ",SeqNo"; |
|
77 |
strcmd += ",PersonCode"; |
|
78 |
strcmd += ",TO_CHAR(PetitionApprovalDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
79 |
strcmd += ",TO_CHAR(ApprovalLimitDates, 'YYYY/MM/DD HH24:MI:ss')"; |
|
80 |
strcmd += ",ApprovalStatus"; |
|
81 |
strcmd += ",InputComment"; |
|
82 |
strcmd += ",TO_CHAR(EntryDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
83 |
strcmd += ",TO_CHAR(UpdateDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
84 |
strcmd += " FROM ProcessApproval"; |
|
85 |
|
|
86 |
return strcmd; |
|
87 |
} |
|
88 |
#endregion |
|
89 |
|
|
90 |
#region 承認データ検索(複数) |
|
91 |
/// <summary> |
|
92 |
/// 承認データ検索(複数) |
|
93 |
/// </summary> |
|
94 |
/// <param name="AddSQLString"></param> |
|
95 |
/// <param name="data"></param> |
|
96 |
/// <param name="bConnect"></param> |
|
97 |
/// <returns></returns> |
|
98 |
public bool SelectAction(string AddSQLString, ref List<ProcessApproval> data, bool bConnect = true) |
|
99 |
{ |
|
100 |
//Oracle インターフェース |
|
101 |
string strcmd = ""; |
|
102 |
ArrayList arData = new ArrayList(); |
|
103 |
|
|
104 |
try |
|
105 |
{ |
|
106 |
// SQL作成 |
|
107 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
108 |
|
|
109 |
// SQL実行 |
|
110 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
111 |
|
|
112 |
// データセット |
|
113 |
foreach (object[] objwrk in arData) |
|
114 |
{ |
|
115 |
ProcessApproval work = new ProcessApproval(); |
|
116 |
Reader2Struct(objwrk, ref work); |
|
117 |
data.Add(work); |
|
118 |
} |
|
119 |
|
|
120 |
return true; |
|
121 |
} |
|
122 |
catch (Exception ex) |
|
123 |
{ |
|
124 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
125 |
return false; |
|
126 |
} |
|
127 |
|
|
128 |
} |
|
129 |
#endregion |
|
130 |
|
|
131 |
#region 承認データ検索(1件) |
|
132 |
/// <summary> |
|
133 |
/// 承認データ検索(1件) |
|
134 |
/// </summary> |
|
135 |
/// <param name="AddSQLString"></param> |
|
136 |
/// <param name="data"></param> |
|
137 |
/// <param name="bConnect"></param> |
|
138 |
/// <returns></returns> |
|
139 |
public bool SelectAction(string AddSQLString, ref ProcessApproval data, bool bConnect = true) |
|
140 |
{ |
|
141 |
//Oracle インターフェース |
|
142 |
string strcmd = ""; |
|
143 |
ArrayList arData = new ArrayList(); |
|
144 |
|
|
145 |
try |
|
146 |
{ |
|
147 |
// SQL作成 |
|
148 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
149 |
|
|
150 |
// SQL実行 |
|
151 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
152 |
if (arData.Count == 0) return false; |
|
153 |
|
|
154 |
// データセット |
|
155 |
object[] objwrk = (object[])arData[0]; |
|
156 |
Reader2Struct(objwrk, ref data); |
|
157 |
|
|
158 |
return true; |
|
159 |
} |
|
160 |
catch (Exception ex) |
|
161 |
{ |
|
162 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
163 |
return false; |
|
164 |
} |
|
165 |
|
|
166 |
} |
|
167 |
#endregion |
|
168 |
|
|
169 |
#region 承認データ追加(複数) |
|
170 |
/// <summary> |
|
171 |
/// 承認データ追加(複数) |
|
172 |
/// </summary> |
|
173 |
/// <param name="data">承認データデータ</param> |
|
174 |
/// <returns>true:成功 false:失敗</returns> |
|
175 |
public bool InsertAction(List<ProcessApproval> data, bool bConnect = true) |
|
176 |
{ |
|
177 |
string strcmd = ""; |
|
178 |
try |
|
179 |
{ |
|
180 |
foreach (ProcessApproval work in data) |
|
181 |
{ |
|
182 |
if (!InsertAction(work, bConnect)) return false; |
|
183 |
} |
|
184 |
return true; |
|
185 |
} |
|
186 |
catch (Exception ex) |
|
187 |
{ |
|
188 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
189 |
return false; |
|
190 |
} |
|
191 |
} |
|
192 |
#endregion |
|
193 |
|
|
194 |
#region 承認データ追加(1件) |
|
195 |
/// <summary> |
|
196 |
/// 承認データ追加(1件) |
|
197 |
/// </summary> |
|
198 |
/// <param name="data"></param> |
|
199 |
/// <param name="bConnect"></param> |
|
200 |
/// <returns></returns> |
|
201 |
public bool InsertAction(ProcessApproval data, bool bConnect = true) |
|
202 |
{ |
|
203 |
string strcmd = ""; |
|
204 |
try |
|
205 |
{ |
|
206 |
|
|
207 |
strcmd = "INSERT INTO ProcessApproval"; |
|
208 |
|
|
209 |
strcmd += " ("; |
|
210 |
bool bFirst = true; |
|
211 |
foreach (var gender in Enum.GetValues(typeof(ColumnName))) |
|
212 |
{ |
|
213 |
if (!bFirst) strcmd += " ,"; |
|
214 |
strcmd += gender.ToString(); |
|
215 |
bFirst = false; |
|
216 |
} |
|
217 |
strcmd += ") VALUES ("; |
|
218 |
|
|
219 |
strcmd += string.Format(" {0}", data.ConstructionCode.ToString()); |
|
220 |
strcmd += string.Format(", {0}", data.ApprovalCode.ToString()); |
|
221 |
strcmd += string.Format(", {0}", data.OrderNo.ToString()); |
|
222 |
strcmd += string.Format(", {0}", data.SeqNo.ToString()); |
|
223 |
strcmd += string.Format(", {0}", data.PersonCode.ToString()); |
|
224 |
strcmd += string.Format(", TO_DATE('{0}','YYYY/MM/DD HH24:MI:SS')", data.PetitionApprovalDate.ToString()); |
|
225 |
|
|
226 |
strcmd += string.Format(", TO_DATE('{0}','YYYY/MM/DD HH24:MI:SS')", data.ApprovalLimitDates.ToString()); |
|
227 |
strcmd += string.Format(", {0}", data.ApprovalStatus.ToString()); |
|
228 |
strcmd += string.Format(",'{0}'", data.InputComment.ToString()); |
|
229 |
|
|
230 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
231 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
232 |
strcmd = strcmd + ")"; |
|
233 |
|
|
234 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
235 |
|
|
236 |
return true; |
|
237 |
} |
|
238 |
catch (Exception ex) |
|
239 |
{ |
|
240 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
241 |
return false; |
|
242 |
} |
|
243 |
} |
|
244 |
#endregion |
|
245 |
|
|
246 |
#region 承認データ更新 |
|
247 |
/// <summary> |
|
248 |
/// 承認データ更新 |
|
249 |
/// </summary> |
|
250 |
/// <param name="AddSQLString">更新条件SQL文字列</param> |
|
251 |
/// <param name="data">承認データデータ</param> |
|
252 |
/// <returns>true:成功 false:失敗</returns> |
|
253 |
public bool UpdateAction(string AddSQLString, ProcessApproval data, bool bConnect = true) |
|
254 |
{ |
|
255 |
string strcmd = ""; |
|
256 |
try |
|
257 |
{ |
|
258 |
|
|
259 |
strcmd = "UPDATE ProcessApproval"; |
|
260 |
|
|
261 |
strcmd += " SET"; |
|
262 |
|
|
263 |
strcmd += string.Format(" ConstructionCode = {0}", data.ConstructionCode.ToString()); |
|
264 |
strcmd += string.Format(",ApprovalCode = {0}", data.ApprovalCode.ToString()); |
|
265 |
strcmd += string.Format(",OrderNo = {0}", data.OrderNo.ToString()); |
|
266 |
strcmd += string.Format(",SeqNo = {0}", data.SeqNo.ToString()); |
|
267 |
strcmd += string.Format(",PersonCode = {0}", data.PersonCode.ToString()); |
|
268 |
strcmd += string.Format(",PetitionApprovalDate = TO_DATE('{0}','YYYY/MM/DD HH24:MI:SS')", data.PetitionApprovalDate.ToString()); |
|
269 |
strcmd += string.Format(",ApprovalLimitDates = TO_DATE('{0}','YYYY/MM/DD HH24:MI:SS')", data.ApprovalLimitDates.ToString()); |
|
270 |
strcmd += string.Format(",ApprovalStatus = {0}", data.ApprovalStatus.ToString()); |
|
271 |
strcmd += string.Format(",InputComment = '{0}'", data.InputComment); |
|
272 |
|
|
273 |
strcmd += ", UpdateDate = TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
274 |
strcmd += AddSQLString; |
|
275 |
|
|
276 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
277 |
|
|
278 |
return true; |
|
279 |
} |
|
280 |
catch (Exception ex) |
|
281 |
{ |
|
282 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
283 |
return false; |
|
284 |
} |
|
285 |
} |
|
286 |
#endregion |
|
287 |
|
|
288 |
#region 承認データ削除 |
|
289 |
/// <summary> |
|
290 |
/// 承認データ削除 |
|
291 |
/// </summary> |
|
292 |
/// <param name="AddSQLString">削除条件SQL文字列</param> |
|
293 |
/// <param name="data">承認データデータ</param> |
|
294 |
/// <returns>true:成功 false:失敗</returns> |
|
295 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
|
296 |
{ |
|
297 |
//Oracle インターフェース |
|
298 |
string strcmd = ""; |
|
299 |
try |
|
300 |
{ |
|
301 |
strcmd = string.Format("{0}{1}", "DELETE FROM ProcessApproval", AddSQLString); |
|
302 |
|
|
303 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
304 |
|
|
305 |
return true; |
|
306 |
} |
|
307 |
catch (Exception ex) |
|
308 |
{ |
|
309 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
310 |
return false; |
|
311 |
} |
|
312 |
} |
|
313 |
#endregion |
|
314 |
|
|
315 |
#region 1項目更新処理 |
|
316 |
/// <summary> |
|
317 |
/// 1項目の更新を行う |
|
318 |
/// </summary> |
|
319 |
/// <returns></returns> |
|
320 |
public bool UpdateFeild(int ConstructionCode, int FeildNo, object value, bool bConnect = true, int ApprovalCode = 0, int OrderNo = 0, int SeqNo = 0) |
|
321 |
{ |
|
322 |
string strcmd = ""; |
|
323 |
try |
|
324 |
{ |
|
325 |
strcmd = "UPDATE ProcessApproval"; |
|
326 |
|
|
327 |
strcmd += " SET"; |
|
328 |
switch (FeildNo) |
|
329 |
{ |
|
330 |
case (int)ColumnName.ConstructionCode: |
|
331 |
strcmd += string.Format(" ConstructionCode = {0}", ((int)value).ToString()); |
|
332 |
break; |
|
333 |
case (int)ColumnName.ApprovalCode: |
|
334 |
strcmd += string.Format(" ApprovalCode = {0}", ((int)value).ToString()); |
|
335 |
break; |
|
336 |
case (int)ColumnName.OrderNo: |
|
337 |
strcmd += string.Format(" OrderNo = {0}", ((int)value).ToString()); |
|
338 |
break; |
|
339 |
case (int)ColumnName.SeqNo: |
|
340 |
strcmd += string.Format(" SeqNo = {0}", ((int)value).ToString()); |
|
341 |
break; |
|
342 |
case (int)ColumnName.PersonCode: |
|
343 |
strcmd += string.Format(" PersonCode = {0}", ((int)value).ToString()); |
|
344 |
break; |
|
345 |
case (int)ColumnName.PetitionApprovalDate: |
|
346 |
strcmd += string.Format(" PetitionApprovalDate = TO_DATE('{0}','YYYY/MM/DD')", ((DateTime)value).ToShortDateString()); |
|
347 |
break; |
|
348 |
case (int)ColumnName.ApprovalLimitDates: |
|
349 |
strcmd += string.Format(" ApprovalLimitDates = TO_DATE('{0}','YYYY/MM/DD')", ((DateTime)value).ToShortDateString()); |
|
350 |
break; |
|
351 |
case (int)ColumnName.ApprovalStatus: |
|
352 |
strcmd += string.Format(" ApprovalStatus = {0}", ((int)value).ToString()); |
|
353 |
break; |
|
354 |
case (int)ColumnName.InputComment: |
|
355 |
strcmd += string.Format(" InputComment = '{0}'", value.ToString()); |
|
356 |
break; |
|
357 |
} |
|
358 |
|
|
359 |
strcmd += ", UpdateDate = TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
360 |
strcmd += CreatePrimarykeyString(ConstructionCode, ApprovalCode, OrderNo, SeqNo); |
|
361 |
|
|
362 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
363 |
|
|
364 |
return true; |
|
365 |
} |
|
366 |
catch (Exception ex) |
|
367 |
{ |
|
368 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
369 |
return false; |
|
370 |
} |
|
371 |
} |
|
372 |
#endregion |
|
373 |
|
|
374 |
#region OracleDataReaderより構造体へセットする |
|
375 |
/// <summary> |
|
376 |
/// OracleDataReaderより構造体へセットする |
|
377 |
/// </summary> |
|
378 |
/// <param name="reader">OracleDataReader</param> |
|
379 |
/// <param name="wrk">構造体</param> |
|
380 |
public void Reader2Struct(object[] objwrk, ref ProcessApproval wrk) |
|
381 |
{ |
|
382 |
try |
|
383 |
{ |
|
384 |
// データ取得 |
|
385 |
wrk.ConstructionCode = int.Parse(objwrk[(int)ColumnName.ConstructionCode].ToString()); |
|
386 |
wrk.ApprovalCode = int.Parse(objwrk[(int)ColumnName.ApprovalCode].ToString()); |
|
387 |
wrk.OrderNo = int.Parse(objwrk[(int)ColumnName.OrderNo].ToString()); |
|
388 |
wrk.SeqNo = int.Parse(objwrk[(int)ColumnName.SeqNo].ToString()); |
|
389 |
wrk.PersonCode = int.Parse(objwrk[(int)ColumnName.PersonCode].ToString()); |
|
390 |
wrk.PetitionApprovalDate = DateTime.Parse(objwrk[(int)ColumnName.PetitionApprovalDate].ToString()); |
|
391 |
wrk.ApprovalLimitDates = DateTime.Parse(objwrk[(int)ColumnName.ApprovalLimitDates].ToString()); |
|
392 |
wrk.ApprovalStatus = int.Parse(objwrk[(int)ColumnName.ApprovalStatus].ToString()); |
|
393 |
wrk.InputComment = objwrk[(int)ColumnName.InputComment].ToString(); |
|
394 |
|
|
395 |
wrk.EntryDate = DateTime.Parse(objwrk[(int)ColumnName.EntryDate].ToString()); |
|
396 |
wrk.UpdateDate = DateTime.Parse(objwrk[(int)ColumnName.UpdateDate].ToString()); |
|
397 |
} |
|
398 |
catch (OracleException oraex) |
|
399 |
{ |
|
400 |
logger.ErrorFormat("オラクルエラー:{0}:{1}", CommonMotions.GetMethodName(), oraex.Message); |
|
401 |
} |
|
402 |
catch (Exception ex) |
|
403 |
{ |
|
404 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
405 |
} |
|
406 |
} |
|
407 |
#endregion |
|
408 |
|
|
409 |
#region 主キー検索の文字列を返す |
|
410 |
/// <summary> |
|
411 |
/// 主キー検索の文字列を返す |
|
412 |
/// </summary> |
|
413 |
/// <param name="BusinessTypeCode"></param> |
|
414 |
/// <returns>Where文字列</returns> |
|
415 |
public string CreatePrimarykeyString(int ConstructionCode, int ApprovalCode = 0, int OrderNo = 0, int SeqNo = 0, string APara = "") |
|
416 |
{ |
|
417 |
string strWork = string.Empty; |
|
418 |
try |
|
419 |
{ |
|
420 |
strWork = string.Format(" Where {0}ConstructionCode = {1}", APara, ConstructionCode.ToString()); |
|
421 |
if (ApprovalCode != 0) |
|
422 |
strWork += string.Format(" And {0}ApprovalCode = {1}", APara, ApprovalCode.ToString()); |
|
423 |
if (OrderNo != 0) |
|
424 |
strWork += string.Format(" And {0}OrderNo = {1}", APara, OrderNo.ToString()); |
|
425 |
if (SeqNo != 0) |
|
426 |
strWork += string.Format(" And {0}SeqNo = {1}", APara, SeqNo.ToString()); |
|
427 |
} |
|
428 |
catch (Exception ex) |
|
429 |
{ |
|
430 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork); |
|
431 |
} |
|
432 |
|
|
433 |
return strWork; |
|
434 |
} |
|
435 |
#endregion |
|
436 |
|
|
437 |
#region 受付番号の最大値を取得する |
|
438 |
/// <summary> |
|
439 |
/// 受付番号の最大値を取得する |
|
440 |
/// </summary> |
|
441 |
/// <param name="AddSQLString"></param> |
|
442 |
/// <param name="bConnect"></param> |
|
443 |
/// <returns></returns> |
|
444 |
public int SelectMaxOrderNoCount(string AddSQLString, bool bConnect = true) |
|
445 |
{ |
|
446 |
//Oracle インターフェース |
|
447 |
string strcmd = ""; |
|
448 |
ArrayList arData = new ArrayList(); |
|
449 |
int iRet = 0; |
|
450 |
try |
|
451 |
{ |
|
452 |
// SQL作成 |
|
453 |
strcmd = "SELECT NVL(MAX(OrderNo), 0) FROM ProcessApproval" + AddSQLString; |
|
454 |
|
|
455 |
// SQL実行 |
|
456 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return iRet; |
|
457 |
|
|
458 |
// データセット |
|
459 |
foreach (object[] objwrk in arData) |
|
460 |
{ |
|
461 |
if (objwrk[0].ToString().Equals("null")) |
|
462 |
iRet = 0; |
|
463 |
else |
|
464 |
iRet = int.Parse(objwrk[0].ToString()); |
|
465 |
} |
|
466 |
|
|
467 |
} |
|
468 |
catch (Exception ex) |
|
469 |
{ |
|
470 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
471 |
} |
|
472 |
return iRet; |
|
473 |
} |
|
474 |
#endregion |
|
475 |
|
|
476 |
#region 枝番の最大値を取得する |
|
477 |
/// <summary> |
|
478 |
/// 枝番の最大値を取得する |
|
479 |
/// </summary> |
|
480 |
/// <param name="AddSQLString"></param> |
|
481 |
/// <param name="bConnect"></param> |
|
482 |
/// <returns></returns> |
|
483 |
public int SelectMaxSeqNoCount(string AddSQLString, bool bConnect = true) |
|
484 |
{ |
|
485 |
//Oracle インターフェース |
|
486 |
string strcmd = ""; |
|
487 |
ArrayList arData = new ArrayList(); |
|
488 |
int iRet = 0; |
|
489 |
try |
|
490 |
{ |
|
491 |
// SQL作成 |
|
492 |
strcmd = "SELECT NVL(MAX(SeqNo), 0) FROM ProcessApproval" + AddSQLString; |
|
493 |
|
|
494 |
// SQL実行 |
|
495 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return iRet; |
|
496 |
|
|
497 |
// データセット |
|
498 |
foreach (object[] objwrk in arData) |
|
499 |
{ |
|
500 |
if (objwrk[0].ToString().Equals("null")) |
|
501 |
iRet = 0; |
|
502 |
else |
|
503 |
iRet = int.Parse(objwrk[0].ToString()); |
|
504 |
} |
|
505 |
|
|
506 |
} |
|
507 |
catch (Exception ex) |
|
508 |
{ |
|
509 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
510 |
} |
|
511 |
return iRet; |
|
512 |
} |
|
513 |
#endregion |
|
514 |
} |
|
515 |
} |
trunk/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOMTerm.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Collections; |
|
6 |
|
|
7 |
using log4net; |
|
8 |
using Oracle.ManagedDataAccess.Client; |
|
9 |
|
|
10 |
using ProcessManagement.DB.Oracle; |
|
11 |
using ProcessManagement.DB.Core; |
|
12 |
using ProcessManagement.DataModel; |
|
13 |
|
|
14 |
using ProcessManagement.Common; |
|
15 |
|
|
16 |
namespace ProcessManagement.DB.IOAccess |
|
17 |
{ |
|
18 |
/// <summary> |
|
19 |
/// 期限マスタアクセスクラス |
|
20 |
/// </summary> |
|
21 |
public class IOMTerm : OracleProcess |
|
22 |
{ |
|
23 |
#region 定義部 |
|
24 |
/// <summary> |
|
25 |
/// log4netログを使用する |
|
26 |
/// </summary> |
|
27 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
28 |
#endregion |
|
29 |
|
|
30 |
#region 定数 |
|
31 |
/// <summary> |
|
32 |
/// 行動予定フィールド並び |
|
33 |
/// </summary> |
|
34 |
public enum NameColumn |
|
35 |
{ |
|
36 |
ConstructionStatusFlg = 0, |
|
37 |
FieldNo, |
|
38 |
SeqNo, |
|
39 |
DisplayOrder, |
|
40 |
CheckSchdule, |
|
41 |
TermDays, |
|
42 |
SendTitle, |
|
43 |
SendMessage, |
|
44 |
BackColor, |
|
45 |
ForeColor, |
|
46 |
EntryDate, |
|
47 |
UpdateDate, |
|
48 |
} |
|
49 |
#endregion |
|
50 |
|
|
51 |
#region コンストラクタ |
|
52 |
/// <summary> |
|
53 |
/// コンストラクタ |
|
54 |
/// </summary> |
|
55 |
/// <param name="ConnectionString"></param> |
|
56 |
public IOMTerm() |
|
57 |
: base(DBCommon.Instance.DBConnectString) |
|
58 |
{ |
|
59 |
} |
|
60 |
|
|
61 |
#endregion |
|
62 |
|
|
63 |
#region パブリックメソッド |
|
64 |
/// <summary> |
|
65 |
/// 行動予定検索 |
|
66 |
/// </summary> |
|
67 |
/// <param name="AddSQLString">検索条件SQL文字列</param> |
|
68 |
/// <param name="data">行動予定データ</param> |
|
69 |
/// <returns>true:成功 false:失敗</returns> |
|
70 |
public bool SelectAction(string AddSQLString, ref List<TermMaster> data, bool bConnect = true) |
|
71 |
{ |
|
72 |
//Oracle インターフェース |
|
73 |
string strcmd = ""; |
|
74 |
ArrayList arData = new ArrayList(); |
|
75 |
|
|
76 |
try |
|
77 |
{ |
|
78 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
79 |
strcmd = "SELECT"; |
|
80 |
strcmd += " ConstructionStatusFlg"; |
|
81 |
strcmd += " ,FieldNo"; |
|
82 |
strcmd += " ,SeqNo"; |
|
83 |
strcmd += " ,DisplayOrder"; |
|
84 |
strcmd += " ,CheckSchdule"; |
|
85 |
strcmd += " ,TermDays"; |
|
86 |
strcmd += " ,SendTitile"; |
|
87 |
strcmd += " ,SendMessage"; |
|
88 |
strcmd += " ,BackColor"; |
|
89 |
strcmd += " ,ForeColor"; |
|
90 |
strcmd += " ,TO_CHAR(EntryDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
91 |
strcmd += " ,TO_CHAR(UpdateDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
92 |
strcmd += " FROM TermMaster"; |
|
93 |
strcmd += AddSQLString; |
|
94 |
|
|
95 |
// SQL実行 |
|
96 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
97 |
|
|
98 |
// データセット |
|
99 |
foreach (object[] objwrk in arData) |
|
100 |
{ |
|
101 |
TermMaster work = new TermMaster(); |
|
102 |
Reader2Struct(objwrk, ref work); |
|
103 |
data.Add(work); |
|
104 |
} |
|
105 |
|
|
106 |
return true; |
|
107 |
} |
|
108 |
catch (Exception ex) |
|
109 |
{ |
|
110 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
111 |
return false; |
|
112 |
} |
|
113 |
|
|
114 |
} |
|
115 |
|
|
116 |
/// <summary> |
|
117 |
/// 行動予定追加 |
|
118 |
/// </summary> |
|
119 |
/// <param name="data">行動予定データ</param> |
|
120 |
/// <returns>true:成功 false:失敗</returns> |
|
121 |
public bool OneRecInsertAction(TermMaster data, bool bConnect = true) |
|
122 |
{ |
|
123 |
string strcmd = ""; |
|
124 |
try |
|
125 |
{ |
|
126 |
|
|
127 |
strcmd = "INSERT INTO TermMaster"; |
|
128 |
|
|
129 |
strcmd += " VALUES ("; |
|
130 |
strcmd += string.Format(" {0}", data.ConstructionStatusFlg.ToString()); |
|
131 |
strcmd += string.Format(",{0}", data.FieldNo.ToString()); |
|
132 |
strcmd += string.Format(",{0}", data.SeqNo.ToString()); |
|
133 |
strcmd += string.Format(",{0}", data.DisplayOrder); |
|
134 |
strcmd += string.Format(",{0}", data.CheckSchdule.ToString()); |
|
135 |
strcmd += string.Format(",{0}", data.TermDays.ToString()); |
|
136 |
strcmd += string.Format(",'{0}'", data.SendTitle); |
|
137 |
strcmd += string.Format(",'{0}'", data.SendMessage); |
|
138 |
strcmd += string.Format(",'{0}'", data.BackColor); |
|
139 |
strcmd += string.Format(",'{0}'", data.ForeColor); |
|
140 |
|
|
141 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
142 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
143 |
strcmd = strcmd + ")"; |
|
144 |
|
|
145 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
146 |
|
|
147 |
return true; |
|
148 |
} |
|
149 |
catch (Exception ex) |
|
150 |
{ |
|
151 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
152 |
return false; |
|
153 |
} |
|
154 |
} |
|
155 |
public bool InsertAction(List<TermMaster> data, bool bConnect = true) |
|
156 |
{ |
|
157 |
string strcmd = ""; |
|
158 |
try |
|
159 |
{ |
|
160 |
|
|
161 |
foreach (TermMaster work in data) |
|
162 |
{ |
|
163 |
if (!OneRecInsertAction(work, bConnect)) return false; |
|
164 |
} |
|
165 |
return true; |
|
166 |
} |
|
167 |
catch (Exception ex) |
|
168 |
{ |
|
169 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
170 |
return false; |
|
171 |
} |
|
172 |
} |
|
173 |
/// <summary> |
|
174 |
/// 行動予定更新 |
|
175 |
/// </summary> |
|
176 |
/// <param name="AddSQLString">更新条件SQL文字列</param> |
|
177 |
/// <param name="data">行動予定データ</param> |
|
178 |
/// <returns>true:成功 false:失敗</returns> |
|
179 |
public bool UpdateAction(string AddSQLString, TermMaster data, bool bConnect = true) |
|
180 |
{ |
|
181 |
string strcmd = ""; |
|
182 |
try |
|
183 |
{ |
|
184 |
|
|
185 |
strcmd = "UPDATE TermMaster"; |
|
186 |
|
|
187 |
strcmd += " SET"; |
|
188 |
strcmd += string.Format(" ConstructionStatusFlg = {0}", data.ConstructionStatusFlg.ToString()); |
|
189 |
strcmd += string.Format(",FieldNo = {0}", data.FieldNo.ToString()); |
|
190 |
strcmd += string.Format(",SeqNo = {0}", data.SeqNo.ToString()); |
|
191 |
strcmd += string.Format(",DisplayOrder = {0}", data.DisplayOrder); |
|
192 |
strcmd += string.Format(",CheckSchdule = {0}", data.CheckSchdule.ToString()); |
|
193 |
|
|
194 |
strcmd += string.Format(",TermDays = {0}", data.TermDays.ToString()); |
|
195 |
strcmd += string.Format(",SendTitile = '{0}'", data.SendTitle); |
|
196 |
strcmd += string.Format(",SendMessage = '{0}'", data.SendMessage); |
|
197 |
strcmd += string.Format(",BackColor = '{0}'", data.BackColor); |
|
198 |
strcmd += string.Format(",ForeColor = '{0}'", data.ForeColor); |
|
199 |
|
|
200 |
strcmd += ", UpdateDate = TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
201 |
strcmd += AddSQLString; |
|
202 |
|
|
203 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
204 |
|
|
205 |
return true; |
|
206 |
} |
|
207 |
catch (Exception ex) |
|
208 |
{ |
|
209 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
210 |
return false; |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
/// <summary> |
|
216 |
/// 行動予定削除 |
|
217 |
/// </summary> |
|
218 |
/// <param name="AddSQLString">削除条件SQL文字列</param> |
|
219 |
/// <param name="data">行動予定データ</param> |
|
220 |
/// <returns>true:成功 false:失敗</returns> |
|
221 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
|
222 |
{ |
|
223 |
//Oracle インターフェース |
|
224 |
string strcmd = ""; |
|
225 |
try |
|
226 |
{ |
|
227 |
strcmd = string.Format("{0}{1}", "DELETE FROM TermMaster", AddSQLString); |
|
228 |
|
|
229 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
230 |
|
|
231 |
return true; |
|
232 |
} |
|
233 |
catch (Exception ex) |
|
234 |
{ |
|
235 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
236 |
return false; |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
240 |
/// <summary> |
|
241 |
/// OracleDataReaderより構造体へセットする |
|
242 |
/// </summary> |
|
243 |
/// <param name="reader">OracleDataReader</param> |
|
244 |
/// <param name="wrk">構造体</param> |
|
245 |
public void Reader2Struct(object[] objwrk, ref TermMaster wrk) |
|
246 |
{ |
|
247 |
try |
|
248 |
{ |
|
249 |
// データ取得 |
|
250 |
wrk.ConstructionStatusFlg = int.Parse(objwrk[(int)NameColumn.ConstructionStatusFlg].ToString()); |
|
251 |
wrk.FieldNo = int.Parse(objwrk[(int)NameColumn.FieldNo].ToString()); |
|
252 |
wrk.SeqNo = int.Parse(objwrk[(int)NameColumn.SeqNo].ToString()); |
|
253 |
|
|
254 |
wrk.DisplayOrder = int.Parse(objwrk[(int)NameColumn.DisplayOrder].ToString()); |
|
255 |
|
|
256 |
wrk.CheckSchdule = int.Parse(objwrk[(int)NameColumn.CheckSchdule].ToString()); |
|
257 |
wrk.TermDays = int.Parse(objwrk[(int)NameColumn.TermDays].ToString()); |
|
258 |
wrk.SendTitle = objwrk[(int)NameColumn.SendTitle].ToString(); |
|
259 |
wrk.SendMessage = objwrk[(int)NameColumn.SendMessage].ToString(); |
|
260 |
wrk.BackColor = objwrk[(int)NameColumn.BackColor].ToString(); |
|
261 |
wrk.ForeColor = objwrk[(int)NameColumn.ForeColor].ToString(); |
|
262 |
|
|
263 |
wrk.EntryDate = DateTime.Parse(objwrk[(int)NameColumn.EntryDate].ToString()); |
|
264 |
wrk.UpdateDate = DateTime.Parse(objwrk[(int)NameColumn.UpdateDate].ToString()); |
|
265 |
} |
|
266 |
catch (OracleException oraex) |
|
267 |
{ |
|
268 |
logger.ErrorFormat("オラクルエラー:{0}:{1}", CommonMotions.GetMethodName(), oraex.Message); |
|
269 |
} |
|
270 |
catch (Exception ex) |
|
271 |
{ |
|
272 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
273 |
} |
|
274 |
} |
|
275 |
|
|
276 |
#endregion |
|
277 |
|
|
278 |
#region パブリックメソッド(特殊処理) |
|
279 |
|
|
280 |
/// <summary> |
|
281 |
/// 主キー検索の文字列を返す |
|
282 |
/// </summary> |
他の形式にエクスポート: Unified diff