Esempio n. 1
0
        public void AddUser(EUser user)
        {
            using (var dmTrans = _rep.GetTransaction())
            {
                try
                {
                    var tran = dmTrans.BeginTransaction();
                    if (_rep.Get<EUser>(p => p.UserName == user.UserName) != null)
                    {
                        throw new ArgumentException("存在相同用户名!");
                    };
                    user.UserAvatar = "/Content/Images/noPic.jpg";
                    user.Password = user.Password.GetMD5By32();
                    user.LastLoginTime = DateTime.Now;

                    //添加用户
                    _rep.Add(user, tran);

                    dmTrans.Commit();
                }
                catch
                {
                    dmTrans.Rollback();
                    throw;
                }
            }
        }
Esempio n. 2
0
        private EUser RegisterMemberByOpenLogin(EUser user, int? deviceGpsTypeId, string deviceGpsNo, string deviceGpsSimNo, int? roleId)
        {
            using (var dmTrans = _rep.GetTransaction())
            {
                try
                {
                    var tran = dmTrans.BeginTransaction();

                    //添加用户
                    _rep.Add(user, tran);
                    if (roleId.HasValue)
                    {
                        //添加角色
                        _rep.Add(new EUserRole() { UserId = user.Id, RoleId = roleId.Value }, null, tran);
                    }

                    //添加车辆分组
                    var deviceGroup = new EDeviceGroup()
                    {
                        DeviceGroupName = "默认分组",
                        DeviceGroupOrderId = 0,
                        IsRoot = true,
                        UserId = user.Id
                    };
                    _rep.Add(deviceGroup, tran);

                    if (deviceGpsNo.HasValue() && deviceGpsSimNo.HasValue())
                    {
                        //添加设备
                        if (_deviceService.CheckDeviceGpsNoIsExist(deviceGpsNo))
                        {
                            throw new BusinessException("已经存在Gps设备号!");
                        }
                        if (_deviceService.CheckDeviceGpsSimNoIsExist(deviceGpsSimNo))
                        {
                            throw new BusinessException("已经存在Sim卡号!");
                        }

                        var device = new EDevice
                        {
                            UserId = user.Id,
                            DeviceName = deviceGpsNo,
                            DeviceGpsNo = deviceGpsNo,
                            DeviceGpsSimNo = deviceGpsSimNo,
                            DeviceGpsTypeId = deviceGpsTypeId,
                            DeviceTypeId = 1,
                            DeviceGroupId = deviceGroup.Id,
                            CreateTime = DateTime.Now,
                            NodeId = _nodeService.GetNodeIdByCreateTime(DateTime.Now),
                            DeviceGpsInstallTime = DateTime.Now,
                            DeviceExpireTime = DateTime.Now.AddYears(1)
                        };
                        device.DeviceGpsCode = _deviceService.GetDeviceGpsCode(device.DeviceGpsTypeId.Value, device.DeviceGpsNo, device.DeviceGpsSimNo);
                        _rep.Add(device, tran);
                        _rep.Add(new EAlarmSettingOverspeed() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                        _rep.Add(new EAlarmSettingInOutArea() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                        _rep.Add(new EAlarmSettingParkingNotStalled() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                        _rep.Add(new EAlarmSettingTired() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                        _rep.Add(new EAlarmSettingAutoFortify() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59), Radius = 50, ActivationTime = 10 }, tran);
                        _rep.Add(new EAlarmSettingMainPowerBreak() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                    }
                    dmTrans.Commit();
                    //更新车辆分组缓存
                    _cacheService.RemoveByKey(Cdev.Core.Gps.CacheKey.Gps_DeviceGroups_All);
                    return user;
                }
                catch
                {
                    dmTrans.Rollback();
                    throw;
                }
            }
        }
Esempio n. 3
0
        public void RegisterMember(string userName, int? deviceGpsTypeId, string deviceGpsNo, string deviceGpsSimNo, string password, int? roleId)
        {
            using (var dmTrans = _rep.GetTransaction())
            {
                try
                {
                    var tran = dmTrans.BeginTransaction();
                    var user = new EUser()
                    {
                        UserName = userName,
                        NickName = userName,
                        Password = password.GetMD5By32(),
                        UserAvatar = "/Content/Images/noPic.jpg",
                        LastLoginTime = DateTime.Now
                    };
                    if (_rep.Get<EUser>(p => p.UserName == user.UserName) != null)
                    {
                        throw new ArgumentException("存在相同用户名!");
                    };

                    //添加用户
                    _rep.Add(user, tran);
                    if (roleId.HasValue)
                    {
                        //添加角色
                        _rep.Add(new EUserRole() { UserId = user.Id, RoleId = roleId.Value }, null, tran);
                    }

                    //添加车辆分组
                    var deviceGroup = new EDeviceGroup()
                    {
                        DeviceGroupName = "默认分组",
                        DeviceGroupOrderId = 0,
                        IsRoot = true,
                        UserId = user.Id
                    };

                    _rep.Add(deviceGroup, tran);

                    if (deviceGpsNo.HasValue() && deviceGpsSimNo.HasValue())
                    {
                        //添加设备
                        if (_deviceService.CheckDeviceGpsNoIsExist(deviceGpsNo))
                        {
                            throw new BusinessException("已经存在Gps设备号!");
                        }
                        if (_deviceService.CheckDeviceGpsSimNoIsExist(deviceGpsSimNo))
                        {
                            throw new BusinessException("已经存在Sim卡号!");
                        }

                        var device = new EDevice
                        {
                            UserId = user.Id,
                            DeviceName = deviceGpsNo,
                            DeviceGpsNo = deviceGpsNo,
                            DeviceGpsSimNo = deviceGpsSimNo,
                            DeviceGpsTypeId = deviceGpsTypeId,
                            DeviceTypeId = 1,
                            DeviceGroupId = deviceGroup.Id,
                            CreateTime = DateTime.Now,
                            NodeId = _nodeService.GetNodeIdByCreateTime(DateTime.Now),
                            DeviceGpsInstallTime = DateTime.Now,
                            DeviceExpireTime = DateTime.Now.AddYears(5)
                        };
                        device.DeviceGpsCode = _deviceService.GetDeviceGpsCode(device.DeviceGpsTypeId.Value, device.DeviceGpsNo, device.DeviceGpsSimNo);
                        _rep.Add(device, tran);
                        _rep.Add(new EAlarmSettingOverspeed() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                        _rep.Add(new EAlarmSettingInOutArea() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                        _rep.Add(new EAlarmSettingParkingNotStalled() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                        _rep.Add(new EAlarmSettingTired() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                        _rep.Add(new EAlarmSettingAutoFortify() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59), Radius = 50, ActivationTime = 10 }, tran);
                        _rep.Add(new EAlarmSettingMainPowerBreak() { DeviceId = device.Id, ReceiveStartTime = new TimeSpan(0, 0, 0), ReceiveEndTime = new TimeSpan(23, 59, 59) }, tran);
                    }

                    dmTrans.Commit();
                    //更新车辆分组缓存
                    _cacheService.RemoveByKey(Cdev.Core.Gps.CacheKey.Gps_DeviceGroups_All);
                }
                catch
                {
                    dmTrans.Rollback();
                    throw;
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 编辑
 /// </summary>
 /// <returns></returns>
 public ActionResult EditMember(EUser user)
 {
     if (user.Id == 0)
     {
         CheckIsHaveMBPermission(47);
         _aUserService.AddMember(user, null, 1);//自动分配一个普通会员
         return JsonResult(user, "添加成功!");
     }
     else
     {
         CheckIsHaveMBPermission(48);
         _userService.SaveMember(user);
         return JsonResult(user, "保存成功!");
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 编辑
 /// </summary>
 /// <returns></returns>
 public ActionResult EditUser(EUser user)
 {
     if (user.Id == 0)
     {
         CheckIsHaveMBPermission(77);
         _aUserService.AddUser(user);
         return JsonResult(user, "添加成功!");
     }
     else
     {
         CheckIsHaveMBPermission(78);
         _userService.SaveUser(user);
         return JsonResult(user, "保存成功!");
     }
 }
Esempio n. 6
0
        private EPassport LoginByAppOpenId(EUser user)
        {
            if (user == null)
            {
                throw new NullReferenceException("不存在用户!");
            }

            if (user.UserStatus == EnumUserStatus.Forbid)
            {
                throw new NullReferenceException("当前用户已经被禁止登录!");
            }

            user.AppTicket = Guid.NewGuid().ToString();
            _rep.Save(user, p => p.Id == user.Id, p => new Columns(p.AppTicket));
            return new EPassport() { User = user };
        }
Esempio n. 7
0
        private void LoginByOpenLogin(EUser user)
        {
            if (user == null)
            {
                throw new NullReferenceException("不存在用户!");
            }

            if (user.UserStatus == EnumUserStatus.Forbid)
            {
                throw new NullReferenceException("当前用户已经被禁止登录!");
            }

            var passport = new EPassport();
            passport.User = user;
            passport.Roles = _userService.GetVUserRolesByUserId(user.Id);
            if (user.IsSuperAdmin)
            {
                passport.Menu = _menuService.GetMenuTree();
            }
            else
            {
                passport.Auths = _menuService.GetAllMenuAuthsByUserId(user.Id);
                passport.Menu = _menuService.GetMenuTreeByUserId(user.Id, passport.Auths);
            }

            //更新用户信息
            _rep.Save(new EUser() { LastLoginTime = DateTime.Now }, p => p.Id == user.Id, p => new Columns(p.LastLoginTime));

            _stateService.SavePassport(passport);
        }
Esempio n. 8
0
        public void AddMember(EUser user, int? parentUserId, int? roleId)
        {
            using (var dmTrans = _rep.GetTransaction())
            {
                try
                {
                    var tran = dmTrans.BeginTransaction();
                    if (_rep.Get<EUser>(p => p.UserName == user.UserName) != null)
                    {
                        throw new ArgumentException("存在相同用户名!");
                    };
                    user.UserAvatar = "/Content/Images/noPic.jpg";
                    user.Password = user.Password.GetMD5By32();
                    user.LastLoginTime = DateTime.Now;
                    user.ParentUserId = parentUserId;
                    //添加用户
                    _rep.Add(user, tran);

                    if (roleId.HasValue)
                    {
                        //添加角色
                        _rep.Add(new EUserRole() { UserId = user.Id, RoleId = roleId.Value }, null, tran);
                    }

                    dmTrans.Commit();
                }
                catch
                {
                    dmTrans.Rollback();
                    throw;
                }
            }
        }
Esempio n. 9
0
 /// <summary>
 /// 保存
 /// </summary>
 public void SaveMember(EUser user)
 {
     _rep.Save(user, p => p.Id == user.Id,
         p => new Columns(
             p.Address,
             p.Email,
             p.Fax,
             p.NickName,
             p.Mobile,
             p.QQ,
             p.Sex,
             p.UserStatus));
 }
Esempio n. 10
0
 /// <summary>
 /// 保存
 /// </summary>
 public void SaveUser(EUser user)
 {
     _rep.Save(user, p => p.Id == user.Id,
         p => new Columns(
             p.Address,
             p.Email,
             p.Fax,
             p.NickName,
             p.Mobile,
             p.QQ,
             p.Sex,
             p.UserStatus,
             p.ParentUserId,
             p.IsAdmin,
             p.IsSuperAdmin));
 }
Esempio n. 11
0
 /// <summary>
 /// 保存用户基本信息
 /// </summary>
 public EUser EditMyProfile(EUser user)
 {
     _rep.Save(user, p => p.Id == user.Id,
         p => new Columns(
             p.Address,
             p.Email,
             p.Fax,
             p.NickName,
             p.Mobile,
             p.QQ,
             p.Sex,
             p.UserAvatar));
     _cacheService.UpdateCacheDependent(CacheKey.Core_Auto_Complete_User);
     return _rep.Get<EUser>(p => p.Id == user.Id);
 }
Esempio n. 12
0
 /// <summary>
 /// 保存用户基本信息
 /// </summary>
 /// <returns></returns>
 public ActionResult EditMyProfile(EUser user)
 {
     _userService.EditMyProfile(user);
     return JsonResult(user, "保存成功!");
 }
Esempio n. 13
0
 public void RegisterMember(string userName, int deviceGpsTypeId, string deviceGpsNo, string deviceGpsSimNo, string password, int? roleId)
 {
     using (var dmTrans = _rep.GetTransaction())
     {
         try
         {
             var tran = dmTrans.BeginTransaction();
             var user = new EUser()
             {
                 UserName = userName,
                 NickName = userName,
                 Password = password.GetMD5By32(),
                 UserAvatar = "/Content/Images/noPic.jpg",
                 LastLoginTime = DateTime.Now
             };
             if (_rep.Get<EUser>(p => p.UserName == user.UserName) != null)
             {
                 throw new ArgumentException("存在相同用户名!");
             };
             if (roleId.HasValue)
             {
                 //添加角色
                 _rep.Add(new EUserRole() { UserId = user.Id, RoleId = roleId.Value }, null, tran);
             }
             //添加用户
             _rep.Add(user, tran);
             dmTrans.Commit();
         }
         catch
         {
             dmTrans.Rollback();
             throw;
         }
     }
 }
Esempio n. 14
0
        public EUser RegisterMemberByQQLogin(string openId, string accessToken, int expiresIn, string userAvatar, string nickName, EnumSex sex, int? deviceGpsTypeId, string deviceGpsNo, string deviceGpsSimNo, int? roleId)
        {
            var user = new EUser()
            {
                QQOpenId = openId,
                QQAccessToken = accessToken,
                QQExpiresIn = expiresIn,
                Sex = sex,
                IsCanSetUserName = true,
                UserName = "******".GetFormat(nickName, (int)sex, DateTime.Now.ToString("ssff")),
                Password = "******".GetMD5By32(),
                NickName = nickName,
                UserAvatar = userAvatar,
                LastLoginTime = DateTime.Now
            };

            return RegisterMemberByOpenLogin(user, deviceGpsTypeId, deviceGpsNo, deviceGpsSimNo, roleId);
        }
Esempio n. 15
0
 /// <summary>
 /// 编辑
 /// </summary>
 /// <returns></returns>
 public ActionResult EditMember(EUser user)
 {
     if (user.Id == 0)
     {
         _aUserService.AddMember(user, Passport.User.Id, 3); //自动分配一个运营商客户 角色
         return JsonResult(user, "添加成功!");
     }
     else
     {
         _userService.SaveMember(user);
         return JsonResult(user, "保存成功!");
     }
 }
Esempio n. 16
0
        public void AddUser(EUser user)
        {
            using (var dmTrans = _rep.GetTransaction())
            {
                try
                {
                    var tran = dmTrans.BeginTransaction();
                    if (_rep.Get<EUser>(p => p.UserName == user.UserName) != null)
                    {
                        throw new ArgumentException("存在相同用户名!");
                    };
                    user.UserAvatar = "/Content/Images/noPic.jpg";
                    user.Password = user.Password.GetMD5By32();
                    user.LastLoginTime = DateTime.Now;

                    //添加用户
                    _rep.Add(user, tran);

                    //添加车辆分组
                    _rep.Add(new EDeviceGroup() { DeviceGroupName = "默认分组", DeviceGroupOrderId = 0, IsRoot = true, UserId = user.Id }, tran);
                    dmTrans.Commit();
                    //更新车辆分组缓存
                    _cacheService.RemoveByKey(Cdev.Core.Gps.CacheKey.Gps_DeviceGroups_All);
                }
                catch
                {
                    dmTrans.Rollback();
                    throw;
                }
            }
        }
Esempio n. 17
0
 /// <summary>
 /// 保存
 /// </summary>
 public void SaveUser(EUser user)
 {
     _rep.Save(user, p => p.Id == user.Id, p => new Columns(p.Address, p.Email, p.Fax, p.LastLoginTime, p.NickName, p.Mobile, p.QQ, p.Sex, p.UserStatus, p.Amount, p.IsSuperAdmin, p.UserAvatar));
 }