123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- 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<string,string> GetPropertyDescription<T>(string stringType)
- {
- Dictionary<string, string> retDic = new Dictionary<string, string>();
- 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;
- }
- }
- }
|