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 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 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 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; } }
/// <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; }
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; }