Beispiel #1
0
 /// <summary>
 /// Updates the user.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="operUser">The oper user.</param>
 /// <returns></returns>
 public bool Modify(Sys_AdminUser user, Sys_AdminUser operUser)
 {
     var res = false;
     if (user != null && user.id > 0)
     {
         var log = new Sys_AdminUserLog();
         log.AddTime = System.DateTime.Now;
         log.IpAddress = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetRealIP();
         log.PageUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetCurrentUrl();
         log.ReferrerUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetReferrerUrl();
         log.State = true;
         log.TypeId = 1;
         try
         {
             adminUserRepository.Modify(user);
             res = true;
             if (operUser != null)
             {
                 log.UserId = operUser.id;
                 log.ShortMessage = "用户Id:" + operUser.id.ToString() + " 改变用户Id号:" + user.id.ToString() + " 的信息";
                 log.FullMessage = "UpdateUser 用户名:" + operUser.username + " 用户Id:" + operUser.id.ToString()
                     + " 改变了用户Id号:" + user.id.ToString() + " 的信息";
             }
             else
             {
                 log.UserId = 0;
                 log.ShortMessage = "用户Id号:" + user.id.ToString() + " 的信息被修改";
                 log.FullMessage = "UpdateUser " + "用户Id号:" + user.id.ToString() + " 的信息被修改";
             }
         }
         catch (Exception ex)
         {
             #region  exception
             if (operUser != null && operUser.id > 0)
             {
                 log.ShortMessage = "更新用户数据异常";
                 log.FullMessage = log.ShortMessage = "更新用户Id:" + user.id + " 用户名:" + user.username + " 操作用户Id:" + operUser.id + " 错误信息:" + ex.Message;
                 if (ex.InnerException != null)
                 {
                     log.FullMessage += "   内部错误信息:" + ex.InnerException.Message;
                 }
             }
             else
             {
                 log.ShortMessage = "更新用户数据异常";
                 log.FullMessage = log.ShortMessage = "更新用户Id:" + user.id + " 用户名:" + user.username + " 错误信息:" + ex.Message;
                 if (ex.InnerException != null)
                 {
                     log.FullMessage += "   内部错误信息:" + ex.InnerException.Message;
                 }
             }
             #endregion
         }
         Miaow.Infrastructure.Data.LoggerReopsitoryManager.AddLogInfo(log);
     }
     return res;
 }
Beispiel #2
0
 /// <summary>
 /// Deletes the name of the user by.
 /// 只设置为不可用
 /// </summary>
 /// <param name="email"></param>
 /// <param name="operUser">The oper user.</param>
 /// <returns></returns>
 public bool DeleteByEmail(string email, Sys_AdminUser operUser)
 {
     var res = false;
     if (!string.IsNullOrEmpty(email))
     {
         var user = GetUserByEmail(email);
         if (user != null)
         {
             res = Delete(user, operUser);
         }
     }
     return res;
 }
Beispiel #3
0
        public bool Add(IList<Sys_AdminUser> entity, Sys_AdminUser operUser)
        {
            var res = false;
            if (entity != null && entity.Count > 0)
            {
                try
                {
                    foreach (var item in entity)
                    {
                        if (item != null && !ExistUserByName(item.username) && !ExistUserByEmail(item.Email))
                        {
                            InitAddUser(item, operUser);
                            adminUserRepository.Add(item);
                            adminUserRepository.Uow.Commit();

                            var log = new Sys_AdminUserLog();
                            log.AddTime = System.DateTime.Now;
                            log.IpAddress = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetRealIP();
                            log.PageUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetCurrentUrl();
                            log.ReferrerUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetReferrerUrl();
                            log.State = true;
                            log.TypeId = 1;
                            if (operUser != null)
                            {
                                log.UserId = operUser.id;
                                log.ShortMessage = "用户Id:" + operUser.id + " 添加一个新用户Id:" + item.id;
                                log.FullMessage = "AddUser 用户名:" + operUser.username + " 用户Id:" + operUser.id.ToString()
                                    + " 添加用户Id:" + item.id + " 添加用户名:" + item.username;
                            }
                            else
                            {
                                log.UserId = 0;
                                log.ShortMessage = "用户名:" + item.username + "被添加";
                                log.FullMessage = "AddUser " + "用户名:" + item.username + "被添加";
                            }
                            Miaow.Infrastructure.Data.LoggerReopsitoryManager.AddLogInfo(log);
                        }
                    }
                    res = true;
                }
                catch (Exception ex)
                {
                }
            }
            return res;
        }
 public bool Add(IList<Sys_AdminUserExtension> entity, Sys_AdminUser operUser)
 {
     var res = false;
     if (entity != null && entity.Count > 0)
     {
         try
         {
             foreach (var item in entity)
             {
                 if (item != null)
                 {
                     userExtensionRepository.Add(item);
                 }
             }
             userExtensionRepository.Uow.Commit();
             res = true;
         }
         catch (Exception ex)
         {
         }
     }
     return res;
 }
 public bool Delete(IList<Sys_AdminUserExtension> entity, Sys_AdminUser operUser)
 {
     var res = false;
     if (entity != null && entity.Count > 0)
     {
         try
         {
             foreach (var item in entity)
             {
                 if (item != null)
                 {
                     item.State = false;
                     userExtensionRepository.Modify(item);
                 }
             }
             res = true;
         }
         catch (Exception ex)
         {
         }
     }
     return res;
 }
Beispiel #6
0
 /// <summary>
 /// Deletes the name of the user by.
 /// 只设置为不可用
 /// </summary>
 /// <param name="guid">The GUID.</param>
 /// <param name="operUser">The oper user.</param>
 /// <returns></returns>
 public bool DeleteByUserGuid(string guid, Sys_AdminUser operUser)
 {
     var res = false;
     if (!string.IsNullOrEmpty(guid))
     {
         var user = GetUserByUserGuid(guid);
         if (user != null)
         {
             res = Delete(user, operUser);
         }
     }
     return res;
 }
Beispiel #7
0
 public bool DeleteTrue(IList<int> idList, Sys_AdminUser operUser)
 {
     var res = false;
     if (idList != null && idList.Count > 0)
     {
         var delete = adminUserRepository.GetList(e => idList.Contains(e.id)).ToList();
         if (delete.Count > 0)
         {
             res = DeleteTrue(delete, operUser);
         }
     }
     return res;
 }
Beispiel #8
0
 public bool Delete(IList<int> idList, Sys_AdminUser operUser)
 {
     throw new NotImplementedException();
 }
Beispiel #9
0
 public bool Delete(IList<Sys_AdminUser> entity, Sys_AdminUser operUser)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
 public bool DeleteTrue(IList<Sys_AdminUser> entity, Sys_AdminUser operUser)
 {
     bool res = false;
     if (entity != null && entity.Count > 0)
     {
         foreach (var item in entity)
         {
             try
             {
                 //删除自己
                 adminUserRepository.Delete(item);
                 //用户扩展信息
                 var userExtension = adminUserExtensionRepository.GetList(d => d.UserId == item.id);
                 foreach (var temp in userExtension)
                 {
                     adminUserExtensionRepository.Delete(temp);
                 }
                 //个性化设置内容
                 var userIndividu = adminUserIndividuationRepository.GetList(d => d.UserId == item.id);
                 foreach (var temp in userIndividu)
                 {
                     adminUserIndividuationRepository.Delete(temp);
                 }
                 //要删除角色
                 var userRoles = userRoleRepository.GetList(d => d.UserID == item.id);
                 foreach (var temp in userRoles)
                 {
                     userRoleRepository.Delete(temp);
                 }
                 adminUserRepository.Uow.Commit();
                 adminUserExtensionRepository.Uow.Commit();
                 adminUserIndividuationRepository.Uow.Commit();
                 userRoleRepository.Uow.Commit();
                 //rolePermissionRepository.这是角色权限
                 var log = new Sys_AdminUserLog();
                 log.AddTime = System.DateTime.Now;
                 log.IpAddress = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetRealIP();
                 log.PageUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetCurrentUrl();
                 log.ReferrerUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetReferrerUrl();
                 log.State = true;
                 log.TypeId = 1;
                 if (operUser != null)
                 {
                     log.UserId = operUser.id;
                     log.ShortMessage = "用户Id:" + operUser.id + " 物理删除用户Id号:" + item.id.ToString();
                     log.FullMessage = "DeleteUserTrue 用户:" + operUser.username + " 用户Id:" + operUser.id.ToString()
                         + " 删除用户Id号:" + item.id.ToString();
                 }
                 else
                 {
                     log.UserId = 0;
                     log.ShortMessage = "用户Id号:" + item.id.ToString() + " 被删除";
                     log.FullMessage = "DeleteUserTrue " + "用户Id号:" + item.id.ToString() + " 被删除";
                 }
                 Miaow.Infrastructure.Data.LoggerReopsitoryManager.AddLogInfo(log);
                 res = true;
             }
             catch (Exception ex)
             {
             }
         }
     }
     return res;
 }
 /// <summary>
 /// 创建新的 Sys_AdminUser 对象。
 /// </summary>
 /// <param name="id">id 属性的初始值。</param>
 public static Sys_AdminUser CreateSys_AdminUser(global::System.Int32 id)
 {
     Sys_AdminUser sys_AdminUser = new Sys_AdminUser();
     sys_AdminUser.id = id;
     return sys_AdminUser;
 }
 /// <summary>
 /// 用于向 Sys_AdminUser EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToSys_AdminUser(Sys_AdminUser sys_AdminUser)
 {
     base.AddObject("Sys_AdminUser", sys_AdminUser);
 }
Beispiel #13
0
        /// <summary>
        /// Regsters the user.
        /// </summary>
        /// <param name="entity">The user.</param>
        /// <param name="userRole">The user role.</param>
        /// <param name="operUser">The oper user.</param>
        /// <returns></returns>
        public bool Add(Sys_AdminUser entity, Sys_UserRoles userRole, Miaow.Infrastructure.Data.DataSys.Sys_AdminUser operUser)
        {
            var res = false;
            if (entity != null && !ExistUserByName(entity.username) && !ExistUserByEmail(entity.Email))
            {
                try
                {
                    #region admin user
                    InitAddUser(entity, operUser);
                    adminUserRepository.Add(entity);
                    adminUserRepository.Uow.Commit();
                    #endregion

                    #region user role
                    userRole.UserID = entity.id;
                    userRoleRepository.Add(userRole);
                    userRoleRepository.Uow.Commit();
                    #endregion

                    var log = new Sys_AdminUserLog();
                    log.AddTime = System.DateTime.Now;
                    log.IpAddress = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetRealIP();
                    log.PageUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetCurrentUrl();
                    log.ReferrerUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetReferrerUrl();
                    log.State = true;
                    log.TypeId = 1;
                    if (operUser != null)
                    {
                        log.UserId = operUser.id;
                        log.ShortMessage = "用户Id:" + operUser.id + " 添加一个新用户Id:" + entity.id;
                        log.FullMessage = "AddUser 用户名:" + operUser.username + " 用户Id:" + operUser.id.ToString()
                            + " 添加用户Id:" + entity.id + " 添加用户名:" + entity.username + " 添加用户角色Id:" + userRole.RoleID;
                    }
                    else
                    {
                        log.UserId = 0;
                        log.ShortMessage = "用户名:" + entity.username + "被添加";
                        log.FullMessage = "AddUser " + "用户名:" + entity.username + "被添加";
                    }
                    Miaow.Infrastructure.Data.LoggerReopsitoryManager.AddLogInfo(log);
                }
                catch (Exception ex)
                {
                    entity.id = 0;
                }
            }
            return res;
        }
Beispiel #14
0
 /// <summary>
 /// Users the name of the change PWD by.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="pwd">The PWD.</param>
 /// <returns></returns>
 public bool ModifyPwdByName(string name, string pwd, Sys_AdminUser operUser)
 {
     bool b = false;
     pwd = Miaow.Infrastructure.Crosscutting.Function.StringHelper.Tomd5(pwd);
     int id = GetUserIdByName(name);
     if (id > 0)
     {
         b = ModifyPwdById(id, pwd, operUser);
     }
     return b;
 }
Beispiel #15
0
 /// <summary>
 /// Users the change PWD by id.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="pwd">The PWD.</param>
 /// <returns></returns>
 public bool ModifyPwdById(int id, string pwd, Sys_AdminUser operUser)
 {
     bool b = false;
     pwd = Miaow.Infrastructure.Crosscutting.Function.StringHelper.Tomd5(pwd);
     int res = ProcedureService.UserChangePwdById(id, pwd);
     if (res > 0)
     {
         b = true;
         var log = new Sys_AdminUserLog();
         log.AddTime = System.DateTime.Now;
         log.IpAddress = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetRealIP();
         log.PageUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetCurrentUrl();
         log.ReferrerUrl = Miaow.Infrastructure.Crosscutting.Function.StringHelper.GetReferrerUrl();
         log.State = true;
         log.TypeId = 1;
         if (operUser != null)
         {
             log.UserId = operUser.id;
             log.ShortMessage = "用户Id:" + operUser.id + " 改变用户Id号:" + id.ToString() + " 的密码";
             log.FullMessage = "UserChangePwdById 用户:" + operUser.username + " 用户Id:" + operUser.id.ToString()
                 + " 改变用户Id号:" + id.ToString() + " 的密码:" + pwd;
         }
         else
         {
             log.UserId = 0;
             log.ShortMessage = "用户Id号:" + id.ToString() + " 的密码被修改";
             log.FullMessage = "UserChangePwdById " + "用户Id号:" + id.ToString() + " 的密码被修改";
         }
     }
     return b;
 }