RoleItem.cs 6.3 KB

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