我们编写管理软件时,很重要的一个基础观念是:
1. 当前软件系统是谁在操作?
2. 当前软件系统的操作者部门信息是什么? 公司信息是什么? 通过这些信息获得相关数据. 3. 当前软件系统操作者是否为系统管理员? 4. 当前软件系统是谁在输入数据,谁在修改数据?这个基础思想甚至会影响你整个系统的架构,贯穿各个层。若没有这些数据,操作员在你系统里干了坏事,总得能记录吧?好让警察来破案。在管理软件中,在登录过程中,确认当前操作员是谁?谁在操作数据等。当软件系统不需要登录时,也可以把IP地址等标示信息,看成是一个特定的用户信息。每个公司侧重的数据,每个软件侧重的数据理念都会有些不同,命名也有些不同,
其中的信息也大有不同,现在我只是提一个建议。大家都统一命名为 BaseUserInfo,类的实体都命名为 UserInfo。你可能这里的属性只需要几个,但是多几个也无妨,就当是后备用好了。在C/S系统中,当前用户的信息可以存储在 Static 类里,在B/S系统中可以存在 Session 中。
1 // ------------------------------------------------------------ 2 // All Rights Reserved , Copyright (C) 2008 , Jirisoft , Ltd. 3 // ------------------------------------------------------------ 4 5 using System; 6 7 namespace Jirisoft.Common.Utilities 8 { 9 /**/ /// <summary> 10 /// BaseUserInfo 11 /// 当前操作员信息的简要信息类 12 /// 13 /// 修改纪录 14 /// 15 /// 2008.08.26 JiRiGaLa 版本:1.2 整理代码。 16 /// 2006.05.03 JiRiGaLa 版本:1.1 添加到工程项目中。 17 /// 2006.01.21 JiRiGaLa 版本:1.0 远程传递参数用。 18 /// 19 /// 版本:1.2 20 /// 21 /// <author> 22 /// <name> JiRiGaLa </name> 23 /// <date> 2008.08.26 </date> 24 /// </author> 25 /// </summary> 26 [Serializable] 27 public class BaseUserInfo 28 { 29 /**/ /// <summary> 30 /// 操作员代码 31 /// </summary> 32 private String id = String.Empty; 33 public String ID 34 { 35 get 36 { 37 return this .id; 38 } 39 set 40 { 41 this .id = value; 42 } 43 } 44 45 /**/ /// <summary> 46 /// 操作员用户名 47 /// </summary> 48 private String userName = String.Empty; 49 public String UserName 50 { 51 get 52 { 53 return this .userName; 54 } 55 set 56 { 57 this .userName = value; 58 } 59 } 60 61 /**/ /// <summary> 62 /// 操作员姓名 63 /// </summary> 64 private String realname = String.Empty; 65 public String Realname 66 { 67 get 68 { 69 return this .realname; 70 } 71 set 72 { 73 this .realname = value; 74 } 75 } 76 77 /**/ /// <summary> 78 /// 当前的组织结构部门代码 79 /// </summary> 80 private String departmentID = String.Empty; 81 public String DepartmentID 82 { 83 get 84 { 85 return this .departmentID; 86 } 87 set 88 { 89 this .departmentID = value; 90 } 91 } 92 93 /**/ /// <summary> 94 /// 当前的组织结构部门编号 95 /// </summary> 96 private String departmentCode = String.Empty; 97 public String DepartmentCode 98 { 99 get 100 { 101 return this .departmentCode; 102 } 103 set 104 { 105 this .departmentCode = value; 106 } 107 } 108 109 /**/ /// <summary> 110 /// 当前的组织结构部门名称 111 /// </summary> 112 private String departmentFullName = String.Empty; 113 public String DepartmentFullName 114 { 115 get 116 { 117 return this .departmentFullName; 118 } 119 set 120 { 121 this .departmentFullName = value; 122 } 123 } 124 125 /**/ /// <summary> 126 /// 当前的组织结构公司代码 127 /// </summary> 128 private String companyID = String.Empty; 129 public String CompanyID 130 { 131 get 132 { 133 return this .companyID; 134 } 135 set 136 { 137 this .companyID = value; 138 } 139 } 140 141 /**/ /// <summary> 142 /// 当前的组织结构公司编号 143 /// </summary> 144 private String companyCode = String.Empty; 145 public String CompanyCode 146 { 147 get 148 { 149 return this .companyCode; 150 } 151 set 152 { 153 this .companyCode = value; 154 } 155 } 156 157 /**/ /// <summary> 158 /// 当前的组织结构公司名称 159 /// </summary> 160 private String companyFullName = String.Empty; 161 public String CompanyFullName 162 { 163 get 164 { 165 return this .companyFullName; 166 } 167 set 168 { 169 this .companyFullName = value; 170 } 171 } 172 173 /**/ /// <summary> 174 /// 操作员类型 175 /// </summary> 176 private String operatorCategory = String.Empty; 177 public String OperatorCategory 178 { 179 get 180 { 181 return this .operatorCategory; 182 } 183 set 184 { 185 this .operatorCategory = value; 186 } 187 } 188 189 /**/ /// <summary> 190 /// 操作员类型名称 191 /// </summary> 192 private String operatorCategoryFullName = String.Empty; 193 public String OperatorCategoryFullName 194 { 195 get 196 { 197 return this .operatorCategoryFullName; 198 } 199 set 200 { 201 this .operatorCategoryFullName = value; 202 } 203 } 204 205 /**/ /// <summary> 206 /// IP地址 207 /// </summary> 208 private String iPAddress = String.Empty; 209 public String IPAddress 210 { 211 get 212 { 213 return this .iPAddress; 214 } 215 set 216 { 217 this .iPAddress = value; 218 } 219 } 220 221 /**/ /// <summary> 222 /// MAC地址 223 /// </summary> 224 private String macAddress = String.Empty; 225 public String MACAddress 226 { 227 get 228 { 229 return this .macAddress; 230 } 231 set 232 { 233 this .macAddress = value; 234 } 235 } 236 237 /**/ /// <summary> 238 /// 当前语言选择 239 /// </summary> 240 private String currentLanguage = String.Empty; 241 public String CurrentLanguage 242 { 243 get 244 { 245 return this .currentLanguage; 246 } 247 set 248 { 249 this .currentLanguage = value; 250 } 251 } 252 253 /**/ /// <summary> 254 /// 当前布局风格选择 255 /// </summary> 256 private String themes = String.Empty; 257 public String Themes 258 { 259 get 260 { 261 return this .themes; 262 } 263 set 264 { 265 this .themes = value; 266 } 267 } 268 269 /**/ /// <summary> 270 /// 描述 271 /// </summary> 272 private String description = String.Empty; 273 public String Description 274 { 275 get 276 { 277 return this .description; 278 } 279 set 280 { 281 this .description = value; 282 } 283 } 284 285 /**/ /// <summary> 286 /// WebService 用户名 287 /// </summary> 288 private String webServiceUsername = " Jirisoft " ; 289 public String WebServiceUsername 290 { 291 get 292 { 293 return this .webServiceUsername; 294 } 295 set 296 { 297 this .webServiceUsername = value; 298 } 299 } 300 301 /**/ /// <summary> 302 /// WebService 密码 303 /// </summary> 304 private String webServicePassword = " Jirisoft " ; 305 public String WebServicePassword 306 { 307 get 308 { 309 return this .webServicePassword; 310 } 311 set 312 { 313 this .webServicePassword = value; 314 } 315 } 316 317 public BaseUserInfo() 318 { 319 this .GetUserInfo(); 320 } 321 322 public void GetUserInfo() #region public void GetUserInfo() 323 /**/ /// <summary> 324 /// 获取信息 325 /// </summary> 326 public void GetUserInfo() 327 { 328 this .WebServiceUsername = BaseConfiguration.Instance.WebServiceUsername; 329 this .WebServicePassword = BaseConfiguration.Instance.WebServicePassword; 330 this .ID = BaseSystemInfo.OperatorID; 331 this .Realname = BaseSystemInfo.OperatorFullName; 332 this .UserName = BaseSystemInfo.OperatorUserName; 333 this .OperatorCategory = BaseSystemInfo.OperatorCategory; 334 this .OperatorCategoryFullName = BaseSystemInfo.OperatorCategoryFullName; 335 this .CompanyID = BaseSystemInfo.OperatorCompanyID; 336 this .CompanyCode = BaseSystemInfo.OperatorCompanyCode; 337 this .CompanyFullName = BaseSystemInfo.OperatorCompanyFullName; 338 this .DepartmentID = BaseSystemInfo.OperatorDepartmentID; 339 this .DepartmentCode = BaseSystemInfo.OperatorDepartmentCode; 340 this .DepartmentFullName = BaseSystemInfo.OperatorDepartmentFullName; 341 this .CurrentLanguage = BaseSystemInfo.CurrentLanguage; 342 this .Themes = BaseSystemInfo.Themes; 343 this .IPAddress = BaseSystemInfo.IPAddress; 344 this .MACAddress = BaseSystemInfo.MACAddress; 345 } 346 #endregion 347 348 /**/ /// <summary> 349 /// 当前操作员是否为系统管理员 350 /// </summary> 351 public bool IsAdministrator 352 { 353 get 354 { 355 if ( this .ID.Equals(Jirisoft.Common.OperatorCategory.Administrator.ToString())) 356 { 357 return true ; 358 } 359 if ( this .OperatorCategory.Equals(Jirisoft.Common.OperatorCategory.Administrator.ToString())) 360 { 361 return true ; 362 } 363 return false ; 364 } 365 } 366 } 367 } 368