华恒Mes鼎捷代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
8.5 KiB

5 months ago
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using ICSSoft.Frame.Data.Entity;
  5. using System.Linq;
  6. using System.Data.Linq;
  7. using System.Xml.Linq;
  8. using ICSSoft.Base.Config.AppConfig;
  9. using ICSSoft.Frame.DataCollect;
  10. using ICSSoft.Frame.Helper;
  11. using System.Windows.Forms;
  12. namespace ICSSoft.Frame.DataConnect.Action
  13. {
  14. /// <summary>
  15. /// ���������ɼ�
  16. /// </summary>
  17. public class ActionTS : IActionWithStatus
  18. {
  19. private FramDataContext _domainDataProvider = null;
  20. // public ActionTS()
  21. // {
  22. // //
  23. // // TODO: �ڴ˴����ӹ��캯���߼�
  24. // //
  25. // }
  26. public ActionTS(FramDataContext domainDataProvider)
  27. {
  28. this._domainDataProvider = domainDataProvider;
  29. }
  30. public FramDataContext DataProvider
  31. {
  32. get
  33. {
  34. return _domainDataProvider;
  35. }
  36. }
  37. /// <summary>
  38. /// ����Ʒ�ɼ�
  39. /// </summary>
  40. /// <param name="domainDataProvider"></param>
  41. /// <param name="iD"></param>
  42. /// <param name="actionType"></param>
  43. /// <param name="resourceCode"></param>
  44. /// <param name="userCode"></param>
  45. /// <param name="product"></param>
  46. /// <param name="datas1"></param>
  47. /// <param name="datas2"></param>
  48. /// <returns></returns>
  49. public Messages Execute(ActionEventArgs actionEventArgs)
  50. {
  51. Messages messages = new Messages();
  52. Messages msgAutoGoMO = new Messages();
  53. try
  54. {
  55. // �Զ���Undo
  56. messages.AddMessages((new ActionUndoNG(this.DataProvider)).UndoNG(actionEventArgs));
  57. // Added end
  58. ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
  59. //��дSIMULATION ���鹤����ID��;�̡�����
  60. messages.AddMessages(dataCollect.CheckID(actionEventArgs));
  61. if (messages.IsSuccess())
  62. {
  63. //����SIMULATION ������Ϣ
  64. actionEventArgs.ProductInfo.NowSimulation.PRODUCTSTATUS = ProductStatus.NG;
  65. actionEventArgs.ProductInfo.NowSimulation.NGTIMES = actionEventArgs.ProductInfo.NowSimulation.NGTIMES + 1;
  66. messages.AddMessages(dataCollect.Execute(actionEventArgs));
  67. if (messages.IsSuccess())
  68. {
  69. //��ȡErrorGroup2ErrorCode
  70. if (actionEventArgs.ActionType == ActionType.DataCollectAction_NG)
  71. {
  72. actionEventArgs.ProductInfo.ECG2ErrCodes = ParseECG2Errs(((TSActionEventArgs)actionEventArgs).ErrorCodes, actionEventArgs.ActionType);
  73. }
  74. else
  75. {
  76. actionEventArgs.ProductInfo.ECG2ErrCodes = ParseECG2Errs(((TSActionEventArgs)actionEventArgs).ErrorInfor, actionEventArgs.ActionType);
  77. }
  78. ReportHelper reportCollect = new ReportHelper(this.DataProvider);
  79. messages.AddMessages(reportCollect.ReportLineQuanMaster(this.DataProvider, actionEventArgs.ActionType, actionEventArgs.ProductInfo));
  80. }
  81. }
  82. }
  83. catch (Exception e)
  84. {
  85. messages.Add(new Message(e));
  86. }
  87. //return messages;
  88. if (msgAutoGoMO.Count() < 1 || (msgAutoGoMO.IsSuccess() == true && messages.IsSuccess() == false))
  89. return messages;
  90. else
  91. {
  92. msgAutoGoMO.IgnoreError();
  93. msgAutoGoMO.AddMessages(messages);
  94. return msgAutoGoMO;
  95. }
  96. }
  97. //��ȡ���������顢��������
  98. public static string ParseECG2Errs(object[] errorInfo, string actType)
  99. {
  100. string strReturn = String.Empty;
  101. if (errorInfo == null)
  102. {
  103. return strReturn;
  104. }
  105. for (int i = 0; i < errorInfo.Length; i++)
  106. {
  107. if (actType == ActionType.DataCollectAction_NG || actType == ActionType.DataCollectAction_OutLineNG)
  108. {
  109. ICSECG2EC tsLoc = ((ICSECG2EC)errorInfo[i]);
  110. strReturn += tsLoc.ECGCODE + ":" + tsLoc.ECODE + ";";
  111. }
  112. }
  113. return strReturn;
  114. }
  115. /// <summary>
  116. /// ����Ʒ�ɼ�
  117. /// </summary>
  118. /// <param name="domainDataProvider"></param>
  119. /// <param name="iD"></param>
  120. /// <param name="actionType"></param>
  121. /// <param name="resourceCode"></param>
  122. /// <param name="userCode"></param>
  123. /// <param name="product"></param>
  124. /// <param name="datas1"></param>
  125. /// <param name="datas2"></param>
  126. /// <returns></returns>
  127. public Messages Execute(ActionEventArgs actionEventArgs, ActionCheckStatus actionCheckStatus)
  128. {
  129. Messages messages = new Messages();
  130. Messages msgAutoGoMO = new Messages();
  131. try
  132. {
  133. ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
  134. //��дSIMULATION ���鹤����ID��;�̡�����
  135. messages.AddMessages(dataCollect.CheckID(actionEventArgs, actionCheckStatus));
  136. if (messages.IsSuccess())
  137. {
  138. //����SIMULATION ������Ϣ
  139. actionEventArgs.ProductInfo.NowSimulation.PRODUCTSTATUS = ProductStatus.NG;
  140. actionEventArgs.ProductInfo.NowSimulation.NGTIMES = actionEventArgs.ProductInfo.NowSimulation.NGTIMES + 1;
  141. if (actionCheckStatus.NeedUpdateSimulation)
  142. {
  143. //�������β��ŵ�ICSONWIP.DUTYDEPARTMENT��λ
  144. if (actionCheckStatus.DutyDepartment.ToString() != string.Empty)
  145. {
  146. actionEventArgs.DutyDepartment = actionCheckStatus.DutyDepartment;
  147. }
  148. if (actionCheckStatus.TroubleStage.ToString() != string.Empty)
  149. {
  150. actionEventArgs.TroubleStage = actionCheckStatus.TroubleStage;
  151. }
  152. //End
  153. messages.AddMessages(dataCollect.Execute(actionEventArgs));
  154. }
  155. else
  156. {
  157. messages.AddMessages(dataCollect.Execute(actionEventArgs, actionCheckStatus));
  158. }
  159. if (messages.IsSuccess())
  160. {
  161. //Laws Lu,2005/12/19,���� ��ȡErrorGroup2ErrorCode
  162. if (actionEventArgs.ActionType == ActionType.DataCollectAction_NG)
  163. {
  164. actionEventArgs.ProductInfo.ECG2ErrCodes = ParseECG2Errs(((TSActionEventArgs)actionEventArgs).ErrorCodes, actionEventArgs.ActionType);
  165. }
  166. else
  167. {
  168. actionEventArgs.ProductInfo.ECG2ErrCodes = ParseECG2Errs(((TSActionEventArgs)actionEventArgs).ErrorInfor, actionEventArgs.ActionType);
  169. }
  170. //����ErrorCode,ErrorGroup�Ƿ���ȷ TODO
  171. //����CS��ȷ��ErrorCode,ErrorGroup����ȷ�ģ��˴��߼�����ȥ��
  172. messages.AddMessages(dataCollect.CollectErrorInformation(actionEventArgs.ActionType, actionEventArgs.ProductInfo, ((TSActionEventArgs)actionEventArgs).ErrorCodes, ((TSActionEventArgs)actionEventArgs).Memo));
  173. ReportHelper reportCollect = new ReportHelper(this.DataProvider);
  174. messages.AddMessages(reportCollect.ReportLineQuanMaster(this.DataProvider, actionEventArgs.ActionType, actionEventArgs.ProductInfo));
  175. }
  176. else
  177. {
  178. return messages;
  179. }
  180. }
  181. }
  182. catch (Exception e)
  183. {
  184. messages.Add(new Message(e));
  185. }
  186. if (msgAutoGoMO.Count() < 1 || (msgAutoGoMO.IsSuccess() == true && messages.IsSuccess() == false))
  187. return messages;
  188. else
  189. {
  190. msgAutoGoMO.IgnoreError();
  191. msgAutoGoMO.AddMessages(messages);
  192. return msgAutoGoMO;
  193. }
  194. }
  195. }
  196. }