Esempio n. 1
0
File: Service.cs Progetto: JuRogn/OA
        public void AddConsultation(FLOW_CONSULTATION_T flowConsultation, SubmitData submitData)
        {
            OracleConnection con = ADOHelper.GetOracleConnection();
            SMT.FlowWFService.NewFlow.Service s2 = new SMT.FlowWFService.NewFlow.Service();
            s2.AddConsultation(con,flowConsultation,  submitData);
            #region 旧代码
            //if (strIsFlowEngine.ToLower() == "true")
            //{
            //    try
            //    {
            //        flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T =
            //            FlowBLL.GetFLOW_FLOWRECORDMASTER_T(flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID);
            //        FlowEngineService.EngineWcfGlobalFunctionClient FlowEngine = new FlowEngineService.EngineWcfGlobalFunctionClient();
            //        FlowEngineService.CustomUserMsg[] cs = new FlowEngineService.CustomUserMsg[1];

            //        FlowEngineService.CustomUserMsg cu = new FlowEngineService.CustomUserMsg();
            //        cu.FormID = flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID;
            //        cu.UserID = flowConsultation.REPLYUSERID;
            //        cs[0] = cu;
            //        ModelInfo modelinfo = FlowBLL.GetSysCodeByModelCode(submitData.ModelCode);
            //        MessageData tmpMessageData = new MessageData("Flow", modelinfo.SysCode,
            //            flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID,
            //            submitData.ModelCode, modelinfo.ModelName, submitData.FormID, flowConsultation.FLOW_FLOWRECORDDETAIL_T.STATECODE, flowConsultation.FLOW_FLOWRECORDDETAIL_T.CHECKSTATE, "", "", "", "");
            //        FlowBLL flowBLL = new FlowBLL();
            //        StringBuilder FlowResultXml = flowBLL.BuildMessageData(tmpMessageData);
            //        //FlowEngine = new FlowEngineService.EngineWcfGlobalFunctionClient();
            //        //log = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
            //        if (!string.IsNullOrEmpty(flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT))
            //        {
            //            submitData.XML = flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT;
            //        }

            //        bool b = FlowEngine.FlowConsultati(cs, "", FlowResultXml.ToString(), submitData.XML);
            //        if (!b)
            //        {
            //            Tracer.Debug("FlowEngineService-FlowConsultati:" + flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID
            //                + "\nsubmitData:" + submitData.XML);
            //        }

            //        FlowBLL bll = new FlowBLL();

            //        bll.AddConsultation(flowConsultation);
            //    }
            //    catch (Exception ex)
            //    {
            //        Tracer.Debug("AddConsultation: -" + flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID + "-" + ex.InnerException + ex.Message);
            //        throw ex;
            //    }
            //}

            #endregion

        }
Esempio n. 2
0
        public void AddConsultation(OracleConnection con, FLOW_CONSULTATION_T flowConsultation, SubmitData submitData)
        {
            
            if (strIsFlowEngine.ToLower() == "true")
            {
                try
                {
                    flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T =
                        FlowBLL2.GetFLOW_FLOWRECORDMASTER_T(con, flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FLOWRECORDMASTERID);
                    FlowEngineService.EngineWcfGlobalFunctionClient FlowEngine = new FlowEngineService.EngineWcfGlobalFunctionClient();
                    FlowEngineService.CustomUserMsg[] cs = new FlowEngineService.CustomUserMsg[1];

                    FlowEngineService.CustomUserMsg cu = new FlowEngineService.CustomUserMsg();
                    cu.FormID = flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID;
                    cu.UserID = flowConsultation.REPLYUSERID;
                    cs[0] = cu;
                    ModelInfo modelinfo = FlowBLL2.GetSysCodeByModelCode(con, submitData.ModelCode);
                    MessageData tmpMessageData = new MessageData("Flow", modelinfo.SysCode,
                        flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID,
                        submitData.ModelCode, modelinfo.ModelName, submitData.FormID, flowConsultation.FLOW_FLOWRECORDDETAIL_T.STATECODE, flowConsultation.FLOW_FLOWRECORDDETAIL_T.CHECKSTATE, "", "", "", "");
                    FlowBLL2 flowBLL = new FlowBLL2();
                    StringBuilder FlowResultXml = flowBLL.BuildMessageData(tmpMessageData);
                    //FlowEngine = new FlowEngineService.EngineWcfGlobalFunctionClient();
                    //log = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
                    if (!string.IsNullOrEmpty(flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT))
                    {
                        submitData.XML = flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT;
                    }

                    bool b = FlowEngine.FlowConsultati(cs, "", FlowResultXml.ToString(), submitData.XML);
                    if (!b)
                    {
                        Tracer.Debug("FlowEngineService-FlowConsultati:" + flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID
                            +"\nsubmitData:"+submitData.XML);
                    }

                    FlowBLL2 bll = new FlowBLL2();

                    bll.AddConsultation(con, flowConsultation);
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog("AddConsultation异常信息 :" + ex.ToString());
                    //Tracer.Debug("AddConsultation: -" + flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID + "-" + ex.InnerException + ex.Message);
                    throw ex;
                }
            }

               
           
        }
Esempio n. 3
0
        /// <summary>
        /// 检查流程参数是否符合规则
        /// </summary>
        /// <param name="ApprovalData"></param>
        /// <param name="APPDataResult"></param>
        /// <returns></returns>
        public static bool CheckFlowData(SubmitData ApprovalData, ref DataResult APPDataResult)
        {
            try
            {

                if (ApprovalData.FormID == null || ApprovalData.FormID == "")
                {
                    APPDataResult.Err = "业务对象的FORMID为空";
                    return false;
                }

                if (ApprovalData.ModelCode == null || ApprovalData.ModelCode == "")
                {
                    APPDataResult.Err = "模块代码为空";
                    return false;
                }

                //if (ApprovalData.SubmitFlag == null || (ApprovalData.SubmitFlag != SubmitFlag.New && ApprovalData.SubmitFlag != SubmitFlag.Approval))
                //{
                //    APPDataResult.Err = "流程提交标志(SubmitFlag)有误,需要设置成SubmitFlag.New或者SubmitFlag.Approval";
                //    return false;
                //}

                if (ApprovalData.SubmitFlag == null)
                {
                    APPDataResult.Err = "流程提交标志(SubmitFlag)不能为空";
                    return false;
                }

                if (ApprovalData.FlowSelectType == null || (ApprovalData.FlowSelectType != FlowSelectType.FixedFlow && ApprovalData.FlowSelectType != FlowSelectType.FreeFlow))
                {
                    APPDataResult.Err = "流程审批类型设置有误,应设置成FlowSelectType.FixedFlow或FlowSelectType.FreeFlow";
                    return false;
                }

                if (ApprovalData.ApprovalUser == null)
                {
                    APPDataResult.Err = "提交用户信息不能为空";
                    return false;
                }
                else if (ApprovalData.ApprovalUser.CompanyID == null || ApprovalData.ApprovalUser.CompanyID == "")
                {
                    APPDataResult.Err = "提交用户所属公司不能为空";
                    return false;
                }
                else if (ApprovalData.ApprovalUser.DepartmentID == null || ApprovalData.ApprovalUser.DepartmentID == "")
                {
                    APPDataResult.Err = "提交用户所属部门不能为空";
                    return false;
                }
                else if (ApprovalData.ApprovalUser.PostID == null || ApprovalData.ApprovalUser.PostID == "")
                {
                    APPDataResult.Err = "提交用户所属岗位不能为空";
                    return false;
                }
                else if (ApprovalData.ApprovalUser.UserID == null || ApprovalData.ApprovalUser.UserID == "")
                {
                    APPDataResult.Err = "提交用户ID不能为空";
                    return false;
                }
                else if (ApprovalData.ApprovalUser.UserName == null || ApprovalData.ApprovalUser.UserName == "")
                {
                    APPDataResult.Err = "提交用户名称不能为空";
                    return false;
                }

                if (ApprovalData.NextApprovalUser != null)
                {
                    if ((ApprovalData.NextApprovalUser.CompanyID != null && ApprovalData.NextApprovalUser.CompanyID != "")
                        || (ApprovalData.NextApprovalUser.DepartmentID != null && ApprovalData.NextApprovalUser.DepartmentID != "")
                        || (ApprovalData.NextApprovalUser.PostID != null && ApprovalData.NextApprovalUser.PostID != "")
                        || (ApprovalData.NextApprovalUser.UserID != null && ApprovalData.NextApprovalUser.UserID != "")
                        || (ApprovalData.NextApprovalUser.UserName != null && ApprovalData.NextApprovalUser.UserName != ""))
                    {
                        if (ApprovalData.NextStateCode == null || ApprovalData.NextStateCode == "")
                        {
                            //APPDataResult.Err = "设置了下一审核人时下一审核节点代码不能为空";
                            //return false;
                        }
                        else if (ApprovalData.NextApprovalUser.CompanyID == null || ApprovalData.NextApprovalUser.CompanyID == "")
                        {
                            //APPDataResult.Err = "下一审核用户所属公司不能为空";
                            //return false;
                        }
                        else if (ApprovalData.NextApprovalUser.DepartmentID == null || ApprovalData.NextApprovalUser.DepartmentID == "")
                        {
                            //APPDataResult.Err = "下一审核用户所属部门不能为空";
                            //return false;
                        }
                        else if (ApprovalData.NextApprovalUser.PostID == null || ApprovalData.NextApprovalUser.PostID == "")
                        {
                            //APPDataResult.Err = "下一审核用户所属岗位不能为空";
                            //return false;
                        }
                        else if (ApprovalData.NextApprovalUser.UserID == null || ApprovalData.NextApprovalUser.UserID == "")
                        {
                            //APPDataResult.Err = "下一审核用户ID不能为空";
                            //return false;
                        }
                        else if (ApprovalData.NextApprovalUser.UserName == null || ApprovalData.NextApprovalUser.UserName == "")
                        {
                            //APPDataResult.Err = "下一审核用户名称不能为空";
                            //return false;
                        }
                    }
                    else if (ApprovalData.NextStateCode != null && ApprovalData.NextStateCode != "")
                    {
                        //APPDataResult.Err = "未设置下一审核人时,不能设置下一审核节点代码";
                        //return false;
                    }
                }
                else if (ApprovalData.NextStateCode != null && ApprovalData.NextStateCode != "")
                {
                    //APPDataResult.Err = "未设置下一审核人时,不能设置下一审核节点代码";
                    //return false;
                }

                return true;
            }
            catch (Exception e)
            {

                throw e;
            }
        }
Esempio n. 4
0
        public string GetFlowDefine(OracleConnection con, SubmitData ApprovalData)
        {
            try
            {

                LogHelper.WriteLog("FlowBLL2.GetFlowDefine.GetFlowByModelName(ApprovalData.ApprovalUser.DepartmentID=" + ApprovalData.ApprovalUser.DepartmentID + ";OrgType='" + ((int)ApprovalData.FlowType).ToString() + ")'");

                List<FLOW_MODELFLOWRELATION_T> MODELFLOWRELATION = GetFlowByModelName(con, ApprovalData.ApprovalUser.CompanyID, ApprovalData.ApprovalUser.DepartmentID, ApprovalData.ModelCode, ((int)ApprovalData.FlowType).ToString());


                if (MODELFLOWRELATION == null || MODELFLOWRELATION.Count == 0)
                {

                    return null;
                }
                return MODELFLOWRELATION.First().FLOW_FLOWDEFINE_T.LAYOUT;
            }
            catch (Exception e)
            {
                LogHelper.WriteLog("FlowBll2->GetFlowDefine" + e.Message);
                throw e;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 自选流程(对数据库操作、对服务操作)
        /// </summary>
        /// <param name="ApprovalData"></param>
        /// <param name="APPDataResult"></param>
        /// <param name="fd"></param>
        /// <returns></returns>
        public DataResult ApprovalFreeFlow(OracleConnection con, SubmitData ApprovalData, DataResult APPDataResult, List<FLOW_FLOWRECORDDETAIL_T> fd)
        {
            // WorkflowRuntime workflowRuntime = null;
            WorkflowInstance instance = null;
            FLOW_FLOWRECORDDETAIL_T entity = new FLOW_FLOWRECORDDETAIL_T();
            entity.FLOW_FLOWRECORDMASTER_T = new FLOW_FLOWRECORDMASTER_T();
            UserInfo AppUser = new UserInfo(); //下一审核人
            UserInfo AgentAppUser = new UserInfo(); //代理下一审核人
            try
            {
                APPDataResult.RunTime += "---GetAppInfoStart:" + DateTime.Now.ToString();
                List<FLOW_FLOWRECORDDETAIL_T> tmp = fd.Where(c => (c.EDITUSERID == ApprovalData.ApprovalUser.UserID || c.AGENTUSERID == ApprovalData.ApprovalUser.UserID) && c.FLAG == "0").ToList();
                APPDataResult.RunTime += "---GetAppInfoEnd:" + DateTime.Now.ToString();
                if (tmp == null)
                {
                    APPDataResult.FlowResult = FlowResult.FAIL;
                    APPDataResult.Err = "没有找到待审核信息";
                    // DataResult.UserInfo = null;
                    return APPDataResult;
                }

                entity = tmp[0];
                entity.EDITDATE = DateTime.Now;  //审批时间

                if (entity.AGENTUSERID == ApprovalData.ApprovalUser.UserID)
                {
                    entity.AGENTEDITDATE = entity.EDITDATE;  //代理审批时审批时间与代理审批时间到致
                }
                //entity.EditUserID = AppUserId;
                entity.CONTENT = ApprovalData.ApprovalContent;
                entity.CHECKSTATE = ((int)ApprovalData.ApprovalResult).ToString();


                workflowRuntime = SMTWorkFlowManage.CreateWorkFlowRuntime(true);
                LogHelper.WriteLog("ApprovalFreeFlow从持久化库在恢复创建工作流实例ID=" + tmp[0].FLOW_FLOWRECORDMASTER_T.INSTANCEID);
                instance = SMTWorkFlowManage.GetWorkflowInstance(workflowRuntime, tmp[0].FLOW_FLOWRECORDMASTER_T.INSTANCEID);// workflowRuntime.GetWorkflow(new Guid(tmp[0].FLOW_FLOWRECORDMASTER_T.INSTANCEID));

                //不同意状态处理
                if (ApprovalData.ApprovalResult == ApprovalResult.NoPass)
                {
                    instance.Terminate("0");
                    entity.FLOW_FLOWRECORDMASTER_T.CHECKSTATE = "3"; //设为终审不通过
                    entity.FLOW_FLOWRECORDMASTER_T.EDITUSERID = ApprovalData.ApprovalUser.UserID;
                    entity.FLOW_FLOWRECORDMASTER_T.EDITUSERNAME = ApprovalData.ApprovalUser.UserName;
                    entity.FLOW_FLOWRECORDMASTER_T.EDITDATE = DateTime.Now;
                    UpdateFlowRecord(con, entity, ApprovalData.NextStateCode, ApprovalData.NextApprovalUser.UserID);
                    FLOW_FLOWRECORDMASTER_TDAL.Update(con, entity.FLOW_FLOWRECORDMASTER_T);//对数据库操作
                    APPDataResult.CheckState = "3";//
                    APPDataResult.FlowResult = FlowResult.END;
                    // DataResult.UserInfo = null;
                    // return DataResult;

                }
                else
                {


                    //下一审核人赋值
                    AppUser = ApprovalData.NextApprovalUser;

                    AgentAppUser = GetAgentUserInfo(ApprovalData.ModelCode, AppUser.UserID); //查询是否启用了代理人(对服务操作)

                    FlowDataType.FlowData FlowData = new FlowDataType.FlowData();
                    FlowData.xml = ApprovalData.XML;



                    workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
                    {//完成工作流实例
                        instance = null;
                    };

                    ApprovalData.NextStateCode = ApprovalData.NextStateCode == "EndFlow" ? "EndFlow" : "Approval";
                    APPDataResult.RunTime += "---DoFlowStart:" + DateTime.Now.ToString();

                    APPDataResult = DoFlowRecord(con, workflowRuntime, instance, entity, ApprovalData.NextStateCode, AppUser, AgentAppUser, ApprovalData.SubmitFlag, ApprovalData.FlowType); //处理流程数据
                    APPDataResult.AgentUserInfo = AgentAppUser;
                    APPDataResult.RunTime += "---DoFlowEnd:" + DateTime.Now.ToString();
                    if (ApprovalData.NextStateCode == "EndFlow")
                    {
                        workflowRuntime.GetService<FlowEvent>().OnDoFlow(instance.InstanceId, FlowData); //激发流程引擎执行到一下流程
                        System.Threading.Thread.Sleep(1000);
                    }



                }
                return APPDataResult;
            }
            catch (Exception e)
            {

                throw new Exception(e.Message);
            }
            finally
            {
                AppUser = null;
                AgentAppUser = null;
                entity = null;
                instance = null;
                SMTWorkFlowManage.ColseWorkFlowRuntime(workflowRuntime);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 自选流程审批(对服务操作)
        /// </summary>
        /// <param name="ApprovalData"></param>
        /// <param name="APPDataResult"></param>
        /// <returns></returns>
        public DataResult AddFreeFlow(OracleConnection con, SubmitData ApprovalData, DataResult APPDataResult)
        {
            // WorkflowRuntime workflowRuntime = null;
            WorkflowInstance instance = null;
            FLOW_FLOWRECORDDETAIL_T entity = new FLOW_FLOWRECORDDETAIL_T();
            entity.FLOW_FLOWRECORDMASTER_T = new FLOW_FLOWRECORDMASTER_T();
            UserInfo AppUser = new UserInfo(); //下一审核人
            UserInfo AgentAppUser = new UserInfo(); //代理下一审核人
            try
            {
                entity.FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT = ApprovalData.XML;
                entity.FLOW_FLOWRECORDMASTER_T.FORMID = ApprovalData.FormID;
                entity.FLOW_FLOWRECORDMASTER_T.MODELCODE = ApprovalData.ModelCode;

                // entity.FLOWRECORDDETAILID = FlowGUID;
                entity.CREATECOMPANYID = ApprovalData.ApprovalUser.CompanyID;
                entity.CREATEDEPARTMENTID = ApprovalData.ApprovalUser.DepartmentID;
                entity.CREATEPOSTID = ApprovalData.ApprovalUser.PostID;
                entity.CREATEUSERID = ApprovalData.ApprovalUser.UserID;
                entity.CREATEUSERNAME = ApprovalData.ApprovalUser.UserName;
                entity.FLOW_FLOWRECORDMASTER_T.FLOWTYPE = ((int)ApprovalData.FlowType).ToString();
                entity.FLOW_FLOWRECORDMASTER_T.FLOWSELECTTYPE = ((int)ApprovalData.FlowSelectType).ToString();
                entity.FLOW_FLOWRECORDMASTER_T.FLOWCODE = "FreeFlow";
                workflowRuntime = SMTWorkFlowManage.CreateWorkFlowRuntime(true);
                instance = SMTWorkFlowManage.CreateWorkflowInstance(workflowRuntime, "FreeFlow.xml");//自选流程使用
                LogHelper.WriteLog("自选流程使用 AddFreeFlow(try)创建工作流实例ID=" + instance.InstanceId);
                entity.FLOW_FLOWRECORDMASTER_T.INSTANCEID = instance.InstanceId.ToString();


                //下一审核人赋值
                AppUser = ApprovalData.NextApprovalUser;

                APPDataResult.RunTime += "---DoFlowStart:" + DateTime.Now.ToString();
                ApprovalData.NextStateCode = "Approval";
                AgentAppUser = GetAgentUserInfo(ApprovalData.ModelCode, AppUser.UserID); //查询是否启用了代理人(对服务操作)

                APPDataResult = DoFlowRecord(con, workflowRuntime, instance, entity, ApprovalData.NextStateCode, AppUser, AgentAppUser, ApprovalData.SubmitFlag, ApprovalData.FlowType); //处理流程数据
                APPDataResult.AgentUserInfo = AgentAppUser;
                APPDataResult.RunTime += "---DoFlowEnd:" + DateTime.Now.ToString();
                return APPDataResult;
            }
            catch (Exception e)
            {

                throw new Exception(e.Message);
            }
            finally
            {
                AppUser = null;
                AgentAppUser = null;
                entity = null;
                instance = null;
                SMTWorkFlowManage.ColseWorkFlowRuntime(workflowRuntime);
            }
        }
Esempio n. 7
0
        //下一审核人提交审核时调用方法
        /// <summary>
        /// 下一审核人提交审核时调用方法
        /// </summary>
        /// <param name="submitData"></param>
        /// <param name="dataResult"></param>
        /// <param name="listDetail"></param>
        /// <returns></returns>
        public DataResult ApprovalFlow2(OracleConnection con, SubmitData submitData, DataResult dataResult, List<FLOW_FLOWRECORDDETAIL_T> listDetail, ref string msg)
        {
            ///针对会签,该次审核成功后是否跳转至下一状态
            bool isGotoNextState = true;
            // WorkflowRuntime workflowRuntime = null;
            WorkflowInstance instance = null;
            FLOW_FLOWRECORDDETAIL_T entity = new FLOW_FLOWRECORDDETAIL_T();
            entity.FLOW_FLOWRECORDMASTER_T = new FLOW_FLOWRECORDMASTER_T();

            try
            {
                #region Entity赋值
                List<FLOW_FLOWRECORDDETAIL_T> tmpEntity = listDetail.Where(c => (c.EDITUSERID == submitData.ApprovalUser.UserID || c.AGENTUSERID == submitData.ApprovalUser.UserID) && c.FLAG == "0").ToList();
                if (tmpEntity == null)
                {
                    dataResult.FlowResult = FlowResult.FAIL;
                    dataResult.Err = "没有找到待审核信息";
                    return dataResult;
                }
                entity = tmpEntity[0];
                entity.EDITDATE = DateTime.Now;  //审批时间
                if (entity.AGENTUSERID == submitData.ApprovalUser.UserID)
                {
                    entity.AGENTEDITDATE = entity.EDITDATE;  //代理审批时审批时间与代理审批时间到致
                }

                entity.CONTENT = submitData.ApprovalContent;
                entity.CHECKSTATE = ((int)submitData.ApprovalResult).ToString();
                #endregion

                //workflowRuntime.StartRuntime();
                msg += "SMTWorkFlowManage.CreateWorkFlowRuntime(true)" + DateTime.Now.ToString() + "\r\n";
                workflowRuntime = SMTWorkFlowManage.CreateWorkFlowRuntime(true);
                try
                {
                    instance = SMTWorkFlowManage.GetWorkflowInstance(workflowRuntime, entity.FLOW_FLOWRECORDMASTER_T.INSTANCEID);// workflowRuntime.GetWorkflow(new Guid(tmp[0].FLOW_FLOWRECORDMASTER_T.INSTANCEID));
                    LogHelper.WriteLog("FormID=" + submitData.FormID + ";ApprovalFlow2(try)从持久化库[ 完成 ]恢复创建工作流实例ID=" + entity.FLOW_FLOWRECORDMASTER_T.INSTANCEID);


                }
                catch (Exception exGetWorkflowInstance)
                {
                    #region 重新创建新流程,将新流程设置为当前状态。
                    try
                    {
                        string exc = "FormID=" + submitData.FormID + ";从持久化恢复工作流失败 SMTWorkFlowManage.GetWorkflowInstance(" + workflowRuntime.Name + ", " + entity.FLOW_FLOWRECORDMASTER_T.INSTANCEID + ");原因如下:\r\n" + exGetWorkflowInstance.ToString() + ";\r\n下面重新创建新流程,并将新流程设置为当前状态;\r\nGetFlowByModelName:submitData.ApprovalUser.DepartmentID=" + submitData.ApprovalUser.DepartmentID + ";OrgType='" + ((int)submitData.FlowType).ToString() + "'";
                        LogHelper.WriteLog(exc);

                        List<FLOW_MODELFLOWRELATION_T> MODELFLOWRELATION = GetFlowByModelName(con, entity.FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID, entity.FLOW_FLOWRECORDMASTER_T.CREATEDEPARTMENTID, submitData.ModelCode, ((int)submitData.FlowType).ToString());

                        FLOW_MODELFLOWRELATION_T flowRelation = MODELFLOWRELATION[0];
                        FLOW_FLOWDEFINE_T flowDefine = flowRelation.FLOW_FLOWDEFINE_T;
                        instance = SMTWorkFlowManage.CreateWorkflowInstance(workflowRuntime, flowDefine.XOML, flowDefine.RULES);
                        LogHelper.WriteLog("FormID=" + submitData.FormID + ";ApprovalFlow2(catch)完成重新创建工作流实例ID=" + instance.InstanceId);
                        StateMachineWorkflowInstance workflowinstance = new StateMachineWorkflowInstance(workflowRuntime, instance.InstanceId);
                        workflowinstance.SetState(entity.STATECODE);
                        System.Threading.Thread.Sleep(1000);
                        instance = SMTWorkFlowManage.GetWorkflowInstance(workflowRuntime, instance.InstanceId.ToString());
                        LogHelper.WriteLog("FormID=" + submitData.FormID + ";ApprovalFlow2(catch)从持久化库再恢复刚才创建工作流实例ID=" + instance.InstanceId);

                        entity.FLOW_FLOWRECORDMASTER_T.INSTANCEID = instance.InstanceId.ToString();
                        //FLOW_FLOWRECORDDETAIL_TDAL.UpdateMasterINSTANCEID(entity.FLOW_FLOWRECORDMASTER_T);
                        FLOW_FLOWRECORDMASTER_TDAL.UpdateMasterINSTANCEID(con, entity.FLOW_FLOWRECORDMASTER_T);

                    }
                    catch (Exception exNewInstance)
                    {
                        LogHelper.WriteLog("重新创建新流程,将新流程设置为当前状态失败:FormID=" + submitData.FormID + "FlowBll2->ApprovalFlow2" + exNewInstance.Message);
                        //Tracer.Debug("exNewInstance: -" + submitData.FormID + "--submitDataXML:" + submitData.XML + "-" + exNewInstance.InnerException + exNewInstance.Message);
                        throw exGetWorkflowInstance;
                    }
                    #endregion
                }
                msg += "SMTWorkFlowManage.CreateWorkFlowRuntime(true)完成" + DateTime.Now.ToString() + "\r\n";


                #region 当前状态会签状态处理
                bool currentIsCountersign = false;
                string currentCountersignType = "0";

                Utility.IsCountersign(entity.FLOW_FLOWRECORDMASTER_T.ACTIVEROLE, entity.STATECODE, ref currentIsCountersign, ref currentCountersignType);
                if (currentIsCountersign)
                {
                    msg += "状态会签状态处理" + DateTime.Now.ToString() + "\r\n";
                    if (currentCountersignType == "1")//一人通过即所有通过,可以跳转至下一状态
                    {
                        isGotoNextState = true;
                    }
                    else
                    {
                        ///该审核是会签的最后的审核人
                        if (entity.FLOW_FLOWRECORDMASTER_T.FLOW_FLOWRECORDDETAIL_T.Count == 1)
                        {
                            isGotoNextState = true;
                        }
                        else
                        {
                            isGotoNextState = false;
                        }
                    }
                    msg += "状态会签状态处理完成" + DateTime.Now.ToString() + "\r\n";
                }
                #endregion
                //不同意状态处理
                if (submitData.ApprovalResult == ApprovalResult.NoPass)
                {
                    msg += "不同意状态处理" + DateTime.Now.ToString() + "\r\n";
                    #region
                    instance.Terminate("0");
                    entity.FLOW_FLOWRECORDMASTER_T.CHECKSTATE = "3"; //设为终审不通过
                    entity.FLOW_FLOWRECORDMASTER_T.EDITUSERID = submitData.ApprovalUser.UserID;
                    entity.FLOW_FLOWRECORDMASTER_T.EDITUSERNAME = submitData.ApprovalUser.UserName;
                    entity.FLOW_FLOWRECORDMASTER_T.EDITDATE = DateTime.Now;
                    UpdateFlowRecord(con, entity, submitData.NextStateCode, submitData.NextApprovalUser.UserID);
                    FLOW_FLOWRECORDMASTER_TDAL.Update(entity.FLOW_FLOWRECORDMASTER_T);
                    dataResult.CheckState = "3";//
                    dataResult.FlowResult = FlowResult.END;

                    if (currentIsCountersign)
                    {
                        #region 当前是会签状态,删除未审核记录
                        entity.FLOW_FLOWRECORDMASTER_T.FLOW_FLOWRECORDDETAIL_T
                                .Where(detail => detail.FLOWRECORDDETAILID != entity.FLOWRECORDDETAILID && detail.STATECODE == entity.STATECODE && detail.FLAG == "0")
                                .ToList().ForEach(item =>
                                {
                                    item.FLAG = "1";
                                    item.CHECKSTATE = "8";
                                    UpdateFlowRecord2(con, item);
                                });
                        #endregion
                    }

                    #endregion
                    msg += "不同意状态处理完成" + DateTime.Now.ToString() + "\r\n";

                }
                else
                {
                    if (!isGotoNextState)
                    {
                        msg += "isGotoNextState" + DateTime.Now.ToString() + "\r\n";
                        #region

                        UpdateFlowRecord2(con, entity);
                        dataResult.AppState = entity.STATECODE;
                        dataResult.FlowResult = FlowResult.SUCCESS;
                        dataResult.CheckState = "1";
                        #endregion
                        msg += "isGotoNextState完成" + DateTime.Now.ToString() + "\r\n";
                    }
                    else
                    {
                        msg += "获取下一状态数据" + DateTime.Now.ToString() + "\r\n";
                        #region 获取下一状态数据
                        List<string> User = new List<string>();
                        User.Add(entity.FLOW_FLOWRECORDMASTER_T.CREATEUSERID);
                        User.Add(submitData.ApprovalUser.UserID);

                        List<string> tmpPostID = new List<string>();
                        tmpPostID.Add(entity.FLOW_FLOWRECORDMASTER_T.CREATEPOSTID);
                        tmpPostID.Add(entity.EDITPOSTID);
                        GetUserByInstance2(entity.FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID, workflowRuntime, instance, entity.FLOW_FLOWRECORDMASTER_T.ACTIVEROLE, submitData.XML, entity.STATECODE, User, tmpPostID, submitData.FlowType, ref dataResult);

                        if (dataResult.FlowResult == FlowResult.FAIL)
                        {
                            return dataResult;
                        }
                        submitData.NextStateCode = dataResult.AppState;
                        if (dataResult.IsCountersign)
                        {
                            #region
                            if (dataResult.FlowResult == FlowResult.Countersign)
                            {
                                if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                                {
                                    return dataResult;
                                }
                            }
                            else
                            {
                                if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                                {
                                    submitData.DictCounterUser = dataResult.DictCounterUser;
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            #region
                            if (dataResult.FlowResult == FlowResult.MULTIUSER)
                            {
                                if (submitData.NextApprovalUser == null || (Utility.GetString(submitData.NextApprovalUser.UserID) == "" || Utility.GetString(submitData.NextApprovalUser.UserName) == ""))
                                {
                                    return dataResult;
                                }
                            }
                            else
                            {
                                if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                                {
                                    submitData.NextApprovalUser = dataResult.UserInfo[0];
                                }
                            }
                            #endregion
                        }

                        #endregion

                        msg += "获取下一状态数据完成" + DateTime.Now.ToString() + "\r\n";


                        msg += "单会签情况" + DateTime.Now.ToString() + "\r\n";
                        #region 对于单会签情况,需要将其他审核人的审核设为会签通过状态

                        if (currentIsCountersign && currentCountersignType == "1")
                        {
                            entity.FLOW_FLOWRECORDMASTER_T.FLOW_FLOWRECORDDETAIL_T
                               .Where(detail => detail.FLOWRECORDDETAILID != entity.FLOWRECORDDETAILID && detail.STATECODE == entity.STATECODE && detail.FLAG == "0")
                               .ToList().ForEach(item =>
                               {
                                   item.FLAG = "1";
                                   item.CHECKSTATE = "7";
                                   UpdateFlowRecord2(con, item);
                               });
                        }
                        #endregion
                        msg += "单会签情况完成" + DateTime.Now.ToString() + "\r\n";

                        #region


                        FlowDataType.FlowData FlowData = new FlowDataType.FlowData();
                        FlowData.xml = submitData.XML;
                        workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
                        {
                            instance = null;

                        };
                        msg += "处理kpi" + DateTime.Now.ToString() + "\r\n";

                        #region 处理kpi时间
                        string KPITime = "";
                        //PerformanceServiceWS.PerformanceServiceClient psc = new PerformanceServiceWS.PerformanceServiceClient();
                        string pscResult = entity.FLOW_FLOWRECORDMASTER_T.KPITIMEXML;
                        //psc.Close();
                        if (!string.IsNullOrEmpty(pscResult))
                        {
                            XElement xe = XElement.Parse(pscResult);
                            Func<XElement, bool> f = (x) =>
                            {
                                XAttribute xid = x.Attribute("id");
                                XAttribute xvalue = x.Attribute("value");
                                if (xid == null || xvalue == null)
                                    return false;
                                else
                                {
                                    if (xid.Value == dataResult.AppState)
                                        return true;
                                    else return false;
                                }
                            };
                            XElement FlowNode = xe.Elements("FlowNode").FirstOrDefault(f);
                            if (FlowNode != null)
                            {
                                KPITime = FlowNode.Attribute("value").Value;
                            }
                        }
                        dataResult.KPITime = KPITime;

                        #endregion

                        msg += "处理kpi完成" + DateTime.Now.ToString() + "\r\n";

                        if (!dataResult.IsCountersign)
                        {
                            msg += "非会签" + DateTime.Now.ToString() + "\r\n";
                            #region  非会签

                            UserInfo AppUser = submitData.NextApprovalUser;
                            dataResult.UserInfo.Clear();
                            dataResult.UserInfo.Add(AppUser);
                            UserInfo AgentAppUser = GetAgentUserInfo(submitData.ModelCode, AppUser.UserID);//查询是否启用了代理人                            
                            dataResult = DoFlowRecord2(con, workflowRuntime, instance, entity, submitData.NextStateCode, AppUser, AgentAppUser, submitData.SubmitFlag, submitData.FlowType); //处理流程数据
                            dataResult.AgentUserInfo = AgentAppUser;
                            dataResult.IsCountersign = false;
                            #endregion
                            msg += "非会签完成" + DateTime.Now.ToString() + "\r\n";
                        }
                        else
                        {
                            #region  会签

                            dataResult.DictCounterUser = submitData.DictCounterUser;
                            Dictionary<UserInfo, UserInfo> dictAgentUserInfo = GetAgentUserInfo2(submitData.ModelCode, submitData.DictCounterUser);
                            dataResult = DoFlowRecord_Approval(con, workflowRuntime, instance, entity, submitData.NextStateCode, submitData.DictCounterUser, dictAgentUserInfo, submitData.SubmitFlag, submitData.FlowType); //处理流程数据
                            dataResult.DictAgentUserInfo = dictAgentUserInfo;
                            dataResult.IsCountersign = true;


                            #endregion
                        }

                        msg += "激发流程引擎执行到一下流程" + DateTime.Now.ToString() + "\r\n";
                        #region 激发流程引擎执行到一下流程
                        if (dataResult.AppState == null || dataResult.AppState == "")
                            workflowRuntime.GetService<FlowEvent>().OnDoFlow(instance.InstanceId, FlowData); //激发流程引擎执行到一下流程
                        else
                        {
                            string ss = "";
                            int n = 0;
                            StateMachineWorkflowInstance workflowinstance = new StateMachineWorkflowInstance(workflowRuntime, instance.InstanceId);

                            workflowinstance.SetState(dataResult.AppState); //流程跳转到指定节点
                            //while (true)
                            //{
                            //    ss += (n++).ToString()+"|" + workflowinstance.CurrentStateName;
                            //    string stateName = workflowinstance.CurrentStateName;

                            //    if (stateName != null && stateName.ToUpper().IndexOf("START") == -1)
                            //    {
                            //        break;
                            //    }
                            //}
                        }
                        #endregion
                        msg += "激发流程引擎执行到一下流程完成" + DateTime.Now.ToString() + "\r\n";
                        //dataResult.CanSendMessage = true;

                        msg += "System.Threading.Thread.Sleep(1000)" + DateTime.Now.ToString() + "\r\n";
                        System.Threading.Thread.Sleep(1000);
                        if (submitData.FlowType == FlowType.Task)
                            dataResult.SubModelCode = Utility.GetSubModelCode(entity.FLOW_FLOWRECORDMASTER_T.ACTIVEROLE, dataResult.AppState); //返回下一子模块代码
                        msg += "System.Threading.Thread.Sleep(1000)完成" + DateTime.Now.ToString() + "\r\n";

                        #endregion
                    }


                }
                dataResult.CurrentIsCountersign = currentIsCountersign;
                dataResult.IsGotoNextState = isGotoNextState;
                return dataResult;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {

                entity = null;
                instance = null;
                SMTWorkFlowManage.ColseWorkFlowRuntime(workflowRuntime);
            }
        }
Esempio n. 8
0
File: FlowBLL.cs Progetto: JuRogn/OA
        public string GetFlowDefine(SubmitData ApprovalData)
        {
            try
            {

           
            List<FLOW_MODELFLOWRELATION_T> MODELFLOWRELATION = GetFlowByModelName(ApprovalData.ApprovalUser.CompanyID, ApprovalData.ApprovalUser.DepartmentID, ApprovalData.ModelCode, ((int)ApprovalData.FlowType).ToString());
           

            if (MODELFLOWRELATION == null || MODELFLOWRELATION.Count == 0)
            {
               
                return null;
            }
            return MODELFLOWRELATION.First().FLOW_FLOWDEFINE_T.LAYOUT;
            }
            catch (Exception e)
            {

                throw e ;
            }
        }
Esempio n. 9
0
        public DataResult SubimtFlow(SubmitData submitData)
        {
            #region
            //submitData = new SubmitData();
            //StringBuilder sb2 = new StringBuilder();
            //sb2.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            //sb2.AppendLine("<System>");
            //sb2.AppendLine("  <Name>OA</Name>");
            //sb2.AppendLine("  <Version>1.0</Version>");
            //sb2.AppendLine("  <System>");
            //sb2.AppendLine("    <Function Description=\"事项审批\" Address=\"SmtOAPersonOffice.svc\" FuncName=\"CallApplicationService\" Binding=\"customBinding\" SplitChar=\"Г\">");
            //sb2.AppendLine("      <ParaStr>");
            //sb2.AppendLine("        <Para TableName=\"T_OA_APPROVALINFO\" Name=\"APPROVALID\" Description=\"报批件ID\" Value=\"\"></Para>");
            //sb2.AppendLine("      </ParaStr>");
            //sb2.AppendLine("    </Function>");
            //sb2.AppendLine("  </System>");
            //sb2.AppendLine("  <MsgOpen>");
            //sb2.AppendLine("    <AssemblyName>SMT.SaaS.OA.UI</AssemblyName>");
            //sb2.AppendLine("    <PublicClass>SMT.SaaS.OA.UI.Utility</PublicClass>");
            //sb2.AppendLine("    <ProcessName>CreateFormFromEngine</ProcessName>");
            //sb2.AppendLine("    <PageParameter>SMT.SaaS.OA.UI.UserControls.ApprovalForm_aud</PageParameter>");
            //sb2.AppendLine("    <ApplicationOrder>{APPROVALID}</ApplicationOrder>");
            //sb2.AppendLine("    <FormTypes>Audit</FormTypes>");
            //sb2.AppendLine("  </MsgOpen>");
            //sb2.AppendLine("  <Object Name=\"T_OA_APPROVALINFO\" Description=\"事项审批\" Key=\"APPROVALID\" id=\"ea454559-3810-4fa2-8500-b20c480dd4bd\">");
            //sb2.AppendLine("    <Attribute Name=\"CURRENTEMPLOYEENAME\" LableResourceID=\"CURRENTEMPLOYEENAME\" Description=\"提交者\" DataType=\"string\" DataValue=\"\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"APPROVALID\" LableResourceID=\"APPROVALID\" Description=\"报批件ID\" DataType=\"string\" DataValue=\"ea454559-3810-4fa2-8500-b20c480dd4bd\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"APPROVALCODE\" LableResourceID=\"CODINGMATTERS\" Description=\"事项编码\" DataType=\"string\" DataValue=\"BPJ201205050001\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"APPROVALTITLE\" LableResourceID=\"TITLEMATTERS\" Description=\"事项标题\" DataType=\"string\" DataValue=\"旧流程数据到新流程数据过度测试\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"TEL\" LableResourceID=\"TEL\" Description=\"电话\" DataType=\"string\" DataValue=\"88997744\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"ISCHARGE\" LableResourceID=\"ISCHARGE\" Description=\"是否有费用\" DataType=\"string\" DataValue=\"1\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CHARGEMONEY\" LableResourceID=\"Fees\" Description=\"费用\" DataType=\"decimal\" DataValue=\"500\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CHECKSTATE\" LableResourceID=\"CHECKSTATE\" Description=\"审批状态\" DataType=\"string\" DataValue=\"0\" DataText=\"审核中\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"OWNERID\" LableResourceID=\"OWNERID\" Description=\"所属员工\" DataType=\"string\" DataValue=\"1bc4b78a-d178-4499-b948-16e18a9d73d3\" DataText=\"人事001-人事经理-人力资源部-模拟测试公司\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"OWNERNAME\" LableResourceID=\"OWNERNAME\" Description=\"当事人\" DataType=\"string\" DataValue=\"人事001\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"OWNERCOMPANYID\" LableResourceID=\"OWNERCOMPANYID\" Description=\"所属公司\" DataType=\"string\" DataValue=\"491d6eac-3bae-47ca-8998-89d39fc6faea\" DataText=\"模拟测试公司\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"OWNERDEPARTMENTID\" LableResourceID=\"OWNERDEPARTMENTID\" Description=\"所属部门\" DataType=\"string\" DataValue=\"4b146209-9442-489a-b19d-b70bd6a720d6\" DataText=\"人力资源部\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"OWNERPOSTID\" LableResourceID=\"OWNERPOSTID\" Description=\"所属岗位\" DataType=\"string\" DataValue=\"6d438cb1-92a8-4a07-a2ab-49926c68d1cd\" DataText=\"人事经理\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CREATEUSERID\" LableResourceID=\"CREATEUSERID\" Description=\"创建人\" DataType=\"string\" DataValue=\"1bc4b78a-d178-4499-b948-16e18a9d73d3\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CREATEUSERNAME\" LableResourceID=\"CREATEUSERNAME\" Description=\"创建人\" DataType=\"string\" DataValue=\"人事001\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CREATECOMPANYID\" LableResourceID=\"CREATECOMPANYID\" Description=\"创建公司\" DataType=\"string\" DataValue=\"491d6eac-3bae-47ca-8998-89d39fc6faea\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CREATEDEPARTMENTID\" LableResourceID=\"CREATEDEPARTMENTID\" Description=\"创建人部门\" DataType=\"string\" DataValue=\"4b146209-9442-489a-b19d-b70bd6a720d6\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CREATEPOSTID\" LableResourceID=\"CREATEPOSTID\" Description=\"创建人岗位\" DataType=\"string\" DataValue=\"6d438cb1-92a8-4a07-a2ab-49926c68d1cd\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CREATEDATE\" LableResourceID=\"CREATEDATE\" Description=\"创建日期\" DataType=\"DateTime\" DataValue=\"2012/5/5 15:42:27\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"UPDATEUSERID\" LableResourceID=\"UPDATEUSERID\" Description=\"修改人\" DataType=\"string\" DataValue=\"\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"UPDATEUSERNAME\" LableResourceID=\"UPDATEUSERNAME\" Description=\"修改人名\" DataType=\"string\" DataValue=\"\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"UPDATEDATE\" LableResourceID=\"UPDATEDATE\" Description=\"修改时间\" DataType=\"DateTime\" DataValue=\"\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"CONTENT\" LableResourceID=\"CONTENT\" Description=\"内容\" DataType=\"RTF\" DataValue=\"ea454559-3810-4fa2-8500-b20c480dd4bd\" DataText=\"ea454559-3810-4fa2-8500-b20c480dd4bd\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"AttachMent\" LableResourceID=\"AttachMent\" Description=\"附件\" DataType=\"attachmentlist\" DataValue=\"ea454559-3810-4fa2-8500-b20c480dd4bd\" DataText=\"ea454559-3810-4fa2-8500-b20c480dd4bd\" />");
            //sb2.AppendLine("    <Attribute Name=\"POSTLEVEL\" LableResourceID=\"POSTLEVEL\" Description=\"岗位级别\" DataType=\"string\" DataValue=\"15\" DataText=\"15\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"TYPEAPPROVAL\" LableResourceID=\"TYPEAPPROVAL\" Description=\"事项类型\" DataType=\"string\" DataValue=\"5\" DataText=\"公司制度修改\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"TYPEAPPROVALONE\" LableResourceID=\"TYPEAPPROVALONE\" Description=\"上级事项审批类型\" DataType=\"string\" DataValue=\"0\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"TYPEAPPROVALTWO\" LableResourceID=\"TYPEAPPROVALTWO\" Description=\"上上级事项审批类型\" DataType=\"string\" DataValue=\"\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("    <Attribute Name=\"TYPEAPPROVALTHREE\" LableResourceID=\"TYPEAPPROVALTHREE\" Description=\"上上上级事项审批类型\" DataType=\"string\" DataValue=\"\" DataText=\"\"></Attribute>");
            //sb2.AppendLine("  </Object>");
            //sb2.AppendLine("</System>");

            //submitData.FlowSelectType = FlowSelectType.FixedFlow;
            //submitData.FormID = "ea454559-3810-4fa2-8500-b20c480dd4bd";
            //submitData.ModelCode = "T_OA_APPROVALINFO";
            //submitData.ApprovalUser = new UserInfo();
            //submitData.ApprovalUser.CompanyID = "491d6eac-3bae-47ca-8998-89d39fc6faea";
            //submitData.ApprovalUser.DepartmentID = "4b146209-9442-489a-b19d-b70bd6a720d6";
            //submitData.ApprovalUser.PostID = "6d438cb1-92a8-4a07-a2ab-49926c68d1cd";
            //submitData.ApprovalUser.UserID = "1bc4b78a-d178-4499-b948-16e18a9d73d3";
            //submitData.ApprovalUser.UserName = "******";
            //submitData.NextStateCode = "";
            //submitData.NextApprovalUser = new UserInfo();
            //submitData.NextApprovalUser.CompanyID = "";
            //submitData.NextApprovalUser.DepartmentID = "";
            //submitData.NextApprovalUser.PostID = "";
            //submitData.NextApprovalUser.UserID = "";
            //submitData.NextApprovalUser.UserName = "";
            //submitData.SubmitFlag = SubmitFlag.New;
            //submitData.XML = sb2.ToString();
            //submitData.FlowType = FlowType.Approval;
            //submitData.ApprovalResult = ApprovalResult.Pass;
            //submitData.ApprovalContent = "提交";
            #endregion
            //调试外网 st = new 调试外网();
            //return st.SubimtFlow(submitData);
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("submitData.FlowSelectType =\"" + submitData.FlowSelectType + "\";");
            sb.AppendLine("submitData.FormID = \"" + submitData.FormID + "\";");
            sb.AppendLine("submitData.ModelCode = \"" + submitData.ModelCode + "\";");
            sb.AppendLine("submitData.ApprovalUser.CompanyID = \"" + submitData.ApprovalUser.CompanyID + "\";");
            sb.AppendLine("submitData.ApprovalUser.DepartmentID = \"" + submitData.ApprovalUser.DepartmentID + "\";");
            sb.AppendLine("submitData.ApprovalUser.PostID = \"" + submitData.ApprovalUser.PostID + "\";");
            sb.AppendLine("submitData.ApprovalUser.UserID = \"" + submitData.ApprovalUser.UserID + "\";");
            sb.AppendLine("submitData.ApprovalUser.UserName = \"" + submitData.ApprovalUser.UserName + "\";");
            sb.AppendLine("submitData.NextStateCode = \"" + (submitData.NextStateCode != null ? submitData.NextStateCode : "空") + "\";");
            sb.AppendLine("submitData.NextApprovalUser = \"" + submitData.NextApprovalUser + "\";");
            sb.AppendLine("submitData.NextApprovalUser.CompanyID = \"" + (submitData.NextApprovalUser != null ? submitData.NextApprovalUser.CompanyID : "空") + "\";");
            sb.AppendLine("submitData.NextApprovalUser.DepartmentID = \"" + (submitData.NextApprovalUser != null ? submitData.NextApprovalUser.DepartmentID : "空") + "\";");
            sb.AppendLine("submitData.NextApprovalUser.PostID = \"" + (submitData.NextApprovalUser != null ? submitData.NextApprovalUser.PostID : "空") + "\";");
            sb.AppendLine("submitData.NextApprovalUser.UserID = \"" + (submitData.NextApprovalUser != null ? submitData.NextApprovalUser.UserID : "空") + "\";");
            sb.AppendLine("submitData.NextApprovalUser.UserName = \"" + (submitData.NextApprovalUser != null ? submitData.NextApprovalUser.UserName : "******") + "\";");
            sb.AppendLine("submitData.SubmitFlag = \"" + submitData.SubmitFlag + "\";");
            // sb.AppendLine("submitData.XML = \"" + submitData.XML + "\";");
            sb.AppendLine("submitData.FlowType = \"" + submitData.FlowType.ToString() + "\";");
            sb.AppendLine("submitData.ApprovalResult = \"" + submitData.ApprovalResult.ToString() + "\";");
            sb.AppendLine("submitData.ApprovalContent = \"" + submitData.ApprovalContent + "\";");
            LogHelper.WriteLog("提交审核的信息:\r\n" + sb.ToString() + "\r\n");
            LogHelper.WriteLog("流程引擎的XML数据", "SubimtFlow入口处:" + submitData.ApprovalContent + " FormID=" + submitData.FormID + ";ModelCode=" + submitData.ModelCode + " \r\n submitData.XML:\r\n" + submitData.XML);
            LogHelper.WriteLog("***********************************************开始" + DateTime.Now.ToString() + "***********************************************");
            string msg = "";

            // MsOracle.BeginTransaction(con);

            DateTime dtStart = DateTime.Now;
            DateTime dtEngineStart = DateTime.Now;
            DateTime dtEnd = DateTime.Now;
            DateTime dtCheckData = DateTime.Now;
            //using (TransactionScope ts = new TransactionScope())
            //设置2分钟超时时间
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(DateTime.Now.AddMinutes(2).Ticks)))
            {
                OracleConnection con = ADOHelper.GetOracleConnection();
                #region 事务处理

                //System.Threading.Thread.Sleep(60000);
                DataResult dataResult = new DataResult();
                FlowBLL2 Flowbill = new FlowBLL2();
                string AppCompanyID = "";  //申请公司
                string MessageUserID = ""; //申请人ID
                string MessageUserName = ""; //申请人名
                dataResult.FlowResult = FlowResult.SUCCESS;
                try
                {
                    #region 检查流程数据是否规范
                    if (!FlowBLL2.CheckFlowData(submitData, ref dataResult))
                    {
                        dataResult.FlowResult = FlowResult.FAIL;
                        {
                            //ts.Complete();
                            return dataResult;
                        }
                    }
                    #endregion
                    submitData.ApprovalResult = submitData.SubmitFlag == SubmitFlag.New ? ApprovalResult.Pass : submitData.ApprovalResult;
                    submitData.FlowSelectType = submitData.FlowSelectType == null ? FlowSelectType.FixedFlow : submitData.FlowSelectType;
                    #region
                    #region 检查是否已提交流程(对数据库操作)
                    msg += "检查是否已提交流程" + DateTime.Now.ToString() + "\r\n";
                    LogHelper.WriteLog("检查是否已提交流程FormID = " + submitData.FormID);
                    OracleConnection ocon = ADOHelper.GetOracleConnection();
                    CheckResult CheckFlowResult = Flowbill.CheckFlow2(ocon, submitData, dataResult);//对数据库操作                    
                    msg += "检查是否已提交流程完成" + DateTime.Now.ToString() + "\r\n";
                    LogHelper.WriteLog("检查是否已提交流程完成FormID =" + submitData.FormID);
                    dtCheckData = DateTime.Now;
                    dataResult = CheckFlowResult.APPDataResult;
                    if (CheckFlowResult.Flag == 0)//已审批:1,未审批:0
                    {
                        //ts.Complete();
                        //return dataResult;
                    }
                    if (ocon.State == ConnectionState.Open)
                    {
                        ocon.Close();
                    }

                    #endregion
                    dataResult.AppState = submitData.NextStateCode;
                    //提交新流程
                    if (submitData.SubmitFlag == SubmitFlag.New)
                    {
                        #region 新增
                        AppCompanyID = submitData.ApprovalUser.CompanyID;
                        if (submitData.FlowSelectType == FlowSelectType.FreeFlow)
                            //自选流程
                            dataResult = Flowbill.AddFreeFlow(con, submitData, dataResult);//对数据库操作
                        else
                        {
                            //固定流程
                            msg += "固定流程" + DateTime.Now.ToString() + "\r\n";
                            LogHelper.WriteLog("固定流程.Flowbill.AddFlow2");
                            dataResult = Flowbill.AddFlow2(con, submitData, dataResult, ref msg);//对数据库操作
                            msg += "固定流程完成" + DateTime.Now.ToString() + "\r\n";
                        }
                        #endregion

                    }
                    else if (submitData.SubmitFlag == SubmitFlag.Cancel)
                    {
                        #region 撤单
                        if (!string.IsNullOrEmpty(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT))
                        {
                            submitData.XML = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT;
                        }
                        submitData.ApprovalContent = "";
                        dataResult = Flowbill.CancelFlow(submitData, dataResult, CheckFlowResult.fd);
                        dataResult.SubmitFlag = submitData.SubmitFlag;
                        #endregion
                    }

                    //审批流程
                    else
                    {
                        msg += "审核" + DateTime.Now.ToString() + "\r\n";
                        #region  审核
                        if (!string.IsNullOrEmpty(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT))
                        {
                            submitData.XML = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT;
                        }
                        //引擎消息数据
                        AppCompanyID = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID;
                        MessageUserID = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATEUSERID;
                        MessageUserName = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATEUSERNAME;
                        submitData.ApprovalUser.CompanyID = CheckFlowResult.fd[0].EDITCOMPANYID;
                        submitData.ApprovalUser.DepartmentID = CheckFlowResult.fd[0].EDITDEPARTMENTID;
                        submitData.ApprovalUser.PostID = CheckFlowResult.fd[0].EDITPOSTID;
                        submitData.FlowSelectType = (FlowSelectType)Convert.ToInt32(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.FLOWSELECTTYPE);
                        if (submitData.FlowSelectType == FlowSelectType.FreeFlow)
                            dataResult = Flowbill.ApprovalFreeFlow(con, submitData, dataResult, CheckFlowResult.fd);//对数据库操作、对服务操作
                        else
                            dataResult = Flowbill.ApprovalFlow2(con, submitData, dataResult, CheckFlowResult.fd, ref msg);
                        #endregion
                        msg += "审核完成" + DateTime.Now.ToString() + "\r\n";
                    }

                    #endregion
                    ModelInfo modelinfo = FlowBLL2.GetSysCodeByModelCode(con, submitData.ModelCode);//对数据库操作
                    if (dataResult.FlowResult == FlowResult.MULTIUSER)
                    {//如果检出有多个审核人时,返回界面让用户选择一个人进行审核
                        string users = "检出有多个审核人\r\n";
                        foreach (var u in dataResult.UserInfo)
                        {
                            users += "CompanyID      =" + u.CompanyID + "\r\n";
                            users += "DepartmentID   = " + u.DepartmentID + "\r\n";
                            users += "PostID         = " + u.PostID + "\r\n";
                            users += "serID          = " + u.UserID + "\r\n";
                            users += "UserName       = "******"\r\n";
                            users += "------------------------------------\r\n";
                        }
                        LogHelper.WriteLog(users + "检出有多个审核人,返回界面让用户选择一个人进行审核 FormID =" + submitData.FormID);
                        return dataResult;
                    }
                    //return dataResult;//测试检查流程用的,不能提交事务
                    LogHelper.WriteLog("模块名称:submitData.ModelCode=" + submitData.ModelCode + ";modelinfo.ModelName=" + modelinfo.ModelName);
                    //ts.Complete(); //提交事务                           
                    if (string.IsNullOrEmpty(strIsFlowEngine) || strIsFlowEngine.ToLower() == "true")
                    {
                        msg += "发送审批消息(调用引擎服务)" + DateTime.Now.ToString() + "\r\n";
                        #region 发送审批消息(调用引擎服务)
                        LogHelper.WriteLog("开始(调用引擎服务):SubmitEngineService");
                        SubmitEngineService(con, submitData, dataResult, modelinfo, CheckFlowResult, Flowbill, AppCompanyID, MessageUserID, MessageUserName, ref msg);
                        LogHelper.WriteLog("结束(调用引擎服务):SubmitEngineService");
                        #endregion
                        msg += "发送审批消息(调用引擎服务)完成" + DateTime.Now.ToString() + "\r\n";
                    }
                    dtEnd = DateTime.Now;
                    dataResult.SubmitFlag = submitData.SubmitFlag;
                    msg += "开始时间" + dtStart.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "\r\n";
                    msg += "结束时间" + dtEnd.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "\r\n";
                    msg += "完成时间" + DateDiff(dtEnd, dtStart);
                    ts.Complete();//提交事务
                    MsOracle.Close(con);//关闭数据库  
                    LogHelper.WriteLog("执行流程成功:FormID=" + submitData.FormID);
                    //LogHelper.WriteLog(msg);
                    return dataResult;
                }
                catch (Exception ex)
                {
                    ts.Dispose();
                    if (con.State == System.Data.ConnectionState.Open)
                    {
                        con.Close();
                        con.Dispose();
                    }
                    dataResult.RunTime += "---FlowEnd:" + DateTime.Now.ToString();
                    dataResult.FlowResult = FlowResult.FAIL;
                    // Flowbill              = null;
                    dataResult.Err = ex.Message;
                    // Tracer.Debug("FlowService: -" + submitData.FormID + "--submitDataXML:" + submitData.XML + "-" + ex.InnerException + ex.Message);
                    LogHelper.WriteLog("执行流程失败:FormID=" + submitData.FormID + " 异常信息:" + ex.Message);
                    return dataResult;
                }
                finally
                {
                    if (Flowbill.workflowRuntime != null && Flowbill.workflowRuntime.IsStarted)
                    {
                        Flowbill.workflowRuntime.Dispose();
                    }
                    if (con.State == System.Data.ConnectionState.Open)
                    {
                        con.Close();
                        con.Dispose();
                    }
                    dataResult = null;
                    // Tracer.Debug("-------Trace--FormID:" + submitData.FormID + "DateTime: Start:" + dtStart.ToString()  + "  EngineStart:" + dtEngineStart.ToString() + "  End:" + dtEnd.ToString() + "\n");

                }
                #endregion
            }

        }
Esempio n. 10
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;
            }
        }
Esempio n. 11
0
File: Service.cs Progetto: JuRogn/OA
        /// <summary>
        /// 通过机构ID和模块代码查询对应流程代码
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        //public List<FLOW_MODELFLOWRELATION_T> GetFlowByModel(FLOW_MODELFLOWRELATION_T entity)
        //{
        //    return FlowBLL.GetFlowByModel(entity);
        //}

        public string GetFlowDefine(SubmitData ApprovalData)
        {
            OracleConnection con = ADOHelper.GetOracleConnection();
            SMT.FlowWFService.NewFlow.Service s2 = new SMT.FlowWFService.NewFlow.Service();
            return s2.GetFlowDefine(con, ApprovalData);
            #region 旧代码
            //FlowBLL Flow = new FlowBLL();
            //return Flow.GetFlowDefine(ApprovalData);
            #endregion
           
        }
Esempio n. 12
0
File: Service.cs Progetto: JuRogn/OA
        public DataResult SubimtFlow(SubmitData submitData)
        {
            SMT.FlowWFService.NewFlow.Service s2 = new SMT.FlowWFService.NewFlow.Service();
            return s2.SubimtFlow(submitData);
            #region 旧代码
            //DateTime dtStart = DateTime.Now;
            //DateTime dtEngineStart = DateTime.Now;
            //DateTime dtEnd = DateTime.Now;
            //DateTime dtCheckData = DateTime.Now;
            ////using (TransactionScope ts = new TransactionScope())
            ////设置2分钟超时时间
            //using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(DateTime.Now.AddMinutes(2).Ticks)))
            //{
            //    //System.Threading.Thread.Sleep(60000);
            //    DataResult dataResult = new DataResult();
            //    FlowBLL Flowbill = new FlowBLL();
            //    string AppCompanyID = "";  //申请公司
            //    string MessageUserID = ""; //申请人ID
            //    string MessageUserName = ""; //申请人名
            //    dataResult.FlowResult = FlowResult.SUCCESS;
            //    try
            //    {
            //        #region 检查流程数据是否规范
            //        if (!FlowBLL.CheckFlowData(submitData, ref dataResult))
            //        {
            //            dataResult.FlowResult = FlowResult.FAIL;
            //            {
            //                ts.Complete();
            //                return dataResult;
            //            }
            //        }
            //        #endregion
            //        submitData.ApprovalResult = submitData.SubmitFlag == SubmitFlag.New ? ApprovalResult.Pass : submitData.ApprovalResult;
            //        submitData.FlowSelectType = submitData.FlowSelectType == null ? FlowSelectType.FixedFlow : submitData.FlowSelectType;
            //        #region
            //        #region 检查是否已提交流程
            //        CheckResult CheckFlowResult = Flowbill.CheckFlow2(submitData, dataResult);
            //        dtCheckData = DateTime.Now;
            //        dataResult = CheckFlowResult.APPDataResult;
            //        if (CheckFlowResult.Flag == 0)
            //        {
            //            ts.Complete();
            //            return dataResult;
            //        }
            //        #endregion
            //        dataResult.AppState = submitData.NextStateCode;
            //        //提交新流程
            //        if (submitData.SubmitFlag == SubmitFlag.New)
            //        {
            //            #region 新增
            //            AppCompanyID = submitData.ApprovalUser.CompanyID;
            //            if (submitData.FlowSelectType == FlowSelectType.FreeFlow)
            //                //自选流程
            //                dataResult = Flowbill.AddFreeFlow(submitData, dataResult);
            //            else
            //            {
            //                //固定流程
            //                dataResult = Flowbill.AddFlow2(submitData, dataResult);
            //            }
            //            #endregion

            //        }
            //        else if (submitData.SubmitFlag == SubmitFlag.Cancel)
            //        {
            //            #region 撤单
            //            if (!string.IsNullOrEmpty(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT))
            //            {
            //                submitData.XML = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT;
            //            }
            //            submitData.ApprovalContent = "";
            //            dataResult = Flowbill.CancelFlow(submitData, dataResult, CheckFlowResult.fd);
            //            dataResult.SubmitFlag = submitData.SubmitFlag;
            //            #endregion
            //        }

            //        //审批流程
            //        else
            //        {
            //            #region  审核
            //            if (!string.IsNullOrEmpty(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT))
            //            {
            //                submitData.XML = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT;
            //            }
            //            //引擎消息数据
            //            AppCompanyID = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID;
            //            MessageUserID = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATEUSERID;
            //            MessageUserName = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATEUSERNAME;
            //            submitData.ApprovalUser.CompanyID = CheckFlowResult.fd[0].EDITCOMPANYID;
            //            submitData.ApprovalUser.DepartmentID = CheckFlowResult.fd[0].EDITDEPARTMENTID;
            //            submitData.ApprovalUser.PostID = CheckFlowResult.fd[0].EDITPOSTID;
            //            submitData.FlowSelectType = (FlowSelectType)Convert.ToInt32(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.FLOWSELECTTYPE);
            //            if (submitData.FlowSelectType == FlowSelectType.FreeFlow)
            //                dataResult = Flowbill.ApprovalFreeFlow(submitData, dataResult, CheckFlowResult.fd);
            //            else
            //                dataResult = Flowbill.ApprovalFlow2(submitData, dataResult, CheckFlowResult.fd);
            //            #endregion
            //        }
            //        #endregion
            //        ModelInfo modelinfo = FlowBLL.GetSysCodeByModelCode(submitData.ModelCode);
            //        ts.Complete(); //提交事务
            //        bool bOK = true;
            //        if (string.IsNullOrEmpty(strIsFlowEngine) || strIsFlowEngine.ToLower() == "true")
            //        {
            //            dtEngineStart = DateTime.Now;
            //            #region 发送审批消息
            //            try
            //            {
            //                if (dataResult.FlowResult == FlowResult.SUCCESS || dataResult.FlowResult == FlowResult.END)
            //                {
            //                    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);
            //                            bOK = FlowEngine.SaveFlowTriggerData(FlowResultXml.ToString(), submitData.XML);
            //                            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);
            //                            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);
            //                            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);
            //                                    }
            //                                    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);
            //                                    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);
            //                                    }
            //                                    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);
            //                                    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);
            //                                if (!bOK)
            //                                {
            //                                    Tracer.Debug("FlowEngineService:FormID-" + submitData.FormID + "--submitDataXML:" + submitData.XML);
            //                                }
            //                                #endregion
            //                            }
            //                            #endregion
            //                            break;
            //                    }
            //                    #endregion
            //                }
            //            }
            //            catch (Exception ex)
            //            {
            //                Tracer.Debug("FlowEngineService: -" + "\n\nError:" + ex.InnerException + ex.Message);
            //            }
            //            #endregion
            //        }
            //        dtEnd = DateTime.Now;
            //        dataResult.SubmitFlag = submitData.SubmitFlag;
            //        return dataResult;
            //    }
            //    catch (Exception ex)
            //    {
            //        ts.Dispose();
            //        dataResult.RunTime += "---FlowEnd:" + DateTime.Now.ToString();
            //        dataResult.FlowResult = FlowResult.FAIL;
            //        Flowbill = null;
            //        dataResult.Err = ex.Message;
            //        Tracer.Debug("FlowService: -" + submitData.FormID + "--submitDataXML:" + submitData.XML + "-" + ex.InnerException + ex.Message);
            //        return dataResult;
            //    }
            //    finally
            //    {
            //        dataResult = null;
            //        Tracer.Debug("-------Trace--FormID:" + submitData.FormID + "DateTime: Start:" + dtStart.ToString() + "  EngineStart:" + dtEngineStart.ToString() + "  End:" + dtEnd.ToString() + "\n");


            //    }
            //}
            #endregion
        }
Esempio n. 13
0
File: Service.cs Progetto: JuRogn/OA
        public void ReplyConsultation(FLOW_CONSULTATION_T flowConsultation, SubmitData submitData)
        {
            OracleConnection con = ADOHelper.GetOracleConnection();
            SMT.FlowWFService.NewFlow.Service s2 = new SMT.FlowWFService.NewFlow.Service();
            s2.ReplyConsultation(con, flowConsultation, submitData);
            #region 旧代码
            //if (strIsFlowEngine.ToLower() == "true")
            //{
            //    try
            //    {


            //        FlowEngineService.EngineWcfGlobalFunctionClient FlowEngine = new FlowEngineService.EngineWcfGlobalFunctionClient();
            //        //Byte[] Bo = System.Text.UTF8Encoding.UTF8.GetBytes(submitData.XML);
            //        //XElement xemeBoObject = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(Bo)));
            //        //string strSystemCode = (from item in xemeBoObject.Descendants("Name") select item).FirstOrDefault().Value;


            //        ModelInfo modelinfo = FlowBLL.GetSysCodeByModelCode(submitData.ModelCode);
            //        FlowEngine.FlowConsultatiClose(modelinfo.SysCode, flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID, flowConsultation.REPLYUSERID);

            //        FlowBLL bll = new FlowBLL();
            //        bll.ReplyConsultation(flowConsultation);
            //    }
            //    catch (Exception ex)
            //    {
            //        Tracer.Debug("ReplyConsultation: -" + flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID + "-" + ex.InnerException + ex.Message);
            //        throw ex;
            //    }
            //}
            #endregion
        }
Esempio n. 14
0
        public DataResult SubimtFlow(SubmitData submitData)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("SubmitData.FlowSelectType =\"" + submitData.FlowSelectType + "\";");
            sb.AppendLine("SubmitData.FormID = \"" + submitData.FormID + "\";");
            sb.AppendLine("SubmitData.ModelCode = \"" + submitData.ModelCode + "\";");
            sb.AppendLine("SubmitData.ApprovalUser = \"" + submitData.ApprovalUser + "\";");
            sb.AppendLine("SubmitData.ApprovalUser.CompanyID = \"" + submitData.ApprovalUser.CompanyID + "\";");
            sb.AppendLine("SubmitData.ApprovalUser.DepartmentID = \"" + submitData.ApprovalUser.DepartmentID + "\";");
            sb.AppendLine("SubmitData.ApprovalUser.PostID = \"" + submitData.ApprovalUser.PostID + "\";");
            sb.AppendLine("SubmitData.ApprovalUser.UserID = \"" + submitData.ApprovalUser.UserID + "\";");
            sb.AppendLine("SubmitData.ApprovalUser.UserName = \"" + submitData.ApprovalUser.UserName + "\";");
            sb.AppendLine("SubmitData.NextStateCode = \"\";");
            sb.AppendLine("SubmitData.NextApprovalUser = \"" + submitData.NextApprovalUser + "\";");
            sb.AppendLine("SubmitData.NextApprovalUser.CompanyID = \"\";");
            sb.AppendLine("SubmitData.NextApprovalUser.DepartmentID = \"\";");
            sb.AppendLine("SubmitData.NextApprovalUser.PostID = \"\";");
            sb.AppendLine("SubmitData.NextApprovalUser.UserID = \"\";");
            sb.AppendLine("SubmitData.NextApprovalUser.UserName = \"\";");
            sb.AppendLine("SubmitData.SubmitFlag = \"" + submitData.SubmitFlag + "\";");
            //sb.AppendLine("SubmitData.XML = \"" + submitData.XML + "\";");
            sb.AppendLine("SubmitData.FlowType = \"" + submitData.FlowType + "\";");
            sb.AppendLine("SubmitData.ApprovalResult = \"" + submitData.ApprovalResult + "\";");
            sb.AppendLine("SubmitData.ApprovalContent = \"" + submitData .ApprovalContent+ "\";");


            LogHelper.WriteLog("***********************************************开始" + DateTime.Now.ToString() + "***********************************************\r\n");
            LogHelper.WriteLog("提交审核的信息:\r\n" + sb.ToString() + "\r\n");
            string msg = "";
           
           // MsOracle.BeginTransaction(con);
           
            DateTime dtStart       = DateTime.Now;
            DateTime dtEngineStart = DateTime.Now;
            DateTime dtEnd         = DateTime.Now;
            DateTime dtCheckData   = DateTime.Now;
            //using (TransactionScope ts = new TransactionScope())
            //设置2分钟超时时间
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(DateTime.Now.AddMinutes(2).Ticks)))
            {
                OracleConnection con = ADOHelper.GetOracleConnection();
                #region 事务处理
             
                //System.Threading.Thread.Sleep(60000);
                DataResult dataResult  = new DataResult();
                FlowBLL2 Flowbill      = new FlowBLL2();                
                string AppCompanyID    = "";  //申请公司
                string MessageUserID   = ""; //申请人ID
                string MessageUserName = ""; //申请人名
                dataResult.FlowResult = FlowResult.SUCCESS;
                try
                {
                    #region 检查流程数据是否规范
                    if (!FlowBLL2.CheckFlowData(submitData, ref dataResult))
                    {
                        dataResult.FlowResult = FlowResult.FAIL;
                        {
                          //ts.Complete();
                            return dataResult;
                        }
                    }
                   
                    #endregion 
                    submitData.ApprovalResult = submitData.SubmitFlag == SubmitFlag.New ? ApprovalResult.Pass : submitData.ApprovalResult;
                    submitData.FlowSelectType = submitData.FlowSelectType == null ? FlowSelectType.FixedFlow : submitData.FlowSelectType;                    
                    #region 
                    #region 检查是否已提交流程(对数据库操作)
                    msg += "检查是否已提交流程"+DateTime.Now.ToString()+"\r\n";
                    LogHelper.WriteLog("检查是否已提交流程FormID = " + submitData.FormID);

                    OracleConnection ocon = ADOHelper.GetOracleConnection();
                    CheckResult CheckFlowResult = Flowbill.CheckFlow2(ocon, submitData, dataResult);//对数据库操作                    
                    msg += "检查是否已提交流程完成" + DateTime.Now.ToString() + "\r\n";
                    LogHelper.WriteLog("检查是否已提交流程完成FormID =" + submitData.FormID);
                    dtCheckData = DateTime.Now;
                    dataResult = CheckFlowResult.APPDataResult;
                    if (CheckFlowResult.Flag == 0)//已审批:1,未审批:0
                    {
                        //ts.Complete();
                        //return dataResult;
                    }
                    if (ocon.State == ConnectionState.Open)
                    {
                        ocon.Close();
                    }
                    #endregion 
                    dataResult.AppState = submitData.NextStateCode;
                  
                    //提交新流程
                    if (submitData.SubmitFlag == SubmitFlag.New)
                    {
                        LogHelper.WriteLog("新增(开始) FormID =" + submitData.FormID);
                        #region 新增
                        AppCompanyID = submitData.ApprovalUser.CompanyID;
                        if (submitData.FlowSelectType == FlowSelectType.FreeFlow)
                        {
                            //自选流程
                            LogHelper.WriteLog("自选流程.Flowbill.AddFlow2 FormID =" + submitData.FormID);
                            dataResult = Flowbill.AddFreeFlow(con, submitData, dataResult);//对数据库操作
                        }
                        else
                        {
                            //固定流程
                            msg += "固定流程" + DateTime.Now.ToString() + "\r\n";
                            LogHelper.WriteLog("固定流程.Flowbill.AddFlow2 FormID =" + submitData.FormID);
                            dataResult = Flowbill.AddFlow2(con, submitData, dataResult, ref msg);//对数据库操作
                            msg += "固定流程完成" + DateTime.Now.ToString() + "\r\n";
                        }
                        #endregion 
                        LogHelper.WriteLog("新增(结束) FormID =" + submitData.FormID);

                    }
                    else if (submitData.SubmitFlag == SubmitFlag.Cancel)
                    {
                        #region 撤单
                        LogHelper.WriteLog("撤单(开始) FormID =" + submitData.FormID);
                        if (!string.IsNullOrEmpty(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT))
                        {
                            submitData.XML = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT;
                        }
                        submitData.ApprovalContent = "";
                        dataResult                 = Flowbill.CancelFlow(submitData, dataResult, CheckFlowResult.fd);
                        dataResult.SubmitFlag      = submitData.SubmitFlag;
                        LogHelper.WriteLog("撤单(结束) FormID =" + submitData.FormID);
                        #endregion 
                    }
                    
                    //审批流程
                    else
                    {
                        msg += "审核" + DateTime.Now.ToString() + "\r\n";
                        LogHelper.WriteLog("审核(开始) FormID =" + submitData.FormID);
                        #region  审核
                        if (!string.IsNullOrEmpty(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT))
                        {
                            submitData.XML = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.BUSINESSOBJECT;
                        }                        
                        //引擎消息数据
                        AppCompanyID                         = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATECOMPANYID;
                        MessageUserID                        = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATEUSERID;
                        MessageUserName                      = CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.CREATEUSERNAME;                        
                        submitData.ApprovalUser.CompanyID    = CheckFlowResult.fd[0].EDITCOMPANYID;
                        submitData.ApprovalUser.DepartmentID = CheckFlowResult.fd[0].EDITDEPARTMENTID;
                        submitData.ApprovalUser.PostID       = CheckFlowResult.fd[0].EDITPOSTID;
                        submitData.FlowSelectType            = (FlowSelectType)Convert.ToInt32(CheckFlowResult.fd[0].FLOW_FLOWRECORDMASTER_T.FLOWSELECTTYPE);
                        if (submitData.FlowSelectType == FlowSelectType.FreeFlow)
                            dataResult = Flowbill.ApprovalFreeFlow(con, submitData, dataResult, CheckFlowResult.fd);//对数据库操作、对服务操作
                        else
                            dataResult = Flowbill.ApprovalFlow2(con, submitData, dataResult, CheckFlowResult.fd, ref msg);
                        #endregion 
                        LogHelper.WriteLog("审核(结束) FormID =" + submitData.FormID);
                        msg += "审核完成" + DateTime.Now.ToString() + "\r\n";
                    }
                    
                    #endregion                  
                    ModelInfo modelinfo = FlowBLL2.GetSysCodeByModelCode(con, submitData.ModelCode);
                    #region 记录审核人日志信息
                    string loginfo = "===================================FormID=" + submitData.FormID + "============================================\r\n";
                   
                    if (dataResult.IsCountersign.ToString().ToLower() == "true")
                    {
                        loginfo += "是否会签=" + dataResult.IsCountersign.ToString() + "\r\n";
                        loginfo += "是否会签完成" + dataResult.IsCountersignComplete.ToString() + "\r\n";
                    }
                    loginfo += "模块关联流程ID=" + dataResult.ModelFlowRelationID + "\r\n";
                    loginfo += "子模块代码=" + dataResult.SubModelCode + "\r\n";
                    if (dataResult.AgentUserInfo != null)
                    {
                       
                        loginfo = "\r\n 代理审核人 \r\n";
                        loginfo += "代理公司ID=" + dataResult.AgentUserInfo.CompanyID + "\r\n";
                        loginfo += "代理部门ID=" + dataResult.AgentUserInfo.DepartmentID + "\r\n";
                        loginfo += "代理岗位ID" + dataResult.AgentUserInfo.PostID + "\r\n";
                        loginfo += "代理用户ID=" + dataResult.AgentUserInfo.UserID + "\r\n";
                        loginfo += "代理用户名称=" + dataResult.AgentUserInfo.UserName + "\r\n";
                    }                    
                    if (dataResult.UserInfo.Count > 0)
                    {
                        if (dataResult.FlowResult == FlowResult.MULTIUSER)
                        {//如果检出有多个审核人时,返回界面让用户选择一个人进行审核
                            loginfo = "\r\n 检出有多个审核人 \r\n";
                        }
                        loginfo += "dataResult.UserInfo 审核人员信息\r\n";
                        foreach (var u in dataResult.UserInfo)
                        {
                            loginfo += "公司ID=" + u.CompanyID + "\r\n";
                            loginfo += "部门ID= " + u.DepartmentID + "\r\n";
                            loginfo += "岗位ID= " + u.PostID + "\r\n";
                            loginfo += "用户ID= " + u.UserID + "\r\n";
                            loginfo += "用户名= " + u.UserName + "\r\n";
                            loginfo += "------------------------------------\r\n";
                        }
                    }     
                    loginfo += "模块代码 ModelCode=" + submitData.ModelCode + "\r\n";
                    loginfo += "模块名称 ModelName=" + modelinfo.ModelName + "\r\n";
                    loginfo += "下一审批人 公司ID=" + submitData.NextApprovalUser.CompanyID + "\r\n";
                    loginfo += "下一审批人 部门ID=" + submitData.NextApprovalUser.DepartmentID + "\r\n";
                    loginfo += "下一审批人 岗位ID=" + submitData.NextApprovalUser.PostID + "\r\n";
                    loginfo += "下一审批人 用户ID=" + submitData.NextApprovalUser.UserID + "\r\n";
                    loginfo += "下一审批人 用户名=" + submitData.NextApprovalUser.UserName + "\r\n";
                    loginfo += "下一审批状态 NextStateCode=" + submitData.NextStateCode + "\r\n";
                    loginfo += "使用流程类型 submitData.FlowSelectType=" + submitData.FlowSelectType + "\r\n";
                    loginfo += "业务数据 submitData.XML(AppXML)=" + submitData.XML + "\r\n";
                    loginfo += "================================================================================\r\n";           
                    LogHelper.WriteLog(loginfo);

                    #endregion
                    //return dataResult;//测试检查流程用的,不能提交事务
                    //ts.Complete(); //提交事务                           
                    if (string.IsNullOrEmpty(strIsFlowEngine) || strIsFlowEngine.ToLower() == "true")
                    {
                        msg += "发送审批消息(调用引擎服务)" + DateTime.Now.ToString() + "\r\n";
                        #region 发送审批消息(调用引擎服务)
                        LogHelper.WriteLog("开始(调用引擎服务):SubmitEngineService FormID =" + submitData.FormID);
                        SubmitEngineService(con, submitData,  dataResult,  modelinfo,  CheckFlowResult,  Flowbill,  AppCompanyID,  MessageUserID,  MessageUserName,ref msg);
                        LogHelper.WriteLog("结束(调用引擎服务):SubmitEngineService FormID =" + submitData.FormID);
                        #endregion     
                        msg += "发送审批消息(调用引擎服务)完成" + DateTime.Now.ToString() + "\r\n";
                    }
                    dtEnd = DateTime.Now;
                    dataResult.SubmitFlag = submitData.SubmitFlag;
                    msg += "开始时间" + dtStart.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "\r\n";
                    msg += "结束时间" + dtEnd.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "\r\n";
                    msg += "完成时间" + DateDiff(dtEnd, dtStart);
                    ts.Complete();//提交事务
                    MsOracle.Close(con);//关闭数据库  
                    LogHelper.WriteLog("执行流程成功:FormID=" + submitData.FormID);
                    //LogHelper.WriteLog(msg);
                    return dataResult;
                }
                catch (Exception ex)
                {                    
                    ts.Dispose();
                    if (con.State == System.Data.ConnectionState.Open)
                    {
                        con.Close();
                        con.Dispose();
                    }
                    dataResult.RunTime += "---FlowEnd:" + DateTime.Now.ToString();
                    dataResult.FlowResult = FlowResult.FAIL;                  
                    dataResult.Err        = ex.Message;
                    //Tracer.Debug("FlowService: -" + submitData.FormID + "--submitDataXML:" + submitData.XML + "-" + ex.InnerException + ex.Message);
                    LogHelper.WriteLog("执行流程失败:FormID=" + submitData.FormID+" 异常信息:"+ ex.ToString());
                    return dataResult;
                }
                finally
                {
                    if (Flowbill.workflowRuntime != null && Flowbill.workflowRuntime.IsStarted)
                    {
                        Flowbill.workflowRuntime.Dispose();
                    }
                   // LogHelper.WriteLog(msg);
                    if (con.State == System.Data.ConnectionState.Open)
                    {
                        con.Close();
                        con.Dispose();
                    }     
                    dataResult = null;                   
                    //Tracer.Debug("-------Trace--FormID:" + submitData.FormID + "DateTime: Start:" + dtStart.ToString()  + "  EngineStart:" + dtEngineStart.ToString() + "  End:" + dtEnd.ToString() + "\n");
                    
                }
                #endregion
            }
               
        }
Esempio n. 15
0
        public void ReplyConsultation(OracleConnection con, FLOW_CONSULTATION_T flowConsultation, SubmitData submitData)
        {
            if (strIsFlowEngine.ToLower() == "true")
            {
                try
                {


                    FlowEngineService.EngineWcfGlobalFunctionClient FlowEngine = new FlowEngineService.EngineWcfGlobalFunctionClient();
                    //Byte[] Bo = System.Text.UTF8Encoding.UTF8.GetBytes(submitData.XML);
                    //XElement xemeBoObject = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(Bo)));
                    //string strSystemCode = (from item in xemeBoObject.Descendants("Name") select item).FirstOrDefault().Value;


                    ModelInfo modelinfo = FlowBLL2.GetSysCodeByModelCode(con, submitData.ModelCode);
                    FlowEngine.FlowConsultatiClose(modelinfo.SysCode, flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID, flowConsultation.REPLYUSERID);

                    FlowBLL2 bll = new FlowBLL2();
                    bll.ReplyConsultation(con, flowConsultation);
                }
                catch (Exception ex)
                {
                    Tracer.Debug("ReplyConsultation: -" + flowConsultation.FLOW_FLOWRECORDDETAIL_T.FLOW_FLOWRECORDMASTER_T.FORMID + "-" + ex.InnerException + ex.Message);
                    throw ex;
                }
            }

        }
Esempio n. 16
0
        /// <summary>
        /// 新增流程(对数据库操作)
        /// </summary>
        /// <param name="ApprovalData"></param>
        /// <param name="APPDataResult"></param>
        /// <returns></returns>    
        public DataResult AddFlow2(OracleConnection con, SubmitData submitData, DataResult dataResult, ref string msg)
        {
            // WorkflowRuntime workflowRuntime = null;
            WorkflowInstance instance = null;


            try
            {
                msg += "获取定义的流程" + DateTime.Now.ToString() + "\r\n";
                #region 获取定义的流程
                LogHelper.WriteLog("获取定义的流程.GetFlowByModelName:submitData.ApprovalUser.DepartmentID=" + submitData.ApprovalUser.DepartmentID + ";OrgType='" + ((int)submitData.FlowType).ToString() + "'");
                List<FLOW_MODELFLOWRELATION_T> MODELFLOWRELATION = GetFlowByModelName(con, submitData.ApprovalUser.CompanyID, submitData.ApprovalUser.DepartmentID, submitData.ModelCode, ((int)submitData.FlowType).ToString());//对数据库操作
                if (MODELFLOWRELATION == null || MODELFLOWRELATION.Count == 0)
                {
                    dataResult.FlowResult = FlowResult.FAIL;
                    dataResult.Err = "没有找到可使用的流程";
                    return dataResult;
                }
                msg += "获取定义的流程完成" + DateTime.Now.ToString() + "\r\n";
                #endregion
                FLOW_MODELFLOWRELATION_T flowRelation = MODELFLOWRELATION[0];
                FLOW_FLOWDEFINE_T flowDefine = flowRelation.FLOW_FLOWDEFINE_T;
                if (flowDefine.RULES != null && flowDefine.RULES.Trim() == "")
                {
                    flowDefine.RULES = null;
                }
                //if (string.IsNullOrEmpty(flowDefine.RULES.Trim()))
                //{
                //    flowDefine.RULES = null;
                //}
                msg += " SMTWorkFlowManage.CreateWorkFlowRuntime(true)" + DateTime.Now.ToString() + "\r\n";
                workflowRuntime = SMTWorkFlowManage.CreateWorkFlowRuntime(true);
                instance = SMTWorkFlowManage.CreateWorkflowInstance(workflowRuntime, flowDefine.XOML, flowDefine.RULES);
                LogHelper.WriteLog("AddFlow2创建工作流实例ID=" + instance.InstanceId);
                workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
                {
                    instance = null;

                };
                msg += " SMTWorkFlowManage.CreateWorkFlowRuntime(true)完成" + DateTime.Now.ToString() + "\r\n";
                #region master赋值
                FLOW_FLOWRECORDMASTER_T master = new FLOW_FLOWRECORDMASTER_T();
                master.INSTANCEID = instance.InstanceId.ToString();
                master.BUSINESSOBJECT = submitData.XML;
                master.FORMID = submitData.FormID;
                master.MODELCODE = submitData.ModelCode;
                master.ACTIVEROLE = Utility.GetActiveRlue(flowDefine.LAYOUT);
                master.FLOWTYPE = ((int)submitData.FlowType).ToString();
                master.FLOWSELECTTYPE = ((int)submitData.FlowSelectType).ToString();
                master.FLOWCODE = flowDefine.FLOWCODE;
                #endregion

                #region 获取下一状态数据
                msg += " 获取下一状态数据" + DateTime.Now.ToString() + "\r\n";
                DateTime star = DateTime.Now;
                GetUserByFlow2(submitData.ApprovalUser.CompanyID, flowDefine.XOML, flowDefine.RULES, master.ACTIVEROLE, submitData.XML, submitData.ApprovalUser.UserID, submitData.ApprovalUser.PostID, submitData.FlowType, ref dataResult, ref msg);
                DateTime end = DateTime.Now;
                msg += " 获取下一状态数据完成" + DateTime.Now.ToString() + "\r\n";
                string str = Service2.DateDiff(end, star);
                if (dataResult.FlowResult == FlowResult.FAIL)
                {
                    return dataResult;
                }
                submitData.NextStateCode = dataResult.AppState;
                if (dataResult.IsCountersign)
                {
                    #region
                    if (dataResult.FlowResult == FlowResult.Countersign)
                    {
                        if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                        {
                            return dataResult;
                        }
                    }
                    else
                    {
                        if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                        {
                            submitData.DictCounterUser = dataResult.DictCounterUser;
                        }
                    }
                    #endregion
                }
                else
                {
                    #region
                    if (dataResult.FlowResult == FlowResult.MULTIUSER)
                    {
                        if (submitData.NextApprovalUser == null || (Utility.GetString(submitData.NextApprovalUser.UserID) == "" || Utility.GetString(submitData.NextApprovalUser.UserName) == ""))
                        {
                            return dataResult;
                        }
                    }
                    else
                    {
                        if (submitData.DictCounterUser == null || submitData.DictCounterUser.Keys.Count == 0)
                        {
                            submitData.NextApprovalUser = dataResult.UserInfo[0];
                        }
                    }
                    #endregion
                }

                #endregion

                #region 实体赋值
                FLOW_FLOWRECORDDETAIL_T entity = new FLOW_FLOWRECORDDETAIL_T();
                entity.FLOW_FLOWRECORDMASTER_T = master;
                entity.CREATECOMPANYID = submitData.ApprovalUser.CompanyID;
                entity.CREATEDEPARTMENTID = submitData.ApprovalUser.DepartmentID;
                entity.CREATEPOSTID = submitData.ApprovalUser.PostID;
                entity.CREATEUSERID = submitData.ApprovalUser.UserID;
                entity.CREATEUSERNAME = submitData.ApprovalUser.UserName;
                #endregion
                msg += " 处理kpi时间" + DateTime.Now.ToString() + "\r\n";
                #region 处理kpi时间
                string KPITime = "";
                #region 加入缓存
                string pscResult = CacheProvider.GetCache<string>(flowRelation.MODELFLOWRELATIONID);
                if (string.IsNullOrEmpty(pscResult))
                {
                    PerformanceServiceWS.PerformanceServiceClient psc = new PerformanceServiceWS.PerformanceServiceClient();
                    pscResult = psc.GetKPIPointsByBusinessCode(flowRelation.MODELFLOWRELATIONID);//调用服务
                    CacheProvider.Add<string>(flowRelation.MODELFLOWRELATIONID, pscResult);
                    psc.Close();
                }
                #endregion
                //PerformanceServiceWS.PerformanceServiceClient psc = new PerformanceServiceWS.PerformanceServiceClient();
                //string pscResult = psc.GetKPIPointsByBusinessCode(flowRelation.MODELFLOWRELATIONID);//调用服务
                //psc.Close();
                if (!string.IsNullOrEmpty(pscResult))
                {
                    XElement xe = XElement.Parse(pscResult);
                    Func<XElement, bool> f = (x) =>
                    {
                        XAttribute xid = x.Attribute("id");
                        XAttribute xvalue = x.Attribute("value");
                        if (xid == null || xvalue == null)
                            return false;
                        else
                        {
                            if (xid.Value == dataResult.AppState)
                                return true;
                            else return false;
                        }
                    };
                    XElement FlowNode = xe.Elements("FlowNode").FirstOrDefault(f);
                    if (FlowNode != null)
                    {
                        KPITime = FlowNode.Attribute("value").Value;
                    }
                }

                dataResult.KPITime = KPITime;
                master.KPITIMEXML = pscResult;
                #endregion
                msg += " 处理kpi时间完成" + DateTime.Now.ToString() + "\r\n";
                FlowDataType.FlowData FlowData = new FlowDataType.FlowData();
                FlowData.xml = submitData.XML;

                if (!dataResult.IsCountersign)
                {
                    #region  非会签
                    UserInfo AppUser = new UserInfo(); //下一审核人
                    AppUser = submitData.NextApprovalUser;
                    dataResult.UserInfo.Clear();
                    dataResult.UserInfo.Add(AppUser);
                    UserInfo AgentAppUser = GetAgentUserInfo(submitData.ModelCode, AppUser.UserID);//查询是否启用了代理人                    
                    dataResult = DoFlowRecord2(con, workflowRuntime, instance, entity, submitData.NextStateCode, AppUser, AgentAppUser, submitData.SubmitFlag, submitData.FlowType); //处理流程数据
                    dataResult.IsCountersign = false;
                    dataResult.AgentUserInfo = AgentAppUser;
                    #endregion
                }
                else
                {
                    msg += " 会签" + DateTime.Now.ToString() + "\r\n";
                    #region  会签
                    //Tracer.Debug("-----DoFlowRecord_Add:" + DateTime.Now.ToString()+"\n");
                    dataResult.DictCounterUser = submitData.DictCounterUser;
                    Dictionary<UserInfo, UserInfo> dictAgentUserInfo = GetAgentUserInfo2(submitData.ModelCode, submitData.DictCounterUser);
                    dataResult = DoFlowRecord_Add(con, workflowRuntime, instance, entity, submitData.NextStateCode, submitData.DictCounterUser, dictAgentUserInfo, submitData.SubmitFlag, submitData.FlowType); //处理流程数据
                    //Tracer.Debug("-----DoFlowRecord_AddEnd:" + DateTime.Now.ToString()+"\n");
                    dataResult.IsCountersign = true;
                    dataResult.DictAgentUserInfo = dictAgentUserInfo;
                    #endregion
                    msg += "会签完成" + DateTime.Now.ToString() + "\r\n";
                }
                msg += "激发流程引擎执行到一下流程" + DateTime.Now.ToString() + "\r\n";
                #region 激发流程引擎执行到一下流程
                string ss = "";
                int n = 0;
                if (dataResult.AppState == null || dataResult.AppState == "")
                {
                    msg += " workflowRuntime.GetService<FlowEvent>()" + DateTime.Now.ToString() + "\r\n";
                    workflowRuntime.GetService<FlowEvent>().OnDoFlow(instance.InstanceId, FlowData); //激发流程引擎执行到一下流程
                    msg += " workflowRuntime.GetService<FlowEvent>()完成" + DateTime.Now.ToString() + "\r\n";
                }
                else
                {
                    StateMachineWorkflowInstance workflowinstance = new StateMachineWorkflowInstance(workflowRuntime, instance.InstanceId);

                    workflowinstance.SetState(dataResult.AppState); //流程跳转到指定节点

                    while (true)
                    {

                        ss += (n++).ToString() + "|" + workflowinstance.CurrentStateName + "\r\n";
                        string stateName = workflowinstance.CurrentStateName;
                        if (stateName != null && stateName.ToUpper().IndexOf("STATE") >= 0)
                        {
                            break;
                        }

                    }
                }

                #endregion
                msg += "激发流程引擎执行到一下流程完成" + DateTime.Now.ToString() + "\r\n";
                msg += "System.Threading.Thread.Sleep(1000)" + DateTime.Now.ToString() + "\r\n";
                //System.Threading.Thread.Sleep(1000);//当前用到
                dataResult.ModelFlowRelationID = flowRelation.MODELFLOWRELATIONID; //返回关联ID
                dataResult.KPITime = KPITime;
                //dataResult.CanSendMessage = true;
                if (submitData.FlowType == FlowType.Task)
                {
                    dataResult.SubModelCode = Utility.GetSubModelCode(master.ACTIVEROLE, dataResult.AppState); //返回下一子模块代码
                }
                msg += "System.Threading.Thread.Sleep(1000)完成" + DateTime.Now.ToString() + "\r\n";
                return dataResult;
            }

            catch (Exception e)
            {

                throw new Exception(e.Message);
            }
            finally
            {

                instance = null;
                SMTWorkFlowManage.ColseWorkFlowRuntime(workflowRuntime);
            }


        }
Esempio n. 17
0
        /// <summary>
        /// 通过机构ID和模块代码查询对应流程代码
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        //public List<FLOW_MODELFLOWRELATION_T> GetFlowByModel(FLOW_MODELFLOWRELATION_T entity)
        //{
        //    return FlowBLL2.GetFlowByModel(entity);
        //}

        public string GetFlowDefine(OracleConnection con, SubmitData ApprovalData)
        {

            FlowBLL2 Flow = new FlowBLL2();
            return Flow.GetFlowDefine(con, ApprovalData);
        }
Esempio n. 18
0
        public DataResult CancelFlow(SubmitData submitData, DataResult dataResult, List<FLOW_FLOWRECORDDETAIL_T> fd)
        {
            //WorkflowRuntime workflowRuntime = null;
            WorkflowInstance instance = null;

            FLOW_FLOWRECORDDETAIL_T entity = new FLOW_FLOWRECORDDETAIL_T();
            #region
            entity.FLOWRECORDDETAILID = Guid.NewGuid().ToString();
            entity.CREATECOMPANYID = submitData.ApprovalUser.CompanyID;
            entity.CREATEDEPARTMENTID = submitData.ApprovalUser.DepartmentID;
            entity.CREATEPOSTID = submitData.ApprovalUser.PostID;
            entity.CREATEUSERID = submitData.ApprovalUser.UserID;
            entity.CREATEUSERNAME = submitData.ApprovalUser.UserName;
            entity.EDITDATE = DateTime.Now;
            entity.CONTENT = submitData.ApprovalContent;
            entity.CHECKSTATE = "9";
            entity.STATECODE = "Cancel";
            entity.FLAG = "1";
            entity.PARENTSTATEID = entity.FLOWRECORDDETAILID;

            entity.CREATEDATE = DateTime.Now;
            entity.EDITDATE = DateTime.Now;
            entity.EDITUSERID = entity.CREATEUSERID;
            entity.EDITUSERNAME = entity.CREATEUSERNAME;
            entity.EDITCOMPANYID = entity.CREATECOMPANYID;
            entity.EDITDEPARTMENTID = entity.CREATEDEPARTMENTID;
            entity.EDITPOSTID = entity.CREATEPOSTID;

            entity.FLOW_FLOWRECORDMASTER_T = fd[0].FLOW_FLOWRECORDMASTER_T;
            entity.FLOW_FLOWRECORDMASTER_T.FLOW_FLOWRECORDDETAIL_T.Add(entity);
            entity.FLOW_FLOWRECORDMASTER_T.CHECKSTATE = "9"; //设为撤销
            entity.FLOW_FLOWRECORDMASTER_T.EDITUSERID = submitData.ApprovalUser.UserID;
            entity.FLOW_FLOWRECORDMASTER_T.EDITUSERNAME = submitData.ApprovalUser.UserName;
            entity.FLOW_FLOWRECORDMASTER_T.EDITDATE = DateTime.Now;
            #endregion

            workflowRuntime = SMTWorkFlowManage.CreateWorkFlowRuntime(true);
            LogHelper.WriteLog("CancelFlow从持久化库在恢复创建工作流实例ID=" + entity.FLOW_FLOWRECORDMASTER_T.INSTANCEID);
            instance = SMTWorkFlowManage.GetWorkflowInstance(workflowRuntime, entity.FLOW_FLOWRECORDMASTER_T.INSTANCEID);
            instance.Terminate("0");
            FLOW_FLOWRECORDDETAIL_TDAL Dal = new FLOW_FLOWRECORDDETAIL_TDAL();
            entity.FLAG = "1";
            //Dal.AddFlowRecord(entity);
            FLOW_FLOWRECORDDETAIL_TDAL.Add(entity);
            FLOW_FLOWRECORDMASTER_TDAL.Update(entity.FLOW_FLOWRECORDMASTER_T);
            fd.Where(detail => detail.FLAG == "0").ToList().ForEach(item =>
                {
                    //Dal.Delete(item);
                    //Dal.DeleteFlowRecord(item);
                    FLOW_FLOWRECORDDETAIL_TDAL.Delete(item);
                });
            dataResult.CheckState = "9";//
            dataResult.FlowResult = FlowResult.SUCCESS;
            return dataResult;
        }
Esempio n. 19
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
        }
Esempio n. 20
0
 public DataResult SubimtFlow(SubmitData submitData)
 {
     SMT.FlowWFService.NewFlow.FlowService FlowSv = new SMT.FlowWFService.NewFlow.FlowService();
     return FlowSv.SubimtFlow(submitData);
 }