protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["type"] == "logout") { Session[AppConfig.AdminSession] = null; HttpCookie Cookie = CookiesHelper.GetCookie("upup1000Admin"); if (Cookie != null && Cookie.Value != null && Cookie.Value != "") { CookiesHelper.SetCookie("upup1000Admin", "uname", "", DateTime.Now.AddYears(-1)); CookiesHelper.SetCookie("upup1000Admin", "psd", "", DateTime.Now.AddYears(-1)); } } try { if (Request.Cookies["upup1000Admin"]["uname"] != null && Request.Cookies["upup1000Admin"]["uname"] != string.Empty && Request.Cookies["upup1000Admin"]["psd"] != null && Request.Cookies["upup1000Admin"]["psd"] != string.Empty) { string username = CommonTools.Decode(Request.Cookies["upup1000Admin"]["uname"]); string password = CommonTools.Decode(Request.Cookies["upup1000Admin"]["psd"]); LoginCheck(username, password); Response.Cache.SetCacheability(HttpCacheability.NoCache); } }catch {} } }
/// <summary> /// 写入日志 /// </summary> /// <param name="action">动作</param> public static void WriteLogActions(string action) { if (IsAdminLogin()) { string adminLogId = SessionHelper.GetSession(sessionAdminLogIDKey).ToString(); //string adminLogId = AuthenticationHelper.GetClaim(sessionAdminLogIDKey); if (string.IsNullOrEmpty(adminLogId)) { adminLogId = CookiesHelper.GetCookie(cookiesAdminLogIDKey);//日志GUID //adminLogId = AuthenticationHelper.GetClaim(cookiesAdminLogIDKey);//日志GUID } if (!string.IsNullOrEmpty(adminLogId)) { AdminLog log = AdminLog.FindByGUID(adminLogId); if (log != null) { if (string.IsNullOrEmpty(log.Actions)) { log.Actions = $"{DateTime.Now:yyyy-MM-dd HH:mm}: {action}"; } else { log.Actions = log.Actions + $"|||{DateTime.Now:yyyy-MM-dd HH:mm}: {action}"; } log.LastUpdateTime = DateTime.Now; log.Update(); } } } }
public LoginInfoModel GetLoginInfo() { var model = new LoginInfoModel(); var loginCookie = CookiesHelper.GetCookie(WebConfigOperation.CookieName);//是否已存在登录的用户cookie if (loginCookie != null) { //2.获取用户信息 model.UserInfo = new LoginBLL().GetUserInfo(loginCookie.Value); if (model.UserInfo == null) { return(model); } } var ykCookie = CookiesHelper.GetCookie(WebConfigOperation.YkCookieName); if (ykCookie == null) { var yk = EncryptAndDecrypt.Encrypt(DateTime.Now.ToString()); CookiesHelper.AddCookie(WebConfigOperation.YkCookieName, yk); CookiesHelper.SetCookie(WebConfigOperation.YkCookieName, DateTime.Now.AddMonths(1)); model.ykCookie = yk; } else { model.ykCookie = ykCookie.Value.ToString(); } return(model); }
private void CheckLogin() { LoginAction la = new LoginAction(); HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie == null) { pnlCookie.Visible = false; pnlLogin.Visible = true; } else { string BaseUserName = Cookie.Values["UserName"]; string BaseUserPassword = Cookie.Values["Password"]; string NickName = Cookie.Values["NickName"]; if (la.ChkAdminExit(BaseUserName, BaseUserPassword)) { lbNICK_NAME.Text = NickName; pnlCookie.Visible = true; pnlLogin.Visible = false; } else { pnlCookie.Visible = false; pnlLogin.Visible = true; } } }
protected void SetCommentCookies(int sysno) { string tmpstr = ""; if (Request.Cookies["upup1000"] != null && Request.Cookies["upup1000"]["QuestComment"] != null && Request.Cookies["upup1000"]["QuestComment"] != string.Empty) { tmpstr = CommonTools.Decode(Request.Cookies["upup1000"]["QuestComment"]) + "|" + sysno + "," + DateTime.Now.ToString("yyyy-MM-dd"); } else { tmpstr = sysno.ToString() + "," + DateTime.Now.ToString("yyyy-MM-dd"); } HttpCookie Cookie = CookiesHelper.GetCookie("upup1000"); if (Cookie == null || Cookie.Value == null || Cookie.Value == "") { Cookie = new HttpCookie("upup1000"); Cookie.Values.Add("QuestComment", CommonTools.Encode(tmpstr)); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddYears(50); CookiesHelper.AddCookie(Cookie); } else { CookiesHelper.SetCookie("upup1000", "QuestComment", CommonTools.Encode(tmpstr), DateTime.Now.AddYears(50)); } }
public Task <ApiResult> Post([FromBody] ICommand command) { var batchCount = 1; int.TryParse(CookiesHelper.GetCookie("batchCount").Value, out batchCount); return(Task.Factory.StartNew(() => { BatchCommands.Add(command); if (BatchCommands.Count >= 3) { int i = 0; try { var commands = new List <ICommand>(BatchCommands); while (i++ < batchCount) { DoCommand(commands); } } catch (Exception e) { return new ApiResult { ErrorCode = ErrorCode.UnknownError, Message = e.GetBaseException().Message }; } BatchCommands.Clear(); } return new ApiResult(); })); }
public static string GetKey(string name) { var userSetLocale = CookiesHelper.GetCookie(Constants.Keys.CurrentCultureCookieKey); var defaultLocale = AppConfig.DefaultLocale; var currentLocale = CultureInfo.CurrentCulture.Name; if (!string.IsNullOrWhiteSpace(userSetLocale) && KeyExists(name, userSetLocale)) { return(GetKey(name, userSetLocale, AppConfig.PerformanceMode)); } else { if (KeyExists(name, currentLocale)) { return(GetKey(name, currentLocale, AppConfig.PerformanceMode)); } else { if (KeyExists(name, defaultLocale)) { return(GetKey(name, defaultLocale, AppConfig.PerformanceMode)); } else { return($"KEY_[{name}]_UNDEFINED"); } } } }
public string QueryByEQId(string ExamQuestionId, int typeId = 0) { try { var list = examquestion_BLL.QueryByEQId(ExamQuestionId); List <Questions> result = list; if (typeId == 0) { List <TestPage> test = new List <TestPage>(); for (int i = 0; i < result.Count(); i++) { TestPage m = new TestPage { QuestionNum = result[i].QuestionNum, Answer = result[i].Answer }; test.Add(m); result[i].Answer = CookiesHelper.GetCookie(result[i].QuestionNum); } //写入Cookie CookiesHelper.SetCookie(ExamQuestionId, JsonConvert.SerializeObject(test), DateTime.Now.AddDays(1)); result = RandomQuestions(list, list.Count()); } return(JsonConvert.SerializeObject(result)); } catch (Exception ex) { ErrorLog.WriteLog(ex); return(null); } }
public static string GetMessage(string name) { var userSetLocale = CookiesHelper.GetCookie(Constants.Keys.CurrentCultureCookieKey); var defaultLocale = AppConfig.DefaultLocale; var currentLocale = CultureInfo.CurrentCulture.Name; if (!string.IsNullOrWhiteSpace(userSetLocale) && MessageExistsFromSettings(name, userSetLocale)) { return(GetMessage(name, userSetLocale)); } else { if (MessageExistsFromSettings(name, currentLocale)) { return(GetMessage(name, currentLocale)); } else { if (MessageExistsFromSettings(name, defaultLocale)) { return(GetMessage(name, defaultLocale)); } else { return(string.Empty); } } } }
/// <summary> /// ** 描述:学生信息添加页面 /// ** 创始时间:2018年11月2日11点11分 /// ** 修改时间:- /// ** 作者:mqc /// </summary> public ActionResult Student_Add() { var result = HttpUtility.UrlDecode(CookiesHelper.GetCookie("UID")); Users user = JsonConvert.DeserializeObject <Users>(result); ViewBag.User = user; return(View()); }
protected void Page_Load(object sender, EventArgs e) { HttpCookie Cookie = CookiesHelper.GetCookie("UserInfo"); if (Cookie != null) { this.yhm.Text = Server.UrlDecode(Cookie.Values["userName"]); } }
/// <summary> /// 验证管理员是否登录 /// </summary> /// <returns>是否登录</returns> public static bool IsAdminLogin() { string adminName = SessionHelper.GetSession(sessionAdminNameKey).ToString(); //用户名 string adminID = SessionHelper.GetSession(sessionAdminIDKey).ToString(); //ID //如果Session失效,则用Cookies判断 if (string.IsNullOrEmpty(adminName) || string.IsNullOrEmpty(adminID)) { string cooAdminName = CookiesHelper.GetCookie(cookiesAdminNameKey); //用户名 string cooAdminID = CookiesHelper.GetCookie(cookiesAdminIDKey); //ID string cooLoginInfo = CookiesHelper.GetCookie(cookiesAdminInfoKey); //信息 string cooAdminLogID = CookiesHelper.GetCookie(cookiesAdminLogIDKey); //日志GUID if (string.IsNullOrEmpty(cooAdminID) || string.IsNullOrEmpty(cooAdminName) || string.IsNullOrEmpty(cooLoginInfo) || string.IsNullOrEmpty(cooAdminLogID)) { return(false);//信息不完整 } else { //全不为空则判断信息是否正确 Admin model = Find(Admin._.UserName == Utils.SqlStr(cooAdminName));// FindByName(Utils.SqlStr(cooAdminName)); if (model == null) { return(false);//找不到管理员 } else { if (Utils.MD5(model.UserName + model.PassWord + model.Salt + Utils.GetIP()) == cooLoginInfo) { //信息正确,重建session //获取日志ID if (AdminLog.FindByGUID(cooAdminLogID) == null) { ClearInfo(); //清除信息 return(false); //日志出错 } //重新写入Session 和 Cookies SetAdminInfo(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt); return(true); } else { ClearInfo(); //清除信息 return(false); //信息错误 } } } } else { return(true);//Session未失效,正确 } }
/// <summary> /// ** 描述:读取缓存中学生数据 /// ** 创始时间:2018-11-06 /// ** 修改时间:- /// ** 作者:lc /// </summary> public Students GetStu() { //获取当前登录学生的信息 string sid = HttpUtility.UrlDecode(CookiesHelper.GetCookie("SId")); Students stu = JsonConvert.DeserializeObject <Students>(sid); if (stu != null) { return(stu); } return(null); }
private bool ValidateCode() { if (code.Text.Trim().ToUpper() == CommonTools.Decode(CookiesHelper.GetCookie("CheckCode").Value).ToUpper()) { return(true); } else { ltrCode.Text = "验证码输入错误,请重新输入"; code.Text = ""; return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpCookie Cookie = CookiesHelper.GetCookie("UserInfo"); if (Cookie != null) { this.account.Value = Cookie.Values["uName"]; string psd = Cookie.Values["uPassword"]; this.password.Attributes.Add("Value",psd); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { trValidate.Visible = false; Session["userCode"] = null; HttpCookie Cookie = CookiesHelper.GetCookie("UserInfo"); if (Cookie != null) { this.txtUserCode.Value = Cookie.Values["userName"]; this.txtUserPwd.Value = Cookie.Values["usertPwd"]; this.CheckBox1.Checked = true; } } }
/// <summary> /// 验证用户是否登录 /// </summary> /// <returns>是否登录</returns> public static bool IsMemberLogin() { string username = SessionHelper.GetSession(KEY_S_UserName).ToString(); //用户名 string uid = SessionHelper.GetSession(KEY_S_Uid).ToString(); //ID //使用Oauth 第三方登录 string oauth_access_token = SessionHelper.GetSession(KEY_OAUTH_ACCESS_TOKEN).ToString(); string oauth_openid = SessionHelper.GetSession(KEY_OAUTH_OPENID).ToString(); //如果Session失效,则用Cookies判断 if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(uid)) { string cooUserName = CookiesHelper.GetCookie(KEY_C_UserName); //用户名 string cooUID = CookiesHelper.GetCookie(KEY_C_Uid); //ID string cooLoginInfo = CookiesHelper.GetCookie(KEY_C_UserInfo); //信息 string cooLogID = CookiesHelper.GetCookie(KEY_C_LOGID); //日志GUID if (string.IsNullOrEmpty(cooUID) || string.IsNullOrEmpty(cooUserName) || string.IsNullOrEmpty(cooLoginInfo)) { return(false);//信息不完整 } else { //全不为空则判断信息是否正确 Member model = Find(_.UserName, Utils.SqlStr(cooUserName)); if (model == null) { return(false);// } else { if (Utils.MD5(model.UserName + model.PassWord + model.Salt) == cooLoginInfo) { SetUserInfo(model.UserName, model.PassWord, model.Id, 60 * 2, model.Salt, cooLogID); return(true); } else { ClearUserInfo(); //清除用户信息 return(false); //信息错误 } } } } else { return(true);//Session未失效,正确 } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { trValidate.Visible = false; if (Request["clear"] == null || !Request["clear"].ToString().Equals("1")) { HttpCookie Cookie = CookiesHelper.GetCookie("UserInfo"); if (Cookie != null) { LoginCheck(Server.UrlDecode(Cookie.Values["userName"]), Server.UrlDecode(Cookie.Values["usertPwd"])); this.CheckBox1.Checked = true; } } } }
public void LoginCheck(string username, string password) { SYS_AdminMod m_admin = SYS_AdminBll.GetInstance().CheckAdmin(username, password); if (m_admin.CustomerSysNo != AppConst.IntNull)//COOKIES验证成功 { WebForAnalyse.SessionInfo m_session = new SessionInfo(); m_session.AdminEntity = m_admin; m_session.PrivilegeDt = SYS_AdminBll.GetInstance().GetAdminPrivilege(m_admin.CustomerSysNo); Session[AppConfig.AdminSession] = m_session; //记住我 if (CheckBox1.Checked) { HttpCookie Cookie = CookiesHelper.GetCookie("upup1000Admin"); if (Cookie == null || Cookie.Value == null || Cookie.Value == "") { Cookie = new HttpCookie("upup1000Admin"); Cookie.Values.Add("uname", CommonTools.Encode(username)); Cookie.Values.Add("psd", CommonTools.Encode(password)); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddYears(50); CookiesHelper.AddCookie(Cookie); } else { CookiesHelper.SetCookie("upup1000Admin", "uname", CommonTools.Encode(username), DateTime.Now.AddYears(50)); CookiesHelper.SetCookie("upup1000Admin", "psd", CommonTools.Encode(password), DateTime.Now.AddYears(50)); } } LogManagement.getInstance().WriteTrace(m_session.AdminEntity, "Login", "IP:" + Request.UserHostAddress + "|AdminID:" + m_session.AdminEntity.Username); //跳转 if (Request.QueryString["url"] != null && Request.QueryString["url"] != "") { Response.Redirect(Request.QueryString["url"]); } else { Response.Redirect("BaZi/PatternList.aspx"); } } else { this.ltrNotice.Text = "用户名或密码错误!"; base.ClientScript.RegisterStartupScript(base.GetType(), "", "document.getElementById('" + divNotice.ClientID + "').style.display='';", true); } }
protected void lbtnExit_Click(object sender, EventArgs e) { HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie != null) { Cookie = new HttpCookie(SiteInfo.CookieName()); Cookie.Values.Add("UserId", ""); Cookie.Values.Add("UserName", ""); Cookie.Values.Add("Password", ""); Cookie.Values.Add("NickName", ""); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddDays(-1); CookiesHelper.AddCookie(Cookie); } pnlCookie.Visible = false; pnlLogin.Visible = true; }
protected void Unnamed2_Click(object sender, EventArgs e) { string username = txtEmail.Text.Trim(); string password = txtPass.Text.Trim(); #region 验证邮箱有效性 #endregion USR_CustomerMod m_user = USR_CustomerBll.GetInstance().CheckUser(username, password); if (m_user.SysNo != AppConst.IntNull)//COOKIES验证成功 { SessionInfo m_session = new SessionInfo(); m_session.CustomerEntity = m_user; m_session.GradeEntity = USR_GradeBll.GetInstance().GetModel(m_user.SysNo); Session[AppConfig.CustomerSession] = m_session; //记住我 if (chkRemember.Checked) { HttpCookie Cookie = CookiesHelper.GetCookie("upup1000"); if (Cookie == null || Cookie.Value == null || Cookie.Value == "") { Cookie = new HttpCookie("upup1000"); Cookie.Values.Add("uname", CommonTools.Encode(username)); Cookie.Values.Add("psd", CommonTools.Encode(password)); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddYears(50); CookiesHelper.AddCookie(Cookie); } else { CookiesHelper.SetCookie("upup1000", "uname", CommonTools.Encode(username), DateTime.Now.AddYears(50)); CookiesHelper.SetCookie("upup1000", "psd", CommonTools.Encode(password), DateTime.Now.AddYears(50)); } } LogManagement.getInstance().WriteTrace("前台会员登录", "Login", "IP:" + Request.UserHostAddress + "|AdminID:" + m_session.CustomerEntity.Email); //跳转 Response.Redirect("Qin/View/" + m_user.SysNo); } else { Response.Redirect("Passport/Login.aspx?email=" + txtEmail.Text.Trim() + "&error=" + (int)AppEnum.ErrorType.WrongAccount); } }
public void LoginCheck(string username, string password) { USR_CustomerMod m_user = USR_CustomerBll.GetInstance().CheckUser(username, password); if (m_user.SysNo != AppConst.IntNull)//COOKIES验证成功 { SetSession(m_user); //记住我 if (CheckBox1.Checked) { HttpCookie Cookie = CookiesHelper.GetCookie("upup1000"); if (Cookie == null || Cookie.Value == null || Cookie.Value == "") { Cookie = new HttpCookie("upup1000"); Cookie.Values.Add("uname", CommonTools.Encode(username)); Cookie.Values.Add("psd", CommonTools.Encode(password)); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddYears(50); CookiesHelper.AddCookie(Cookie); } else { CookiesHelper.SetCookie("upup1000", "uname", CommonTools.Encode(username), DateTime.Now.AddYears(50)); CookiesHelper.SetCookie("upup1000", "psd", CommonTools.Encode(password), DateTime.Now.AddYears(50)); } } LogManagement.getInstance().WriteTrace("前台会员登录", "Login", "IP:" + Request.UserHostAddress + "|UserID:" + GetSession().CustomerEntity.Email); //跳转 if (Request.QueryString["url"] != null && Request.QueryString["url"] != "") { Response.Redirect(Request.QueryString["url"]); } else { Response.Redirect("../Qin/View/" + m_user.SysNo); } } else { password1Tip.InnerHtml = AppEnum.GetErrorType(2); } }
/// <summary> /// 写入日志 /// </summary> /// <param name="action">动作</param> public static void WriteLogActions(string action) { if (IsMemberLogin()) { string LogId = SessionHelper.GetSession(KEY_C_LOGID).ToString(); if (string.IsNullOrEmpty(LogId)) { LogId = CookiesHelper.GetCookie(KEY_C_LOGID);//日志GUID } if (!string.IsNullOrEmpty(LogId)) { MemberLog log = MemberLog.FindByGUID(LogId); if (log != null) { log.Actions = log.Actions + action; log.LastUpdateTime = DateTime.Now; log.Update(); } } } }
/// <summary> /// 写入日志 /// </summary> /// <param name="action">动作</param> public static void WriteLogActions(string action) { if (IsAdminLogin()) { string adminLogId = SessionHelper.GetSession(sessionAdminLogIDKey).ToString(); if (string.IsNullOrEmpty(adminLogId)) { adminLogId = CookiesHelper.GetCookie(cookiesAdminLogIDKey);//日志GUID } if (!string.IsNullOrEmpty(adminLogId)) { AdminLog log = AdminLog.FindByGUID(adminLogId); if (log != null) { log.Actions = log.Actions + action; log.LastUpdateTime = DateTime.Now; log.Update(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["type"] == "logout") { Session[AppConfig.CustomerSession] = null; HttpCookie Cookie = CookiesHelper.GetCookie("upup1000"); if (Cookie != null && Cookie.Value != null && Cookie.Value != "") { CookiesHelper.SetCookie("upup1000", "uname", "", DateTime.Now.AddYears(-1)); CookiesHelper.SetCookie("upup1000", "psd", "", DateTime.Now.AddYears(-1)); } } else if (Request.QueryString["error"] != null && Request.QueryString["error"] != "") { try { email.Text = Request.QueryString["email"]; password1Tip.InnerText = AppEnum.GetErrorType(int.Parse(Request.QueryString["error"])); return; } catch { } } try { if (Request.Cookies["upup1000"]["uname"] != null && Request.Cookies["upup1000"]["uname"] != string.Empty && Request.Cookies["upup1000"]["psd"] != null && Request.Cookies["upup1000"]["psd"] != string.Empty) { string username = CommonTools.Decode(Request.Cookies["upup1000"]["uname"]); string password = CommonTools.Decode(Request.Cookies["upup1000"]["psd"]); LoginCheck(username, password); Response.Cache.SetCacheability(HttpCacheability.NoCache); } } catch { } Unnamed1.Focus(); } }
private bool SetCookie(string name, string pwd) { //下次自动登录 if (CheckBox1.Checked == true) { if (!Convert.ToBoolean(hfIsEnableCookie.Value)) { // Response.Write("<script language='javascript'>alert('提示!您的浏览器不接受cookie,将影响一些功能的正常使用,请将浏览器cookie启用!')</script>"); msg.InnerHtml = "【友情提示】:您的浏览器不接受cookie,将影响一些功能的正常使用,请将浏览器cookie启用!"; return(false); } else { HttpCookie Cookie = CookiesHelper.GetCookie("UserInfo"); if (Cookie == null) { Cookie = new HttpCookie("UserInfo"); Cookie.Values.Add("userName", name); Cookie.Values.Add("usertPwd", pwd); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddMonths(1);//DateTime.Now.AddDays(365); CookiesHelper.AddCookie(Cookie); } else if (!Cookie.Values["userName"].Equals(name) || !Cookie.Values["usertPwd"].Equals(pwd)) { CookiesHelper.SetCookie("UserInfo", "userName", name); CookiesHelper.SetCookie("UserInfo", "usertPwd", pwd); } return(true); } } else { CookiesHelper.RemoveCookie("UserInfo"); HttpCookie Cookie = CookiesHelper.GetCookie("UserInfo"); int a = Request.Cookies.Count; return(true); } }
private bool CheckLogin() { LoginAction la = new LoginAction(); HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie == null) { return(false); } BaseUserName = Cookie.Values["UserName"]; BaseUserPassword = Cookie.Values["Password"]; BaseNickName = Cookie.Values["NickName"]; BaseUserID = Cookie.Values["UserId"]; if (la.ChkAdminExit(BaseUserName, BaseUserPassword)) { return(true); } else { return(false); } }
void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) { var locale = AppConfig.DefaultLocale; var now = Util.Utilities.DateTimeNow(); if (!string.IsNullOrWhiteSpace(filterContext.HttpContext.Request.QueryString["Lang"])) { locale = filterContext.HttpContext.Request.QueryString["Lang"]; } else { locale = CookiesHelper.GetCookie(Constants.Keys.CurrentCultureCookieKey) ?? AppConfig.DefaultLocale; } CookiesHelper.SetCookie(Constants.Keys.CurrentCultureCookieKey, locale, now.AddYears(1)); CookiesHelper.SetCookie(Constants.Keys.CurrentCultureDirectionCookieKey, LanguageHelper.GetLocaleDirection(locale), now.AddYears(1)); filterContext.HttpContext.Session[Constants.Keys.CurrentCultureSessionKey] = locale; this.OnActionExecuting(filterContext); }
public static bool CheckLoginLxj() { LoginAction la = new LoginAction(); HttpCookie Cookie = CookiesHelper.GetCookie(SiteInfo.CookieName()); if (Cookie == null) { return(false); } string BaseUserName1 = Cookie.Values["UserName"]; string BaseUserPassword1 = Cookie.Values["Password"]; string BaseNickName1 = Cookie.Values["NickName"]; string BaseUserID1 = Cookie.Values["UserId"]; if (la.ChkAdminExit(BaseUserName1, BaseUserPassword1)) { return(true); } else { return(false); } }
public int AddTest(string answer, string ExamQuestionId, int StudentId, string ename, string StudentNum, DateTime ExamEndDate, string StudentName) { try { List <Score_His> socreList = new List <Score_His>(); var redisList = RedisHelper.Get <List <Score_His> >("Score_His" + StudentId); if (redisList != null) { socreList = redisList; } //分数 var sore = 0; //单选题分数 var oneNum = 0; //多选题分数 var twoNum = 0; //判断题分数 var threeNum = 0; //根据试题ID获取cookie中的答案 var json = CookiesHelper.GetCookie(ExamQuestionId); //答案集合 var answerList = JsonConvert.DeserializeObject <List <TestPage> >(json); //我的答案 var myAnswer = JsonConvert.DeserializeObject <List <TestPage> >(answer); if (myAnswer.Count != 0) { //20个题的分数 if (myAnswer.Count == 20) { oneNum = 5; twoNum = 5; threeNum = 5; } //40个题的分数 if (myAnswer.Count == 40) { oneNum = 3; twoNum = 2; threeNum = 2; } //60个题的分数 if (myAnswer.Count == 60) { oneNum = 2; twoNum = 2; threeNum = 1; } //100个题的分数 if (myAnswer.Count == 100) { oneNum = 1; twoNum = 1; threeNum = 1; } //我的答案 var myAnswerStr = ""; for (int i = 0; i < answerList.Count; i++) { for (int j = 0; j < myAnswer.Count; j++) { if (answerList[i].QuestionNum == myAnswer[j].QuestionNum) { myAnswerStr += myAnswer[j].Answer + ","; if (answerList[i].Answer == myAnswer[j].Answer) { if (myAnswer[j].TypeId == 1) { sore += oneNum; } if (myAnswer[j].TypeId == 2) { sore += twoNum; } if (myAnswer[j].TypeId == 3) { sore += threeNum; } } } } } if (myAnswerStr.Length == 0) { myAnswerStr = ""; } else { myAnswerStr = myAnswerStr.Substring(0, myAnswerStr.Length - 1); } Score_His sh = new Score_His(); sh.StudentId = StudentId; sh.ScoreNum = sore; sh.ExamQuestionId = ExamQuestionId; sh.MyAnswerStr = myAnswerStr; sh.CreateDate = DateTime.Now; sh.ExamName = ename; sh.ExamEndDate = ExamEndDate; sh.StudentNum = StudentNum; sh.StudentName = StudentName; socreList.Add(sh); //写入缓存 var result = RedisHelper.Set <List <Score_His> >("Score_His" + StudentId, socreList); ////添加成绩 //var result = iScores_BLL.Add(StudentId, sore, ExamQuestionId, myAnswerStr, DateTime.Now); } else { sore = 0; } return(sore); } catch (Exception ex) { ErrorLog.WriteLog(ex); return(0); } }