MesHelper.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. using Oracle.ManagedDataAccess.Client;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Text;
  7. namespace UMES.DllService
  8. {
  9. public class MESHelper
  10. {
  11. //用于拼接SQL
  12. StringBuilder sql = new StringBuilder();
  13. //用于存放批量执行的SQL
  14. List<string> sqls = new List<string>();
  15. //系统默认的的连接字符串
  16. private string ConnectionStrings = "Data Source=192.168.1.23/orcl;User ID=MES;PassWord=select!#%*(;";
  17. //用户选择的数据库的连接字符串
  18. private OracleConnection connection;
  19. //用户选择的数据库的连接字符串
  20. private OracleCommand command = null;
  21. public MESHelper()
  22. {
  23. connection = new OracleConnection(ConnectionStrings);
  24. }
  25. public MESHelper(string IP)
  26. {
  27. connection = new OracleConnection("Data Source=" + IP + "/orcl;User ID=MES;PassWord=select!#%*(;");
  28. }
  29. /// <summary>
  30. /// 检测当前的岗位资源对应的工序
  31. /// </summary>
  32. /// <param name="iSN"></param>
  33. /// <param name="iResCode"></param>
  34. /// <param name="oErrMessage"></param>
  35. /// <returns></returns>
  36. [Description("序列号对应工序检测")]
  37. public bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage)
  38. {
  39. if (iSN == "")
  40. {
  41. oErrMessage = "SN不能为空";
  42. return false;
  43. }
  44. oErrMessage = "";
  45. string[] param = new string[] { "", iResCode, iSN, "", "", "", oErrMessage };
  46. string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
  47. CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
  48. oErrMessage = param[6];
  49. DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=( select max(ms_id) from makeserial where ms_sncode in ( select '" + iSN + "' from dual union select sn from makesnrelation where beforesn='" + iSN + "' and sn<>' ' union select beforesn from makesnrelation where sn='" + iSN + "' and beforesn<>' '))", "select");
  50. string ms_status = "";
  51. string ms_stepcode = "";
  52. string ms_nextstepcode = "";
  53. if (dt.Rows.Count > 0)
  54. {
  55. ms_status = dt.Rows[0]["ms_status"].ToString();
  56. ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  57. ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
  58. }
  59. string stepcode = GetStepCodeBySource(iResCode);
  60. if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
  61. {
  62. oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
  63. return false;
  64. }
  65. if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && stepcode == ms_stepcode))
  66. {
  67. if (ms_status == "3")
  68. {
  69. oErrMessage = "";
  70. }
  71. DataTable dt1 = (DataTable)ExecuteSql("select 1 from makebadcount where mbc_sncode='" + iSN + "' and mbc_stepcode='" + stepcode + "' and mbc_status=0","select");
  72. int BadCount = dt1.Rows.Count;
  73. //测试不良3次不允许再测试,必须先维修
  74. if (BadCount == 3)
  75. {
  76. oErrMessage = stepcode + "连续三次测试不良,请进行维修";
  77. return false;
  78. }
  79. return true;
  80. }
  81. else
  82. return false;
  83. }
  84. /// <summary>
  85. /// 验证用户身份信息
  86. /// </summary>
  87. /// <param name="iUserCode"></param>
  88. /// <param name="oErrorMessage"></param>
  89. /// <returns></returns>
  90. private bool CheckUserLogin(string iUserCode, string iPassWord, out string oErrorMessage)
  91. {
  92. oErrorMessage = "";
  93. string SQL = "select em_code from employee where em_code=:UserName and em_password =:PassWord";
  94. DataTable dt;
  95. dt = (DataTable)ExecuteSql(SQL, "select", iUserCode, iPassWord);
  96. if (dt.Rows.Count > 0)
  97. return true;
  98. else
  99. {
  100. oErrorMessage = "用户名或者密码不正确!";
  101. return false;
  102. }
  103. }
  104. /// <summary>
  105. /// 验证用户身份信息和岗位资源
  106. /// </summary>
  107. /// <param name="iUserCode"></param>
  108. /// <param name="iResCode"></param>
  109. /// <param name="oErrMessage"></param>
  110. /// <returns></returns>
  111. [Description("验证身份信息")]
  112. public bool CheckUserAndResourcePassed(string iUserCode, string iResCode, string iPassWord, out string oErrMessage)
  113. {
  114. oErrMessage = "";
  115. if (iUserCode == "" || iPassWord == "" || iResCode == "")
  116. {
  117. oErrMessage = "用户名,密码,岗位资源必须填写";
  118. return false;
  119. }
  120. if (CheckUserLogin(iUserCode, iPassWord, out oErrMessage))
  121. {
  122. string SQL = "select em_code,em_type,em_name from employee where em_code=:UserName ";
  123. DataTable dt;
  124. dt = (DataTable)ExecuteSql(SQL, "select", iUserCode);
  125. if (dt.Rows.Count > 0)
  126. {
  127. string em_name = dt.Rows[0]["em_name"].ToString();
  128. string em_type = dt.Rows[0]["em_type"].ToString();
  129. if (iResCode == "")
  130. {
  131. oErrMessage = "岗位资源不允许为空";
  132. return false;
  133. }
  134. if (em_type == "admin")
  135. {
  136. if (CheckExist("Source", "sc_code='" + iResCode + "' and sc_statuscode='AUDITED'"))
  137. {
  138. return true;
  139. }
  140. else
  141. {
  142. oErrMessage = "岗位资源编号错误或者未审核!";
  143. return false;
  144. }
  145. }
  146. else
  147. {
  148. dt = getFieldsDatasByCondition("cs$empgroup left join cs$userresource on ur_groupcode=eg_groupcode left join source on ur_resourcecode=sc_code", new string[] { "ur_resourcecode" }, "eg_emcode = '" + iUserCode + "' and sc_statuscode='AUDITED'");
  149. //如果存在该编号
  150. if (dt.Rows.Count > 0)
  151. {
  152. //判断如果多个岗位资源存在,用户输入的只要在其中就行
  153. for (int i = 0; i < dt.Rows.Count; i++)
  154. {
  155. if (dt.Rows[i]["ur_resourcecode"].ToString() == iResCode)
  156. return true;
  157. }
  158. oErrMessage = "用户不处于当前资源所属分组!";
  159. }
  160. else
  161. oErrMessage = "岗位资源编号错误或者未审核!";
  162. }
  163. }
  164. else
  165. oErrMessage = "用户不存在!";
  166. }
  167. return false;
  168. }
  169. /// <summary>
  170. /// 分配Mac地址和BT地址
  171. /// </summary>
  172. /// <param name="iSN"></param>
  173. /// <param name="oWIFI"></param>
  174. /// <param name="oBT"></param>
  175. /// <param name="oCode1"></param>
  176. /// <param name="oCode2"></param>
  177. /// <param name="oCdoe3"></param>
  178. /// <param name="oErrMessage"></param>
  179. /// <returns></returns>
  180. [Description("分配MAC和BT信息")]
  181. public bool GetAddressRangeByMO(string iSN, out Dictionary<string, string> oInfo, out string oErrMessage)
  182. {
  183. oInfo = new Dictionary<string, string>();
  184. string oWIFI = "";
  185. string oBT = "";
  186. string oCode1 = "";
  187. string oCode2 = "";
  188. string oCdoe3 = "";
  189. if (iSN == "")
  190. {
  191. oErrMessage = "SN不能为空";
  192. return false;
  193. }
  194. oErrMessage = "";
  195. string omakeCode = "";
  196. GetRcardMOInfo(iSN, out omakeCode, out oErrMessage);
  197. string[] param = new string[] { iSN, omakeCode, oWIFI, oBT, oCode1, oCode2, oCdoe3, oErrMessage };
  198. string[] ParamName = new string[] { "v_i_sncode", "v_i_macode", "v_o_mac", "v_o_bt", "v_o_code1", "v_o_code2", "v_o_code3", "v_o_errmsg" };
  199. CallProcedure("CS_GETADDRESSBYMAKECODE", ParamName, ref param);
  200. oInfo.Add("MAC", param[2]);
  201. oInfo.Add("BT", param[3]);
  202. oInfo.Add("Code1", param[4]);
  203. oInfo.Add("Code2", param[5]);
  204. oInfo.Add("Code3", param[6]);
  205. oErrMessage = param[7];
  206. if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
  207. return true;
  208. else
  209. return false;
  210. }
  211. /// <summary>
  212. /// 输入的 SN 号查找在制品是否有 IMEI 信息存在,如果存在则将 IMEI 信息传出,如果没有则在该工单下未使用的 IMEI 中随机分配一组
  213. /// 如果iIMEI1、iNetCode不为空,则分别作为获取的附件加条件。
  214. /// </summary>
  215. /// <param name="iSN"></param>
  216. /// <param name="iIMEI1"></param>
  217. /// <param name="iNetCode"></param>
  218. /// <param name="oIMEI1"></param>
  219. /// <param name="oIMEI2"></param>
  220. /// <param name="oIMEI3"></param>
  221. /// <param name="oMEID"></param>
  222. /// <param name="oNetCode"></param>
  223. /// <param name="oPSN"></param>
  224. /// <param name="oID1"></param>
  225. /// <param name="oID2"></param>
  226. /// <param name="oID3"></param>
  227. /// <param name="oErrMessage"></param>
  228. /// <returns></returns>
  229. [Description("分配IMEI和NetCode信息")]
  230. public bool GetMEIOrNetCodeRange(string iSN, string iIMEI1, string iNetCode, out Dictionary<string, string> oInfo, out string oErrMessage)
  231. {
  232. oInfo = new Dictionary<string, string>();
  233. string oIMEI1 = "";
  234. string oIMEI2 = "";
  235. string oMEID = "";
  236. string oNetCode = "";
  237. string oPSN = "";
  238. string oID1 = "";
  239. string oID2 = "";
  240. string oID3 = "";
  241. if (iSN == "")
  242. {
  243. oErrMessage = "SN不能为空";
  244. return false;
  245. }
  246. oErrMessage = "";
  247. string[] param = new string[] { iSN, "", iIMEI1, iNetCode, oIMEI1, oIMEI2, "", oMEID, oNetCode, oPSN, oID1, oID2, oID3, oErrMessage };
  248. string[] ParamName = new string[] { "v_i_sncode", "v_i_macode", "v_i_imei", "v_i_netcode", "v_o_imei1", "v_o_imei2", "v_o_imei3", "v_o_meid", "v_o_netcode", "v_o_psn", "v_o_id1", "v_o_id2", "v_o_id3", "v_o_errmsg" };
  249. CallProcedure("CS_GETIMEIORNETCODERANGE", ParamName, ref param);
  250. oInfo.Add("IMEI1", param[4]);
  251. oInfo.Add("IMEI2", param[5]);
  252. oInfo.Add("MEID", param[7]);
  253. oInfo.Add("NETCODE", param[8]);
  254. oInfo.Add("PSN", param[9]);
  255. oInfo.Add("ID1", param[10]);
  256. oInfo.Add("ID2", param[11]);
  257. oInfo.Add("ID3", param[12]);
  258. oErrMessage = param[13];
  259. if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
  260. return true;
  261. else
  262. return false;
  263. }
  264. /// <summary>
  265. /// 获取工单的最近一条执行记录
  266. /// </summary>
  267. /// <param name="iSN"></param>
  268. /// <param name="oMoCode"></param>
  269. /// <param name="oErrMessage"></param>
  270. /// <returns></returns>
  271. [Description("获取序列号对应工单信息")]
  272. public bool GetRcardMOInfo(string iSN, out string oMoCode, out string oErrMessage)
  273. {
  274. //取MakeProcess表中的执行记录ID最大的一个工单的号码
  275. oMoCode = "";
  276. if (iSN == "")
  277. {
  278. oErrMessage = "SN不能为空";
  279. return false;
  280. }
  281. oErrMessage = "";
  282. sql.Length = 0;
  283. sql.Append("select max(ms_id) from makeserial where ms_sncode in (select '" + iSN + "' from dual union select sn from ");
  284. sql.Append("makesnrelation where beforesn='" + iSN + "' and sn<>' ' union select beforesn from makesnrelation where sn='" + iSN + "' and beforesn<>' ')");
  285. DataTable dt = (DataTable)ExecuteSql(sql.ToString(), "select");
  286. string ms_id = dt.Rows[0][0].ToString();
  287. oMoCode = getFieldDataByCondition("MakeSerial", "ms_makecode", "ms_id='" + ms_id + "'").ToString();
  288. if (oMoCode != "")
  289. return true;
  290. else
  291. {
  292. oErrMessage = "序列号:" + iSN + " 未归属工单";
  293. return false;
  294. }
  295. }
  296. /// <summary>
  297. /// 获取序列号的所有串号信息
  298. /// </summary>
  299. /// <param name="iSN"></param>
  300. /// <param name="oWIFI"></param>
  301. /// <param name="oBT"></param>
  302. /// <param name="oCode1"></param>
  303. /// <param name="oCode2"></param>
  304. /// <param name="oCode3"></param>
  305. /// <param name="oIMEI1"></param>
  306. /// <param name="oIMEI2"></param>
  307. /// <param name="oIMEI3"></param>
  308. /// <param name="oMEID"></param>
  309. /// <param name="oNetCode"></param>
  310. /// <param name="oPSN"></param>
  311. /// <param name="oID1"></param>
  312. /// <param name="oID2"></param>
  313. /// <param name="oID3"></param>
  314. /// <param name="oID4"></param>
  315. /// <param name="oID5"></param>
  316. /// <param name="oErrMessage"></param>
  317. /// <returns></returns>
  318. [Description("查询已分配的信息")]
  319. public bool GetMobileAllInfo(string iSN, out Dictionary<string, string> oInfo, out string oErrMessage)
  320. {
  321. oInfo = new Dictionary<string, string>();
  322. oErrMessage = "";
  323. if (iSN == "")
  324. {
  325. oErrMessage = "SN不能为空";
  326. return false;
  327. }
  328. //通过序列号获取最近操作的工单号
  329. string ms_id = getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + iSN + "'").ToString();
  330. if (ms_id != "")
  331. {
  332. DataTable dt = getFieldsDataByCondition("MakeSerial", new string[] { "ms_id", "ms_mac", "ms_bt", "ms_meid", "ms_netcode", "ms_psn", "ms_imei1", "ms_imei2", "ms_imei3", "ms_othcode1", "ms_othcode2", "ms_othcode3", "ms_othid1", "ms_othid2", "ms_othid3" }, "ms_id='" + ms_id + "'");
  333. if (dt.Rows.Count > 0)
  334. {
  335. string Code1 = "";
  336. string Code2 = "";
  337. string Code3 = "";
  338. string Code4 = "";
  339. string Code5 = "";
  340. string Code6 = "";
  341. string Code7 = "";
  342. string Code8 = "";
  343. string Code9 = "";
  344. string Code10 = "";
  345. string Code11 = "";
  346. string Code12 = "";
  347. string Code13 = "";
  348. string Code14 = "";
  349. string Code15 = "";
  350. string[] param = new string[] { ms_id, Code1, Code2, Code3, Code4, Code5, Code6, Code7, Code8, Code9, Code10, Code11, Code12, Code13, Code14, Code15 };
  351. string[] ParamName = new string[] { "v_ms_id", "v_i_code1", "v_i_code2", "v_i_code3", "v_i_code4", "v_i_code5", "v_i_code6", "v_i_code7", "v_i_code8", "v_i_code9", "v_i_code10", "v_i_code11", "v_i_code12", "v_i_code13", "v_i_code14", "v_i_code15" };
  352. CallProcedure("GetMobileAllInfo", ParamName, ref param);
  353. for (int i = 1; i < param.Length; i++)
  354. {
  355. //获取出来的参数使用^分割
  356. if (param[i] != "" && param[i] != "null" && param[i] != null)
  357. {
  358. oInfo.Add(param[i].Split('^')[0], param[i].Split('^')[1]);
  359. }
  360. }
  361. oErrMessage = "";
  362. return true;
  363. }
  364. else
  365. {
  366. oErrMessage = "序列号" + iSN + "不存在";
  367. return false;
  368. }
  369. }
  370. else
  371. {
  372. oErrMessage = "序列号" + iSN + "不存在";
  373. return false;
  374. }
  375. }
  376. /// <summary>
  377. /// 记录操作日志
  378. /// </summary>
  379. /// <param name="iSnCode"></param>
  380. /// <param name="iMakeCode"></param>
  381. /// <param name="iMPKind"></param>
  382. /// <param name="result"></param>
  383. /// <param name="iUserCode"></param>
  384. private void InsertMakeProcess(string iSnCode, string iMakeCode, string iSourceCode, string iMPKind, string result, string iUserCode)
  385. {
  386. string CurrentStep = "";
  387. string LineCode = "";
  388. string CurrentStepName = "";
  389. GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
  390. sql.Length = 0;
  391. sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");
  392. sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode,mp_snstatus,mp_sncheckno,mp_snoutboxcode)");
  393. sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,'" + CurrentStep + "','" + CurrentStepName + "',");
  394. sql.Append("ma_craftcode,ma_craftname,'" + iMPKind + "','" + result + "',sysdate,'" + iUserCode + "',ma_wccode,'" + LineCode + "','" + iSourceCode + "',");
  395. sql.Append("ms_status,ms_checkno,ms_outboxcode from make left join makeserial on ms_makecode=ma_code left join step on st_code=ms_stepcode ");
  396. sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and st_code='" + CurrentStep + "'");
  397. ExecuteSql(sql.ToString(), "insert");
  398. }
  399. /// <summary>
  400. /// 保存Mac地址和BT地址
  401. /// </summary>
  402. /// <param name="iSN"></param>
  403. /// <param name="iMac"></param>
  404. /// <param name="iBT"></param>
  405. /// <param name="iCode1"></param>
  406. /// <param name="iCode2"></param>
  407. /// <param name="iCode3"></param>
  408. /// <param name="oErrMessage"></param>
  409. /// <returns></returns>
  410. [Description("写入SN的Wifi,BT信息")]
  411. public bool SetAddressInfo(string iSN, string iMac, string iBT, string iCode1, string iCode2, string iCode3, out string oErrMessage)
  412. {
  413. if (iSN == "")
  414. {
  415. oErrMessage = "SN不能为空";
  416. return false;
  417. }
  418. oErrMessage = "";
  419. string[] param = new string[] { iSN, iMac, iBT, iCode1, iCode2, iCode3, oErrMessage };
  420. string[] ParamName = new string[] { "v_i_sncode", "v_i_mac", "v_i_bt", "v_i_code1", "v_i_code2", "v_i_code3", "v_o_errmsg" };
  421. CallProcedure("CS_SETADDRESSINFO", ParamName, ref param);
  422. oErrMessage = param[6];
  423. if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
  424. return true;
  425. else
  426. return false;
  427. }
  428. [Description("序列号跳到下一 步")]
  429. public bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, string iErrCode, out string oErrMessage)
  430. {
  431. if (iSN == "")
  432. {
  433. oErrMessage = "SN不能为空";
  434. return false;
  435. }
  436. oErrMessage = "";
  437. string StepCode = getFieldDataByCondition("Makeserial", "ms_stepcode", "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'").ToString();
  438. string CurrentStep = GetStepCodeBySource(iSourceCode);
  439. string BgCode = getFieldDataByCondition("step", "st_badgroupcode", "st_code='" + CurrentStep + "'").ToString();
  440. switch (iResult)
  441. {
  442. case "OK":
  443. break;
  444. case "NG":
  445. if (iErrCode == "")
  446. {
  447. oErrMessage = "测试结果为NG时必须传递不良代码";
  448. return false;
  449. }
  450. else
  451. {
  452. UpdateByCondition("makebad", "mb_status=-1", "mb_sncode='" + iSN + "' and mb_makecode='" + iMakeCode + "' and mb_stepcode='" + CurrentStep + "' and mb_status=0");
  453. string[] BadCode = iErrCode.Split(',');
  454. sql.Length = 0;
  455. sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
  456. sql.Append(",mb_sourcecode,mb_badcode,mb_badtable,mb_bgcode,mb_soncode,mb_status) select makebad_seq.nextval");
  457. sql.Append(",ma_code,ms_code,ms_sncode,'" + iUserCode + "',sysdate,'" + CurrentStep + "','" + iSourceCode + "',:bc_code,'',");
  458. sql.Append("'" + BgCode + "',sp_soncode,'0' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
  459. sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'");
  460. List<string> InsertSQL = new List<string>();
  461. for (int i = 0; i < BadCode.Length; i++)
  462. {
  463. InsertSQL.Add(sql.ToString().Replace(":bc_code", "'" + BadCode[i] + "'"));
  464. }
  465. ExecuteSQLTran(InsertSQL.ToArray());
  466. //将不良的序列号的状态码设为3
  467. ExecuteSql("update makeserial set ms_status='3' where ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'", "update");
  468. }
  469. break;
  470. default:
  471. oErrMessage = "测试结果必须为NG或者OK";
  472. return false;
  473. }
  474. //不良采集为良品是更新
  475. if (StepCode == CurrentStep && iResult == "OK")
  476. {
  477. DataTable dt = getFieldsDataByCondition("makeserial", new string[] { "ms_status", "ms_craftcode", "ms_prodcode" }, "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'");
  478. if (dt.Rows.Count > 0)
  479. {
  480. string ms_status = dt.Rows[0]["ms_status"].ToString();
  481. string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
  482. string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  483. if (ms_status == "3")
  484. {
  485. string nextstepcode = getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid ", "cd_nextstepcode", "cr_code='" + ms_craftcode + "' and cr_prodcode='" + ms_prodcode + "' and cd_stepcode='" + CurrentStep + "'").ToString();
  486. UpdateByCondition("makeserial", "ms_status=1,ms_nextstepcode='" + nextstepcode + "'", "ms_sncode='" + iSN + "' and ms_makecode='" + iMakeCode + "'");
  487. UpdateByCondition("makebad", "mb_status=-1", "mb_sncode='" + iSN + "' and mb_makecode='" + iMakeCode + "'");
  488. }
  489. }
  490. }
  491. return CS_SetFinish(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrMessage);
  492. }
  493. /// <summary>
  494. /// 设置测试结果
  495. /// </summary>
  496. /// <param name="iMakeCode"></param>
  497. /// <param name="iSourceCode"></param>
  498. /// <param name="iSN"></param>
  499. /// <param name="iOperater"></param>
  500. /// <param name="iResult"></param>
  501. /// <param name="iUserCode"></param>
  502. /// <param name="oErrorMessage"></param>
  503. /// <returns></returns>
  504. [Description("设置测试结果,结果必须为NG或者OK")]
  505. public bool SetMobileData(string iTSN, string iSN, string iSourceCode, string iOperater, string iResult, string iErrCode, string flag, out string oErrorMessage)
  506. {
  507. oErrorMessage = "";
  508. if (iTSN == "") { oErrorMessage = "TSN不能为空"; return false; }
  509. if (iSN == "") { oErrorMessage = "SN不能为空"; return false; }
  510. string[] param = new string[] { iTSN, iSN, iSourceCode, iOperater, iResult, iErrCode, oErrorMessage };
  511. string[] ParamName = new string[] { "v_i_tsn", "v_i_sncode", "v_i_sourcecode", "v_i_usercode", "v_i_result", "v_i_errcode", "v_o_errmsg" };
  512. CallProcedure("CS_DLLSNCHANGE", ParamName, ref param);
  513. oErrorMessage = param[6];
  514. if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
  515. return true;
  516. else
  517. return false;
  518. }
  519. private bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, string iResult, out string oErrMessage)
  520. {
  521. if (iSN == "")
  522. {
  523. oErrMessage = "SN不能为空";
  524. return false;
  525. }
  526. oErrMessage = "";
  527. string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, iResult, oErrMessage };
  528. string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_i_result", "v_o_errmsg" };
  529. CallProcedure("CS_SETSTEPRESULT", ParamName, ref param);
  530. oErrMessage = param[5];
  531. if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
  532. return true;
  533. else
  534. return false;
  535. }
  536. /// <summary>
  537. /// 方法说明:测试详细信息录入系统,针对一个SN多个测试项目结果可循环调用
  538. /// </summary>
  539. /// <param name="iSN">序列号</param>
  540. /// <param name="iClass"></param>
  541. /// <param name="iSubClass1"></param>
  542. /// <param name="iSubClass2"></param>
  543. /// <param name="iSubClass3"></param>
  544. /// <param name="iMaxValue"></param>
  545. /// <param name="iMinValue"></param>
  546. /// <param name="iActualValue"></param>
  547. /// <param name="iValue1"></param>
  548. /// <param name="iValue2"></param>
  549. /// <param name="iValue3"></param>
  550. /// <param name="iTestResult"></param>
  551. /// <param name="oErrMessage"></param>
  552. /// <returns></returns>
  553. [Description("设置测试结果")]
  554. public bool SetTestDetail(string iSN, string iClass, string iResCode, string[,] iTestDetail, out string oErrMessage)
  555. {
  556. if (iSN == "" || iSN == null)
  557. {
  558. oErrMessage = "SN不能为空";
  559. return false;
  560. }
  561. oErrMessage = "";
  562. string omakeCode = "";
  563. GetRcardMOInfo(iSN, out omakeCode, out oErrMessage);
  564. sql.Length = 0;
  565. sql.Append("begin ");
  566. bool needBreak = false;
  567. for (int i = 0; i < iTestDetail.Length / 200; i++)
  568. {
  569. string DataField = "Insert into MES_TEST(STD_ID,STD_SN,STD_MAKECODE,STD_CLASS,STD_TESTDATE,";
  570. string ValueField = ")values(MES_TEST_SEQ.nextval,'" + iSN + "','" + omakeCode + "','" + iClass + "',sysdate,";
  571. for (int j = 0; j < 200; j++)
  572. {
  573. if (j == 0)
  574. {
  575. DataField += "STD_ITEMNAME,";
  576. //如果传递的参数没有测试名称则中断插入
  577. if (iTestDetail[i, j] == "" || iTestDetail[i, j] == null)
  578. {
  579. //外层循环也需要中断
  580. needBreak = true;
  581. break;
  582. }
  583. }
  584. else
  585. {
  586. DataField += "STD_ITEM" + j + " ,";
  587. }
  588. ValueField += "'" + iTestDetail[i, j] + "',";
  589. }
  590. if (needBreak)
  591. break;
  592. sql.Append(DataField.Substring(0, DataField.Length - 1) + ValueField.Substring(0, ValueField.Length - 1) + ");");
  593. }
  594. sql.Append("end;");
  595. ExecuteSql(sql.ToString(), "insert");
  596. return true;
  597. }
  598. /// <summary>
  599. /// 作业调用该方法将确认接收SN对应的IMEI及附属信息。
  600. /// </summary>
  601. /// <param name="iSN"></param>
  602. /// <param name="iMO"></param>
  603. /// <param name="iIMEI1"></param>
  604. /// <param name="iIMEI2"></param>
  605. /// <param name="iIMEI3"></param>
  606. /// <param name="iMEID"></param>
  607. /// <param name="iNetCode"></param>
  608. /// <param name="iPSN"></param>
  609. /// <param name="iID1"></param>
  610. /// <param name="iBT"></param>
  611. /// <param name="iID1"></param>
  612. /// <param name="iID2"></param>
  613. /// <param name="iID3"></param>
  614. /// <param name="oErrorMessage"></param>
  615. /// <returns></returns>
  616. [Description("设置IMEI信息")]
  617. public bool SetIMEIInfo(string iSN, string iIMEI1, out string oErrMessage)
  618. {
  619. if (iSN == "")
  620. {
  621. oErrMessage = "SN不能为空";
  622. return false;
  623. }
  624. oErrMessage = "";
  625. string[] param = new string[] { iSN, iIMEI1, "", "", "", "", "", "", "", "", oErrMessage };
  626. string[] ParamName = new string[] { "v_i_sncode", "v_i_imei1", "v_i_imei2", "v_i_imei3", "v_i_meid", "v_i_netcode", "v_i_psn", "v_i_id1", "v_i_id2", "v_i_id3", "v_o_errmsg" };
  627. CallProcedure("CS_SETIMEIINFO", ParamName, ref param);
  628. oErrMessage = param[10];
  629. if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
  630. return true;
  631. else
  632. return false;
  633. }
  634. /// <summary>
  635. ///
  636. /// </summary>
  637. /// <param name="iSN"></param>
  638. /// <param name="iResCode"></param>
  639. /// <param name="iOperator"></param>
  640. /// <param name="iResult"></param>
  641. /// <param name="iErrCode"></param>
  642. /// <param name="oErrMessage"></param>
  643. /// <returns></returns>
  644. [Description("设置测试结果")]
  645. public bool SetPcbaData(string iSN, string iResCode, string iOperator, string iResult, string iErrCode, out string oErrMessage)
  646. {
  647. if (iSN == "")
  648. {
  649. oErrMessage = "SN不能为空";
  650. return false;
  651. }
  652. oErrMessage = "";
  653. string oMakeCode = "";
  654. GetRcardMOInfo(iSN, out oMakeCode, out oErrMessage);
  655. if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null")
  656. return SetStepFinish(oMakeCode, iResCode, iSN, "", iResult, iOperator, iErrCode, out oErrMessage);
  657. else
  658. return false;
  659. }
  660. /// <summary>
  661. /// 序列号归属工单
  662. /// </summary>
  663. /// <param name="iMO"></param>
  664. /// <param name="iSN"></param>
  665. /// <param name="iResCode"></param>
  666. /// <param name="oErrMessage"></param>
  667. /// <returns></returns>
  668. [Description("序列号归属工单")]
  669. public bool GoMo(string iMO, string iSN, string iResCode, out string oErrMessage)
  670. {
  671. if (iSN == "")
  672. {
  673. oErrMessage = "SN不能为空";
  674. return false;
  675. }
  676. oErrMessage = "";
  677. string[] param = new string[] { iMO, iResCode, iSN, "", "", "", oErrMessage };
  678. string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
  679. CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
  680. oErrMessage = param[6];
  681. DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')", "select");
  682. string ms_status = "";
  683. string ms_stepcode = "";
  684. string ms_nextstepcode = "";
  685. if (dt.Rows.Count > 0)
  686. {
  687. ms_status = dt.Rows[0]["ms_status"].ToString();
  688. ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  689. ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
  690. }
  691. string stepcode = GetStepCodeBySource(iResCode);
  692. if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && ms_stepcode == stepcode))
  693. {
  694. if (ms_status == "3")
  695. {
  696. oErrMessage = "";
  697. }
  698. return true;
  699. }
  700. else
  701. return false;
  702. }
  703. /// <summary>
  704. /// 获取执行步骤代码,名称和线别
  705. /// </summary>
  706. /// <param name="Source"></param>
  707. /// <param name="StepCode"></param>
  708. /// <param name="StepName"></param>
  709. /// <param name="LineCode"></param>
  710. private void GetStepCodeAndNameAndLineBySource(string Source, ref string StepCode, ref string StepName, ref string LineCode)
  711. {
  712. DataTable dt = getFieldsDataByCondition("source", new string[] { "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
  713. if (dt.Rows.Count > 0)
  714. {
  715. StepCode = dt.Rows[0]["sc_stepcode"].ToString();
  716. StepName = dt.Rows[0]["sc_stepname"].ToString();
  717. LineCode = dt.Rows[0]["sc_linecode"].ToString();
  718. }
  719. }
  720. /// <summary>
  721. /// 获取步骤代码和名称
  722. /// </summary>
  723. /// <param name="Source"></param>
  724. /// <param name="StepCode"></param>
  725. /// <param name="StepName"></param>
  726. private void GetStepCodeAndNameBySource(string Source, ref string StepCode, ref string StepName)
  727. {
  728. DataTable dt = getFieldsDataByCondition("source", new string[] { "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
  729. if (dt.Rows.Count > 0)
  730. {
  731. StepCode = dt.Rows[0]["sc_stepcode"].ToString();
  732. StepName = dt.Rows[0]["sc_stepname"].ToString();
  733. }
  734. }
  735. /// <summary>
  736. /// 获取步骤代码
  737. /// </summary>
  738. /// <param name="Source"></param>
  739. /// <returns></returns>
  740. private string GetStepCodeBySource(string Source)
  741. {
  742. return getFieldDataByCondition("source", "sc_stepcode", "sc_code='" + Source + "'").ToString();
  743. }
  744. /// <summary>
  745. /// 获取第一行第一列的信息
  746. /// </summary>
  747. private object getFieldDataByCondition(string TableName, string Field, string Condition)
  748. {
  749. DataTable dt = new DataTable();
  750. string sql = "select " + Field + " from " + TableName + " where " + Condition;
  751. command = new OracleCommand(sql, connection);
  752. Reconnect(command);
  753. OracleDataAdapter ad = new OracleDataAdapter();
  754. ad.SelectCommand = command;
  755. try
  756. {
  757. ad.Fill(dt);
  758. }
  759. catch (Exception)
  760. {
  761. connection = new OracleConnection(ConnectionStrings);
  762. connection.Open();
  763. command = new OracleCommand(sql, connection);
  764. ad = new OracleDataAdapter();
  765. ad.SelectCommand = command;
  766. ad.Fill(dt);
  767. }
  768. ad.Dispose();
  769. command.Dispose();
  770. if (dt.Rows.Count > 0)
  771. {
  772. return dt.Rows[0][0];
  773. }
  774. else
  775. {
  776. return "";
  777. }
  778. }
  779. /// <summary>
  780. /// 通过表名和获取单行的记录
  781. /// </summary>
  782. private DataTable getFieldsDataByCondition(string TableName, string[] Fields, string Condition)
  783. {
  784. DataTable dt = new DataTable();
  785. string sql = "select ";
  786. sql += AddField(Fields);
  787. sql += " from " + TableName + " where " + Condition + " and rownum=1";
  788. command = new OracleCommand(sql, connection);
  789. Reconnect(command);
  790. OracleDataAdapter ad = new OracleDataAdapter(command);
  791. try
  792. {
  793. ad.Fill(dt);
  794. }
  795. catch (Exception)
  796. {
  797. connection = new OracleConnection(ConnectionStrings);
  798. connection.Open();
  799. command = new OracleCommand(sql, connection);
  800. ad = new OracleDataAdapter();
  801. ad.SelectCommand = command;
  802. ad.Fill(dt);
  803. }
  804. ad.Dispose();
  805. command.Dispose();
  806. return dt;
  807. }
  808. /// <summary>
  809. /// 通过表名,字段和条件获取DataTable类型的数据
  810. /// </summary>
  811. private DataTable getFieldsDatasByCondition(string TableName, string[] Fields, string Condition)
  812. {
  813. DataTable dt = new DataTable();
  814. string sql = "select ";
  815. sql += AddField(Fields);
  816. sql += " from " + TableName + " where " + Condition;
  817. command = new OracleCommand(sql, connection);
  818. Reconnect(command);
  819. OracleDataAdapter ad = new OracleDataAdapter(command);
  820. try
  821. {
  822. ad.Fill(dt);
  823. }
  824. catch (Exception)
  825. {
  826. connection = new OracleConnection(ConnectionStrings);
  827. connection.Open();
  828. command = new OracleCommand(sql, connection);
  829. ad = new OracleDataAdapter();
  830. ad.SelectCommand = command;
  831. ad.Fill(dt);
  832. }
  833. ad.Dispose();
  834. command.Dispose();
  835. return dt;
  836. }
  837. /// <summary>
  838. /// 通过表名,字段获取DataTable类型的数据
  839. /// </summary>
  840. private DataTable getFieldsDatas(string TableName, string Fields)
  841. {
  842. DataTable dt = new DataTable();
  843. string sql = "select ";
  844. sql += Fields;
  845. sql += " from " + TableName;
  846. command = new OracleCommand(sql, connection);
  847. Reconnect(command);
  848. OracleDataAdapter ad = new OracleDataAdapter(command);
  849. ad.SelectCommand = command;
  850. try
  851. {
  852. ad.Fill(dt);
  853. }
  854. catch (Exception)
  855. {
  856. connection = new OracleConnection(ConnectionStrings);
  857. connection.Open();
  858. command = new OracleCommand(sql, connection);
  859. ad = new OracleDataAdapter();
  860. ad.SelectCommand = command;
  861. ad.Fill(dt);
  862. }
  863. ad.Dispose();
  864. command.Dispose();
  865. return dt;
  866. }
  867. /// <summary>
  868. /// 检测内容是否存在
  869. /// </summary>
  870. /// <param name="TableName"></param>
  871. /// <param name="Condition"></param>
  872. /// <returns></returns>
  873. private bool CheckExist(string TableName, string Condition)
  874. {
  875. string sql = "select count(1) from " + TableName + " where " + Condition;
  876. command = new OracleCommand(sql, connection);
  877. Reconnect(command);
  878. OracleDataAdapter ad = new OracleDataAdapter(command);
  879. DataTable dt = new DataTable();
  880. ad.Fill(dt);
  881. ad.Dispose();
  882. command.Dispose();
  883. return int.Parse(dt.Rows[0][0].ToString()) > 0;
  884. }
  885. /// <summary>
  886. /// 直接执行SQL,同时传入SQL的类型
  887. /// </summary>
  888. /// <param name="SQL"></param>
  889. /// <param name="Type"></param>
  890. /// <returns></returns>
  891. private object ExecuteSql(string SQL, string Type, params object[] names)
  892. {
  893. object result = null;
  894. command = new OracleCommand(SQL, connection);
  895. Reconnect(command);
  896. //用来拼接参数的
  897. if (names.Length > 0)
  898. {
  899. string[] par = SQL.Split(':');
  900. //用来存参数的数组
  901. StringBuilder[] addpar = new StringBuilder[par.Length - 1];
  902. for (int i = 0; i < par.Length - 1; i++)
  903. {
  904. //新建一个char类型的数组用来存储每个字节的变量
  905. char[] c = par[i + 1].ToCharArray();
  906. addpar[i] = new StringBuilder();
  907. for (int j = 0; j < c.Length; j++)
  908. {
  909. if (c[j] != ' ' && c[j] != ',' && c[j] != ')')
  910. {
  911. addpar[i].Append(c[j]);
  912. }
  913. else
  914. {
  915. break;
  916. }
  917. }
  918. }
  919. for (int i = 0; i < addpar.Length; i++)
  920. {
  921. command.Parameters.Add(new OracleParameter(addpar[i].ToString(), names[i]));
  922. }
  923. }
  924. switch (Type.ToUpper())
  925. {
  926. case "SELECT":
  927. OracleDataAdapter ad = new OracleDataAdapter(command);
  928. result = new DataTable();
  929. try
  930. {
  931. ad.Fill((DataTable)result);
  932. }
  933. catch (Exception)
  934. {
  935. connection = new OracleConnection(ConnectionStrings);
  936. connection.Open();
  937. command = new OracleCommand(SQL, connection);
  938. ad = new OracleDataAdapter();
  939. ad.SelectCommand = command;
  940. ad.Fill((DataTable)result);
  941. }
  942. break;
  943. case "DELETE":
  944. try
  945. {
  946. result = command.ExecuteNonQuery();
  947. }
  948. catch (Exception)
  949. {
  950. command.Connection = new OracleConnection(ConnectionStrings);
  951. command.Connection.Open();
  952. result = command.ExecuteNonQuery();
  953. }
  954. break;
  955. case "UPDATE":
  956. try
  957. {
  958. result = command.ExecuteNonQuery();
  959. }
  960. catch (Exception)
  961. {
  962. command.Connection = new OracleConnection(ConnectionStrings);
  963. command.Connection.Open();
  964. result = command.ExecuteNonQuery();
  965. }
  966. break;
  967. case "INSERT":
  968. try
  969. {
  970. result = command.ExecuteNonQuery();
  971. }
  972. catch (Exception)
  973. {
  974. command.Connection = new OracleConnection(ConnectionStrings);
  975. command.Connection.Open();
  976. result = command.ExecuteNonQuery();
  977. }
  978. break;
  979. }
  980. command.Dispose();
  981. return result;
  982. }
  983. /// <summary>
  984. /// 出现异常进行回滚的执行方法
  985. /// </summary>
  986. /// <param name="SQL"></param>
  987. private void ExecuteSQLTran(params string[] SQL)
  988. {
  989. command = new OracleCommand();
  990. command.Connection = new OracleConnection(ConnectionStrings);
  991. command.Connection.Open();
  992. Reconnect(command);
  993. OracleTransaction tx = command.Connection.BeginTransaction(IsolationLevel.ReadCommitted);
  994. command.Transaction = tx;
  995. try
  996. {
  997. foreach (string sql in SQL)
  998. {
  999. if (!string.IsNullOrEmpty(sql))
  1000. {
  1001. command.CommandText = sql;
  1002. command.ExecuteNonQuery();
  1003. }
  1004. }
  1005. tx.Commit();
  1006. }
  1007. catch (OracleException E)
  1008. {
  1009. tx.Rollback();
  1010. throw new Exception(E.Message);
  1011. }
  1012. command.Dispose();
  1013. }
  1014. private string UpdateByCondition(string TableName, string update, string condition)
  1015. {
  1016. string sql = "update " + TableName + " set " + update + " where " + condition;
  1017. command = new OracleCommand(sql, connection);
  1018. Reconnect(command);
  1019. try
  1020. {
  1021. command.ExecuteNonQuery();
  1022. }
  1023. catch (Exception)
  1024. {
  1025. command.Connection = new OracleConnection(ConnectionStrings);
  1026. command.Connection.Open();
  1027. command.ExecuteNonQuery();
  1028. }
  1029. command.Dispose();
  1030. return sql;
  1031. }
  1032. private void CallProcedure(string ProcedureName, string[] ParamName, ref string[] param)
  1033. {
  1034. command = new OracleCommand(ProcedureName);
  1035. command.Connection = connection;
  1036. Reconnect(command);
  1037. command.CommandText = ProcedureName;
  1038. command.CommandType = CommandType.StoredProcedure;
  1039. for (int i = 0; i < param.Length; i++)
  1040. {
  1041. command.Parameters.Add(new OracleParameter(ParamName[i], OracleDbType.Varchar2, 200, param[i], ParameterDirection.InputOutput));
  1042. //command.Parameters.Add(new OracleParameter(ParamName[i], OracleType.VarChar, 200, ParameterDirection.InputOutput, "", DataRowVersion.Default, true, param[i]));
  1043. }
  1044. try
  1045. {
  1046. command.ExecuteNonQuery();
  1047. }
  1048. catch (Exception)
  1049. {
  1050. command.Connection = new OracleConnection(ConnectionStrings);
  1051. command.Connection.Open();
  1052. command.ExecuteNonQuery();
  1053. }
  1054. for (int i = 0; i < command.Parameters.Count; i++)
  1055. param[i] = command.Parameters[i].Value.ToString();
  1056. command.Dispose();
  1057. }
  1058. private string AddField(string[] Fields)
  1059. {
  1060. string sql = " ";
  1061. foreach (string field in Fields)
  1062. {
  1063. sql += field + ",";
  1064. }
  1065. return sql.Substring(0, sql.Length - 1);
  1066. }
  1067. private string[] GetField(string field)
  1068. {
  1069. string[] fields = field.Split(',');
  1070. for (int i = 0; i < fields.Length; i++)
  1071. {
  1072. fields[i] = fields[i].Substring(fields[i].LastIndexOf("as") + 2, fields[i].Length - fields[i].LastIndexOf("as") - 2).Trim();
  1073. }
  1074. return fields;
  1075. }
  1076. private void Reconnect(OracleCommand cmd)
  1077. {
  1078. if (cmd.Connection.State == ConnectionState.Closed)
  1079. {
  1080. cmd.Connection.Open();
  1081. }
  1082. }
  1083. }
  1084. }