//LongPolling Action 2 - 异步处理完成,向客户端发送响应 public ActionResult LongPollingCompleted(LoginLogModel model) { var log = _loginLogService.GetLoginLog(model.Id); if (log != null) { log.IsDeleted = true; _loginLogService.Update(); var authenticationManager = HttpContext.GetOwinContext().Authentication; var identity = UserService.CreateIdentity(log.WeChatUser, DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignIn(new AuthenticationProperties(), identity); } return Json(model, JsonRequestBehavior.AllowGet); }
public object Post(LoginLogModel model) { if (model.WeChatUserModel.OpenId != null) { var wecharuser = _weChatUserService.GetWeChatUser(model.WeChatUserModel.OpenId); if (wecharuser == null) { wecharuser = new WeChatUser { Id = Guid.NewGuid(), OpenId = model.WeChatUserModel.OpenId, NickName = model.WeChatUserModel.NickName, Gender = (Gender)model.WeChatUserModel.Gender, Language = model.WeChatUserModel.Language, City = model.WeChatUserModel.City, Province = model.WeChatUserModel.Province, Headimgurl = model.WeChatUserModel.Headimgurl }; _weChatUserService.Insert(wecharuser); } else { wecharuser.OpenId = model.WeChatUserModel.OpenId; wecharuser.NickName = model.WeChatUserModel.NickName; wecharuser.Gender = (Gender)model.WeChatUserModel.Gender; wecharuser.Language = model.WeChatUserModel.Language; wecharuser.City = model.WeChatUserModel.City; wecharuser.Province = model.WeChatUserModel.Province; wecharuser.Headimgurl = model.WeChatUserModel.Headimgurl; _weChatUserService.Update(); } var loginLogId = Guid.NewGuid(); if (_loginLogService.GetLoginLog(model.State) == null) { _loginLogService.Insert(new LoginLog { Id = loginLogId, State = model.State, CreateTime = DateTime.Now, WeChatUser_Id = wecharuser.Id }); model.CreateTime = DateTime.Now; model.Id = loginLogId; } return model; } return null; }