public void AddSystemUser(t_SystemUser mSystemUser,string sUserID) { if (!Func.tSystemUser.IsAuthUser(sUserID)) throw new ArgumentException("用户权限不足!"); Func.tSystemUser.AddUser(mSystemUser); }
internal static void AddUser(t_SystemUser mSystemUser) { if (mSystemUser == null) throw new ArgumentException("参数不能为空!"); VerfyUser(mSystemUser); mSystemUser.sLoginName = mSystemUser.sLoginName.ToLower(); if (IsExist(mSystemUser.sLoginName)) throw new ArgumentException("用户已存在!"); mSystemUser.KeyID = "SYSUser:" + DateTime.Now.Ticks.ToString(); mSystemUser.sPassword = CommFunc.EncryptStorageSring(mSystemUser.sLoginName, mSystemUser.sPassword); mSystemUser.LastUpdate = DateTime.Now; mSystemUser.IsEnable = true; bSystemUser.Add(mSystemUser); }
/// <summary> /// 验证USER是否合法 /// </summary> /// <param name="mUser"></param> private static void VerfyUser(t_SystemUser mUser) { if (string.IsNullOrEmpty(mUser.sLoginName)) throw new ArgumentException("登录名不能为空!"); if (string.IsNullOrEmpty(mUser.sUserName)) throw new ArgumentException("用户名不能为空!"); if (string.IsNullOrEmpty(mUser.sPassword)) throw new ArgumentException("密码不能为空!"); }
internal static void Update(t_SystemUser mUser, string OperatorID) { if (!IsAuthUser(OperatorID)) throw new ArgumentException("用户权限不足!"); bool IsChangePassword = true; if (string.IsNullOrEmpty(mUser.sPassword)) { IsChangePassword = false; mUser.sPassword = "******"; } VerfyUser(mUser); t_SystemUser mOld = bSystemUser.GetModel(mUser.KeyID); mUser.sLoginName = mUser.sLoginName.ToLower();//登录名转换为小写 if (mOld.sLoginName!=mUser.sLoginName) { if (mUser.sLoginName.Equals("admin")) throw new ArgumentException("不能修改admin账户登录名称!"); if (IsExist(mUser.sLoginName)) throw new ArgumentException("登录名已存在!"); mOld.sLoginName = mUser.sLoginName; } mOld.sUserName = mUser.sUserName; if (IsChangePassword) { mOld.sPassword = CommFunc.DecryptTransString(mUser.sPassword); mOld.sPassword = CommFunc.EncryptStorageSring(mOld.sLoginName, mOld.sPassword); } mOld.LastUpdate = DateTime.Now; bSystemUser.Update(mOld); }
public void SetSystemUser(t_SystemUser mUser, string OperatorID) { Func.tSystemUser.Update(mUser, OperatorID); }