using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using wispro.sp.entity.workflowDefine; namespace wispro.sp.share.Utility { public class UserConditionHelper { public static string UserFieldLabel(UserField userField, string bindObjectType) { switch (userField.UserConditionType) { case UserConditionType.Department: return $"部门:{userField.Department}"; break; case UserConditionType.DepartmentPosition: return $"[部门:{userField.Department}].[职位:{userField.Positon}]"; break; case UserConditionType.UserDepartment: switch (userField.UserType) { case UserType.BindObjectProperty: Type t = Type.GetType(bindObjectType); return $"{ObjectHelper.GetPropertyDescription(userField.UserValue, bindObjectType)}部门"; break; case UserType.DoActionUser: return $"[{userField.UserValue}处理人部门]"; break; case UserType.LoginUser: return $"[登录用户部门]"; break; case UserType.Staff: return $"[{userField.UserValue}部门]"; break; } break; case UserConditionType.UserDepartmentPosition: switch (userField.UserType) { case UserType.BindObjectProperty: return $"[{ObjectHelper.GetPropertyDescription(userField.UserValue, bindObjectType)}部门职位:{userField.Positon}]"; break; case UserType.DoActionUser: return $"[{userField.UserValue}处理人部门职位:{userField.Positon}]"; break; case UserType.LoginUser: return $"[登录用户部门职位:{userField.Positon}]"; break; case UserType.Staff: break; } break; case UserConditionType.Staff: switch (userField.UserType) { case UserType.BindObjectProperty: return $"[{ObjectHelper.GetPropertyDescription(userField.UserValue, bindObjectType)}"; break; case UserType.DoActionUser: return $"[{userField.UserValue}处理人].[部门].[职位:{userField.Positon}]"; break; case UserType.LoginUser: return "登录用户"; break; case UserType.Staff: return $"用户:{userField.UserValue}"; break; } break; } return ""; } public static Dictionary GetPropertyDescription(string stringType) { Dictionary retDic = new Dictionary(); Type type = Type.GetType(stringType); foreach(var property in type.GetProperties()) { if(property.PropertyType == typeof(T)) { DescriptionAttribute att = property.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute; if (att == null) { retDic.Add(property.Name, property.Name); } else { retDic.Add(att.Description, property.Name); } } } return retDic; } } }