/// <summary>
 /// 用于向 Sys_UserRoles EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToSys_UserRoles(Sys_UserRoles sys_UserRoles)
 {
     base.AddObject("Sys_UserRoles", sys_UserRoles);
 }
 /// <summary>
 /// 创建新的 Sys_UserRoles 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="userID">UserID 属性的初始值。</param>
 /// <param name="roleID">RoleID 属性的初始值。</param>
 public static Sys_UserRoles CreateSys_UserRoles(global::System.Int32 id, global::System.Int32 userID, global::System.Int32 roleID)
 {
     Sys_UserRoles sys_UserRoles = new Sys_UserRoles();
     sys_UserRoles.Id = id;
     sys_UserRoles.UserID = userID;
     sys_UserRoles.RoleID = roleID;
     return sys_UserRoles;
 }
Beispiel #3
0
        public bool Add(IList<Sys_AdminUser> entity, Sys_UserRoles userRole, Sys_AdminUser operUser)
        {
            var res = false;
            if (entity != null && entity.Count > 0)
            {
                foreach (var item in entity)
                {
                    if (item != null && !ExistUserByName(item.username) && !ExistUserByEmail(item.Email))
                    {
                        try
                        {
                            #region admin user
                            InitAddUser(item, operUser);
                            adminUserRepository.Add(item);
                            adminUserRepository.Uow.Commit();
                            #endregion

                            #region user role
                            userRole.UserID = item.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:" + item.id;
                                log.FullMessage = "AddUser 用户名:" + operUser.username + " 用户Id:" + operUser.id.ToString()
                                    + " 添加用户Id:" + item.id + " 添加用户名:" + item.username + " 添加用户角色Id:" + userRole.RoleID;
                            }
                            else
                            {
                                log.UserId = 0;
                                log.ShortMessage = "用户名:" + item.username + "被添加";
                                log.FullMessage = "AddUser " + "用户名:" + item.username + "被添加";
                            }
                            Miaow.Infrastructure.Data.LoggerReopsitoryManager.AddLogInfo(log);
                        }
                        catch (Exception ex)
                        {
                            item.id = 0;
                        }
                    }
                }
            }
            return res;
        }