示例#1
0
文件: FlowBLL2.cs 项目: JuRogn/OA
        /// <summary>
        /// 通过状态代码查询下一处理人(对服务操作)
        /// </summary>
        /// <param name="StateCode">状态代码</param>
        /// <returns></returns>
        private List<UserInfo> GetUserByStateCode(string StateCode, string UserID, string PostID, ref bool isHigher)
        {
            PermissionServiceClient WcfPermissionService = new PermissionServiceClient();
            PersonnelServiceClient WcfPersonnel = new PersonnelServiceClient();
            try
            {

                string CurrentStateName = StateCode == "EndFlow" ? "End" : StateCode; //取得当前状态
                List<UserInfo> listUser = new List<UserInfo>();



                if (CurrentStateName != "End")
                {
                    //if (CurrentStateName.Substring(0, 5) == "State")
                    //{
                    //    CurrentStateName = CurrentStateName.Substring(5);
                    //}

                    string WFCurrentStateName = "";
                    int isDirect = 0;
                    foreach (Higher c in Enum.GetValues(typeof(Higher)))
                    {
                        if (CurrentStateName.ToUpper() == c.ToString().ToUpper())
                        {
                            isDirect = (int)c;//== 1 ? true : false;

                            WFCurrentStateName = CurrentStateName;
                            isHigher = true;
                        }
                    }


                    if (WFCurrentStateName != "")
                    {
                        //PermissionService

                        V_EMPLOYEEVIEW[] User = WcfPersonnel.GetEmployeeLeaders(PostID, isDirect);
                        string strtemp = "查找处理人:WcfPersonnel.GetEmployeeLeaders(岗位ID=" + PostID + ", isDirect=" + isDirect + ")";
                        if (User != null && User.Length > 0)
                        {
                            for (int i = 0; i < User.Length; i++)
                            {
                                UserInfo tmp = new UserInfo();
                                tmp.UserID = User[i].EMPLOYEEID;
                                tmp.UserName = User[i].EMPLOYEECNAME;
                                tmp.CompanyID = User[i].OWNERCOMPANYID;
                                tmp.DepartmentID = User[i].OWNERDEPARTMENTID;
                                tmp.PostID = User[i].OWNERPOSTID;
                                listUser.Add(tmp);
                                strtemp += "UserID=" + User[i].EMPLOYEEID + "\r\n";
                                strtemp += "UserName ="******"\r\n";
                                strtemp += "CompanyID = " + User[i].OWNERCOMPANYID + "\r\n";
                                strtemp += "DepartmentID =" + User[i].OWNERDEPARTMENTID + "\r\n";
                                strtemp += "PostID = " + User[i].OWNERPOSTID + "\r\n";
                            }
                        }
                        LogHelper.WriteLog(strtemp);
                    }
                    else
                    {
                        WFCurrentStateName = new Guid(CurrentStateName).ToString("D");

                        foreach (var op in WcfPermissionService.Endpoint.Contract.Operations)
                        {
                            var dataContractBehavior = op.Behaviors[typeof(DataContractSerializerOperationBehavior)]
                                as DataContractSerializerOperationBehavior;
                            if (dataContractBehavior != null)
                            {
                                dataContractBehavior.MaxItemsInObjectGraph = Int32.MaxValue; //int.MaxValue;
                            }
                        }
                        try
                        {
                            T_SYS_USER[] User = WcfPermissionService.GetSysUserByRole(WFCurrentStateName); //检索本状态(角色)对应用户
                            string strRole = "检索本状态(角色)对应用户:WcfPermissionService.GetSysUserByRole(角色ID=" + WFCurrentStateName + ")\r\n";

                            if (User != null && User.Length > 0)
                            {
                                for (int i = 0; i < User.Length; i++)
                                {
                                    UserInfo tmp = new UserInfo();
                                    tmp.UserID = User[i].EMPLOYEEID;
                                    tmp.UserName = User[i].EMPLOYEENAME;
                                    tmp.CompanyID = User[i].OWNERCOMPANYID;
                                    tmp.DepartmentID = User[i].OWNERDEPARTMENTID;
                                    tmp.PostID = User[i].OWNERPOSTID;
                                    listUser.Add(tmp);
                                    strRole += "UserID=" + User[i].EMPLOYEEID + "\r\n";
                                    strRole += "UserName ="******"\r\n";
                                    strRole += "EMPLOYEENAME =" + User[i].EMPLOYEENAME + "\r\n";
                                    strRole += "CompanyID = " + User[i].OWNERCOMPANYID + "\r\n";
                                    strRole += "DepartmentID =" + User[i].OWNERDEPARTMENTID + "\r\n";
                                    strRole += "PostID = " + User[i].OWNERPOSTID + "\r\n";
                                }
                            }
                            #region 新接口
                            //PermissionService.FlowUserInfo[] User = WcfPermissionService.GetFlowUserInfoByRoleID(WFCurrentStateName);//新的接口
                            //string strRole = "检索本状态(角色)对应用户:WcfPermissionService.GetSysUserByRole(角色ID=" + WFCurrentStateName + ")\r\n";

                            //if (User != null && User.Length > 0)
                            //{
                            //    for (int i = 0; i < User.Length; i++)
                            //    {
                            //        #region
                            //        UserInfo tmp = new UserInfo();
                            //        strRole += "公司ID   = " + User[i].CompayID + "\r\n";
                            //        strRole += "部门ID   = " + User[i].DepartmentID + "\r\n";
                            //        strRole += "岗位ID   = " + User[i].PostID + "\r\n";
                            //        strRole += "员工ID   = " + User[i].UserID + "\r\n";

                            //        strRole += "公司名称 = " + User[i].CompayName + "\r\n";
                            //        strRole += "部门名称 = " + User[i].DepartmentName + "\r\n";
                            //        strRole += "岗位名称 = " + User[i].PostName + "\r\n";
                            //        strRole += "员工姓名 = " + User[i].EmployeeName + "\r\n";

                            //        tmp.UserID = User[i].UserID;
                            //        tmp.UserName = User[i].EmployeeName;
                            //        tmp.CompanyID = User[i].CompayID;
                            //        tmp.DepartmentID = User[i].DepartmentID;
                            //        tmp.PostID = User[i].PostID;
                            //        tmp.PostID = User[i].CompayName;
                            //        tmp.PostID = User[i].DepartmentName;
                            //        tmp.PostID = User[i].PostName;
                            //        foreach (var role in User[i].Roles)
                            //        {
                            //            tmp.Roles.Add(role);
                            //            strRole += "角色ID   = " + role.ROLEID + "\r\n";
                            //            strRole += "角色名称 = " + role.ROLENAME + "\r\n";
                            //        }
                            //        listUser.Add(tmp);
                            //        strRole += "\r\n";
                            //        strRole += "==================================================================================\r\n";
                            //        #endregion

                            //    }
                            //}   
                            #endregion
                            LogHelper.WriteLog(strRole);
                        }
                        catch (Exception ex)
                        {
                            LogHelper.WriteLog("权限服务GetSysUserByRole异常信息 角色id:" + WFCurrentStateName + "" + ex.ToString());
                            throw new Exception("下一审核人为空,请联系公司权限管理员检查角色下的人员,角色id:" + WFCurrentStateName);
                        }


                    }

                }
                else
                {
                    //已经到流程结束状态
                    UserInfo tmp = new UserInfo();
                    tmp.UserID = "End";
                    tmp.UserName = "******";

                    listUser.Add(tmp);
                }

                return listUser;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("GetUserByStateCode异常信息 :" + ex.ToString());
                throw new Exception(ex.Message);
                // return null ;
            }
            finally
            {
                WcfPermissionService.Close();
                WcfPersonnel.Close();
                WcfPermissionService = null;
                WcfPersonnel = null;
            }


        }
示例#2
0
文件: Service2.cs 项目: JuRogn/OA
        /// <summary>
        /// 启动与工作流程相同类型流程,查询对应节点用户
        /// </summary>
        /// <param name="CompanyID">公司ID</param>
        /// <param name="ModelCode">模块代码</param>
        /// <param name="FlowGUID">待审批流GUID,新增时为空或者为StartFlow</param>
        /// <returns></returns>
        public DataResult GetAppUser(OracleConnection con, string CompanyID, string ModelCode, string FlowGUID, string xml)
        {

            DataResult GetAppUserResult = new DataResult();
            try
            {
                string StateName = null;


                if (FlowGUID == "" || FlowGUID == "StartFlow")
                {
                    StateName = "StartFlow";
                }
                else
                {
                    //根据待审批流程GUID,检索待审批状态节点代码
                    List<FLOW_FLOWRECORDDETAIL_T> FlowRecord = FlowBLL2.GetFlowInfo(con, "", FlowGUID, "", "", "", "", "", null);
                    if (FlowRecord == null)
                    {
                        GetAppUserResult.Err = "没有待处理的审核";
                        GetAppUserResult.UserInfo = null;
                        return GetAppUserResult;
                    }
                    StateName = FlowRecord[0].STATECODE;
                }

                //根据公司ID,模块代码获取配置的流程
                WorkflowInstance instance = null;
                LogHelper.WriteLog("根据公司ID,模块代码获取配置的流程FlowBLL2.GetFlowByModelName:OgrType='0'");

                List<FLOW_MODELFLOWRELATION_T> MODELFLOWRELATION = FlowBLL2.GetFlowByModelName(con, CompanyID, "", ModelCode, "0");

                if (MODELFLOWRELATION == null || MODELFLOWRELATION.Count == 0)
                {
                    GetAppUserResult.Err = "没有可使用的流程";
                    GetAppUserResult.UserInfo = null;
                    return GetAppUserResult;
                }
                FLOW_FLOWDEFINE_T Xoml = MODELFLOWRELATION[0].FLOW_FLOWDEFINE_T;

                XmlReader readerxoml, readerule;
                StringReader strXoml = new StringReader(Xoml.XOML);
                StringReader strRules = new StringReader(Xoml.RULES == null ? "" : Xoml.RULES);

                readerxoml = XmlReader.Create(strXoml);
                readerule = XmlReader.Create(strRules);

                WorkflowRuntime workflowRuntime = new WorkflowRuntime();
                workflowRuntime.StartRuntime();

                FlowEvent ExternalEvent = new FlowEvent();
                ExternalDataExchangeService objService = new ExternalDataExchangeService();
                workflowRuntime.AddService(objService);
                objService.AddService(ExternalEvent);
                TypeProvider typeProvider = new TypeProvider(null);
                workflowRuntime.AddService(typeProvider);

                //XmlReader readerxoml = XmlReader.Create(HttpContext.Current.Server.MapPath ("TestFlow.xml"));
                // instance = workflowRuntime.CreateWorkflow(readerxoml);
                if (Xoml.RULES == null)
                    instance = workflowRuntime.CreateWorkflow(readerxoml);
                else
                    instance = workflowRuntime.CreateWorkflow(readerxoml, readerule, null);
                // instance = workflowRuntime.CreateWorkflow(typeof(TestFlow));
                instance.Start();
                StateMachineWorkflowInstance workflowinstance = new StateMachineWorkflowInstance(workflowRuntime, instance.InstanceId);

                //从实例中获取定义
                if (1 == 2)
                {
                    System.Workflow.Activities.StateMachineWorkflowActivity smworkflow = new StateMachineWorkflowActivity();
                    smworkflow = workflowinstance.StateMachineWorkflow;
                    RuleDefinitions ruleDefinitions = smworkflow.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
                    WorkflowMarkupSerializer markupSerializer = new WorkflowMarkupSerializer();

                    StringBuilder xoml = new StringBuilder();
                    StringBuilder rule = new StringBuilder();
                    XmlWriter xmlWriter = XmlWriter.Create(xoml);
                    XmlWriter ruleWriter = XmlWriter.Create(rule);
                    markupSerializer.Serialize(xmlWriter, smworkflow);
                    markupSerializer.Serialize(ruleWriter, ruleDefinitions);
                    xmlWriter.Close();
                    ruleWriter.Close();
                    StringReader readxoml = new StringReader(xoml.ToString());
                    StringReader readrule = new StringReader(rule.ToString());
                    XmlReader readerxoml2 = XmlReader.Create(readxoml);
                    XmlReader readerrule2 = XmlReader.Create(readrule);
                    WorkflowInstance instance1 = workflowRuntime.CreateWorkflow(readerxoml2, readerrule2, null);
                    instance1.Start();
                    StateMachineWorkflowInstance workflowinstance1 = new StateMachineWorkflowInstance(workflowRuntime, instance1.InstanceId);
                    workflowinstance1.SetState(StateName);
                }
                //从实例中获取定义并启动新实例

                //跳转到节点StateName
                workflowinstance.SetState(StateName);

                FlowDataType.FlowData FlowData = new FlowDataType.FlowData();
                FlowData.xml = xml;
                //  FlowData.Flow_FlowRecord_T = null;

                ExternalEvent.OnDoFlow(instance.InstanceId, FlowData);//激发流程引擎流转到下一状态
                System.Threading.Thread.Sleep(1000);
                PermissionServiceClient WcfPermissionService = new PermissionServiceClient();
                string CurrentStateName = workflowinstance.CurrentStateName == null ? "End" : workflowinstance.CurrentStateName; //取得当前状态
                List<UserInfo> listUser = new List<UserInfo>();
                if (CurrentStateName != "End")
                {
                    if (CurrentStateName.Substring(0, 5) == "State")
                    {
                        CurrentStateName = CurrentStateName.Substring(5);
                    }
                    string WFCurrentStateName = new Guid(CurrentStateName).ToString("D");
                    T_SYS_USER[]  User = WcfPermissionService.GetSysUserByRole(WFCurrentStateName); //检索本状态(角色)对应用户

                    if (User != null)
                        for (int i = 0; i < User.Length; i++)
                        {
                            UserInfo tmp = new UserInfo();
                            tmp.UserID = User[i].EMPLOYEEID;
                            tmp.UserName = User[i].EMPLOYEENAME;
                            listUser.Add(tmp);
                        }



                }
                else
                {
                    //已经到流程结束状态
                    UserInfo tmp = new UserInfo();
                    tmp.UserID = "End";
                    tmp.UserName = "******";

                    listUser.Add(tmp);
                }


                GetAppUserResult.UserInfo = listUser.Count > 0 ? listUser : null;

                if (GetAppUserResult.UserInfo == null)
                    GetAppUserResult.Err = "没有找到用户";

                return GetAppUserResult;
                // return listUser;


                //return workflowinstance.CurrentStateName == null ? "End" : workflowinstance.CurrentStateName;
            }
            catch (Exception ex)
            {
                GetAppUserResult.Err = ex.Message;
                GetAppUserResult.UserInfo = null;
                return GetAppUserResult;
            }
        }
示例#3
0
文件: FlowBLL.cs 项目: JuRogn/OA
        /// <summary>
        /// 通过状态代码查询下一处理人
        /// </summary>
        /// <param name="StateCode">状态代码</param>
        /// <returns></returns>
        private List<UserInfo> GetUserByStateCode(string StateCode, string UserID, string PostID, ref bool isHigher)
        {
            PermissionServiceClient WcfPermissionService = new PermissionServiceClient();
            PersonnelServiceClient WcfPersonnel = new PersonnelServiceClient();
            try
            {

                string CurrentStateName = StateCode == "EndFlow" ? "End" : StateCode; //取得当前状态
                List<UserInfo> listUser = new List<UserInfo>();

                
       
                if (CurrentStateName != "End")
                {
                    //if (CurrentStateName.Substring(0, 5) == "State")
                    //{
                    //    CurrentStateName = CurrentStateName.Substring(5);
                    //}

                    string WFCurrentStateName = "";
                    int isDirect = 0;
                    foreach (Higher c in Enum.GetValues(typeof(Higher)))
                    {
                        if (CurrentStateName.ToUpper() == c.ToString().ToUpper())
                        {
                            isDirect = (int)c;//== 1 ? true : false;

                            WFCurrentStateName = CurrentStateName;
                            isHigher = true;
                        }
                    }


                    if (WFCurrentStateName != "")
                    {
                        //PermissionService
                        
                        V_EMPLOYEEVIEW[] User = WcfPersonnel.GetEmployeeLeaders(PostID, isDirect);
                        if (User != null && User.Length > 0)
                            for (int i = 0; i < User.Length; i++)
                            {
                                UserInfo tmp = new UserInfo();
                                tmp.UserID = User[i].EMPLOYEEID;
                                tmp.UserName = User[i].EMPLOYEECNAME;
                                tmp.CompanyID = User[i].OWNERCOMPANYID;
                                tmp.DepartmentID = User[i].OWNERDEPARTMENTID;
                                tmp.PostID = User[i].OWNERPOSTID;
                                listUser.Add(tmp);
                            }
                    }
                    else
                    {
                        WFCurrentStateName = new Guid(CurrentStateName).ToString("D");

                        foreach (var op in WcfPermissionService.Endpoint.Contract.Operations)
                        {
                            var dataContractBehavior = op.Behaviors[typeof(DataContractSerializerOperationBehavior)]
                                as DataContractSerializerOperationBehavior;
                            if (dataContractBehavior != null)
                            {
                                dataContractBehavior.MaxItemsInObjectGraph = Int32.MaxValue; //int.MaxValue;
                            }
                        }
                        T_SYS_USER[] User = WcfPermissionService.GetSysUserByRole(WFCurrentStateName); //检索本状态(角色)对应用户
                 
                        if (User != null && User.Length > 0)
                            for (int i = 0; i < User.Length; i++)
                            {
                                UserInfo tmp = new UserInfo();
                                tmp.UserID = User[i].EMPLOYEEID;
                                tmp.UserName = User[i].EMPLOYEENAME;
                                tmp.CompanyID = User[i].OWNERCOMPANYID;
                                tmp.DepartmentID = User[i].OWNERDEPARTMENTID;
                                tmp.PostID = User[i].OWNERPOSTID;
                                listUser.Add(tmp);
                            }

                    }

                }
                else
                {
                    //已经到流程结束状态
                    UserInfo tmp = new UserInfo();
                    tmp.UserID = "End";
                    tmp.UserName = "******";

                    listUser.Add(tmp);
                }

                return listUser;
            }
            catch (Exception ex)
            {
                throw new Exception("GetUserByStateCode:"+ex.Message);
                // return null ;
            }
            finally
            {
                WcfPermissionService.Close();
                WcfPersonnel.Close();
                WcfPermissionService = null;
                WcfPersonnel = null;
            }


        }