public ActionResult getFunctions() { //1.0获取用户id int uid = UserMgr.GetCurrentUserInfo().uID; //2.0获取从前台传入的当前页面url string url = Request.Form["murl"]; //3.0根据url从单钱用户的权限按钮缓存数据中获取指定的按钮 var allFunctionsFromCache = _permissSer.GetFunctionsForUserByCache(uid); //3.0.1从allFunctionsFromCache集合中获取指定的url对应的按钮数据 var functions = allFunctionsFromCache.Where(c => c.mUrl.ToLower() == url.ToLower()); //4.0遍历functions拼接成ligerUIGrid中toolbar要求的json格式字符串 System.Text.StringBuilder resJson = new System.Text.StringBuilder("[", 200); if (functions.Any()) { foreach (var item in functions) { // { text: '增加', click: add, icon: 'add' }, resJson.Append("{ \"text\": \"" + item.fName + "\", \"click\": \"" + item.fFunction + "\", \"icon\": \"" + item.fPicName + "\" }, { \"line\": \"true\" },"); } //将最后一个逗号移除 if (resJson.Length > 1) { resJson.Remove(resJson.Length - 1, 1); } } resJson.Append("]"); var str = resJson.ToString(); return(Content(str)); }
public ActionResult SetMessage() { //1.0 接收ajax发送过来的数据 string touserid = Request.Params["touserid"]; string torealname = Request.Params["torealname"]; string msgbody = Request.Params["msgbody"]; //2.0 参数合法性验证 ChatMsg msg = new ChatMsg() { ToUserId = int.Parse(touserid), ToRealName = torealname, FromRealName = UserMgr.GetCurrentUserInfo().uRealName , FromUserId = UserMgr.GetCurrentUserInfo().uID, SendTime = DateTime.Now, MessageBody = msgbody }; //3.0包装成chatmsg对象发送给WCF聊天服务 ChatMgrClient c = new ChatMgrClient(); c.SetMessage(msg); return(WriteSuccess("消息发送成功")); }
public ActionResult add(int id, sysFunctionView model) { try { if (ModelState.IsValid == false) { return(WriteError("数据验证失败")); } //2.0 将model中的Mid补全 model.mID = id; model.fCreateTime = DateTime.Now; model.fUpdateTime = DateTime.Now; model.fCreatorID = UserMgr.GetCurrentUserInfo().uID; var entity = model.EntityMap(); funSer.Add(entity); funSer.SaveChanges(); return(WriteSucess("新增成功")); } catch (Exception ex) { return(WriteError(ex)); } }
public async Task <IActionResult> UserRegistration(User user) { if (ModelState.IsValid) { var newUser = new User { FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, UserName = user.UserName, Password = user.Password }; var result = await UserMgr.CreateAsync(newUser, user.Password); if (result.Succeeded) { await SignInMgr.SignInAsync(newUser, isPersistent : false); return(RedirectToAction("Dashboard", "Application")); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View(user)); }
/// <summary> /// 删除购物车中指定套餐中的某商品 /// </summary> /// <note>Request Param: /// PackageSysNo-套餐编号 /// ProductSysNo-商品编号 /// </note> /// <returns></returns> public PartialViewResult DelPackageProduct() { #region 1.Check string checkResultMessage = ""; int packageSysNo = 0; int productSysNo = 0; if (!int.TryParse(Request.Params["PackageSysNo"], out packageSysNo)) { checkResultMessage = "请输入正确的套餐编号!"; } else if (!int.TryParse(Request.Params["ProductSysNo"], out productSysNo)) { checkResultMessage = "请输入正确的商品编号!"; } string PackageTypeSingleList = Request.QueryString["PackageTypeSingle"]; string PackageTypeGroupList = Request.QueryString["PackageTypeGroup"]; #endregion #region 2.删除套餐中的商品 ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); ShoppingCart newShoppingCart = ShoppingStorageManager.GetShoppingCartFromCreateNew(); if (string.IsNullOrWhiteSpace(checkResultMessage)) { //删除套餐中的商品 newShoppingCart = DelPackageProductCalcShoppingCart(shoppingCart, packageSysNo, productSysNo); } //用于计算会员价: LoginUser userInfo = UserMgr.ReadUserInfo(); newShoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo; #endregion return(LoadShoppingCartData(newShoppingCart, checkResultMessage, PackageTypeSingleList, PackageTypeGroupList)); }
/// <summary> /// 获取客户端 /// </summary> /// <param name="name"></param> /// <returns></returns> public List <SocketClient.SocketClient> GetClients(string name) { var user = UserMgr.GetUserByName(name); var client = SocketClientMgr.Instance.GetClient(user.SessionId); return(client); }
public async Task <IActionResult> ResetPassword(ResetPasswordViewModel model) { Console.WriteLine(model.Email); Console.WriteLine(model.Token); if (ModelState.IsValid) { var user = await UserMgr.FindByEmailAsync(model.Email); if (user != null) { var result = await UserMgr.ResetPasswordAsync(user, model.Token, model.Password); if (result.Succeeded) { return(View("ResetPasswordConfirmation")); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } return(View(model)); } return(View("ResetPasswordConfirmation")); } return(View(model)); }
/// <summary> /// Mini购物车获取商品数量 /// </summary> /// <returns></returns> public JsonResult GetMiniShoppingCartCount() { LoginUser userInfo = UserMgr.ReadUserInfo(); int userSysNo = userInfo == null ? 0 : userInfo.UserSysNo; int totalProductCount = 0; //ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartByCustomer(userSysNo); if (shoppingCart == null) { shoppingCart = new ShoppingCart(); } if (shoppingCart != null && shoppingCart.ShoppingItemGroupList != null) { foreach (var itemGroup in shoppingCart.ShoppingItemGroupList) { foreach (var item in itemGroup.ShoppingItemList) { totalProductCount += itemGroup.Quantity * item.UnitQuantity; } } } //ShoppingStorageManager.SaveShoppingCart(shoppingCart); //将迷你购物车加入Cookie OrderPipelineProcessResult shoppingResult = ShoppingFacade.BuildShoppingCart(shoppingCart); ShoppingStorageManager.SaveShoppingCartMini(ShoppingFacade.BuildMiniShoppingCartFromPipeline(shoppingResult)); return(new JsonResult() { Data = totalProductCount }); }
public void NotifyInDisConnectClient(ServerPacketData requestData) { var sessionIndex = requestData.SessionIndex; var user = UserMgr.GetUser(sessionIndex); if (user != null) { var roomNum = user.RoomNumber; if (roomNum != PacketDef.INVALID_ROOM_NUMBER) { var packet = new PKTInternalNtfRoomLeave() { RoomNumber = roomNum, UserID = user.ID(), }; var packetBodyData = MessagePackSerializer.Serialize(packet); var internalPacket = new ServerPacketData(); internalPacket.Assign("", sessionIndex, (Int16)PACKETID.NTF_IN_ROOM_LEAVE, packetBodyData); ServerNetwork.Distribute(internalPacket); } UserMgr.RemoveUser(sessionIndex); } MainServer.MainLogger.Debug($"Current Connected Session Count: {ServerNetwork.SessionCount}"); }
public async Task <IActionResult> ConfirmEmail(string userId, string token) { if (userId == null || token == null) { return(RedirectToAction("Index", "Home")); } var user = await UserMgr.FindByIdAsync(userId); if (user == null) { ViewBag.ErrorMessage = $"O Id de usuário {userId} é inválido"; return(View("Error")); } var result = await UserMgr.ConfirmEmailAsync(user, token); if (result.Succeeded) { ViewBag.Message = "Email confirmado com sucesso!"; return(View("Messages")); } ViewBag.ErrorMessage = "Email não pôde ser confirmado :("; return(View("Error")); }
// // GET: /Web/Home/ public ActionResult Logout() { UserMgr.Logout(); string url = PageHelper.BuildUrl("Web_Index"); return(Redirect(url)); }
private IEnumerable <Models.ViewModel.DoctorStationInfo> GetDoctorStationInfo(int doctorId, int rootStationId) { var doc = _db.vwCHIS_Code_Doctor.AsNoTracking().FirstOrDefault(m => m.DoctorId == doctorId); var cus = _db.CHIS_Code_Customer.AsNoTracking().FirstOrDefault(m => m.CustomerID == doc.CustomerId); var dep = _db.vwCHIS_Code_Rel_DoctorDeparts.AsNoTracking().Where(m => m.DoctorId == doc.DoctorId).OrderBy(m => m.StationID).ToList(); var stationRoles = _db.CHIS_Sys_Rel_DoctorStationRoles.AsNoTracking().Where(m => m.DoctorId == doc.DoctorId).OrderBy(m => m.StationId).ToList(); var roleids = stationRoles.Select(m => m.RoleId.Value).Distinct().ToList(); var roles = _db.CHIS_SYS_Role.AsNoTracking().Where(m => roleids.Contains(m.RoleID)).Select(m => new RoleItem { RoleId = m.RoleID, RoleKey = m.RoleKey, RoleName = m.RoleName }).ToList(); var allowStations = UserMgr.GetAllowedStationsAndSubStationsQuery(_db, doctorId, rootStationId).ToList(); var stationids = stationRoles.Where(m => m.MyStationIsEnable == true).Select(m => m.StationId.Value).Distinct().ToList(); // stationids.AddRange(stationRoles.Select(m => m.StationId.Value).Distinct()); stationids = (from item in stationids.Distinct() where allowStations.Contains(item) select item).ToList(); var stations = _db.CHIS_Code_WorkStation.AsNoTracking().Where(m => stationids.Contains(m.StationID)).ToList(); var model = new Models.ViewModel.DoctorInfo { Doctor = doc, Customer = cus }; model.InitialStationInfo(dep, stationRoles, roles, stations); return(model.StationInfos); }
//public async Task<IActionResult> Register(string firstName, string lastName, string username, string password, string email) public async Task <IActionResult> Register(RegisterInfo registerInfo) { IdentityResult result; try { AppUser user = await UserMgr.FindByNameAsync(registerInfo.UserName); if (user == null) { user = new AppUser { UserName = registerInfo.UserName, Email = registerInfo.Email, FirstName = registerInfo.FirstName, LastName = registerInfo.LastName }; result = await UserMgr.CreateAsync(user, registerInfo.Password); } } catch (Exception ex) { ViewBag.Message = ex.Message; } return(RedirectToAction("Login", "Account")); }
public ActionResult AjaxLogin() { var model = new LoginVM(); this.TryUpdateModel <LoginVM>(model); //判断是否需要输入验证码 bool showAuthCode = LoginFacade.CheckShowAuthCode(model.CustomerID); if (showAuthCode) { string verifyCode = CookieHelper.GetCookie <String>("VerifyCode"); if (!String.Equals(verifyCode, model.ValidatedCode, StringComparison.InvariantCultureIgnoreCase)) { return(Json(new { type = "f", verifycode = "y", message = "验证码不正确" }, JsonRequestBehavior.AllowGet)); } } if (UserMgr.Login(model)) { return(Json(new { type = "s" }, JsonRequestBehavior.AllowGet)); } if (showAuthCode) { return(Json(new { type = "f", verifycode = "y", message = "登录账户名或密码不正确" }, JsonRequestBehavior.AllowGet)); } return(Json(new { type = "f", message = "登录账户名或密码不正确" }, JsonRequestBehavior.AllowGet)); }
public async Task <bool> Login(JObject userJson) { var userInfo = JsonConvert.DeserializeObject <UserLoginModel>(userJson.ToString()); if (!ModelState.IsValid) { return(false); } var user = await UserMgr.FindByEmailAsync(userInfo.Email); if (user != null && await UserMgr.CheckPasswordAsync(user, userInfo.Password)) { var identity = new ClaimsIdentity(IdentityConstants.ApplicationScheme); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); await HttpContext.SignInAsync(IdentityConstants.ApplicationScheme, new ClaimsPrincipal(identity)); return(true); } else { ModelState.AddModelError("", "Invalid UserName or Password"); return(false); } }
public async Task <string> getMethod() { var Message = ""; try { Message = "User already registered"; AppUser user = await UserMgr.FindByNameAsync("nhoarau"); if (user == null) { user = new AppUser(); user.UserName = "******"; user.Email = "*****@*****.**"; user.FirstName = "Nathan"; user.LastName = "HOARAU"; IdentityResult result = await UserMgr.CreateAsync(user, "PhilDougTest33*"); Message = "User was created"; } } catch (Exception ex) { Message = ex.Message; } return(Message); }
protected UserInfo GetUserByWebSocket(WebSocket socket) { var connMgr = AppServer.Instance.connManager; var socketid = connMgr.GetId(socket); return(UserMgr.GetUser(socketid)); }
public async Task <IActionResult> ReLogin(Models.ViewModel.HisLoginViewModel model) { try { if (model.StationId <= 0) { throw new Exception(); } var login = UserMgr.GetMyLoginData(UserSelf.LoginId); if (!model.DepartId.HasValue) { model.DepartId = findDepartId(login.DoctorId.Value, model.StationId); } await SignInProcess(login, model.StationId, model.DepartId, model.LoginExtMobile); await Logger.WriteInfoAsync("Home", "Login", $"用户({login.CustomerId},{login.CustomerName})切换登录到工作站({model.StationId})"); return(RedirectToAction("LoginedDefault")); //登录到默认页面 } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(View("Login", model)); } }
/// <summary> /// 插入用户留言 /// </summary> /// <param name="leaveWordsModel"></param> /// <returns></returns> public bool InsertLeaveWords(UserLeaveWordsModel leaveWordsModel) { if (!leaveWordsModel.UserEmail.IsEmail()) { throw new BusinessException("请输入有效的邮箱地址。"); } if (string.IsNullOrWhiteSpace(leaveWordsModel.Content)) { throw new BusinessException("请输入反馈内容。"); } CustomerLeaveWords entity = new CustomerLeaveWords(); entity.InDate = DateTime.Now; entity.Subject = HeaderHelper.GetClientType().ToString(); entity.LeaveWords = leaveWordsModel.Content; entity.CustomerEmail = leaveWordsModel.UserEmail; entity.CompanyCode = ConstValue.CompanyCode; entity.LanguageCode = ConstValue.LanguageCode; entity.StoreCompanyCode = ConstValue.StoreCompanyCode; var loginedUser = UserMgr.ReadUserInfo(); if (loginedUser != null) { entity.CustomerSysNo = loginedUser.UserSysNo; entity.CustomerName = loginedUser.UserID; } return(CustomerFacade.InsertCustomerLeaveWords(entity)); }
//返回登录后的首页 public IActionResult RedirectDefaultIndexPage() { TempData["IsMenuLoad"] = base.getQuery("IsMenuLoad"); var docCanTreat = UserMgr.IsMenuAllowed("PationtVisitV20");//允许访问接诊页面 var station = UserMgr.GetMyStation(); //医生 if (UserSelf.IsCanTreat && docCanTreat) { if (UserSelf.MyRoleNames.Contains("ds_assistant_doctor") || UserSelf.MyRoleNames.Contains("ds_doctor")) { return(RedirectToAction("DrugStoreIndex_Nurse")); //药店医生或者药店助理医生 } if (station.IsNetPlat) { return(RedirectToAction("DoctorIndex_NetPlat")); } else { return(RedirectToAction("DoctorIndex")); //避免浏览器缓存买有刷新菜单 } } return(RedirectToAction("DoctorIndex_Normal")); }
public ActionResult UCNoReviewOrderProducts(int pageIndex, int pageSize) { LoginUser suer = UserMgr.ReadUserInfo(); var noReviewOrders = ReviewFacade.QueryCustomerNoReviewOrderProducts(suer.UserSysNo, pageIndex, pageSize); return(PartialView("_NoReviewOrderProducts", noReviewOrders)); }
///// <summary> ///// 更新用户基本信息,但不包含密码 ///// </summary> ///// <param name="entity"></param> ///// <returns></returns> public JsonResult SaveUserInfo(User entity) { StateModel result = new StateModel(); result.Status = UserMgr.UpdateInfo(entity); return(Json(result)); }
public async Task <IActionResult> Login(User model, string totalPrice) { result = await SignInMgr.PasswordSignInAsync(model.Email, model.Password, false, false); if (result.Succeeded && totalPrice != null) { currentUser = await UserMgr.FindByEmailAsync(model.Email); await ChangeToKeyCustomer(currentUser); IsKeyCustomer = UserMgr.IsInRoleAsync(currentUser, "KeyCustomer"); DiscountedPrice = Convert.ToDouble(totalPrice); if (IsKeyCustomer.Result == true) { DiscountedPrice = DiscountedPrice * 0.9; return(RedirectToAction("SelectPaymentAndDeliveryOption", "OrderConfirmation", new { totalPrice = DiscountedPrice.ToString(), keyCustomer = IsKeyCustomer.Result })); } return(RedirectToAction("SelectPaymentAndDeliveryOption", "OrderConfirmation", new { totalPrice = totalPrice, keyCustomer = IsKeyCustomer.Result })); } if (result.Succeeded) { return(RedirectToAction("Index", "Products")); } ModelState.AddModelError(string.Empty, "Invalid Login Attempt"); return(View(model)); }
public async Task <IActionResult> Login(string username, string password) { if (ModelState.IsValid) { var user = await UserMgr.FindByNameAsync(username); if (user != null && !user.EmailConfirmed && (await UserMgr.CheckPasswordAsync(user, password))) { ModelState.AddModelError(string.Empty, "Email ainda não confirmado"); return(View()); } var result = await SignInMgr.PasswordSignInAsync(username, password, false, false); if (result.Succeeded) { return(RedirectToAction("index", "home")); } ModelState.AddModelError(string.Empty, "Invalid Login Attempt"); } return(View()); }
public void RequestLobbyLeave(ServerPacketData packetData) { var sessionID = packetData.SessionID; LobbyServer.MainLogger.Debug("RequestLobbyLeave"); try { var user = UserMgr.GetUserByNetSessionID(sessionID); if (user == null) { return; } if (LeaveLobbyUser(sessionID, user.LobbyNumber) == false) { return; } user.LeaveLobby(); ResponseLobbyLeaveToClient(sessionID, ERROR_CODE.NONE); LobbyServer.MainLogger.Debug("RequestLeave - Success"); } catch (Exception ex) { LobbyServer.MainLogger.Error(ex.ToString()); } }
public async Task <IActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserMgr.FindByEmailAsync(model.Email); if (user != null && await UserMgr.IsEmailConfirmedAsync(user)) { var token = await UserMgr.GeneratePasswordResetTokenAsync(user); var passwordResetLink = Url.Action("ResetPassword", "Account", new { email = model.Email, token = token }, Request.Scheme); logger.Log(LogLevel.Warning, passwordResetLink); return(View("ForgotPasswordConfirmation")); } Console.WriteLine("Eu não entrei no if"); return(View("ForgotPasswordConfirmation")); } return(View(model)); }
public ActionResult AccountInfo() { var userId = UserMgr.GetUserId(HttpContext.User); var user = UserMgr.FindByIdAsync(userId).Result; return(View(user)); }
//添加剖面 public ActionResult AddSection(SectionView model, string RID11, string RID22, string RID33, double?Altitude1) { model.Altitude = Altitude1; model.RID1 = RID11; model.RID2 = RID22; model.RID3 = RID33; ModelState.Remove("Altitude1"); if (!ModelState.IsValid) { return(WriteStatusError(ModelState)); } if (sectionSer.Any(x => x.SectionName == model.SectionName)) { return(WriteError("剖面名称" + model.SectionName + "已经存在,请确认!")); } var user = UserMgr.CurrUserInfo(); model.User_ID = user.User_ID; var Model = new Section(); Model.CopyFrom(model); sectionSer.Add(Model); Model.S_ID = Guid.NewGuid().ToString(); sectionSer.SaveChanges(); return(WriteSuccess(new { Model.S_ID, msg = "添加成功!" })); }
public ActionResult GetCouponPopContent(int MerchantSysNo) { CouponContentInfo Model = new CouponContentInfo(); //优惠卷 LoginUser user = UserMgr.ReadUserInfo(); List <CustomerCouponInfo> CustomerCouponList = new List <CustomerCouponInfo>(); if (user != null) { CustomerCouponList = ShoppingFacade.GetCustomerPlatformCouponCode(user.UserSysNo, MerchantSysNo); } //获取当前有效的优惠券活动 List <CouponInfo> CouponList = new List <CouponInfo>(); if (user != null) { CouponList = ShoppingFacade.GetCouponList(user.UserSysNo, MerchantSysNo); } if (user != null) { Model.UserSysNo = user.UserSysNo; Model.MerchantSysNo = MerchantSysNo; Model.customerCouponCodeList = CustomerCouponList; Model.couponList = CouponList; } PartialViewResult view = PartialView("~/Views/Shared/_CouponPop.cshtml", Model); return(view); }
/// <summary> /// 购物车 /// </summary> /// <returns></returns> public ActionResult Index() { ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); //用于计算会员价: LoginUser userInfo = UserMgr.ReadUserInfo(); shoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo; if (shoppingCart != null) { ShoppingStorageManager.SaveShoppingCart(shoppingCart); } OrderPipelineProcessResult shoppingResult = ShoppingFacade.BuildShoppingCart(shoppingCart); ShoppingCart pipelineShoppingCart = (shoppingResult.ReturnData != null && shoppingResult.ReturnData["ShoppingCart"] != null) ? shoppingResult.ReturnData["ShoppingCart"] as ShoppingCart : new ShoppingCart(); shoppingCart.OrderSelectGiftSysNo = pipelineShoppingCart.OrderSelectGiftSysNo; shoppingCart.OrderDeleteGiftSysNo = pipelineShoppingCart.OrderDeleteGiftSysNo; ShoppingStorageManager.SaveShoppingCart(shoppingCart); //将迷你购物车加入Cookie ShoppingStorageManager.SaveShoppingCartMini(ShoppingFacade.BuildMiniShoppingCartFromPipeline(shoppingResult)); return(View(shoppingResult)); }
public IEmployee getUser(string ntLogin) { UserMgr userMgr = new UserMgr(MainFactory.getUserSvc()); int employeeID = userMgr.getUser(ntLogin).EmployeeID; return this.repository.getEmployee(employeeID); }
//Инициализация public MainForm(User currentUser, ref List<User> users, UserMgr userManager, FileHandler fileHandler) { InitializeComponent(); this.currentUser = currentUser; this.users = users; this.userManager = userManager; this.fileHandler = fileHandler; users = fileHandler.openUsers(); tasks = fileHandler.openTasks(); projects = fileHandler.openProjects(); projectManager = new ProjectMgr(); //это потом удалить (тест открытия формы) //-------------------------------------------------------------- //projectManager.createProject("test project", ref projects);//| //openTaskForm(projects[0]); //| //-------------------------------------------------------------- }
public static UserMgr getUserMgr() { if (_userMgr == null) _userMgr = new UserMgr(); return _userMgr; }