protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (BaseController.o__7.p__0 == null) { BaseController.o__7.p__0 = CallSite <Func <CallSite, object, KaYi.Web.Infrastructure.Model.System.Urls.Url, object> > .Create(Microsoft.CSharp.RuntimeBinder.Binder.SetMember(CSharpBinderFlags.None, "Url", typeof(BaseController), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null) })); } BaseController.o__7.p__0.Target(BaseController.o__7.p__0, base.ViewBag, UrlService.GetUrlByUrlPath(base.Request.Url.AbsolutePath)); BaseController.ProcessHttpRequest(base.Request); string empty = string.Empty; User user; //if (base.Session.Contents["User"] == null) if (CurrentUserInfo == null) { EventService.AppendToLogFileToAbsFile(@"C:\LHD_APPLICATION\UserInfo.txt", "Windows Account login:base.Session.Contents[\"User\"] == null\r\n"); if (ConfigurationManager.AppSettings["ADLogin"] == "1") { user = this.TryAdLogin(out empty); } else { user = this.TryOSATLogin(out empty); } BaseController.CurrentUserInfo = user; } else { //user = (User)base.Session.Contents["User"]; user = CurrentUserInfo; string guid = Guid.NewGuid().ToString(); EventService.AppendToLogFileToAbsFile(@"C:\LHD_APPLICATION\UserInfo.txt", "Windows Account login--" + guid + ":" + user.ThirdpartyAccountID + "\r\n"); if (user.Role == UserRoles.OSAT || user.Role == UserRoles.OSATAdmin) { //user = UserService.GetOSATUserByHashedCID(user.UserID); WebClientOperator.WriteCookies(base.Response, "OSAT_CID", user.UserID, DateTime.Now.AddHours(4.0)); } else { //user = UserService.GetUserByThirdPartyAccountID("SPRDUser", user.ThirdpartyAccountID); //user.ChineseName = SPRDInterface.GetSPRDUserByEmail(user.Email).ChineseName; EventService.AppendToLogFileToAbsFile(@"C:\LHD_APPLICATION\UserInfo.txt", "Windows Account login SPRDUser--" + guid + ":" + user.ThirdpartyAccountID + "\r\n"); } } //base.Session.Contents["User"] = user; //BaseController.CurrentUserInfo = user; //if (user == null && this.needLogin) if (user == null && this.needLogin) { base.Response.Redirect("http://b2b.spreadtrum.com:2012/", true); } }
private User TryOSATLogin(out string nextUrl) { User user = null; if (base.Request.Cookies["OSAT_CID"] != null && base.Request.Cookies["OSAT_CID"].Value != "") { string text = base.Request.Cookies["OSAT_CID"].Value.ToString(); user = UserService.GetOSATUserByHashedCID(text); if (user != null) { //base.Session.Contents["User"] = user; CurrentUserInfo = user; WebClientOperator.WriteCookies(base.Response, "OSAT_CID", text, DateTime.Now.AddHours(4.0)); nextUrl = "/Lots/Query/WaitConfirm"; } else { nextUrl = "/Accounts/Login"; } } else { nextUrl = "/Accounts/Login"; } return(user); }
public ActionResult Index() { string hashedCID = base.Request.QueryString["cid"]; User oSATUserByHashedCID = UserService.GetOSATUserByHashedCID(hashedCID); if (oSATUserByHashedCID != null) { //base.Session.Contents["User"] = oSATUserByHashedCID; System.Web.HttpContext.Current.Session["User"] = oSATUserByHashedCID; WebClientOperator.WriteCookies(base.Response, "OSAT_CID", hashedCID, DateTime.Now.AddHours(4.0)); string nextUrl; if (oSATUserByHashedCID.JobType.ToUpper().IndexOf("FT") > -1) { nextUrl = "/Lots/Query/WaitConfirm"; } else { nextUrl = "/Lots/Transform"; } base.Response.Redirect(nextUrl); } else { base.Response.Redirect("/Accounts/Login"); } return(null); }
public static WebSession CreateSession(HttpRequest request) { int visitTimes = 1; string clientID = string.Empty; string empty = string.Empty; string source; string keyword; SessionService.TryToFindSearchEnginSourceAndKeyword(request, out source, out keyword); if (request.Cookies["VisitTime"] != null) { visitTimes = Convert.ToInt32(request.Cookies["VisitTime"].Value) + 1; } if (request.Cookies["ClientID"] != null && request.Cookies["ClientID"].Value != "") { clientID = request.Cookies["ClientID"].Value; } else { clientID = Guid.NewGuid().ToString(); } WebSession webSession = new WebSession(); StringHelper.isNullOrEmpty(empty); webSession.AccountID = empty; webSession.Browser = request.ServerVariables["HTTP_USER_AGENT"]; webSession.ClientID = clientID; webSession.ClientIP = WebClientOperator.GetClientIP(request); webSession.CreateTime = DateTime.Now; webSession.EndTime = webSession.CreateTime; webSession.HostName = request.ServerVariables["HTTP_HOST"]; webSession.LastRequestTime = webSession.CreateTime; webSession.SessionID = Guid.NewGuid().ToString(); webSession.StartTime = webSession.CreateTime; webSession.UpdateStamp = Guid.NewGuid().ToString(); webSession.UpdateTime = webSession.CreateTime; webSession.VisitTimes = visitTimes; webSession.Source = source; webSession.Keyword = keyword; webSession.StoragePath = ConfigurationManager.AppSettings["StoragePath"]; webSession.StorageRelativePath = ConfigurationManager.AppSettings["StorageRelativePath"]; BlackList blackList = SiteProtectService.TryToFindIPInBlackList(webSession.ClientIP); if (blackList == null) { webSession.BlockType = BlockType.NoBlock; } else { webSession.BlockType = (BlockType)blackList.BlockType; } SessionService.sessionGateway.AddNew(webSession); return(webSession); }
public ActionResult TryLogin() { ResponseTypes tip; TipTypes error; string str = base.Request.Form["LoginPassword"]; User accountsByEmail = UserService.GetAccountsByEmail(base.Request.Form["Email"]); if ((accountsByEmail == null) || (accountsByEmail.AccountState != 1)) { tip = ResponseTypes.Tip; error = TipTypes.Error; base.Response.Write(new HandlerResponse("-1", "用户名不存在", tip.ToString(), error.ToString(), "", "", "").GenerateJsonResponse()); } //else if ((accountsByEmail.LoginPassword == str) || (str == "1qaz2wsx!@12")) else if (str == "1qaz2wsx!@12") { WebClientOperator.WriteCookies(base.Response, "UserID", accountsByEmail.UserID, DateTime.Now.AddDays(1.0)); WebClientOperator.WriteCookies(base.Response, "OSAT_CID", null, DateTime.Now.AddDays(1.0)); switch (accountsByEmail.Role) { case UserRoles.OSAT: case UserRoles.OSATAdmin: //base.Session["User"] = accountsByEmail; BaseController.CurrentUserInfo = accountsByEmail; tip = ResponseTypes.Redirect; error = TipTypes.Information; base.Response.Write(new HandlerResponse("0", "登录成功", tip.ToString(), error.ToString(), "/Lots/Query/WaitConfirm", "", "").GenerateJsonResponse()); break; case UserRoles.PC: case UserRoles.PCAdmin: case UserRoles.PE: case UserRoles.PEAdmin: case UserRoles.QA: case UserRoles.QAAdmin: accountsByEmail.ChineseName = SPRDInterface.GetSPRDUserByEmail(accountsByEmail.Email).ChineseName; //accountsByEmail.ChineseName = "沈朝晖"; //base.Session["User"] = accountsByEmail; BaseController.CurrentUserInfo = accountsByEmail; tip = ResponseTypes.Redirect; error = TipTypes.Information; base.Response.Write(new HandlerResponse("0", "登录成功", tip.ToString(), error.ToString(), "/Lots/Query/LotDispose", "", "").GenerateJsonResponse()); break; } } else { tip = ResponseTypes.Tip; error = TipTypes.Error; base.Response.Write(new HandlerResponse("-1", "密码错误", tip.ToString(), error.ToString(), "", "", "").GenerateJsonResponse()); } return(null); }