Пример #1
0
        /// <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
        /// <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;
            }


        }