EapBll.cs 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. using Cksoft.Data;
  2. using Cksoft.Data.Repository;
  3. using Cksoft.Unity;
  4. using Cksoft.Unity.Log4NetConfig;
  5. using DllEapDal;
  6. using DllEapEntity;
  7. using Newtonsoft.Json;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. namespace DllEapBll
  12. {
  13. public class EapBll : IDisposable
  14. {
  15. private string CurrDbCode = "sqlconn";
  16. private IDatabase CurrDb = null;
  17. public EapBll(string dbcode)
  18. {
  19. CurrDbCode = dbcode;
  20. CurrDb = DbFactory.Base(CurrDbCode);
  21. }
  22. public void Dispose()
  23. {
  24. if (CurrDb != null)
  25. CurrDb.Close();
  26. }
  27. public Hashtable Login(Hashtable imputds, ref string errorinfo, ref int error)
  28. {
  29. try
  30. {
  31. //errorinfo = "到了登录函数Login";
  32. //return null;
  33. if (imputds == null)
  34. {
  35. errorinfo = "传入数据不能为空,请确认";
  36. error = 1;
  37. return null;
  38. }
  39. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  40. Staff entity = JsonConvert.DeserializeObject<Staff>((string)imputds[nameof(Staff)]);
  41. string usercode = order.usercode;
  42. CurrDb.BeginTrans();
  43. StaffDal tempdal = new StaffDal(CurrDb);
  44. entity = tempdal.Login(entity, ref errorinfo);
  45. if (entity == null)
  46. {
  47. CurrDb.Rollback();
  48. return null;
  49. }
  50. Hashtable reds = new Hashtable();
  51. reds.Add(nameof(Staff), JsonConvert.SerializeObject(entity));
  52. CurrDb.Commit();
  53. return reds;
  54. }
  55. catch (Exception ex)
  56. {
  57. errorinfo = ex.Message.ToString();
  58. error = 1;
  59. CurrDb.Rollback();
  60. return null;
  61. }
  62. finally
  63. {
  64. if (CurrDb != null)
  65. CurrDb.Close();
  66. }
  67. }
  68. public Hashtable IUMacModel(Hashtable imputds, ref string errorinfo, ref int error)
  69. {
  70. try
  71. {
  72. if (imputds == null)
  73. {
  74. errorinfo = "传入数据不能为空,请确认";
  75. error = 1;
  76. return null;
  77. }
  78. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  79. MacModel entity = JsonConvert.DeserializeObject<MacModel>((string)imputds[nameof(MacModel)]);
  80. List<MMSecDetail> details = JsonConvert.DeserializeObject<List<MMSecDetail>>((string)imputds[nameof(MMSecDetail)]);
  81. string usercode = order.usercode;
  82. CurrDb.BeginTrans();
  83. MacModelDal tempdal = new MacModelDal(CurrDb);
  84. entity = tempdal.IUMacModel(entity, details, order.usercode, ref errorinfo);
  85. if (entity == null)
  86. {
  87. CurrDb.Rollback();
  88. return null;
  89. }
  90. Hashtable reds = new Hashtable();
  91. reds.Add(nameof(MacModel), JsonConvert.SerializeObject(entity));
  92. CurrDb.Commit();
  93. return reds;
  94. }
  95. catch (Exception ex)
  96. {
  97. errorinfo = ex.Message.ToString();
  98. error = 1;
  99. CurrDb.Rollback();
  100. return null;
  101. }
  102. finally
  103. {
  104. if (CurrDb != null)
  105. CurrDb.Close();
  106. }
  107. }
  108. public Hashtable DelMacModel(Hashtable imputds, ref string errorinfo, ref int error)
  109. {
  110. try
  111. {
  112. if (imputds == null)
  113. {
  114. errorinfo = "传入数据不能为空,请确认";
  115. error = 1;
  116. return null;
  117. }
  118. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  119. List<MacModel> details = JsonConvert.DeserializeObject<List<MacModel>>((string)imputds[nameof(MacModel)]);
  120. string usercode = order.usercode;
  121. CurrDb.BeginTrans();
  122. MacModelDal tempdal = new MacModelDal(CurrDb);
  123. foreach (var item in details)
  124. {
  125. //entity = tempdal.IUMacModel(entity, details, order.usercode, ref errorinfo);
  126. //if (entity == null)
  127. //{
  128. // CurrDb.Rollback();
  129. // return null;
  130. //}
  131. }
  132. Hashtable reds = new Hashtable();
  133. //reds.Add(nameof(MacModel), JsonConvert.SerializeObject(entity));
  134. CurrDb.Commit();
  135. return reds;
  136. }
  137. catch (Exception ex)
  138. {
  139. errorinfo = ex.Message.ToString();
  140. error = 1;
  141. CurrDb.Rollback();
  142. return null;
  143. }
  144. finally
  145. {
  146. if (CurrDb != null)
  147. CurrDb.Close();
  148. }
  149. }
  150. public Hashtable IUMachine(Hashtable imputds, ref string errorinfo, ref int error)
  151. {
  152. try
  153. {
  154. if (imputds == null)
  155. {
  156. errorinfo = "传入数据不能为空,请确认";
  157. error = 1;
  158. return null;
  159. }
  160. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  161. Machine entity = JsonConvert.DeserializeObject<Machine>((string)imputds[nameof(Machine)]);
  162. string usercode = order.usercode;
  163. CurrDb.BeginTrans();
  164. MachineDal tempdal = new MachineDal(CurrDb);
  165. entity = tempdal.IUMachine(entity, order.usercode, ref errorinfo);
  166. if (entity == null)
  167. {
  168. CurrDb.Rollback();
  169. return null;
  170. }
  171. Hashtable reds = new Hashtable();
  172. reds.Add(nameof(Machine), JsonConvert.SerializeObject(entity));
  173. CurrDb.Commit();
  174. LogHelper<Machine>.LogFatal("新增Machine-->" + Json.ToJson(entity), "用户操作", usercode);
  175. return reds;
  176. }
  177. catch (Exception ex)
  178. {
  179. errorinfo = ex.Message.ToString();
  180. error = 1;
  181. CurrDb.Rollback();
  182. return null;
  183. }
  184. finally
  185. {
  186. if (CurrDb != null)
  187. CurrDb.Close();
  188. }
  189. }
  190. public Hashtable IUOrderMst(Hashtable imputds, ref string errorinfo, ref int error)
  191. {
  192. try
  193. {
  194. if (imputds == null)
  195. {
  196. errorinfo = "传入数据不能为空,请确认";
  197. error = 1;
  198. return null;
  199. }
  200. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  201. OrderMst entity = JsonConvert.DeserializeObject<OrderMst>((string)imputds[nameof(OrderMst)]);
  202. List<OrderDetail> details = JsonConvert.DeserializeObject<List<OrderDetail>>((string)imputds[nameof(OrderDetail)]);
  203. List<OrderData> datas = JsonConvert.DeserializeObject<List<OrderData>>((string)imputds[nameof(OrderData)]);
  204. List<OrderDetailSec> secs = JsonConvert.DeserializeObject<List<OrderDetailSec>>((string)imputds[nameof(OrderDetailSec)]);
  205. string usercode = order.usercode;
  206. CurrDb.BeginTrans();
  207. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  208. entity = tempdal.IUOrderMst(entity, details, datas, secs, order.usercode, ref errorinfo);
  209. if (entity == null)
  210. {
  211. CurrDb.Rollback();
  212. return null;
  213. }
  214. Hashtable reds = new Hashtable();
  215. reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity));
  216. CurrDb.Commit();
  217. LogHelper<OrderMst>.LogFatal("新增OrderMst-->" + Json.ToJson(entity), "用户操作", usercode);
  218. return reds;
  219. }
  220. catch (Exception ex)
  221. {
  222. errorinfo = ex.Message.ToString();
  223. error = 1;
  224. CurrDb.Rollback();
  225. return null;
  226. }
  227. finally
  228. {
  229. if (CurrDb != null)
  230. CurrDb.Close();
  231. }
  232. }
  233. public Hashtable AutoProcessOac(Hashtable imputds, ref string errorinfo, ref int error)
  234. {
  235. try
  236. {
  237. if (imputds == null)
  238. {
  239. errorinfo = "传入数据不能为空,请确认";
  240. error = 1;
  241. return null;
  242. }
  243. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  244. OrderMst entity = JsonConvert.DeserializeObject<OrderMst>((string)imputds[nameof(OrderMst)]);
  245. string usercode = order.usercode;
  246. CurrDb.BeginTrans();
  247. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  248. int result = tempdal.AutoProcessOac(entity.ID, order.usercode, ref errorinfo);
  249. if (result <= 0)
  250. {
  251. CurrDb.Rollback();
  252. return null;
  253. }
  254. Hashtable reds = new Hashtable();
  255. reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity));
  256. CurrDb.Commit();
  257. LogHelper<OrderMst>.LogFatal("AutoProcessOac-->" + Json.ToJson(entity), "用户操作", usercode);
  258. return reds;
  259. }
  260. catch (Exception ex)
  261. {
  262. errorinfo = ex.Message.ToString();
  263. error = 1;
  264. CurrDb.Rollback();
  265. return null;
  266. }
  267. finally
  268. {
  269. if (CurrDb != null)
  270. CurrDb.Close();
  271. }
  272. }
  273. public Hashtable AddVersionOrder(Hashtable imputds, ref string errorinfo, ref int error)
  274. {
  275. try
  276. {
  277. if (imputds == null)
  278. {
  279. errorinfo = "传入数据不能为空,请确认";
  280. error = 1;
  281. return null;
  282. }
  283. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  284. OrderMst entity = JsonConvert.DeserializeObject<OrderMst>((string)imputds[nameof(OrderMst)]);
  285. string usercode = order.usercode;
  286. CurrDb.BeginTrans();
  287. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  288. int result = tempdal.AddVersionOrder(entity, order.usercode, ref errorinfo);
  289. if (result <= 0)
  290. {
  291. CurrDb.Rollback();
  292. return null;
  293. }
  294. Hashtable reds = new Hashtable();
  295. reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity));
  296. CurrDb.Commit();
  297. LogHelper<OrderMst>.LogFatal("新增OrderMst-->" + Json.ToJson(entity), "用户操作", usercode);
  298. return reds;
  299. }
  300. catch (Exception ex)
  301. {
  302. errorinfo = ex.Message.ToString();
  303. error = 1;
  304. CurrDb.Rollback();
  305. return null;
  306. }
  307. finally
  308. {
  309. if (CurrDb != null)
  310. CurrDb.Close();
  311. }
  312. }
  313. public Hashtable CopyOrderDetailTo(Hashtable imputds, ref string errorinfo, ref int error)
  314. {
  315. try
  316. {
  317. if (imputds == null)
  318. {
  319. errorinfo = "传入数据不能为空,请确认";
  320. error = 1;
  321. return null;
  322. }
  323. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  324. List<OrderMst> desordermst = JsonConvert.DeserializeObject<List<OrderMst>>((string)imputds[nameof(OrderMst)]);
  325. List<OrderDetail> orgorderdetails = JsonConvert.DeserializeObject<List<OrderDetail>>((string)imputds[nameof(OrderDetail)]);
  326. string usercode = order.usercode;
  327. CurrDb.BeginTrans();
  328. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  329. foreach (var item in desordermst)
  330. {
  331. int result = tempdal.CopyOrderDetail(orgorderdetails, item, order.usercode, ref errorinfo);
  332. if (result <= 0)
  333. {
  334. CurrDb.Rollback();
  335. return null;
  336. }
  337. }
  338. Hashtable reds = new Hashtable();
  339. reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(desordermst[0]));
  340. CurrDb.Commit();
  341. return reds;
  342. }
  343. catch (Exception ex)
  344. {
  345. errorinfo = ex.Message.ToString();
  346. error = 1;
  347. CurrDb.Rollback();
  348. return null;
  349. }
  350. finally
  351. {
  352. if (CurrDb != null)
  353. CurrDb.Close();
  354. }
  355. }
  356. public Hashtable CopyOrder(Hashtable imputds, ref string errorinfo, ref int error)
  357. {
  358. try
  359. {
  360. if (imputds == null)
  361. {
  362. errorinfo = "传入数据不能为空,请确认";
  363. error = 1;
  364. return null;
  365. }
  366. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  367. OrderMst entity = JsonConvert.DeserializeObject<OrderMst>((string)imputds[nameof(OrderMst)]);
  368. string usercode = order.usercode;
  369. CurrDb.BeginTrans();
  370. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  371. int result = tempdal.CopyOrder(entity, order.usercode, ref errorinfo);
  372. if (result <= 0)
  373. {
  374. CurrDb.Rollback();
  375. return null;
  376. }
  377. Hashtable reds = new Hashtable();
  378. reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity));
  379. CurrDb.Commit();
  380. return reds;
  381. }
  382. catch (Exception ex)
  383. {
  384. errorinfo = ex.Message.ToString();
  385. error = 1;
  386. CurrDb.Rollback();
  387. return null;
  388. }
  389. }
  390. public Hashtable DelOrderMst(Hashtable imputds, ref string errorinfo, ref int error)
  391. {
  392. try
  393. {
  394. if (imputds == null)
  395. {
  396. errorinfo = "传入数据不能为空,请确认";
  397. error = 1;
  398. return null;
  399. }
  400. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  401. List<OrderMst> entitys = JsonConvert.DeserializeObject<List<OrderMst>>((string)imputds[nameof(OrderMst)]);
  402. string usercode = order.usercode;
  403. CurrDb.BeginTrans();
  404. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  405. int result = tempdal.DelOrderMst(entitys, ref errorinfo);
  406. if (result <= 0)
  407. {
  408. CurrDb.Rollback();
  409. return null;
  410. }
  411. Hashtable reds = new Hashtable();
  412. reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entitys[0]));
  413. CurrDb.Commit();
  414. LogHelper<OrderMst>.LogFatal("删除OrderMst-->" + Json.ToJson(entitys), "用户操作", usercode);
  415. return reds;
  416. }
  417. catch (Exception ex)
  418. {
  419. errorinfo = ex.Message.ToString();
  420. error = 1;
  421. CurrDb.Rollback();
  422. return null;
  423. }
  424. }
  425. public Hashtable OrderRelationMca(Hashtable imputds, ref string errorinfo, ref int error)
  426. {
  427. try
  428. {
  429. if (imputds == null)
  430. {
  431. errorinfo = "传入数据不能为空,请确认";
  432. error = 1;
  433. return null;
  434. }
  435. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  436. OrderMst entity = JsonConvert.DeserializeObject<OrderMst>((string)imputds[nameof(OrderMst)]);
  437. List<Machine> entitys = JsonConvert.DeserializeObject<List<Machine>>((string)imputds[nameof(Machine)]);
  438. string usercode = order.usercode;
  439. CurrDb.BeginTrans();
  440. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  441. int result = tempdal.OrderRelationMca(entity, entitys, usercode, ref errorinfo);
  442. if (result <= 0)
  443. {
  444. CurrDb.Rollback();
  445. return null;
  446. }
  447. Hashtable reds = new Hashtable();
  448. reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity));
  449. CurrDb.Commit();
  450. return reds;
  451. }
  452. catch (Exception ex)
  453. {
  454. errorinfo = ex.Message.ToString();
  455. error = 1;
  456. CurrDb.Rollback();
  457. return null;
  458. }
  459. }
  460. public Hashtable IUSec(Hashtable imputds, ref string errorinfo, ref int error)
  461. {
  462. try
  463. {
  464. if (imputds == null)
  465. {
  466. errorinfo = "传入数据不能为空,请确认";
  467. error = 1;
  468. return null;
  469. }
  470. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  471. Sec entity = JsonConvert.DeserializeObject<Sec>((string)imputds[nameof(Sec)]);
  472. string usercode = order.usercode;
  473. CurrDb.BeginTrans();
  474. SecDal tempdal = new SecDal(CurrDb);
  475. Sec reentity = tempdal.IUSec(entity, usercode, ref errorinfo);
  476. if (reentity == null)
  477. {
  478. CurrDb.Rollback();
  479. return null;
  480. }
  481. Hashtable reds = new Hashtable();
  482. reds.Add(nameof(Sec), JsonConvert.SerializeObject(reentity));
  483. CurrDb.Commit();
  484. return reds;
  485. }
  486. catch (Exception ex)
  487. {
  488. errorinfo = ex.Message.ToString();
  489. error = 1;
  490. CurrDb.Rollback();
  491. return null;
  492. }
  493. }
  494. public Hashtable DelReportMst(Hashtable imputds, ref string errorinfo, ref int error)
  495. {
  496. try
  497. {
  498. if (imputds == null)
  499. {
  500. errorinfo = "传入数据不能为空,请确认";
  501. error = 1;
  502. return null;
  503. }
  504. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  505. List<ReportMst> entitys = JsonConvert.DeserializeObject<List<ReportMst>>((string)imputds[nameof(ReportMst)]);
  506. string usercode = order.usercode;
  507. CurrDb.BeginTrans();
  508. ReportMstDal tempdal = new ReportMstDal(CurrDb);
  509. int result = tempdal.DelReportMst(entitys, ref errorinfo);
  510. if (result < 0)
  511. {
  512. CurrDb.Rollback();
  513. return null;
  514. }
  515. Hashtable reds = new Hashtable();
  516. reds.Add(nameof(ReportMst), JsonConvert.SerializeObject(entitys[0]));
  517. CurrDb.Commit();
  518. LogHelper<ReportMst>.LogFatal("删除ReportMst-->" + Json.ToJson(entitys), "用户操作", usercode);
  519. return reds;
  520. }
  521. catch (Exception ex)
  522. {
  523. errorinfo = ex.Message.ToString();
  524. error = 1;
  525. CurrDb.Rollback();
  526. return null;
  527. }
  528. }
  529. public Hashtable IUReportMst(Hashtable imputds, ref string errorinfo, ref int error)
  530. {
  531. try
  532. {
  533. if (imputds == null)
  534. {
  535. errorinfo = "传入数据不能为空,请确认";
  536. error = 1;
  537. return null;
  538. }
  539. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  540. ReportMst entity = JsonConvert.DeserializeObject<ReportMst>((string)imputds[nameof(ReportMst)]);
  541. List<ReportDetail> details = JsonConvert.DeserializeObject<List<ReportDetail>>((string)imputds[nameof(ReportDetail)]);
  542. string usercode = order.usercode;
  543. CurrDb.BeginTrans();
  544. ReportMstDal tempdal = new ReportMstDal(CurrDb);
  545. ReportMst reentity = tempdal.IUReportMst(entity, details, usercode, ref errorinfo);
  546. if (reentity == null)
  547. {
  548. CurrDb.Rollback();
  549. return null;
  550. }
  551. Hashtable reds = new Hashtable();
  552. reds.Add(nameof(ReportMst), JsonConvert.SerializeObject(reentity));
  553. CurrDb.Commit();
  554. return reds;
  555. }
  556. catch (Exception ex)
  557. {
  558. errorinfo = ex.Message.ToString();
  559. error = 1;
  560. CurrDb.Rollback();
  561. return null;
  562. }
  563. }
  564. public Hashtable CopyReportMst(Hashtable imputds, ref string errorinfo, ref int error)
  565. {
  566. try
  567. {
  568. if (imputds == null)
  569. {
  570. errorinfo = "传入数据不能为空,请确认";
  571. error = 1;
  572. return null;
  573. }
  574. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  575. ReportMst entity = JsonConvert.DeserializeObject<ReportMst>((string)imputds[nameof(ReportMst)]);
  576. string usercode = order.usercode;
  577. CurrDb.BeginTrans();
  578. ReportMstDal tempdal = new ReportMstDal(CurrDb);
  579. ReportMst reentity = tempdal.CopyReportMst(entity, usercode, ref errorinfo);
  580. if (reentity == null)
  581. {
  582. CurrDb.Rollback();
  583. return null;
  584. }
  585. Hashtable reds = new Hashtable();
  586. reds.Add(nameof(ReportMst), JsonConvert.SerializeObject(reentity));
  587. CurrDb.Commit();
  588. return reds;
  589. }
  590. catch (Exception ex)
  591. {
  592. errorinfo = ex.Message.ToString();
  593. error = 1;
  594. CurrDb.Rollback();
  595. return null;
  596. }
  597. }
  598. public Hashtable DelMachine(Hashtable imputds, ref string errorinfo, ref int error)
  599. {
  600. try
  601. {
  602. if (imputds == null)
  603. {
  604. errorinfo = "传入数据不能为空,请确认";
  605. error = 1;
  606. return null;
  607. }
  608. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  609. List<Machine> details = JsonConvert.DeserializeObject<List<Machine>>((string)imputds[nameof(Machine)]);
  610. string usercode = order.usercode;
  611. CurrDb.BeginTrans();
  612. MachineDal tempdal = new MachineDal(CurrDb);
  613. object result = tempdal.DelMachine(details, ref errorinfo);
  614. if (result == null)
  615. {
  616. CurrDb.Rollback();
  617. return null;
  618. }
  619. Hashtable reds = new Hashtable();
  620. reds.Add("result", JsonConvert.SerializeObject(result));
  621. CurrDb.Commit();
  622. LogHelper<Machine>.LogFatal("删除Machine-->" + Json.ToJson(details), "用户操作", usercode);
  623. return reds;
  624. }
  625. catch (Exception ex)
  626. {
  627. errorinfo = ex.Message.ToString();
  628. error = 1;
  629. CurrDb.Rollback();
  630. return null;
  631. }
  632. }
  633. public Hashtable DelMacOrder(Hashtable imputds, ref string errorinfo, ref int error)
  634. {
  635. try
  636. {
  637. if (imputds == null)
  638. {
  639. errorinfo = "传入数据不能为空,请确认";
  640. error = 1;
  641. return null;
  642. }
  643. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  644. List<MacOrder> entitys = JsonConvert.DeserializeObject<List<MacOrder>>((string)imputds[nameof(MacOrder)]);
  645. string usercode = order.usercode;
  646. CurrDb.BeginTrans();
  647. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  648. int result = tempdal.DelMacOrder(entitys);
  649. if (result <= 0)
  650. {
  651. CurrDb.Rollback();
  652. return null;
  653. }
  654. Hashtable reds = new Hashtable();
  655. reds.Add(nameof(MacOrder), JsonConvert.SerializeObject(entitys[0]));
  656. CurrDb.Commit();
  657. LogHelper<MacOrder>.LogFatal("删除MacOrder-->" + Json.ToJson(entitys), "用户操作", usercode);
  658. return reds;
  659. }
  660. catch (Exception ex)
  661. {
  662. errorinfo = ex.Message.ToString();
  663. error = 1;
  664. CurrDb.Rollback();
  665. return null;
  666. }
  667. }
  668. public Hashtable IUOrderEvent(Hashtable imputds, ref string errorinfo, ref int error)
  669. {
  670. try
  671. {
  672. if (imputds == null)
  673. {
  674. errorinfo = "传入数据不能为空,请确认";
  675. error = 1;
  676. return null;
  677. }
  678. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  679. List<OrderEvent> details = JsonConvert.DeserializeObject<List<OrderEvent>>((string)imputds[nameof(OrderEvent)]);
  680. List<EventReportDetail> datas = JsonConvert.DeserializeObject<List<EventReportDetail>>((string)imputds[nameof(EventReportDetail)]);
  681. string usercode = order.usercode;
  682. CurrDb.BeginTrans();
  683. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  684. int result = tempdal.IUOrderEvent(details, datas, order.usercode, ref errorinfo);
  685. if (result <= 0)
  686. {
  687. CurrDb.Rollback();
  688. return null;
  689. }
  690. Hashtable reds = new Hashtable();
  691. reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order));
  692. CurrDb.Commit();
  693. return reds;
  694. }
  695. catch (Exception ex)
  696. {
  697. errorinfo = ex.Message.ToString();
  698. error = 1;
  699. CurrDb.Rollback();
  700. return null;
  701. }
  702. }
  703. public Hashtable IUOrderStatus(Hashtable imputds, ref string errorinfo, ref int error)
  704. {
  705. try
  706. {
  707. if (imputds == null)
  708. {
  709. errorinfo = "传入数据不能为空,请确认";
  710. error = 1;
  711. return null;
  712. }
  713. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  714. List<OrderStatus> details = JsonConvert.DeserializeObject<List<OrderStatus>>((string)imputds[nameof(OrderStatus)]);
  715. string usercode = order.usercode;
  716. CurrDb.BeginTrans();
  717. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  718. int result = tempdal.IUOrderStatus(details, order.usercode, ref errorinfo);
  719. if (result <= 0)
  720. {
  721. CurrDb.Rollback();
  722. return null;
  723. }
  724. Hashtable reds = new Hashtable();
  725. reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order));
  726. CurrDb.Commit();
  727. return reds;
  728. }
  729. catch (Exception ex)
  730. {
  731. errorinfo = ex.Message.ToString();
  732. error = 1;
  733. CurrDb.Rollback();
  734. return null;
  735. }
  736. }
  737. public Hashtable AccountOrderSecDetail(Hashtable imputds, ref string errorinfo, ref int error)
  738. {
  739. try
  740. {
  741. if (imputds == null)
  742. {
  743. errorinfo = "传入数据不能为空,请确认";
  744. error = 1;
  745. return null;
  746. }
  747. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  748. OrderMst entity = JsonConvert.DeserializeObject<OrderMst>((string)imputds[nameof(OrderMst)]);
  749. string usercode = order.usercode;
  750. CurrDb.BeginTrans();
  751. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  752. int result = tempdal.AccountOrderSecDetail(entity, order.usercode, ref errorinfo);
  753. if (result <= 0)
  754. {
  755. CurrDb.Rollback();
  756. return null;
  757. }
  758. Hashtable reds = new Hashtable();
  759. reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order));
  760. CurrDb.Commit();
  761. return reds;
  762. }
  763. catch (Exception ex)
  764. {
  765. errorinfo = ex.Message.ToString();
  766. error = 1;
  767. CurrDb.Rollback();
  768. return null;
  769. }
  770. }
  771. public Hashtable UOrderSecDetail(Hashtable imputds, ref string errorinfo, ref int error)
  772. {
  773. try
  774. {
  775. if (imputds == null)
  776. {
  777. errorinfo = "传入数据不能为空,请确认";
  778. error = 1;
  779. return null;
  780. }
  781. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  782. //List<OrderSecDetail> details = JsonConvert.DeserializeObject<List<OrderSecDetail>>((string)imputds[nameof(OrderSecDetail)]);
  783. //string usercode = order.usercode;
  784. //CurrDb.BeginTrans();
  785. //OrderMstDal tempdal = new OrderMstDal(CurrDb);
  786. //int result = tempdal.UOrderSecDetail(details, order.usercode, ref errorinfo);
  787. //if (result <= 0)
  788. //{
  789. // CurrDb.Rollback();
  790. // return null;
  791. //}
  792. Hashtable reds = new Hashtable();
  793. reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order));
  794. CurrDb.Commit();
  795. return reds;
  796. }
  797. catch (Exception ex)
  798. {
  799. errorinfo = ex.Message.ToString();
  800. error = 1;
  801. CurrDb.Rollback();
  802. return null;
  803. }
  804. }
  805. public Hashtable CopyOrderToModel(Hashtable imputds, ref string errorinfo, ref int error)
  806. {
  807. try
  808. {
  809. if (imputds == null)
  810. {
  811. errorinfo = "传入数据不能为空,请确认";
  812. error = 1;
  813. return null;
  814. }
  815. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  816. OrderMst entity = JsonConvert.DeserializeObject<OrderMst>((string)imputds[nameof(OrderMst)]);
  817. MacModel model = JsonConvert.DeserializeObject<MacModel>((string)imputds[nameof(MacModel)]);
  818. string usercode = order.usercode;
  819. CurrDb.BeginTrans();
  820. OrderMstDal tempdal = new OrderMstDal(CurrDb);
  821. int result = tempdal.CopyOrderToModel(entity, model, order.usercode, ref errorinfo);
  822. if (result <= 0)
  823. {
  824. CurrDb.Rollback();
  825. return null;
  826. }
  827. Hashtable reds = new Hashtable();
  828. reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity));
  829. CurrDb.Commit();
  830. return reds;
  831. }
  832. catch (Exception ex)
  833. {
  834. errorinfo = ex.Message.ToString();
  835. error = 1;
  836. CurrDb.Rollback();
  837. return null;
  838. }
  839. }
  840. public Hashtable ImportFileParams(Hashtable imputds, ref string errorinfo, ref int error)
  841. {
  842. try
  843. {
  844. if (imputds == null)
  845. {
  846. errorinfo = "传入数据不能为空,请确认";
  847. error = 1;
  848. return null;
  849. }
  850. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  851. List<FileParams> entity = JsonConvert.DeserializeObject<List<FileParams>>((string)imputds[nameof(FileParams)]);
  852. if (entity.Count <= 0)
  853. {
  854. errorinfo = "未找到传入的机型参数。";
  855. return null;
  856. }
  857. string usercode = order.usercode;
  858. CurrDb.BeginTrans();
  859. int modelid = entity[0].ModelID;
  860. FileParamsDal tempdal = new FileParamsDal(CurrDb);
  861. int result = tempdal.ImportFileParams(modelid, entity, order.usercode, ref errorinfo);
  862. if (result <= 0)
  863. {
  864. CurrDb.Rollback();
  865. return null;
  866. }
  867. Hashtable reds = new Hashtable();
  868. reds.Add("result", result);
  869. CurrDb.Commit();
  870. return reds;
  871. }
  872. catch (Exception ex)
  873. {
  874. errorinfo = ex.Message.ToString();
  875. error = 1;
  876. CurrDb.Rollback();
  877. return null;
  878. }
  879. }
  880. /// <summary>
  881. /// 根据机台编号,时间范围,读取机台对应的日志信息
  882. /// </summary>
  883. /// <param name="imputds"></param>
  884. /// <param name="errorinfo"></param>
  885. /// <param name="error"></param>
  886. /// <returns></returns>
  887. public Hashtable ReadLog(Hashtable imputds, ref string errorinfo, ref int error)
  888. {
  889. try
  890. {
  891. if (imputds == null)
  892. {
  893. errorinfo = "传入数据不能为空,请确认";
  894. error = 1;
  895. return null;
  896. }
  897. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  898. Machine mac = JsonConvert.DeserializeObject<Machine>((string)imputds[nameof(Machine)]);
  899. //DateTime starttime= JsonConvert.DeserializeObject<DateTime>((string)imputds["starttime"]);
  900. //DateTime endtime = JsonConvert.DeserializeObject<DateTime>((string)imputds["endtime"]);
  901. DateTime starttime = DateTime.Parse(imputds["starttime"].ToString());
  902. DateTime endtime = DateTime.Parse(imputds["endtime"].ToString());
  903. string usercode = order.usercode;
  904. LogDal tempdal = new LogDal(CurrDb);
  905. List<string> logs = tempdal.ReadLog(mac, starttime, endtime, ref errorinfo);
  906. if (logs == null)
  907. {
  908. return null;
  909. }
  910. Hashtable reds = new Hashtable();
  911. reds.Add("log", JsonConvert.SerializeObject(logs));
  912. return reds;
  913. }
  914. catch (Exception ex)
  915. {
  916. errorinfo = ex.Message.ToString();
  917. error = 1;
  918. return null;
  919. }
  920. }
  921. public Hashtable ReadBusinessLog(Hashtable imputds, ref string errorinfo, ref int error)
  922. {
  923. try
  924. {
  925. if (imputds == null)
  926. {
  927. errorinfo = "传入数据不能为空,请确认";
  928. error = 1;
  929. return null;
  930. }
  931. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  932. Machine mac = JsonConvert.DeserializeObject<Machine>((string)imputds[nameof(Machine)]);
  933. //DateTime starttime= JsonConvert.DeserializeObject<DateTime>((string)imputds["starttime"]);
  934. //DateTime endtime = JsonConvert.DeserializeObject<DateTime>((string)imputds["endtime"]);
  935. DateTime starttime = DateTime.Parse(imputds["starttime"].ToString());
  936. DateTime endtime = DateTime.Parse(imputds["endtime"].ToString());
  937. string usercode = order.usercode;
  938. LogDal tempdal = new LogDal(CurrDb);
  939. List<string> logs = tempdal.ReadBusinessLog(mac, starttime, endtime, ref errorinfo);
  940. if (logs == null)
  941. {
  942. return null;
  943. }
  944. Hashtable reds = new Hashtable();
  945. reds.Add("log", JsonConvert.SerializeObject(logs));
  946. return reds;
  947. }
  948. catch (Exception ex)
  949. {
  950. errorinfo = ex.Message.ToString();
  951. error = 1;
  952. return null;
  953. }
  954. }
  955. public Hashtable SaveProgram(Hashtable imputds, ref string errorinfo, ref int error)
  956. {
  957. try
  958. {
  959. if (imputds == null)
  960. {
  961. errorinfo = "传入数据不能为空,请确认";
  962. error = 1;
  963. return null;
  964. }
  965. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  966. Machine mac = JsonConvert.DeserializeObject<Machine>((string)imputds[nameof(Machine)]);
  967. CurrDb.BeginTrans();
  968. string usercode = order.usercode;
  969. MacProgram resultprogram = null;
  970. if (mac.SupplierFCode == "KNS")
  971. {
  972. KnsProgramDal dal = new KnsProgramDal(CurrDb);
  973. resultprogram = dal.SaveProgram(mac.FCode, usercode, ref errorinfo);
  974. }
  975. else
  976. {
  977. AsmProgramDal dal = new AsmProgramDal(CurrDb);
  978. resultprogram = dal.SaveProgram(mac.FCode, usercode, ref errorinfo);
  979. }
  980. int result = 1;
  981. if (resultprogram == null)
  982. {
  983. result = -1;
  984. }
  985. Hashtable reds = new Hashtable();
  986. reds.Add("result", result.ToString());
  987. return reds;
  988. }
  989. catch (Exception ex)
  990. {
  991. errorinfo = ex.Message.ToString();
  992. error = 1;
  993. return null;
  994. }
  995. }
  996. public Hashtable SendStopOrder(Hashtable imputds, ref string errorinfo, ref int error)
  997. {
  998. try
  999. {
  1000. if (imputds == null)
  1001. {
  1002. errorinfo = "传入数据不能为空,请确认";
  1003. error = 1;
  1004. return null;
  1005. }
  1006. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  1007. string maccode = (string)imputds["maccode"];
  1008. CurrDb.BeginTrans();
  1009. MacOrderSendDal dal = new MacOrderSendDal(CurrDb);
  1010. int result = dal.SendStopMac(maccode, ref errorinfo);
  1011. Hashtable reds = new Hashtable();
  1012. reds.Add("result", result.ToString());
  1013. return reds;
  1014. }
  1015. catch (Exception ex)
  1016. {
  1017. errorinfo = ex.Message.ToString();
  1018. error = 1;
  1019. return null;
  1020. }
  1021. }
  1022. public int ModifyProgramName(string maccode, string orgname, string desname, ref string errorinfo)
  1023. {
  1024. try
  1025. {
  1026. CurrDb.BeginTrans();
  1027. MacProgramDal dal = new MacProgramDal(CurrDb);
  1028. int result = dal.ModifyProgramName(maccode, orgname, desname, ref errorinfo);
  1029. if (result <= 0)
  1030. {
  1031. CurrDb.Rollback();
  1032. return -1;
  1033. }
  1034. CurrDb.Commit();
  1035. return 1;
  1036. }
  1037. catch (Exception ex)
  1038. {
  1039. errorinfo = ex.Message.ToString();
  1040. CurrDb.Rollback();
  1041. return -1;
  1042. }
  1043. }
  1044. }
  1045. }