123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- using System;
- using WMS.Util;
- using WMS.Info;
- namespace WMS.BZServices
- {
- /// <summary>
- /// 获取登录用户信息
- /// </summary>
- public class BZSessionCookieCore
- {
- public static string GetSessionCookieValue(string Key)
- {
- try
- {
- //return WebUtil.GetSession(Key);
- //if (SysSetCore.GetSysSet().IsSession)
- //{
- // return WebUtil.GetSession(Key);
- //}
- //else
- //{
- // return WebUtil.GetCookie(Key);
- //}
- }
- catch
- {
- }
- return "";
- }
- public static void WriteSessionCookieValue(string Key, string Value)
- {
- try
- {
- //if (SysSetCore.GetSysSet().IsSession)
- //{
- // WebUtil.WriteSession(Key, Value);
- //}
- //else
- //{
- // WebUtil.WriteCookie(Key, Value, 60 * 5);
- //}
- }
- catch (Exception ex)
- {
- //throw ex;
- }
- }
- public static void CheckVerifyCode(string VerifyCode)
- {
- try
- {
- if (GetUserPwdErrorNum() >= 3)
- {
- if (string.IsNullOrWhiteSpace(VerifyCode))
- {
- throw BZSysExCore.ThrowFailException("验证码为空。");
- }
- if (VerifyCode.ToUpper() != GetSessionCookieValue(BZSessionCookieConst.LoginVerifyCodeKey).ToUpper())
- {
- throw BZSysExCore.ThrowFailException("验证码错误。");
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public static int GetUserPwdErrorNum()
- {
- int error = 0;
- if (!int.TryParse(GetSessionCookieValue(BZSessionCookieConst.LoginPwdErrorKey), out error))
- {
- error = 0;
- }
- return error;
- }
- public static void AddLoginToken(string EncryptTokenNo)
- {
- try
- {
- WriteSessionCookieValue(BZSessionCookieConst.LoginPwdErrorKey, "");
- WriteSessionCookieValue(BZSessionCookieConst.LoginTokenKey, EncryptTokenNo);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public static void ClearLoginToken()
- {
- try
- {
- WriteSessionCookieValue(BZSessionCookieConst.LoginPwdErrorKey, "");
- WriteSessionCookieValue(BZSessionCookieConst.LoginTokenKey, "");
- }
- catch //(Exception ex)
- {
- //throw ex;
- }
- }
- public static void LoginPwdErrAdd()
- {
- try
- {
- int error = 0;
- if (!int.TryParse(GetSessionCookieValue(BZSessionCookieConst.LoginPwdErrorKey), out error))
- {
- error = 0;
- }
- WriteSessionCookieValue(BZSessionCookieConst.LoginPwdErrorKey, (error + 1).ToString());
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public static ReqInfo GetWebReqData(ReqInfo reqData)
- {
- reqData.EncryptTokenNo = GetSessionCookieValue(BZSessionCookieConst.LoginTokenKey);
- reqData.IPAddress = NetUtil.Ip;
- reqData.AppType = EAppType.PC;
- return reqData;
- }
- public static string GetLoginTokenNo()
- {
- var key = GetSessionCookieValue(BZSessionCookieConst.LoginTokenKey);
- if (string.IsNullOrWhiteSpace(key))
- {
- if (ConfigHelper.GetConfig().IsSSO)
- {
- var token = WebUtil.GetItem("EncryptTokenNo");
- if (token != null)
- {
- key = token as string;
- }
- }
- else
- {
- var userId = WebUtil.GetItem("userId");
- if (userId != null)
- {
- key = userId as string;
- }
- }
- }
- return key;
- }
- public static string GetBodyUITheme()
- {
- string res = "lr-uitheme-top";
- return res;
- //string wms_UItheme = WebUtil.GetCookie("WMS_UItheme");
- //switch (wms_UItheme)
- //{
- // case "1":
- // res = "lr-uitheme-default"; // 经典版本
- // break;
- // case "2":
- // res = "lr-uitheme-accordion"; // 手风琴版本
- // break;
- // case "3":
- // res = "lr-uitheme-windos"; // Windos版本
- // break;
- // case "4":
- // res = "lr-uitheme-top"; // 顶部菜单版本
- // break;
- // default:
- // res = "lr-uitheme-default"; // 经典版本
- // break;
- //}
- //return res;
- }
- public static string GetMainUITheme()
- {
- string res = "AdminTop";
- return res;
- //string wms_UItheme = WebUtil.GetCookie("WMS_UItheme");
- //switch (wms_UItheme)
- //{
- // case "1":
- // res="AdminDefault"; // 经典版本
- // case "2":
- // res = "AdminAccordion"; // 手风琴版本
- // case "3":
- // res = "AdminWindos"; // Windos版本
- // case "4":
- // res = "AdminTop"; // 顶部菜单版本
- // default:
- // res = "AdminDefault"; // 经典版本
- //}
- }
- public static string GetLoginUITheme()
- {
- string res = "Top";
- return res;
- //string wms_UItheme = WebUtil.GetCookie("WMS_UItheme");
- //switch (wms_UItheme)
- //{
- // case "1":
- // res="Default"; // 经典版本
- // case "2":
- // res = "Accordion"; // 手风琴版本
- // case "3":
- // res = "Window"; // Windos版本
- // case "4":
- // res = "Top"; // 顶部菜单版本
- // default:
- // res = "Default"; // 经典版本
- //}
- }
- }
- }
|