/// <summary>
        /// 登录
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="Password">密码</param>
        /// <returns></returns>
        public AndroidData<RUserInfo> Login(PLogin param)
        {
            AndroidData<RUserInfo> data = new AndroidData<RUserInfo>();
            try
            {
                IUserService service = new UserService();
                PES.Guanaco.Entity.Permission.EUser user = service.GetUser(param.UserName, param.Password);

                //原方法
                //if (user != null)
                //{
                //    data.ResultData = CovnertToUserInfo(user);
                //    data.Ticket = EncryptHelper.Encrypt<Ticket>(new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord });
                //    data.ResultCode = ResultCodeEnum.Success;
                //}
                //else
                //{
                //    data.ResultCode = ResultCodeEnum.Fail;
                //    data.Message = "用户名或密码错误";
                //}

                data = IsInstallPermission(user);

            }
            catch (Exception ex)
            {
                data.ResultCode = ResultCodeEnum.Fail;
                data.Message = ex.Message;

                Logger.Error("Login" + ex.Message, ex);
            }

            return data;
        }
Exemple #2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="Password">密码</param>
        /// <returns></returns>
        public AndroidData<RUserInfo> Login(PLogin param)
        {
            AndroidData<RUserInfo> data = new AndroidData<RUserInfo>();
            try
            {
                UserService service = new UserService();
                EMUser user = service.GetUser(param.UserName, param.Password);

                if (user != null)
                {
                    data.ResultData = getReturnUserInfo(user);
                    data.Ticket = EncryptHelper.Encrypt<Ticket>(new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord });
                    data.ResultCode = (int)ResultCodeEnum.Success;
                }
                else
                {
                    data.ResultCode = (int)ResultCodeEnum.Fail;
                    data.Message = "用户名或密码错误";
                }

            }
            catch (Exception ex)
            {
                data.ResultCode = (int)ResultCodeEnum.Fail;
                data.Message = ex.Message;
                Logger.Error("[Login]" + ex.Message, ex);
            }
            return data;
        }
 public EMUserViewModel GetUser(string userCode)
 {
     try
     {
         UserService userService = new UserService();
         EMUser entity = userService.GetUser(userCode);
         return ConvertHelper.ConvertObj<EMUser, EMUserViewModel>(entity);
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         return null;
     }
 }
 private bool AnyUserInGroup(ulong id)
 {
     UserService userServ = new UserService();
     return userServ.AnyUserInGroup(id);
 }
Exemple #5
0
 public DBProcessResult UserInfoModify(string UserCode, string Password)
 {
     DBProcessResult result = new DBProcessResult();
     try
     {
         IUserService ser = new UserService();
         EMUser model = ser.GetUser(UserCode);
         if (Password != "")
             model.PassWord = Password;
         ser.Modify(model);
         result.IsSuccess = true;
     }
     catch (Exception ex)
     {
         result.IsSuccess = false;
         result.Message = ex.Message;
     }
     return result;
 }
 public ResultContent TransferUserGroup(List<EMUserViewModel> list)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         if (list != null && list.Count > 0)
         {
             foreach (EMUserViewModel model in list)
             {
                 EMUser entity =ConvertTo(model);
                 userService.Update(entity);
             }
             rc.Result = true;
             rc.Message = "转移成功,共计(" + list.Count + ")!";
         }
         else
         {
             rc.Result = false;
             rc.Message = "没有选中数据!";
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
        public ResultContent UpdateUser(UpdateUserViewModel userViewModel)
        {
            ResultContent rc = new ResultContent();
            try
            {
                IUserService userService = new UserService();

                EMUser newEntity = ConvertTo(userViewModel);
                userService.Update(newEntity);
                rc.Result = true;
                rc.Message = "修改成功!";
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                rc.Result = false;
                rc.Message = ex.Message;
            }
            return rc;
        }
 public ResultContent AddUserIncludeVehicle(EMUserGroupOrViewModel userViewModel)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         bool bl = userService.ExistsUser(userViewModel.UserName);
         if (bl)
         {
             rc.Result = false;
             rc.Message = "用户名已存在!";
         }
         else
         {
             IdentityNoService identityNoServ = new IdentityNoService();
             userViewModel.UserCode = identityNoServ.GetUserSerialNo();
             userViewModel.CreateTime = DateTime.Now;
             EMUser entity = ConvertTo(userViewModel);
             entity.Tenant = new EMTenant() { TenantCode = entity.TenantCode };
             userService.Add(entity);
             if (userViewModel.UserGroupID == null)
             {
                 var query = from f in userViewModel.VehicleCodeList select new EMVehicleOfUser { UserCode = entity.UserCode, VehicleCode = f };
                 List<EMVehicleOfUser> vosList = query.ToList();
                 IEMVehicleOfUserService vosSerive = new EMVehicleOfUserService();
                 vosSerive.Insert(vosList);
             }
             rc.Result = true;
             rc.Message = "添加成功!";
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
 public ResultContent DeleteUser(string userCode)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         userService.Delete(userCode);
         rc.Result = true;
         rc.Message = "删除成功!";
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
 public DBProcessResult DeleteOperate(string tenantCode)
 {
     DBProcessResult result = new DBProcessResult() { IsSuccess = false, Message = "删除失败!" };
     try
     {
         IEMTenantService tenantServ = new EMTenantService();
         IUserService userService = new UserService();
         IList<EMTenant> ltTenantAll = tenantServ.GetGrandChildren(tenantCode);
         if (ltTenantAll != null && ltTenantAll.Count > 0)
         {
             result.Message = "对不起,运营商下还存在子运营商或客户,不能删除!";
             result.IsSuccess = false;
         }
         else
         {
             EMTenant  emTenant = tenantServ.Select(tenantCode);
             if(emTenant != null)
             {
                 //EMUser emUser = userService.GetUser(emTenant.RegisterUserCode);
                 userService.Delete(emTenant.RegisterUserCode);//删除注册账号
                 tenantServ.Delete(emTenant);//删除运营商信息
                 result.Message = "删除成功!";
                 result.IsSuccess = true;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
     }
     return result;
 }
 /// <summary>
 /// 获取一下终端用户User信息 不含租户信息
 /// </summary>
 /// <param name="userCode"></param>
 /// <returns></returns>
 public EMUser GetUser(string userCode)
 {
     UserService service = new UserService();
     EMUser user = service.GetUser(userCode);
     return user;
 }
        /// <summary>
        /// 立即体验 登录
        /// </summary>
        /// <param name="ExperienceUserCode"></param>
        /// <returns></returns>
        public UserInfoViewModel ExperienceLogin(string ExperienceUserCode)
        {
            UserInfoViewModel viewModel = new UserInfoViewModel();
            try
            {
                UserService service = new UserService();
                //EMUser user = service.GetUserFullInfo(ExperienceUserCode);
                EMUser user = _LoginUserDAL.GetUserByUserCode(ExperienceUserCode);
                if (user != null)
                {
                    viewModel = ConvertToViewModel(user);

                    //租户类型
                    IEMTenantService tenantService = new EMTenantService();
                    EMTenant tenant = user.Tenant;
                    if (tenant == null)
                    {
                        viewModel.Msg = "error|体验帐户异常,体验帐户对应的租户类型记录不存在,请与平台方联系";
                        return viewModel;
                    }
                    viewModel.TenantType = (int)tenant.TenantType;
                    viewModel.OperatorLevel = tenant.OperatorLevel;
                    if (!string.IsNullOrEmpty(tenant.LogoUrl))
                    {
                        viewModel.TenantLogoImgURl = tenant.LogoUrl;
                    }

                    if (tenant.TenantType != EnumTenantType.PlatProvider)
                    {
                        EMTenant superTenant = tenantService.Select(tenant.SuperTenantID);
                        if (tenant.TenantType == EnumTenantType.EndCustomer)
                        {
                            viewModel.TenantLogoImgURl = superTenant.LogoUrl;
                        }

                        viewModel.SuperContactNumber = superTenant.PhoneNumber;
                        viewModel.SuperTenantName = superTenant.TenantName;
                        ////是否过期
                        //if (tenant.TenantType == EnumTenantType.OperatingMerchant && tenant.ExpireTime.HasValue && DateTime.Now > tenant.ExpireTime.Value)
                        //{
                        //    viewModel.Msg = "error|体验帐户已过有效期,请与MOVO客服联系\n\r联系电话:" + superTenant.PhoneNumber;
                        //    return viewModel;
                        //}
                        ////是否冻结
                        //else if (tenant.IsFreeze)
                        //{
                        //    switch (tenant.TenantType)
                        //    {
                        //        case EnumTenantType.EndCustomer:
                        //            viewModel.Msg = "error|您的账号已被冻结,请与您的设备服务提供商联系!\n\r联系电话:" + superTenant.PhoneNumber;
                        //            break;
                        //        case EnumTenantType.OperatingMerchant:
                        //            viewModel.Msg = "error|您的账号已被冻结,请与MOVO客服联系。\n\r联系电话:" + superTenant.PhoneNumber;
                        //            break;
                        //    }
                        //    return viewModel;
                        //}
                    }

                    switch (viewModel.TenantType)
                    {
                        case 1://平台商
                            EMTenant firstCustomer = tenantService.SelectLastChildEndCustomer("");
                            if (firstCustomer != null)
                            {
                                EMUser firstUser = service.GetUser(firstCustomer.RegisterUserCode);
                                if (firstUser != null)
                                {
                                    viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                                    viewModel.SelectedUser.UserCode = firstUser.UserCode;
                                    viewModel.SelectedUser.UserName = firstUser.UserName;
                                    viewModel.SelectedUser.TenantCode = firstCustomer.TenantCode;
                                    viewModel.SelectedUser.TenantName = firstCustomer.TenantName;
                                    if (!string.IsNullOrEmpty(firstCustomer.SuperTenantID))
                                    {
                                        EMTenant super = this.GetTenant(firstCustomer.SuperTenantID);
                                        if (super != null)
                                        {
                                            viewModel.SelectedUser.SuperTenantCode = super.TenantCode;
                                            viewModel.SelectedUser.SuperTenantName = super.TenantName;
                                        }
                                    }
                                }
                            }
                            break;
                        case 2://运营商
                            EMTenant firstChildEndCustomer = tenantService.SelectLastChildEndCustomer(viewModel.TenantCode);
                            if (firstChildEndCustomer != null)
                            {
                                EMUser firstUser = service.GetUser(firstChildEndCustomer.RegisterUserCode);
                                if (firstUser != null)
                                {
                                    viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                                    viewModel.SelectedUser.UserCode = firstUser.UserCode;
                                    viewModel.SelectedUser.UserName = firstUser.UserName;
                                    viewModel.SelectedUser.TenantCode = firstChildEndCustomer.TenantCode;
                                    viewModel.SelectedUser.TenantName = firstChildEndCustomer.TenantName;
                                    viewModel.SelectedUser.SuperTenantCode = viewModel.TenantCode;
                                    viewModel.SelectedUser.SuperTenantName = viewModel.TenantName;
                                }
                            }

                            break;
                        case 3://终端客户
                            viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                            viewModel.SelectedUser.UserCode = viewModel.UserCode;
                            viewModel.SelectedUser.UserName = viewModel.UserName;
                            viewModel.SelectedUser.TenantCode = viewModel.TenantCode;
                            viewModel.SelectedUser.TenantName = viewModel.TenantName;
                            viewModel.SelectedUser.SuperTenantCode = user.Tenant.SuperTenantID;
                            viewModel.SelectedUser.SuperTenantName = viewModel.SuperTenantName;
                            break;

                    }
                    if (string.IsNullOrEmpty(viewModel.TenantLogoImgURl))
                    {
                        viewModel.TenantLogoImgURl = UploadImageHelper.TenantImgUrl;
                    }

                    //获取地图类型
                    /*PositioningWCFService mapTypeService = new PositioningWCFService();
                    List<MapTypeViewModel> listMapType = mapTypeService.GetMapType();
                    viewModel.MapTypes = listMapType;*/

                    //令牌环
                    Ticket ticket = new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord };
                    string token = EncryptUtil.Encrypt<Ticket>(ticket);
                    viewModel.Token = token;

#if !DEBUG
                        user.LastLoginTime = DateTime.Now;
                        service.Update(user);
#endif

                }
                else
                {
                    viewModel.Msg = "error|体验帐号不存在,请联系系统管理员";
                }
            }
            catch (Exception ex)
            {
                viewModel.Msg = "error|体验帐号登录时,发生未处理错误,请联系系统管理员";
                Logger.Error("[Login]" + ex.Message, ex);
            }
            viewModel.IsExperienceLogin = true;
            return viewModel;
        }
Exemple #13
0
        private UserInfoViewModel GetUserInfoViewModel(string userName, string pwd, string sessionId, UserInfoViewModel viewModel)
        {
            IUserService service = new UserService();
            EMUser user = service.GetUser(userName, pwd);
            if (user != null)
            {
                viewModel = ConvertToViewModel(user);

                //租户类型
                IEMTenantService tenantService = new EMTenantService();
                EMTenant tenant = tenantService.Select(user.TenantCode);
                viewModel.TenantType = (int)tenant.TenantType;
                viewModel.OperatorLevel = tenant.OperatorLevel;
                if (!string.IsNullOrEmpty(tenant.LogoUrl))
                    viewModel.TenantLogoImgURl = tenant.LogoUrl;
                else
                    viewModel.TenantLogoImgURl = UploadImageHelper.TenantImgUrl;
                if (tenant.TenantType != EnumTenantType.PlatProvider)
                {
                    EMTenant superTenant = tenantService.Select(tenant.SuperTenantID);

                    viewModel.SuperContactNumber = superTenant.PhoneNumber;
                    viewModel.SuperTenantName = superTenant.TenantName;
                    
                    if (tenant.TenantType == EnumTenantType.EndCustomer)
                    {
                            viewModel.TenantLogoImgURl = superTenant.LogoUrl;
                    }
                    if (tenant.TenantType == EnumTenantType.OperatingMerchant && tenant.ExpireTime.HasValue && DateTime.Now > tenant.ExpireTime.Value)
                    {
                        viewModel.Msg = "您的账号已过有效期,请与MOVO客服联系\n\r联系电话:" + superTenant.PhoneNumber;
                        viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                        return viewModel;
                    }
                    else if (tenant.IsFreeze)
                    {
                        switch (tenant.TenantType)
                        {
                            case EnumTenantType.EndCustomer:
                                viewModel.Msg = "您的账号已被冻结,请与您的设备服务提供商联系!\n\r联系电话:" + superTenant.PhoneNumber;
                                break;
                            case EnumTenantType.OperatingMerchant:
                                viewModel.Msg = "您的账号已被冻结,请与MOVO客服联系。\n\r联系电话:" + superTenant.PhoneNumber;
                                break;
                        }
                        viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                        return viewModel;
                    }
                }

                //获取地图类型
                PositioningWCFService mapTypeService = new PositioningWCFService();
                List<MapTypeViewModel> listMapType = mapTypeService.GetMapType();
                viewModel.MapTypes = listMapType;

                //令牌环
                Ticket ticket = new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord };
                string token = EncryptUtil.Encrypt<Ticket>(ticket);
                viewModel.Token = token;

#if !DEBUG
                        user.LastLoginTime = DateTime.Now;
                        service.Update(user);
#endif

            }
            else
            {
                viewModel.Msg = "用户名或密码错误";
                viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
            }
            return viewModel;
        }
Exemple #14
0
        public CommandResultViewModel UserReg(string userName, string pwd, string email, string QQ, string companyName)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                IUserService serv = new UserService();
                bool isExists = serv.ExistsUser(userName);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("用户名" + userName + "已经存在,请重新输入!");
                    return vm;
                }

                IEMTenantService tenantServ = new EMTenantService();
                var tempTenant = tenantServ.SelectByName(companyName);
                if (tempTenant != null)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("姓名/公司名" + companyName + "已经存在,请重新输入!");
                    return vm;
                }
                
                IdentityNoService identityNoServ = new IdentityNoService();
                string tenantCode = identityNoServ.GetTenantSerialNo();
                EMTenant tenant = GetTenant(tenantCode,email,QQ,companyName,userName);
                EMUserGroup userGroup = GetEMUserGroup(identityNoServ, tenantCode);
                EMVehicleGroup vehicleGroup = GetEMVehicleGroup(identityNoServ,userName, tenantCode);
                EMUser user = GetEMUser(identityNoServ,userName, pwd, email,QQ, tenant, userGroup);
                IBaseService baseServ = new BaseService();
                tenant.RegisterUserCode = user.UserCode;
                baseServ.Add<EMTenant>(tenant);
                baseServ.Add<EMUserGroup>(userGroup);
                baseServ.Add<EMVehicleGroup>(vehicleGroup);
                baseServ.Add<EMUser>(user);

                vm.CommandResult = EnumCommandResult.Success;
                return vm;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
                return vm;
            }
        }
Exemple #15
0
 public UserInfoViewModel GetUser(string userCode)
 {
     IUserService ser = new UserService();
     EMUser model = ser.GetUser(userCode);
     UserInfoViewModel returnModel = new UserInfoViewModel();
     if (model != null)
         returnModel = ConvertToViewModel(model);
     return returnModel;
 }
 public UserInfoModifyViewModel GetUserAndTenant(string userCode)
 {
     try
     {
         UserInfoModifyViewModel model = null;
         IUserService userService = new UserService();
         EMUser entity = userService.GetUser(userCode);
         IEMTenantService tenantService = new EMTenantService();
         if (entity != null)
         {
             EMTenant tenant = tenantService.Select(entity.TenantCode);
             model = new UserInfoModifyViewModel()
             {
                 UserCode = entity.UserCode,
                 UserName = entity.UserName,
                 TenantCode = entity.TenantCode,
                 Email = tenant.Email,
                 QQ = tenant.QQ,
                 Password = entity.PassWord,
                 IsRegisterUser = entity.IsRegisterUser
             };
             return model;
         }
         return model;
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         return null;
     }
 }
 public DBProcessResult UserAndTenantModify(UserInfoModifyViewModel userViewModel)
 {
     DBProcessResult result = new DBProcessResult();
     try
     {
         IUserService userService = new UserService();
         IEMTenantService tenantService = new EMTenantService();
         if (!string.IsNullOrEmpty(userViewModel.Pwd))
         {
            EMUser user =  userService.GetUser(userViewModel.UserCode);
            user.PassWord = userViewModel.Pwd;
            userService.Update(user);
         }
         EMTenant tenant = tenantService.Select(userViewModel.TenantCode);
         tenant.Email = userViewModel.Email;
         tenant.QQ = userViewModel.QQ;
         tenantService.Update(tenant);
         result.Message = "修改成功!";
         result.IsSuccess = true;
     }
     catch (Exception ex)
     {
         result.IsSuccess = false;
         result.Message = ex.Message;
     }
     return result;
 }
 public DBProcessResult DeleteCustomer(string tenantCode)
 {
     DBProcessResult result = new DBProcessResult() { IsSuccess = false, Message = "删除失败!" };
     try
     {
         EMTenantService tenantServ = new EMTenantService();
         UserService userService = new UserService();
         EMVehicleService vehicleServ = new EMVehicleService();
         IList<EMVehicle> ltEMVehicle = vehicleServ.SelectAll(tenantCode);
         if (ltEMVehicle != null && ltEMVehicle.Count > 0)
         {
             result.Message = "对不起,客户下还存在车辆,不能删除!";
             result.IsSuccess = false;
         }
         else
         {
             EMTenant emTenant = tenantServ.Select(tenantCode);
             if (emTenant != null)
             {
                 //EMUser emUser = userService.GetUser(emTenant.RegisterUserCode);
                 userService.Delete(emTenant.RegisterUserCode);//删除注册账号
                 tenantServ.Delete(emTenant);//删除运营商信息
                 result.Message = "删除成功!";
                 result.IsSuccess = true;
             }
             
             //tenantServ.Delete(tenantCode);
             //result.Message = "删除成功!";
             //result.IsSuccess = true;
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
     }
     return result;
 }
 public ResultContent AddUser(EMUserViewModel userViewModel)
 {
     ResultContent rc = new ResultContent();
     try
     {
         IUserService userService = new UserService();
         bool bl = userService.ExistsUser(userViewModel.UserName);
         if (bl)
         {
             rc.Result = false;
             rc.Message = "用户名已存在!";
         }
         else
         {
             IdentityNoService identityNoServ = new IdentityNoService();
             userViewModel.UserCode = identityNoServ.GetUserSerialNo();
             userViewModel.CreateTime = DateTime.Now;
             EMUser entity = ConvertHelper.ConvertObj<EMUserViewModel, EMUser>(userViewModel);
             entity.Tenant = new EMTenant() { TenantCode = userViewModel.TenantCode };
             userService.Add(entity);
             rc.Result = true;
             rc.Message = "添加成功!";
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         rc.Result = false;
         rc.Message = ex.Message;
     }
     return rc;
 }
        public CommandResultViewModel AddCustomer(CustomerInfoVM customerVM)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                UserService serv = new UserService();
                bool isExists = serv.ExistsUser(customerVM.UserInfo.UserName);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("用户名" + customerVM.UserInfo.UserName + "已经存在,请重新输入!");
                    return vm;
                }
                EMTenantService tenantServ = new EMTenantService();
                var tempTenant = tenantServ.SelectByName(customerVM.Tenant.TenantName);
                if (tempTenant != null)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("客户名称" + customerVM.Tenant.TenantName + "已经存在,请重新输入!");
                    return vm;
                }

                IdentityNoService identityNoServ = new IdentityNoService();
                string tenantCode = identityNoServ.GetTenantSerialNo();
                EMTenant tenant = GetEMTenant(tenantCode,customerVM.Tenant);
                EMUserGroup userGroup = GetEMUserGroup(identityNoServ, tenantCode,customerVM.UserInfo);
                EMVehicleGroup vehicleGroup = GetEMVehicleGroup(identityNoServ, customerVM.UserInfo.UserName, tenantCode);
                EMUser user = GetEMUser(identityNoServ, customerVM.UserInfo, tenant, userGroup);
                IBaseService baseServ = new BaseService();
                tenant.RegisterUserCode = user.UserCode;
                tenant.RegisterUserName = user.UserName;
                baseServ.Add<EMTenant>(tenant);
                baseServ.Add<EMUserGroup>(userGroup);
                baseServ.Add<EMVehicleGroup>(vehicleGroup);
                baseServ.Add<EMUser>(user);

                vm.CommandResult = EnumCommandResult.Success;
                vm.Msg = "新增用户成功!";
                return vm;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
                return vm;
            }
        }
 public EMUserInfoViewModel GetUserListViewModel(string userName, string userGroupID, string tenantCode, int pageIndex, int pageSize)
 {
     try
     {
         MUserGroupService iMUserGroup = new MUserGroupService();
         UserService userService = new UserService();
         int rowCount = 0;
         IList<EMUser> userList = userService.GetUserList(userName, userGroupID, tenantCode, pageIndex, pageSize, ref rowCount);
         EMUserInfoViewModel userInfo = new EMUserInfoViewModel();
         if (userList != null && userList.Count > 0 && rowCount > 0)
         {
             userInfo = new EMUserInfoViewModel();
             List<EMUserListViewModel> list = new List<EMUserListViewModel>();
             for (int i = 0; i < userList.Count; i++)
             {
                 EMUser entity = userList[i];
                 EMUserListViewModel model = new EMUserListViewModel();
                 model = new EMUserListViewModel();
                 model.Index = i + 1;
                 model.UserCode = entity.UserCode;
                 model.UserName = entity.UserName;
                 model.IsRegisterUser = entity.IsRegisterUser;
                 model.PassWord = entity.PassWord;
                 model.RealName = entity.RealName;
                 model.Mobile = entity.Mobile;
                 model.TenantCode = entity.TenantCode;
                 if (entity.UserGroupID != null)
                 {
                     EMUserGroup userGroup = iMUserGroup.Get(entity.UserGroupID);
                     if (userGroup != null)
                     {
                         model.UserGroupID = userGroup.UserGroupID;
                         model.UserGroupName = userGroup.UserGroupName;
                     }
                 }
                 if (entity.LastLoginTime.ToString() == DateTime.MinValue.ToString())
                     model.LastLoginTime = null;
                 else
                     model.LastLoginTime = entity.LastLoginTime;
                 if (entity.CreateTime.ToString() == DateTime.MinValue.ToString())
                     model.CreateTime = DateTime.MaxValue;
                 else
                     model.CreateTime = entity.CreateTime;
                 list.Add(model);
             }
             userInfo.userListViewModel = list;
             userInfo.RowCount = rowCount;
         }
         return userInfo;
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         return null;
     }
 }
 public bool ResetPwd(string userCode, string newPwd)
 {
     try
     {
         UserService serv = new UserService();
         serv.ResetPwd(userCode, newPwd);
         return true;
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         return false;
     }
 }
        public ResultContent UpdateUserIncludeVehicle(EMUserGroupOrViewModel userViewModel)
        {
            ResultContent rc = new ResultContent();
            try
            {
                IUserService userService = new UserService();

                EMUser newEntity = ConvertTo(userViewModel);
                EMUser oldEntity = userService.GetUser(newEntity.UserCode);
                newEntity.CreateTime = oldEntity.CreateTime;
                userService.Update(newEntity);
                IEMVehicleOfUserService vosSerive = new EMVehicleOfUserService();
                //先删除再添加
                vosSerive.Delete(newEntity.UserCode);
                if (userViewModel.UserGroupID == null)
                {
                    var query = from f in userViewModel.VehicleCodeList select new EMVehicleOfUser { UserCode = newEntity.UserCode, VehicleCode = f };
                    List<EMVehicleOfUser> vosList = query.ToList();
                    vosSerive.Insert(vosList);
                }
                rc.Result = true;
                rc.Message = "修改成功!";
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                rc.Result = false;
                rc.Message = ex.Message;
            }
            return rc;
        }
        public CommandResultViewModel UpdateTenantInfo(TenantViewModel tenantVM)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                IEMTenantService tenantServ = new EMTenantService();
                var isExists = tenantServ.IsExists(tenantVM.TenantName, tenantVM.TenantCode);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("客户名称" + tenantVM.TenantName + "已经存在,请重新输入!");
                    return vm;
                }

                EMTenant newTenant = ConvertHelper.ConvertObj<TenantViewModel, EMTenant>(tenantVM);
                tenantServ.UpdateTenant(newTenant);
                IUserService serv = new UserService();
                serv.Update(newTenant.RegisterUserCode, tenantVM.PhoneNumber);

                vm.CommandResult = EnumCommandResult.Success;
                vm.Msg = "修改成功";
                return vm;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
                return vm;
            }
        }
 private EMUser ConvertTo(EMUserViewModel entity)
 {
     EMUser model = null;
     if (entity != null)
     {
         IUserService userService = new UserService();
         EMUser eMUser = userService.GetUser(entity.UserCode);
         model = new EMUser();
         model.UserCode = entity.UserCode;
         model.UserName = entity.UserName;
         model.IsRegisterUser = entity.IsRegisterUser;
         model.PassWord = entity.PassWord;
         model.RealName = entity.RealName;
         model.Mobile = entity.Mobile;
         model.Tenant = new EMTenant() { TenantCode = entity.TenantCode };
         model.LastLoginTime = entity.LastLoginTime;
         if (eMUser != null)
             model.CreateTime = eMUser.CreateTime;
         model.UserGroupID = entity.UserGroupID;
     }
     return model;
 }
Exemple #26
0
        public UserInfoViewModel AutoLogin(string userCode)
        {
            UserInfoViewModel viewModel = new UserInfoViewModel();
            try
            {
                IUserService service = new UserService();
                EMUser user = service.GetUserFullInfo(userCode);
                if (user != null)
                {
                    viewModel = ConvertToViewModel(user);

                    //租户类型
                    IEMTenantService tenantService = new EMTenantService();
                    EMTenant tenant = tenantService.Select(user.TenantCode);
                    viewModel.TenantType = (int)tenant.TenantType;
                    viewModel.TenantLogoImgURl = tenant.LogoUrl;
                    if (tenant.TenantType != EnumTenantType.PlatProvider)
                    {
                        EMTenant superTenant = tenantService.Select(tenant.SuperTenantID);
                        viewModel.SuperContactNumber = superTenant.PhoneNumber;
                        viewModel.SuperTenantName = superTenant.TenantName;
                        viewModel.TenantLogoImgURl = superTenant.LogoUrl;
                    }

                    //获取地图类型
                    PositioningWCFService mapTypeService = new PositioningWCFService();
                    List<MapTypeViewModel> listMapType = mapTypeService.GetMapType();
                    viewModel.MapTypes = listMapType;

                    //令牌环
                    Ticket ticket = new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord };
                    string token = EncryptUtil.Encrypt<Ticket>(ticket);
                    viewModel.Token = token;
                }
                else
                {
                    viewModel.Msg = "未找到记录,UserCode:+" + userCode;
                } return viewModel;
            }
            catch (Exception ex)
            {
                viewModel.Msg = "发生未处理错误,请联系系统管理员";
                Logger.Error(ex.Message);
                return viewModel;
            }
        }