/// <summary> /// 通过状态代码查询下一处理人(对服务操作) /// </summary> /// <param name="StateCode">状态代码(角色ID(RoleName))</param> /// <returns></returns> private List<UserInfo> GetUserByStateCode(string StateCode, string UserID, string PostID, ref bool isHigher) { 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; #region 是否是直接上级,隔级上级,部门负责人 foreach (Higher c in Enum.GetValues(typeof(Higher))) { if (CurrentStateName.ToUpper() == c.ToString().ToUpper()) { isDirect = (int)c;//== 1 ? true : false; WFCurrentStateName = CurrentStateName; isHigher = true; } } #endregion if (WFCurrentStateName != "") { //PermissionService #region 如果是直接上级,隔级上级,部门负责人 LogHelper.WriteLog("UserID=" + UserID + " 开始调用 直接上级,隔级上级,部门负责人:WcfPersonnel.GetEmployeeLeaders(岗位ID=" + PostID + ", isDirect=" + isDirect + ")"); PersonnelServiceClient WcfPersonnel = new PersonnelServiceClient();//Commented by Alan 2012-7-25 ,只在使用时构造 V_EMPLOYEEVIEW[] User = WcfPersonnel.GetEmployeeLeaders(PostID, isDirect); string strtemp = "UserID=" + UserID + " 结束调用 直接上级,隔级上级,部门负责人: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; tmp.CompanyName = User[i].COMPANYNAME; tmp.DepartmentName = User[i].DEPARTMENTNAME; tmp.PostName = User[i].POSTNAME; tmp.Roles = new List<T_SYS_ROLE>(); //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); strtemp += "公司ID = " + User[i].EMPLOYEEID + "\r\n"; strtemp += "部门ID = " + User[i].OWNERDEPARTMENTID + "\r\n"; strtemp += "岗位ID = " + User[i].OWNERPOSTID + "\r\n"; strtemp += "员工ID = " + User[i].EMPLOYEEID + "\r\n"; strtemp += "公司名称 = " + User[i].COMPANYNAME + "\r\n"; strtemp += "部门名称 = " + User[i].DEPARTMENTNAME + "\r\n"; strtemp += "岗位名称 = " + User[i].POSTNAME + "\r\n"; strtemp += "员工姓名 = " + User[i].EMPLOYEECNAME + "\r\n"; } } #endregion LogHelper.WriteLog(strtemp); } else { #region 根据角色ID查找人 LogHelper.WriteLog("UserID=" + UserID + " 开始调用 检索本状态(角色)对应用户:WcfPermissionService.GetFlowUserInfoByRoleID(角色ID=" + WFCurrentStateName + ")"); WFCurrentStateName = new Guid(CurrentStateName).ToString("D"); PermissionServiceClient WcfPermissionService = new PermissionServiceClient(); 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 { FlowUserInfo[] User = WcfPermissionService.GetFlowUserInfoByRoleID(WFCurrentStateName);//新的接口 string strRole = "UserID=" + UserID + " 结束调用 检索本状态(角色)对应用户:WcfPermissionService.GetFlowUserInfoByRoleID(角色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.CompanyName = User[i].CompayName; tmp.DepartmentName = User[i].DepartmentName; tmp.PostName = User[i].PostName; tmp.Roles = new List<T_SYS_ROLE>(); 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 } } LogHelper.WriteLog(strRole); } catch (Exception ex) { LogHelper.WriteLog("权限服务GetSysUserByRole异常信息 角色id:" + WFCurrentStateName + "" + ex.ToString()); throw new Exception("下一审核人为空,请联系公司权限管理员检查角色下的人员,角色id:" + WFCurrentStateName); } #endregion } } 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("调用权限服务出错,请联系管理员!"); // return null ; } //finally //{ // WcfPermissionService.Close(); // WcfPermissionService = null; // WcfPersonnel.Close(); // WcfPersonnel = null; //} }