private void DoWorkItem(Hashtable p_nvAttributes, Boolean p_blnIsProcessCreated) { B_FormsData l_busFormsData = null; try { if (!p_blnIsProcessCreated) { //创建流程 WorkFlowBase.CreateProcess(this.TemplateName, this.ProcessID, p_nvAttributes); //获取第一个节点并且完成。 l_busFormsData = new B_FormsData(); this.WorkItemID = l_busFormsData.GetFirstWorkItemID(this.ProcessID); UpdateDBWorkItem(this.WorkItemID, true, "", "", "", this.StepName, true); if (base.TemplateName.Contains("收文")) { WorkFlowBase.CompleteWorkItem(this.WorkItemID, p_nvAttributes);//完成第一个节点 } if (base.TemplateName.Contains("会务费用报销单") || base.TemplateName.Contains("招待费报销单")) { WorkFlowBase.CompleteWorkItem(this.WorkItemID, p_nvAttributes);//完成第一个节点 } } else { WorkFlowBase.CompleteWorkItem(this.WorkItemID, p_nvAttributes);//完成当前节点 if (base.TemplateName == ProcessConstString.TemplateName.PROGRAM_FILE && (base.StepName == ProcessConstString.StepName.ProgramFile.STEP_DEPTSIGN || base.StepName == ProcessConstString.StepName.ProgramFile.STEP_LEADERSIGN)) { EntityBase entitybase = ControlToEntity(false); B_PF pfEntity = entitybase != null ? entitybase as B_PF : new B_PF(); List <String> strIDs = B_FormsData.GetMultiParapllelInfo(TableName.WorkItemsTableName.T_OA_HN_PF_WorkItems, base.ProcessID, base.StepName, pfEntity.TimesFlag); foreach (String strID in strIDs) { B_PF entity = new B_PF(); //更新其它会签记录 entity.ID = Convert.ToInt32(strID); entity = XmlUtility.DeSerializeXml <B_PF>(entity.FormsData); entity.ID = Convert.ToInt32(strID); entity.LeaderSignList = pfEntity.LeaderSignList; //领导已会签意见内容 entity.DeptSignList = B_PF.GetDeptSignList(entity.DeptSignList, strIDs); //部门已会签意见内容 entity.IsSignReject = pfEntity.IsSignReject; //是否否决 if (entity.WorkItemID == pfEntity.WorkItemID) { entity.D_StepStatus = "Completed"; entity.SubmitAction = this.SubAction; entity.CommentList = pfEntity.CommentList; //entity.DeptSignList = B_PF.GetDeptSignList(entity.DeptSignList, strIDs); }//更新当前节点用户 entity.FormsData = XmlUtility.SerializeXml(entity); if (!entity.Save()) { throw new Exception(entity.ErrMsgs.ToString()); } } pfEntity.ID = int.MinValue;//清空ID } if (base.TemplateName == ProcessConstString.TemplateName.AFFILIATION && (base.StepName == ProcessConstString.StepName.WorkRelationStepName.STEP_DEPTSIGN)) { EntityBase entitybase = ControlToEntity(false); B_WorkRelation wrEntity = entitybase != null ? entitybase as B_WorkRelation : new B_WorkRelation(); List <String> strIDs = B_FormsData.GetMultiParapllelInfo(TableName.WorkItemsTableName.T_OA_WR_WorkItems, base.ProcessID, base.StepName, wrEntity.TimesFlag); foreach (String strID in strIDs) { B_WorkRelation entity = new B_WorkRelation(); //更新其它会签记录 entity.ID = Convert.ToInt32(strID); entity = XmlUtility.DeSerializeXml <B_WorkRelation>(entity.FormsData); entity.ID = Convert.ToInt32(strID); entity.DeptSignList = B_WorkRelation.GetDeptSignList(entity.DeptSignList, strIDs); //部门已会签意见内容 entity.IsSignReject = wrEntity.IsSignReject; //是否否决 if (entity.WorkItemID == wrEntity.WorkItemID) { if (base.SubAction == ProcessConstString.SubmitAction.ACTION_SUBMIT) { entity.D_StepStatus = "Completed"; } entity.SubmitAction = this.SubAction; entity.CommentList = wrEntity.CommentList; }//更新当前节点用户 entity.FormsData = XmlUtility.SerializeXml(entity); if (!entity.Save()) { throw new Exception(entity.ErrMsgs.ToString()); } } wrEntity.ID = int.MinValue;//清空ID } } } catch (Exception ex) { throw ex; } }
/// <summary> /// 程序文件 交办动作处理 /// </summary> /// <param name="p_strActionName"></param> /// <param name="entity"></param> protected ReturnInfo FormSubmitForProFile(Boolean bIsSave, String strActionName, String strParentTbID, String strStepStatus, EntityBase entity) { User l_objUser = null; ReturnInfo l_objReturnInfo = FormSave.SaveEntity(entity, this, bIsSave, this.SubAction, this.TemplateName); if (!l_objReturnInfo.IsSucess) { this.ShowMsgBox(this.Page, MsgType.VbExclamation, "表单保存出错,后续操作不能进行!" + l_objReturnInfo.ErrMessage); return(l_objReturnInfo); } if (!bIsSave) { //处理交办人相关信息 if (String.IsNullOrEmpty(strParentTbID)) { DataTable dt = B_PF.GetNextWorkItemIdForAssign(base.ProcessID);//当前ProcessID 父流程ID EntityBase entitybase = base.EntityData != null ? base.EntityData : new EntityBase(); entitybase.AgentUserID = String.Empty; entitybase.AgentUserName = String.Empty; EntityBase entitybase2 = EntityFactory.CreateEntity2(base.TemplateName);; base.EntityData.Clone(entitybase2); entitybase2.AgentUserID = String.Empty; entitybase2.AgentUserName = String.Empty; entitybase2.ProcessID = dt.Rows[0]["PROC_INST_ID"].ToString(); entitybase.ProcessID = dt.Rows[0]["PROC_INST_ID"].ToString(); entitybase2.WorkItemID = dt.Rows[0]["WORK_ITEM_ID"].ToString(); entitybase.WorkItemID = dt.Rows[0]["WORK_ITEM_ID"].ToString(); entitybase2.D_StepStatus = dt.Rows[0]["STATUS"].ToString(); entitybase.D_StepStatus = dt.Rows[0]["STATUS"].ToString(); entitybase2.ReceiveUserID = dt.Rows[0]["USER_ID"].ToString(); entitybase.ReceiveUserID = dt.Rows[0]["USER_ID"].ToString(); entitybase2.StepName = dt.Rows[0]["NAME"].ToString(); entitybase.StepName = dt.Rows[0]["NAME"].ToString(); entitybase2.SubmitAction = strActionName; entitybase.SubmitAction = strActionName; //接收人姓名 l_objUser = OAUser.GetUser(entitybase.ReceiveUserID); if (l_objUser != null) { entitybase2.ReceiveUserName = l_objUser.Name; entitybase.ReceiveUserName = l_objUser.Name; } entitybase2.FormsData = XmlUtility.SerializeXml(entitybase); if (!entitybase2.Save()) { l_objReturnInfo.IsSucess = false; l_objReturnInfo.ErrMessage = SysString.GetErrorMsgs(entitybase2.ErrMsgs); ILogger log = LoggerFactory.GetLogger(LogType.TxtFile, @"Log", "程序文件"); log.WriteLog("保存实体出错:" + l_objReturnInfo.ErrMessage); return(l_objReturnInfo); } }//新增协助会签节点数据 else { B_PF pfEntity = new B_PF(); pfEntity.ID = int.Parse(strParentTbID); pfEntity = XmlUtility.DeSerializeXml <B_PF>(pfEntity.FormsData); pfEntity.ID = int.Parse(strParentTbID); //清空子流程ProcessID,用于标识当部门领导自己提交表单撤销子流程(如果不为空,则需要注销子流程) pfEntity.ChildProcessID = String.Empty; pfEntity.AssistContent = (entity as B_PF).AssistContent; pfEntity.FormsData = XmlUtility.SerializeXml(pfEntity);//.Replace("<ID>" + pfEntity.ID + "</ID>", "<ID>" + int.MinValue.ToString() + "</ID>"); if (!pfEntity.Save()) { throw new Exception(pfEntity.ErrMsgs.ToString()); } WorkFlowBase.CompleteWorkItem(base.WorkItemID, null); }//更新交办会签节点数据 } l_objReturnInfo.IsSucess = true; return(l_objReturnInfo); }
//public static public void LoadConfig() { #region >>>>Hardware init try { var json_string = File.ReadAllText(File_HardwareCfg); HardwareCfgMgr = JsonConvert.DeserializeObject <HardwareCfgManager>(json_string); } catch (Exception ex) { Messenger.Default.Send <string>(String.Format("Unable to load config file {0}, {1}", File_HardwareCfg, ex.Message), "ShowError"); throw new Exception(ex.Message); } InstrumentBase inst = null; HardwareCfgLevelManager1[] instCfgs = null; string strClassName = ""; Type t = HardwareCfgMgr.GetType(); PropertyInfo[] PropertyInfos = t.GetProperties(); for (int i = 0; i < PropertyInfos.Length; i++) { if (PropertyInfos[i].Name.ToUpper().Contains("COMPORT") || PropertyInfos[i].Name.ToUpper().Contains("ETHERNET") || PropertyInfos[i].Name.ToUpper().Contains("GPIB") || PropertyInfos[i].Name.ToUpper().Contains("NIVISA") || PropertyInfos[i].Name.ToUpper().Contains("CAMERACFG")) { continue; } PropertyInfo pi = PropertyInfos[i]; instCfgs = pi.GetValue(HardwareCfgMgr) as HardwareCfgLevelManager1[]; strClassName = pi.Name.Substring(0, pi.Name.Length - 1); foreach (var it in instCfgs) { if (!it.Enabled) { continue; } inst = t.Assembly.CreateInstance("CPAS.Instrument." + strClassName, true, BindingFlags.CreateInstance, null, new object[] { it }, null, null) as InstrumentBase; if (inst != null && it.Enabled) { if (inst.Init()) { InstrumentMgr.Instance.AddInstrument(it.InstrumentName, inst); } else { Messenger.Default.Send <string>(string.Format("Instrument :{0} init failed", it.InstrumentName), "ShowError"); } } } } #endregion #region >>>>Software init try { var json_string = File.ReadAllText(File_SoftwareCfg); SoftwareCfgMgr = JsonConvert.DeserializeObject <SoftwareCfgManager>(json_string); } catch (Exception ex) { Messenger.Default.Send <string>(String.Format("Unable to load config file {0}, {1}", File_SoftwareCfg, ex.Message), "ShowError"); throw new Exception(ex.Message); } Type tStationCfg = SoftwareCfgMgr.GetType(); PropertyInfo[] pis = tStationCfg.GetProperties(); WorkFlowConfig[] WorkFlowCfgs = null; WorkFlowBase workFlowBase = null; foreach (PropertyInfo pi in pis) { WorkFlowCfgs = pi.GetValue(SoftwareCfgMgr) as SoftwareManager.WorkFlowConfig[]; foreach (var it in WorkFlowCfgs) { if (it.Enable) { workFlowBase = tStationCfg.Assembly.CreateInstance("CPAS.WorkFlow." + it.Name, true, BindingFlags.CreateInstance, null, new object[] { it }, null, null) as WorkFlowBase; WorkFlowMgr.Instance.AddStation(it.Name, workFlowBase); } } } #endregion #region >>>>SystemCfg try { var json_string = File.ReadAllText(File_SystemParaCfg); SystemParaCfgMgr = JsonConvert.DeserializeObject <SystemParaCfgManager>(json_string); } catch (Exception ex) { Messenger.Default.Send <string>(String.Format("Unable to load config file {0}, {1}", File_SystemParaCfg, ex.Message), "ShowError"); throw new Exception(ex.Message); } #endregion }
//public static public void LoadConfig(out List <string> errList) { #region >>>>Hardware init errList = new List <string>(); try { var json_string = File.ReadAllText(File_HardwareCfg); HardwareCfgMgr = JsonConvert.DeserializeObject <HardwareCfgManager>(json_string); } catch (Exception ex) { errList.Add($"Unable to load config file { File_HardwareCfg}, { ex.Message}"); } InstrumentBase instrumentBase = null; Type hardWareMgrType = HardwareCfgMgr.GetType(); foreach (var it in hardWareMgrType.GetProperties()) { switch (it.Name) { case "Instruments": var instrumentCfgs = it.GetValue(HardwareCfgMgr) as InstrumentCfg[]; if (instrumentCfgs == null) { break; } foreach (var instrumentCfg in instrumentCfgs) { if (instrumentCfg.Enabled) { instrumentBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.Instruments." + instrumentCfg.InstrumentName.Substring(0, instrumentCfg.InstrumentName.IndexOf("[")), true, BindingFlags.CreateInstance, null, null, null, null) as InstrumentBase; if (instrumentBase != null) { if (instrumentBase.Init()) { } } } } break; case "IOCards": case "MotonCards": case "Cameras": case "Lights": case "Comports": case "Ethernets": case "Gpibs": case "Visas": break; default: errList.Add("Invalid hardware type!"); break; } } #endregion #region >>>>Software init try { var json_string = File.ReadAllText(File_SoftwareCfg); SoftwareCfgMgr = JsonConvert.DeserializeObject <SoftwareCfgManager>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_SoftwareCfg, ex.Message)); } Type tStationCfg = SoftwareCfgMgr.GetType(); PropertyInfo[] pis = tStationCfg.GetProperties(); WorkFlowConfig[] WorkFlowCfgs = null; WorkFlowBase workFlowBase = null; foreach (PropertyInfo pi in pis) { if (pi.Name == "WorkFlowConfigs") { WorkFlowCfgs = pi.GetValue(SoftwareCfgMgr) as WorkFlowConfig[]; foreach (var it in WorkFlowCfgs) { if (it.Enable) { workFlowBase = tStationCfg.Assembly.CreateInstance("GPAP.WorkFlow." + it.Name, true, BindingFlags.CreateInstance, null, new object[] { it }, null, null) as WorkFlowBase; if (workFlowBase == null) { errList.Add($"Station: {it.Name} Create instance failed!"); } else { WorkFlowMgr.Instance.AddStation(it.Name, workFlowBase); } } } } } #endregion }
//public static public void LoadConfig(out List <string> errList) { #region >>>>Hardware init errList = new List <string>(); try { var json_string = File.ReadAllText(File_HardwareCfg); HardwareCfgMgr = JsonConvert.DeserializeObject <HardwareCfgManager>(json_string); } catch (Exception ex) { errList.Add($"Unable to load config file { File_HardwareCfg}, { ex.Message}"); } IMotion motionBase = null; IIO ioBase = null; InstrumentBase instrumentBase = null; LightBase lightBase = null; Type hardWareMgrType = HardwareCfgMgr.GetType(); //先初始化通信端口 foreach (var it in hardWareMgrType.GetProperties()) { switch (it.Name) { case "Comports": foreach (var comportCfg in HardwareCfgMgr.Comports) { CommunicationPortBase port = new Comport(comportCfg); CommunicationMgr.Instance.AddCommunicationPort(comportCfg.PortName, port); } break; case "Ethernets": case "Gpibs": case "Visas": break; default: break; } } foreach (var it in hardWareMgrType.GetProperties()) { switch (it.Name) { case "MotionCards": var motionCfgs = it.GetValue(HardwareCfgMgr) as MotionCardCfg[]; if (motionCfgs == null) { break; } foreach (var motionCfg in motionCfgs) { if (motionCfg.Enabled) { motionBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.MotionCards." + motionCfg.Name.Substring(0, motionCfg.Name.IndexOf("[")), true, BindingFlags.CreateInstance, null, /*new object[] { motionCfg }*/ null, null, null) as IMotion; if (motionBase != null) { if (motionCfg.ConnectMode.ToLower() != "none") { var p = hardWareMgrType.GetProperty($"{motionCfg.ConnectMode}s"); var portCfgs = p.GetValue(HardwareCfgMgr) as ICommunicationPortCfg[]; var ports = from portCfg in portCfgs where portCfg.PortName == motionCfg.PortName select portCfg; if (ports != null && ports.Count() > 0) { if (motionBase.Init(motionCfg, ports.ElementAt(0))) { //设置单位,轴类型, 软限位等 for (int i = 0; i < motionBase.MAX_AXIS - motionBase.MIN_AXIS + 1; i++) { var settings = HardwareCfgMgr.AxisSettings.Where(a => a.AxisNo == i + motionBase.MIN_AXIS); try { motionBase.SetAxisPara(i, settings == null ? null : settings.First()); } catch (Exception ex) { errList.Add($"{ex.Message}"); } } MotionMgr.Instance.AddMotionCard(motionCfg.Name, motionBase); } else { errList.Add($"{motionCfg.Name} init failed"); } } else { errList.Add($"{motionCfg.Name} init failed"); } } else //无需选择通信端口 { if (motionBase.Init(motionCfg, null)) { //设置单位,轴类型, 软限位等 for (int i = 0; i < motionBase.MAX_AXIS - motionBase.MIN_AXIS; i++) { var settings = HardwareCfgMgr.AxisSettings.Where(a => a.AxisNo == i + motionBase.MIN_AXIS); try { motionBase.SetAxisPara(i, settings == null ? null : settings.First()); } catch (Exception ex) { errList.Add($"{ex.Message}"); } } MotionMgr.Instance.AddMotionCard(motionCfg.Name, motionBase); } else { errList.Add($"{motionCfg.Name} init failed"); } } } else { errList.Add($"{motionCfg.Name} Create instanse failed"); } } } break; case "IOCards": var ioCfgs = it.GetValue(HardwareCfgMgr) as IOCardCfg[]; if (ioCfgs == null) { break; } foreach (var ioCfg in ioCfgs) { if (ioCfg.Enabled) { ioBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.IOCards." + ioCfg.Name.Substring(0, ioCfg.Name.IndexOf("[")), true, BindingFlags.CreateInstance, null, null, null, null) as IIO; if (ioBase != null) { ioBase.ioCfg = ioCfg; if (ioCfg.ConnectMode.ToLower() != "none") //没有屏蔽端口 { var p = hardWareMgrType.GetProperty($"{ioCfg.ConnectMode}s"); var portCfgs = p.GetValue(HardwareCfgMgr) as ICommunicationPortCfg[]; var ports = from portCfg in portCfgs where portCfg.PortName == ioCfg.PortName select portCfg; if (ports != null && ports.Count() > 0) { if (ioBase.Init(ioCfg, ports.ElementAt(0))) { IOCardMgr.Instance.AddIOCard(ioCfg.Name, ioBase); } else { errList.Add($"{ioCfg.Name} init failed"); } } else { errList.Add($"{ioCfg.Name} init failed"); } } else //无需选择通信端口 { if (ioBase.Init(ioCfg, null)) { IOCardMgr.Instance.AddIOCard(ioCfg.Name, ioBase); } else { errList.Add($"{ioCfg.Name} init failed"); } } } else { errList.Add($"{ioCfg.Name} Create instanse failed"); } } } break; case "Instruments": var instrumentCfgs = it.GetValue(HardwareCfgMgr) as InstrumentCfg[]; if (instrumentCfgs == null) { break; } foreach (var instrumentCfg in instrumentCfgs) { if (instrumentCfg.Enabled) { instrumentBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.Instruments." + instrumentCfg.InstrumentName.Substring(0, instrumentCfg.InstrumentName.IndexOf("[")), true, BindingFlags.CreateInstance, null, null, null, null) as InstrumentBase; if (instrumentBase != null) { if (instrumentBase.Init()) { } } } } break; case "Cameras": var cameraCfgs = it.GetValue(HardwareCfgMgr) as CameraCfg[]; break; case "Lights": var lightCfgs = it.GetValue(HardwareCfgMgr) as LightCfg[]; foreach (var lightCfg in lightCfgs) { if (lightCfg.Enabled) { lightBase = hardWareMgrType.Assembly.CreateInstance("JPT_TosaTest.Vision.Light." + lightCfg.Name.Substring(0, lightCfg.Name.IndexOf("[")), true, BindingFlags.CreateInstance, null, null, null, null) as LightBase; if (lightBase != null) { if (lightCfg.ConnectMode.ToLower() != "none") { var p = hardWareMgrType.GetProperty($"{lightCfg.ConnectMode}s"); var portCfgs = p.GetValue(HardwareCfgMgr) as ICommunicationPortCfg[]; var ports = from portCfg in portCfgs where portCfg.PortName == lightCfg.PortName select portCfg; if (ports != null && ports.Count() > 0) { if (lightBase.Init(lightCfg, ports.ElementAt(0))) //如果不需要初始化就直接加入字典 { LigtMgr.Instance.AddLight(lightCfg.Name, lightBase); } else { errList.Add($"{lightCfg.Name} init failed"); } } else { errList.Add($"{lightCfg.Name} init failed"); } } else //无需选择通信端口 { if (lightBase.Init(lightCfg, null)) { LigtMgr.Instance.AddLight(lightCfg.Name, lightBase); } else { errList.Add($"{lightCfg.Name} init failed"); } } } else { errList.Add($"{lightCfg.Name} Create instanse failed"); } } } break; default: break; } } #endregion #region >>>>Software init try { var json_string = File.ReadAllText(File_SoftwareCfg); SoftwareCfgMgr = JsonConvert.DeserializeObject <SoftwareCfgManager>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_SoftwareCfg, ex.Message)); } Type tStationCfg = SoftwareCfgMgr.GetType(); PropertyInfo[] pis = tStationCfg.GetProperties(); WorkFlowConfig[] WorkFlowCfgs = null; WorkFlowBase workFlowBase = null; foreach (PropertyInfo pi in pis) { if (pi.Name == "WorkFlowConfigs") { WorkFlowCfgs = pi.GetValue(SoftwareCfgMgr) as SoftwareManager.WorkFlowConfig[]; foreach (var it in WorkFlowCfgs) { if (it.Enable) { workFlowBase = tStationCfg.Assembly.CreateInstance("JPT_TosaTest.WorkFlow." + it.Name, true, BindingFlags.CreateInstance, null, new object[] { it }, null, null) as WorkFlowBase; if (workFlowBase == null) { errList.Add($"Station: {it.Name} Create instance failed!"); } else { WorkFlowMgr.Instance.AddStation(it.Name, workFlowBase); } } } } } #endregion #region >>>>SystemCfg try { var json_string = File.ReadAllText(File_SystemParaCfg); SystemParaCfgMgr = JsonConvert.DeserializeObject <SystemParaCfgManager>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_SystemParaCfg, ex.Message)); } #endregion #region >>>> UserCfg init try { var json_string = File.ReadAllText(File_UserCfg); UserCfgMgr = JsonConvert.DeserializeObject <UserCfgManager>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_UserCfg, ex.Message)); } #endregion #region >>>>ProcessPara //从文件中读取参数 try { var json_string = File.ReadAllText(File_ProcessPara); ProcessDataMgr = JsonConvert.DeserializeObject <ProcessParaMgr>(json_string); } catch (Exception ex) { errList.Add(String.Format("Unable to load config file {0}, {1}", File_UserCfg, ex.Message)); } #endregion }