RoleItem.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. using System.Collections.ObjectModel;
  2. using Caliburn.Micro.Core;
  3. using MECF.Framework.UI.Client.ClientBase;
  4. using OpenSEMI.ClientBase;
  5. namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles
  6. {
  7. public class RoleItem : PropertyChangedBase
  8. {
  9. public RoleItem(Common.Account.Extends.Role r)
  10. {
  11. this._Role = r;
  12. }
  13. public RoleItem(string roleid)
  14. {
  15. this._Role = new Common.Account.Extends.Role(roleid, string.Empty, false, 0, string.Empty, string.Empty);
  16. }
  17. private Common.Account.Extends.Role _Role;
  18. public Common.Account.Extends.Role Role
  19. {
  20. get { return _Role; }
  21. set { _Role = value; }
  22. }
  23. public string RoleID
  24. {
  25. get { return _Role.RoleID; }
  26. set { _Role.RoleID = value; }
  27. }
  28. public string RoleName
  29. {
  30. get { return _Role.RoleName; }
  31. set { _Role.RoleName = value; }
  32. }
  33. public int AutoLogoutTime
  34. {
  35. get { return _Role.LogoutTime; }
  36. set { _Role.LogoutTime = value; }
  37. }
  38. public string Description
  39. {
  40. get { return _Role.Description; }
  41. set { _Role.Description = value; }
  42. }
  43. public bool IsAutoLogout
  44. {
  45. get { return _Role.IsAutoLogout; }
  46. set { _Role.IsAutoLogout = value; }
  47. }
  48. private string _DisplayRoleName;
  49. public string DisplayRoleName
  50. {
  51. get { return _DisplayRoleName; }
  52. set { _DisplayRoleName = value; NotifyOfPropertyChange("DisplayRoleName"); }
  53. }
  54. public int DisplayAutoLogoutTime
  55. {
  56. get;
  57. set;
  58. }
  59. public bool DisplayIsAutoLogout
  60. {
  61. get;
  62. set;
  63. }
  64. public string DisplayDescription
  65. {
  66. get;
  67. set;
  68. }
  69. private bool _IsSelected = false;
  70. public bool IsSelected
  71. {
  72. get { return _IsSelected; }
  73. set { _IsSelected = value; NotifyOfPropertyChange("IsSelected"); }
  74. }
  75. private bool _RoleNameTextSaved = true;
  76. public bool RoleNameTextSaved
  77. {
  78. get { return _RoleNameTextSaved; }
  79. set
  80. {
  81. if (_RoleNameTextSaved != value)
  82. {
  83. _RoleNameTextSaved = value;
  84. NotifyOfPropertyChange("RoleNameTextSaved");
  85. }
  86. }
  87. }
  88. private bool _TimeTextSaved = true;
  89. public bool TimeTextSaved
  90. {
  91. get { return _TimeTextSaved; }
  92. set
  93. {
  94. if (_TimeTextSaved != value)
  95. {
  96. _TimeTextSaved = value;
  97. NotifyOfPropertyChange("TimeTextSaved");
  98. }
  99. }
  100. }
  101. private bool _DescriptionTextSaved = true;
  102. public bool DescriptionTextSaved
  103. {
  104. get { return _DescriptionTextSaved; }
  105. set
  106. {
  107. if (_DescriptionTextSaved != value)
  108. {
  109. _DescriptionTextSaved = value;
  110. NotifyOfPropertyChange("DescriptionTextSaved");
  111. }
  112. }
  113. }
  114. private ObservableCollection<MenuInfo> _MenuColleciton = new ObservableCollection<MenuInfo>();
  115. public ObservableCollection<MenuInfo> MenuCollection
  116. {
  117. get { return _MenuColleciton; }
  118. }
  119. public void AddMenuInfo(MenuInfo pInfo)
  120. {
  121. if (null == pInfo)
  122. return;
  123. MenuCollection.Add(pInfo);
  124. }
  125. public bool IsRoleChanged()
  126. {
  127. if (this.DisplayRoleName != this.Role.RoleName)
  128. return true;
  129. if (this.DisplayAutoLogoutTime != this.Role.LogoutTime)
  130. return true;
  131. if (this.DisplayIsAutoLogout != this.Role.IsAutoLogout)
  132. return true;
  133. if (this.DisplayDescription != this.Role.Description)
  134. return true;
  135. foreach (MenuInfo item in _MenuColleciton)
  136. {
  137. if (item.DisplayIndexPermission != item.IndexPermission - 1)
  138. return true;
  139. }
  140. return false;
  141. }
  142. }
  143. public class MenuInfo : PropertyChangedBase
  144. {
  145. private string _strMenuID;
  146. public string ID
  147. {
  148. get { return _strMenuID; }
  149. set
  150. {
  151. if (value != _strMenuID)
  152. _strMenuID = value;
  153. }
  154. }
  155. private MenuPermissionEnum _EnummenuPermission;
  156. public MenuPermissionEnum EnumPermission
  157. {
  158. get { return _EnummenuPermission; }
  159. set
  160. {
  161. if (value != _EnummenuPermission)
  162. {
  163. _EnummenuPermission = value;
  164. _IndexMenuPermission = (int)_EnummenuPermission;
  165. }
  166. }
  167. }
  168. private string _StrMenuPermission;
  169. public string stringPermission
  170. {
  171. get { return _StrMenuPermission; }
  172. set
  173. {
  174. if (value != _StrMenuPermission)
  175. _StrMenuPermission = value;
  176. }
  177. }
  178. private int _IndexMenuPermission;
  179. public int IndexPermission
  180. {
  181. get { return _IndexMenuPermission; }
  182. set
  183. {
  184. if (value != _IndexMenuPermission)
  185. {
  186. _IndexMenuPermission = value;
  187. EnumPermission = (MenuPermissionEnum)_IndexMenuPermission;
  188. }
  189. }
  190. }
  191. private int _DisplayIndexPermission;
  192. public int DisplayIndexPermission
  193. {
  194. get { return _DisplayIndexPermission; }
  195. set
  196. {
  197. if (value != _DisplayIndexPermission)
  198. {
  199. _DisplayIndexPermission = value;
  200. }
  201. }
  202. }
  203. private bool _ComboBoxSaved = false;
  204. public bool ComboBoxSaved
  205. {
  206. get { return _ComboBoxSaved; }
  207. set
  208. {
  209. if (_ComboBoxSaved != value)
  210. {
  211. _ComboBoxSaved = value;
  212. NotifyOfPropertyChange("ComboBoxSaved");
  213. }
  214. }
  215. }
  216. private string _strMenuName;
  217. public string Name
  218. {
  219. get { return _strMenuName; }
  220. set
  221. {
  222. if (value != _strMenuName)
  223. _strMenuName = value;
  224. }
  225. }
  226. public MenuInfo Clone()
  227. {
  228. MenuInfo menuInfo = new MenuInfo();
  229. menuInfo.Name = this.Name;
  230. menuInfo.stringPermission = this.stringPermission;
  231. menuInfo.EnumPermission = this.EnumPermission;
  232. menuInfo.ID = this.ID;
  233. menuInfo.IndexPermission = this.IndexPermission;
  234. menuInfo.DisplayIndexPermission = this.IndexPermission - 1;
  235. return menuInfo;
  236. }
  237. }
  238. }