Пример #1
0
        /// <summary>
        /// 发送审批消息(调用引擎服务)
        /// </summary>
        /// <param name="submitData"></param>
        /// <param name="dataResult"></param>
        /// <param name="modelinfo"></param>
        /// <param name="CheckFlowResult"></param>
        /// <param name="Flowbill"></param>
        /// <param name="AppCompanyID">申请公司</param>
        /// <param name="MessageUserID">申请人ID</param>
        /// <param name="MessageUserName">申请人名</param>
        private void SubmitEngineService(OracleConnection con, SubmitData submitData, DataResult dataResult, ModelInfo modelinfo, CheckResult CheckFlowResult, FlowBLL2 Flowbill, string AppCompanyID, string MessageUserID, string MessageUserName, ref string ErroMessage)
        {
            bool bOK = true;
            #region 发送审批消息(调用引擎服务)
            try
            {
                if (dataResult.FlowResult == FlowResult.SUCCESS || dataResult.FlowResult == FlowResult.END)
                {
                    #region 调用引擎服务(原有调用WCF服务)
                    ////EngineWcfGlobalFunctionService.EngineWcfGlobalFunctionClient engineClient = new EngineWcfGlobalFunctionService.EngineWcfGlobalFunctionClient();//旧引擎服务

                    //FlowEngineService.EngineWcfGlobalFunctionClient FlowEngine = new FlowEngineService.EngineWcfGlobalFunctionClient();
                    //string IsTask = dataResult.FlowResult == FlowResult.SUCCESS ? "1" : "0";
                    //MessageData tmpMessageData = null;
                    //StringBuilder FlowResultXml = null;
                    //#region
                    //switch (submitData.SubmitFlag)
                    //{
                    //    case SubmitFlag.New:
                    //        #region 新增
                    //        if (dataResult.IsCountersign)
                    //        {
                    //            #region
                    //            if (dataResult.FlowResult == FlowResult.SUCCESS)
                    //            {
                    //                List<string> listUserID = new List<string>();
                    //                List<string> listUserName = new List<string>();
                    //                if (dataResult.DictCounterUser != null && dataResult.DictCounterUser.Keys.Count > 0)
                    //                {
                    //                    dataResult.DictCounterUser.Values.ToList().ForEach(users =>
                    //                    {
                    //                        users.ForEach(user =>
                    //                        {
                    //                            listUserID.Add(user.UserID);
                    //                            listUserName.Add(user.UserName);
                    //                        });
                    //                    });

                    //                    MessageUserID = string.Join("|", listUserID);
                    //                    MessageUserName = string.Join("|", listUserName);
                    //                }

                    //            }
                    //            if (dataResult.DictAgentUserInfo != null && dataResult.DictAgentUserInfo.Count > 0)
                    //            {
                    //                dataResult.DictAgentUserInfo.Values.ToList().ForEach(user =>
                    //                {
                    //                    MessageUserID += "|" + user.UserID.Trim();
                    //                    MessageUserName += "|" + user.UserName.Trim();

                    //                });
                    //            }
                    //            #endregion
                    //        }
                    //        else
                    //        {
                    //            #region
                    //            if (dataResult.FlowResult == FlowResult.SUCCESS)
                    //            {
                    //                MessageUserID = dataResult.UserInfo[0].UserID.Trim();
                    //                MessageUserName = dataResult.UserInfo[0].UserName.Trim();
                    //            }
                    //            if (dataResult.AgentUserInfo != null)
                    //            {
                    //                MessageUserID += "|" + dataResult.AgentUserInfo.UserID.Trim();
                    //                MessageUserName += "|" + dataResult.AgentUserInfo.UserName.Trim();
                    //            }
                    //            #endregion
                    //        }
                    //        tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                    //            submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                    //        FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);
                    //        DateTime s = DateTime.Now;
                    //        LogHelper.WriteLog("开始新增FlowEngine.SaveFlowTriggerData");
                    //        bOK = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    //        LogHelper.WriteLog("bOK=" + bOK.ToString());
                    //        LogHelper.WriteLog("结束新增FlowEngine.SaveFlowTriggerData");
                    //        //bOK = engineClient.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    //        DateTime e = DateTime.Now;
                    //        string str = DateDiff(e, s);
                    //        if (!bOK)
                    //        {
                    //            Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
                    //        }

                    //        #endregion
                    //        break;
                    //    case SubmitFlag.Cancel:
                    //        #region 撤单
                    //        tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                    //            submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                    //        FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);
                    //        LogHelper.WriteLog("开始撤单FlowEngine.FlowCancel");
                    //        bool bCancel = FlowEngine.FlowCancel(FlowResultXml.ToString(), submitData.XML);
                    //        LogHelper.WriteLog("bCancel=" + bCancel.ToString());
                    //        LogHelper.WriteLog("结束撤单FlowEngine.FlowCancel");
                    //        //bool bCancel = engineClient.FlowCancel(FlowResultXml.ToString(), submitData.XML); 
                    //        if (!bCancel)
                    //        {
                    //            Tracer.Debug("FlowEngineService:DateTime:" + DateTime.Now.ToString() + "\n" + "FlowCancel:submitData.XML" + "\n\nFlowResultXml" + FlowResultXml.ToString());
                    //        }
                    //        #endregion
                    //        break;
                    //    case SubmitFlag.Approval:
                    //        LogHelper.WriteLog("开始审核");
                    //        #region 审核

                    //        if (dataResult.CurrentIsCountersign)
                    //        {
                    //            LogHelper.WriteLog("第1次:TaskMsgClose");
                    //            FlowEngine.TaskMsgClose(modelinfo.SysCode, submitData.FormID, submitData.ApprovalUser.UserID);
                    //            //engineClient.TaskMsgClose(modelinfo.SysCode, submitData.FormID, submitData.ApprovalUser.UserID);
                    //            //einginBll.TaskMsgClose(con, modelinfo.SysCode, submitData.FormID, submitData.ApprovalUser.UserID);

                    //            #region
                    //            if (submitData.ApprovalResult == ApprovalResult.NoPass)
                    //            {
                    //                #region
                    //                List<string> listMessageUserID = new List<string>();
                    //                CheckFlowResult.fd.Where(detail => detail.EDITUSERID != submitData.ApprovalUser.UserID).ToList().ForEach(item =>
                    //                {
                    //                    listMessageUserID.Add(item.EDITUSERID);
                    //                    if (!string.IsNullOrEmpty(item.AGENTUSERID))
                    //                    {
                    //                        listMessageUserID.Add(item.AGENTUSERID);
                    //                    }
                    //                });
                    //                if (listMessageUserID.Count > 0)
                    //                {
                    //                    string messageUserID = string.Join(",", listMessageUserID);
                    //                    LogHelper.WriteLog("第2次:TaskMsgClose");
                    //                    FlowEngine.TaskMsgClose(modelinfo.SysCode, submitData.FormID, messageUserID);

                    //                    //engineClient.TaskMsgClose(modelinfo.SysCode, submitData.FormID, messageUserID);
                    //                    //einginBll.TaskMsgClose(con, modelinfo.SysCode, submitData.FormID, messageUserID);
                    //                }
                    //                tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                    //              submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                    //                FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);

                    //                DateTime s2 = DateTime.Now;
                    //                bOK = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    //                //bOK = engineClient.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    //                // bOK = einginBll.SaveFlowTriggerData(con, FlowResultXml.ToString(), submitData.XML);
                    //                DateTime e2 = DateTime.Now;
                    //                string str2 = DateDiff(e2, s2);
                    //                if (!bOK)
                    //                {
                    //                    Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
                    //                }
                    //                #endregion
                    //            }
                    //            else if (dataResult.IsGotoNextState)
                    //            {
                    //                #region
                    //                List<string> listMessageUserID = new List<string>();
                    //                CheckFlowResult.fd.Where(detail => detail.EDITUSERID != submitData.ApprovalUser.UserID).ToList().ForEach(item =>
                    //                {
                    //                    listMessageUserID.Add(item.EDITUSERID);
                    //                    if (!string.IsNullOrEmpty(item.AGENTUSERID))
                    //                    {
                    //                        listMessageUserID.Add(item.AGENTUSERID);
                    //                    }
                    //                });
                    //                if (listMessageUserID.Count > 0)
                    //                {

                    //                    string messageUserID = string.Join(",", listMessageUserID);
                    //                    LogHelper.WriteLog("第3次:TaskMsgClose");
                    //                    FlowEngine.TaskMsgClose(modelinfo.SysCode, submitData.FormID, messageUserID);

                    //                    //engineClient.TaskMsgClose(modelinfo.SysCode, submitData.FormID, messageUserID);
                    //                    //einginBll.TaskMsgClose(con, modelinfo.SysCode, submitData.FormID, messageUserID);
                    //                }
                    //                if (dataResult.IsCountersign)
                    //                {
                    //                    #region
                    //                    if (dataResult.FlowResult == FlowResult.SUCCESS)
                    //                    {

                    //                        List<string> listUserID = new List<string>();
                    //                        List<string> listUserName = new List<string>();
                    //                        if (dataResult.DictCounterUser != null && dataResult.DictCounterUser.Keys.Count > 0)
                    //                        {
                    //                            dataResult.DictCounterUser.Values.ToList().ForEach(users =>
                    //                            {
                    //                                users.ForEach(user =>
                    //                                {
                    //                                    listUserID.Add(user.UserID);
                    //                                    listUserName.Add(user.UserName);
                    //                                });
                    //                            });

                    //                            MessageUserID = string.Join("|", listUserID);
                    //                            MessageUserName = string.Join("|", listUserName);
                    //                        }

                    //                    }
                    //                    if (dataResult.DictAgentUserInfo != null && dataResult.DictAgentUserInfo.Count > 0)
                    //                    {
                    //                        dataResult.DictAgentUserInfo.Values.ToList().ForEach(user =>
                    //                        {
                    //                            MessageUserID += "|" + user.UserID.Trim();
                    //                            MessageUserName += "|" + user.UserName.Trim();

                    //                        });
                    //                    }
                    //                    #endregion
                    //                }
                    //                else
                    //                {
                    //                    #region
                    //                    if (dataResult.FlowResult == FlowResult.SUCCESS)
                    //                    {
                    //                        MessageUserID = dataResult.UserInfo[0].UserID.Trim();
                    //                        MessageUserName = dataResult.UserInfo[0].UserName.Trim();

                    //                    }

                    //                    if (dataResult.AgentUserInfo != null)
                    //                    {
                    //                        MessageUserID += "|" + dataResult.AgentUserInfo.UserID.Trim();
                    //                        MessageUserName += "|" + dataResult.AgentUserInfo.UserName.Trim();
                    //                    }
                    //                    #endregion
                    //                }
                    //                tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                    //                    submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                    //                FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);

                    //                DateTime s3 = DateTime.Now;
                    //                bOK = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    //                //bOK = engineClient.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    //                //bOK = einginBll.SaveFlowTriggerData(con, FlowResultXml.ToString(), submitData.XML);
                    //                DateTime e3 = DateTime.Now;
                    //                string str3 = DateDiff(e3, s3);
                    //                if (!bOK)
                    //                {
                    //                    Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
                    //                }
                    //                #endregion
                    //            }
                    //            #endregion
                    //        }
                    //        else
                    //        {
                    //            #region
                    //            if (dataResult.IsCountersign)
                    //            {
                    //                #region
                    //                if (dataResult.FlowResult == FlowResult.SUCCESS)
                    //                {

                    //                    List<string> listUserID = new List<string>();
                    //                    List<string> listUserName = new List<string>();
                    //                    if (dataResult.DictCounterUser != null && dataResult.DictCounterUser.Keys.Count > 0)
                    //                    {
                    //                        dataResult.DictCounterUser.Values.ToList().ForEach(users =>
                    //                        {
                    //                            users.ForEach(user =>
                    //                            {
                    //                                listUserID.Add(user.UserID);
                    //                                listUserName.Add(user.UserName);
                    //                            });
                    //                        });

                    //                        MessageUserID = string.Join("|", listUserID);
                    //                        MessageUserName = string.Join("|", listUserName);
                    //                    }

                    //                }
                    //                if (dataResult.DictAgentUserInfo != null && dataResult.DictAgentUserInfo.Count > 0)
                    //                {
                    //                    dataResult.DictAgentUserInfo.Values.ToList().ForEach(user =>
                    //                    {
                    //                        MessageUserID += "|" + user.UserID.Trim();
                    //                        MessageUserName += "|" + user.UserName.Trim();

                    //                    });
                    //                }
                    //                #endregion
                    //            }
                    //            else
                    //            {
                    //                #region
                    //                if (dataResult.FlowResult == FlowResult.SUCCESS)
                    //                {
                    //                    MessageUserID = dataResult.UserInfo[0].UserID.Trim();
                    //                    MessageUserName = dataResult.UserInfo[0].UserName.Trim();

                    //                }

                    //                if (dataResult.AgentUserInfo != null)
                    //                {
                    //                    MessageUserID += "|" + dataResult.AgentUserInfo.UserID.Trim();
                    //                    MessageUserName += "|" + dataResult.AgentUserInfo.UserName.Trim();
                    //                }
                    //                #endregion
                    //            }
                    //            tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                    //                submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                    //            FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);

                    //            DateTime s4 = DateTime.Now;
                    //            LogHelper.WriteLog("开始FlowEngine.SaveFlowTriggerData");
                    //            bOK = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    //            LogHelper.WriteLog("bOK=" + bOK.ToString());
                    //            LogHelper.WriteLog("结束FlowEngine.SaveFlowTriggerData");
                    //            //bOK = engineClient.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    //            //bOK = einginBll.SaveFlowTriggerData(con, FlowResultXml.ToString(), submitData.XML);
                    //            DateTime e4 = DateTime.Now;
                    //            string str4 = DateDiff(e4, s4);
                    //            if (!bOK)
                    //            {
                    //                Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
                    //            }
                    //            else
                    //            {
                    //                LogHelper.WriteLog("第4次:TaskMsgClose");
                    //                FlowEngine.TaskMsgClose(modelinfo.SysCode, submitData.FormID, submitData.ApprovalUser.UserID);

                    //                //engineClient.TaskMsgClose(modelinfo.SysCode, submitData.FormID, submitData.ApprovalUser.UserID);
                    //                //einginBll.TaskMsgClose(con, modelinfo.SysCode, submitData.FormID, submitData.ApprovalUser.UserID);
                    //            }
                    //            #endregion
                    //        }
                    //        #endregion
                    //        LogHelper.WriteLog("结束审核");
                    //        break;
                    //}
                    //#endregion
                    #endregion 调用引擎服务(原有调用WCF服务)
                    #region 调用引擎服务(调用本地服DLL)
                    string IsTask = dataResult.FlowResult == FlowResult.SUCCESS ? "1" : "0";
                    MessageData tmpMessageData = null;
                    StringBuilder FlowResultXml = null;
                    #region
                    switch (submitData.SubmitFlag)
                    {
                        case SubmitFlag.New:
                            #region 新增
                            if (dataResult.IsCountersign)
                            {
                                #region
                                if (dataResult.FlowResult == FlowResult.SUCCESS)
                                {
                                    List<string> listUserID = new List<string>();
                                    List<string> listUserName = new List<string>();
                                    if (dataResult.DictCounterUser != null && dataResult.DictCounterUser.Keys.Count > 0)
                                    {
                                        dataResult.DictCounterUser.Values.ToList().ForEach(users =>
                                        {
                                            users.ForEach(user =>
                                            {
                                                listUserID.Add(user.UserID);
                                                listUserName.Add(user.UserName);
                                            });
                                        });

                                        MessageUserID = string.Join("|", listUserID);
                                        MessageUserName = string.Join("|", listUserName);
                                    }

                                }
                                if (dataResult.DictAgentUserInfo != null && dataResult.DictAgentUserInfo.Count > 0)
                                {
                                    dataResult.DictAgentUserInfo.Values.ToList().ForEach(user =>
                                    {
                                        MessageUserID += "|" + user.UserID.Trim();
                                        MessageUserName += "|" + user.UserName.Trim();

                                    });
                                }
                                #endregion
                            }
                            else
                            {
                                #region
                                if (dataResult.FlowResult == FlowResult.SUCCESS)
                                {
                                    MessageUserID = dataResult.UserInfo[0].UserID.Trim();
                                    MessageUserName = dataResult.UserInfo[0].UserName.Trim();
                                }
                                if (dataResult.AgentUserInfo != null)
                                {
                                    MessageUserID += "|" + dataResult.AgentUserInfo.UserID.Trim();
                                    MessageUserName += "|" + dataResult.AgentUserInfo.UserName.Trim();
                                }
                                #endregion
                            }
                            tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                                submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                            FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);

                            LogHelper.WriteLog("开始新增FlowEngine.SaveFlowTriggerData");
                            LogHelper.WriteLog("流程引擎的XML数据", "新增: FormID=" + submitData.FormID + ";SysCode=" + modelinfo.SysCode + " ModelName=" + modelinfo.ModelName + "\r\n FlowResultXml= \r\n" + FlowResultXml + "\r\n submitData.XML= \r\n" + submitData.XML);
                            bOK = einginBll.SaveFlowTriggerData(con, FlowResultXml.ToString(), submitData.XML, ref ErroMessage);
                            LogHelper.WriteLog("bOK=" + bOK.ToString());
                            LogHelper.WriteLog("结束新增FlowEngine.SaveFlowTriggerData");
                            if (!bOK)
                            {
                                Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
                            }

                            #endregion
                            break;
                        case SubmitFlag.Cancel:
                            #region 撤单
                            tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                                submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                            FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);
                            //bool bCancel = FlowEngine.FlowCancel(FlowResultXml.ToString(), submitData.XML);
                            LogHelper.WriteLog("流程引擎的XML数据", "撤单: FormID=" + submitData.FormID + ";SysCode=" + modelinfo.SysCode + " ModelName=" + modelinfo.ModelName + "\r\n FlowResultXml= \r\n" + FlowResultXml + "\r\n submitData.XML= \r\n" + submitData.XML);

                            bool bCancel = einginBll.FlowCancel(con, FlowResultXml.ToString(), submitData.XML, ref ErroMessage);
                            if (!bCancel)
                            {
                                Tracer.Debug("FlowEngineService:DateTime:" + DateTime.Now.ToString() + "\n" + "FlowCancel:submitData.XML" + "\n\nFlowResultXml" + FlowResultXml.ToString());
                            }
                            #endregion
                            break;
                        case SubmitFlag.Approval:
                            #region 审核
                            //FlowEngine.TaskMsgClose(modelinfo.SysCode, submitData.FormID, submitData.ApprovalUser.UserID);
                            einginBll.TaskMsgClose(con, modelinfo.SysCode, submitData.FormID, submitData.ApprovalUser.UserID);
                            if (dataResult.CurrentIsCountersign)
                            {
                                #region
                                if (submitData.ApprovalResult == ApprovalResult.NoPass)
                                {
                                    #region
                                    List<string> listMessageUserID = new List<string>();
                                    CheckFlowResult.fd.Where(detail => detail.EDITUSERID != submitData.ApprovalUser.UserID).ToList().ForEach(item =>
                                    {
                                        listMessageUserID.Add(item.EDITUSERID);
                                        if (!string.IsNullOrEmpty(item.AGENTUSERID))
                                        {
                                            listMessageUserID.Add(item.AGENTUSERID);
                                        }
                                    });
                                    if (listMessageUserID.Count > 0)
                                    {
                                        string messageUserID = string.Join(",", listMessageUserID);
                                        //FlowEngine.TaskMsgClose(modelinfo.SysCode, submitData.FormID, messageUserID);
                                        einginBll.TaskMsgClose(con, modelinfo.SysCode, submitData.FormID, messageUserID);
                                    }
                                    tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                                  submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                                    FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);
                                    //bOK = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);                                   

                                    LogHelper.WriteLog("开始审核FlowEngine.SaveFlowTriggerData");
                                    LogHelper.WriteLog("流程引擎的XML数据", "审核: FormID=" + submitData.FormID + ";SysCode=" + modelinfo.SysCode + " ModelName=" + modelinfo.ModelName + "\r\n FlowResultXml= \r\n" + FlowResultXml + "\r\n submitData.XML= \r\n" + submitData.XML);
                                    bOK = einginBll.SaveFlowTriggerData(con, FlowResultXml.ToString(), submitData.XML, ref ErroMessage);
                                    LogHelper.WriteLog("bOK=" + bOK.ToString());
                                    LogHelper.WriteLog("结束审核FlowEngine.SaveFlowTriggerData");
                                    if (!bOK)
                                    {
                                        Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
                                    }
                                    #endregion
                                }
                                else if (dataResult.IsGotoNextState)
                                {
                                    #region
                                    List<string> listMessageUserID = new List<string>();
                                    CheckFlowResult.fd.Where(detail => detail.EDITUSERID != submitData.ApprovalUser.UserID).ToList().ForEach(item =>
                                    {
                                        listMessageUserID.Add(item.EDITUSERID);
                                        if (!string.IsNullOrEmpty(item.AGENTUSERID))
                                        {
                                            listMessageUserID.Add(item.AGENTUSERID);
                                        }
                                    });
                                    if (listMessageUserID.Count > 0)
                                    {
                                        string messageUserID = string.Join(",", listMessageUserID);
                                        // FlowEngine.TaskMsgClose(modelinfo.SysCode, submitData.FormID, messageUserID);
                                        einginBll.TaskMsgClose(con, modelinfo.SysCode, submitData.FormID, messageUserID);
                                    }
                                    if (dataResult.IsCountersign)
                                    {
                                        #region
                                        if (dataResult.FlowResult == FlowResult.SUCCESS)
                                        {

                                            List<string> listUserID = new List<string>();
                                            List<string> listUserName = new List<string>();
                                            if (dataResult.DictCounterUser != null && dataResult.DictCounterUser.Keys.Count > 0)
                                            {
                                                dataResult.DictCounterUser.Values.ToList().ForEach(users =>
                                                {
                                                    users.ForEach(user =>
                                                    {
                                                        listUserID.Add(user.UserID);
                                                        listUserName.Add(user.UserName);
                                                    });
                                                });

                                                MessageUserID = string.Join("|", listUserID);
                                                MessageUserName = string.Join("|", listUserName);
                                            }

                                        }
                                        if (dataResult.DictAgentUserInfo != null && dataResult.DictAgentUserInfo.Count > 0)
                                        {
                                            dataResult.DictAgentUserInfo.Values.ToList().ForEach(user =>
                                            {
                                                MessageUserID += "|" + user.UserID.Trim();
                                                MessageUserName += "|" + user.UserName.Trim();

                                            });
                                        }
                                        #endregion
                                    }
                                    else
                                    {
                                        #region
                                        if (dataResult.FlowResult == FlowResult.SUCCESS)
                                        {
                                            MessageUserID = dataResult.UserInfo[0].UserID.Trim();
                                            MessageUserName = dataResult.UserInfo[0].UserName.Trim();

                                        }

                                        if (dataResult.AgentUserInfo != null)
                                        {
                                            MessageUserID += "|" + dataResult.AgentUserInfo.UserID.Trim();
                                            MessageUserName += "|" + dataResult.AgentUserInfo.UserName.Trim();
                                        }
                                        #endregion
                                    }
                                    tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                                        submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                                    FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);
                                    //bOK = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                                    DateTime s3 = DateTime.Now;
                                    bOK = einginBll.SaveFlowTriggerData(con, FlowResultXml.ToString(), submitData.XML, ref ErroMessage);
                                    DateTime e3 = DateTime.Now;
                                    string str3 = DateDiff(e3, s3);
                                    if (!bOK)
                                    {
                                        Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
                                    }
                                    #endregion
                                }
                                #endregion
                            }
                            else
                            {
                                #region
                                if (dataResult.IsCountersign)
                                {
                                    #region
                                    if (dataResult.FlowResult == FlowResult.SUCCESS)
                                    {

                                        List<string> listUserID = new List<string>();
                                        List<string> listUserName = new List<string>();
                                        if (dataResult.DictCounterUser != null && dataResult.DictCounterUser.Keys.Count > 0)
                                        {
                                            dataResult.DictCounterUser.Values.ToList().ForEach(users =>
                                            {
                                                users.ForEach(user =>
                                                {
                                                    listUserID.Add(user.UserID);
                                                    listUserName.Add(user.UserName);
                                                });
                                            });

                                            MessageUserID = string.Join("|", listUserID);
                                            MessageUserName = string.Join("|", listUserName);
                                        }

                                    }
                                    if (dataResult.DictAgentUserInfo != null && dataResult.DictAgentUserInfo.Count > 0)
                                    {
                                        dataResult.DictAgentUserInfo.Values.ToList().ForEach(user =>
                                        {
                                            MessageUserID += "|" + user.UserID.Trim();
                                            MessageUserName += "|" + user.UserName.Trim();

                                        });
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region
                                    if (dataResult.FlowResult == FlowResult.SUCCESS)
                                    {
                                        MessageUserID = dataResult.UserInfo[0].UserID.Trim();
                                        MessageUserName = dataResult.UserInfo[0].UserName.Trim();

                                    }

                                    if (dataResult.AgentUserInfo != null)
                                    {
                                        MessageUserID += "|" + dataResult.AgentUserInfo.UserID.Trim();
                                        MessageUserName += "|" + dataResult.AgentUserInfo.UserName.Trim();
                                    }
                                    #endregion
                                }
                                tmpMessageData = new MessageData("Flow", modelinfo.SysCode, AppCompanyID, submitData.ModelCode, modelinfo.ModelName,
                                    submitData.FormID, dataResult.AppState, dataResult.CheckState, IsTask, MessageUserID, MessageUserName, dataResult.KPITime);
                                FlowResultXml = Flowbill.BuildMessageData(tmpMessageData);
                                // bOK = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                                DateTime s4 = DateTime.Now;
                                bOK = einginBll.SaveFlowTriggerData(con, FlowResultXml.ToString(), submitData.XML, ref ErroMessage);
                                DateTime e4 = DateTime.Now;
                                string str4 = DateDiff(e4, s4);
                                if (!bOK)
                                {
                                    Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
                                }
                                #endregion
                            }
                            #endregion
                            break;
                    }
                    #endregion
                    #endregion  调用引擎服务(调用本地服DLL)

                }
            }
            catch (Exception ex)
            {
                //Tracer.Debug("FlowEngineService: -" + "\n\nError:" + ex.InnerException + ex.Message);
                LogHelper.WriteLog(this, "SubmitEngineService", "", ex);
                throw new Exception(ErroMessage);
            }
            #endregion
        }
Пример #2
0
        /// <summary>
        /// 检查是否已提交流程(对数据库操作)
        /// </summary>
        /// <param name="ApprovalData"></param>
        /// <param name="APPDataResult"></param>
        /// <returns></returns>
        public CheckResult CheckFlow2(OracleConnection con, SubmitData ApprovalData, DataResult APPDataResult)
        {

            CheckResult CheckFlowResult = new CheckResult();
            try
            {

                CheckFlowResult.APPDataResult = APPDataResult;
                APPDataResult.RunTime += "---GetFlowInfoStart:" + DateTime.Now.ToString();
                List<FlowType> FlowTypeList = new List<FlowWFService.FlowType>();
                FlowTypeList.Add(ApprovalData.FlowType);
                List<FLOW_FLOWRECORDDETAIL_T> fd = FlowBLL2.GetFlowInfo(con, ApprovalData.FormID, "", "", "0", ApprovalData.ModelCode, "", "", FlowTypeList);//对数据库操作
                CheckFlowResult.fd = fd;
                APPDataResult.RunTime += "---GetFlowInfoEnd:" + DateTime.Now.ToString();

                if (ApprovalData.SubmitFlag == SubmitFlag.New)
                {
                    #region
                    if (fd != null && fd.Count > 0)
                    {
                        CheckFlowResult.APPDataResult.FlowResult = FlowResult.SUCCESS;
                        CheckFlowResult.Flag = 0;
                        UserInfo AppUser = new UserInfo();//下一审核人
                        AppUser.UserID = fd[0].EDITUSERID;
                        AppUser.UserName = fd[0].EDITUSERNAME;
                        AppUser.CompanyID = fd[0].EDITCOMPANYID;
                        AppUser.DepartmentID = fd[0].EDITDEPARTMENTID;
                        AppUser.PostID = fd[0].EDITPOSTID;

                        CheckFlowResult.APPDataResult.UserInfo.Add(AppUser);
                        CheckFlowResult.APPDataResult.AppState = fd[0].STATECODE;

                        return CheckFlowResult;
                    }
                    #endregion

                }
                else if (ApprovalData.SubmitFlag == SubmitFlag.Cancel)
                {
                }

                else
                {
                    if (fd == null || fd.Count == 0)
                    {
                        CheckFlowResult.APPDataResult.FlowResult = FlowResult.FAIL;
                        CheckFlowResult.APPDataResult.Err = "没有待审批节点,请检查流程是否已经结束或流程有异常!";
                        CheckFlowResult.Flag = 0;

                        return CheckFlowResult;
                    }
                    else
                    {

                        if (fd.Where(c => c.EDITUSERID == ApprovalData.ApprovalUser.UserID || c.AGENTUSERID == ApprovalData.ApprovalUser.UserID).ToList().Count == 0)
                        {
                            APPDataResult.FlowResult = FlowResult.SUCCESS;
                            CheckFlowResult.Flag = 0;
                            UserInfo AppUser = new UserInfo();
                            AppUser.UserID = fd[0].EDITUSERID;
                            AppUser.UserName = fd[0].EDITUSERNAME;
                            AppUser.CompanyID = fd[0].EDITCOMPANYID;
                            AppUser.DepartmentID = fd[0].EDITDEPARTMENTID;
                            AppUser.PostID = fd[0].EDITPOSTID;

                            CheckFlowResult.APPDataResult.UserInfo.Add(AppUser);
                            CheckFlowResult.APPDataResult.AppState = fd[0].STATECODE;

                            return CheckFlowResult;
                        }

                    }


                }
                CheckFlowResult.Flag = 1;
                return CheckFlowResult;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                CheckFlowResult = null;
            }
        }