| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795 |
- using System;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.UI.WebControls;
- namespace CommonTool
- {
- public class WebLibs
- {
- /// <summary>
- /// 将不能在HTML中正常显示的ASCII字符串进行Html语法的翻译
- /// </summary>
- /// <param name="pcStr">需要进行Html语法翻译的ASCII字符串</param>
- public static void AreaToHtml(ref string pcStr)
- {
- if (pcStr != null)
- {
- pcStr = pcStr.Replace(" ", " ");
- pcStr = pcStr.Replace("\r", "<br>");
- }
- }
- /// <summary>
- /// 替换Url地址信息里的 换行符号
- /// </summary>
- /// <param name="pcUrlMsg"></param>
- /// <returns></returns>
- public static string ConvertUrlMsg(string pcUrlMsg)
- {
- pcUrlMsg = pcUrlMsg.Replace("\n\r", " ");
- pcUrlMsg = pcUrlMsg.Replace("\r\n", " ");
- pcUrlMsg = pcUrlMsg.Replace("\r", " ");
- pcUrlMsg = pcUrlMsg.Replace("\n", " ");
- return pcUrlMsg;
- }
- //public static void WebShowMessage(string pcMsg)
- //{
- // WebShowMessage(pcMsg, ErrActType.Return);
- //}
- //public static void WebShowMessage(string pcMsg, ErrActType poErrActType)
- //{
- // pcMsg = ConvertURLMsg(pcMsg);
- // HttpContext.Current.Response.Redirect("../Pub/WebShowMsg.aspx?pc_ErrorMsg=" + pcMsg + "&pc_ActionType=" + poErrActType.ToString());
- //}
- public static Unit IntToUnit(int piPixels)
- {
- return Unit.Parse(piPixels.ToString() + "px");
- }
- public static string ColorToHex(System.Drawing.Color poColor)
- {
- string lcRetVal = poColor.ToArgb().ToString("X");
- lcRetVal = "#" + lcRetVal.Substring(2, 6);
- return lcRetVal;
- }
- public static string CurPageName
- {
- get
- {
- string lcRetVal = "";
- string[] arrayurl = HttpContext.Current.Request.Url.PathAndQuery.Split('?');
- if (arrayurl.Length > 0)
- {
- string file = arrayurl[0];
- string[] arr2 = file.Split('/');
- if (arr2.Length > 0)
- {
- if (arr2.Length == 1)
- lcRetVal = arr2[0];
- else
- lcRetVal = arr2[arr2.Length - 2] + "_" + arr2[arr2.Length - 1];
- }
- }
- return lcRetVal;
- }
- }
- public static UserSession GetUserSession()
- {
- UserSession loRetVal = null;
- if (HttpContext.Current != null && HttpContext.Current.Session != null && HttpContext.Current.Session[Contants.UserInfoId] != null)
- {
- loRetVal = (UserSession)HttpContext.Current.Session[Contants.UserInfoId];
- }
- return loRetVal;
- }
- public static UserSession CheckLogin()
- {
- var loRetVal = GetUserSession();
- if (loRetVal == null)
- {
- //System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>alert('对不起! 您还没有登录或超时'); Form2.submit();</script>");
- // System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>Form2.submit();</script>");
- //System.Web.HttpContext.Current.Response.Write("<script>window.location.href='../Default.aspx';</script>");
- HttpContext.Current.Response.Write("<script>window.location.href='../Manage/login.aspx';</script>");
- //System.Web.HttpContext.Current.Response.Write("timeout");
- HttpContext.Current.Response.End();
- }
- return loRetVal;
- }
- public static UserSession CheckLoginAjax()
- {
- var loRetVal = GetUserSession();
- if (loRetVal == null)
- {
- //System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>alert('对不起! 您还没有登录或超时'); Form2.submit();</script>");
- // System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>Form2.submit();</script>");
- //System.Web.HttpContext.Current.Response.Write("<script>window.location.href='../Default.aspx';</script>");
- //System.Web.HttpContext.Current.Response.Write("<script>window.location.href='../login/login.aspx';</script>");
- HttpContext.Current.Response.Write("timeout");
- HttpContext.Current.Response.End();
- }
- return loRetVal;
- }
- /**
- * 检查参会者的Session
- *
- * */
-
- public static string GetCookieValue(string pcCookieKey)
- {
- return GetCookieValue(pcCookieKey, Contants.SysCookieName);
- }
- public static string GetCookieValue(string pcCookieKey, string pcCookieName)
- {
- string lcRetVal = "";
- if (HttpContext.Current.Request.Browser.Cookies)
- {
- HttpCookie loCookie = HttpContext.Current.Request.Cookies[pcCookieName];
- string lcTempValue = loCookie?[pcCookieKey];
- if (lcTempValue != null)
- lcRetVal = lcTempValue;
- }
- return lcRetVal;
- }
- public static void SetCookieValue(string pcCookieKey, string pcCookieValue)
- {
- SetCookieValue(pcCookieKey, pcCookieValue, Contants.SysCookieName);
- }
- public static void SetCookieValue(string pcCookieKey, string pcCookieValue, string pcCookieName)
- {
- if (HttpContext.Current.Request.Browser.Cookies)
- {
- HttpCookie loCookie = HttpContext.Current.Request.Cookies[pcCookieName] ?? new HttpCookie(pcCookieName);
- loCookie.Values.Remove(pcCookieKey);
- loCookie.Values.Add(pcCookieKey, pcCookieValue);
- loCookie.Expires = DateTime.Now.AddMonths(6);
- HttpContext.Current.Response.SetCookie(loCookie);
- }
- }
- public static string CvStrByType(ref string pcStr, CovType typeUse)
- {
- pcStr = pcStr.Trim();
- switch (((int)typeUse))
- {
- case 1:
- pcStr = pcStr.Replace(@"\", @"\\");
- pcStr = pcStr.Replace("\r\n", @"\n");
- pcStr = pcStr.Replace("\r", "");
- pcStr = pcStr.Replace("\n", "");
- pcStr = pcStr.Replace("'", @"\'");
- break;
- case 2:
- pcStr = pcStr.Replace("&", "&");
- pcStr = pcStr.Replace("<", "<");
- pcStr = pcStr.Replace(">", ">");
- pcStr = pcStr.Replace(" ", " ");
- pcStr = pcStr.Replace("'", "\u2019");
- pcStr = pcStr.Replace("\r\n", "<br>");
- pcStr = pcStr.Replace("\r", "<br>");
- pcStr = pcStr.Replace("\n", "<br>");
- break;
- case 3:
- pcStr = pcStr.Replace("<br>", "\r\n");
- pcStr = pcStr.Replace("<BR>", "\r\n");
- pcStr = pcStr.Replace("<Br>", "\r\n");
- pcStr = pcStr.Replace("<bR>", "\r\n");
- break;
- case 4:
- pcStr = pcStr.Replace("\r\n", "<br>");
- pcStr = pcStr.Replace(" ", " ");
- pcStr = pcStr.Replace("'", "\u2019");
- pcStr = pcStr.Replace("\r", "<br>");
- pcStr = pcStr.Replace("\n", "<br>");
- pcStr = pcStr.Replace("<", "<");
- pcStr = pcStr.Replace(">", ">");
- pcStr = pcStr.Replace("&", "\uff06");
- break;
- default:
- pcStr = pcStr.Replace("'", "''");
- break;
- }
- return (pcStr + "");
- }
- #region //===============================错误处理======================
- /// <summary>
- /// 权限检查错误转向页面
- /// </summary>
- /// <param name="asPowerType">1,没有浏览权;2,没有添加权 ; 3 没有修改权 4;没有删除权;
- /// 5,没有打印权; 7 页面权限编号信息错误</param>
- public static void NotPower(int asPowerType)
- {
- NotPower(asPowerType, "N");
- }
- /// <summary>
- /// 权限检查错误转向页面
- /// </summary>
- /// <param name="asPowerType"> 1,没有浏览权;2,没有添加权 ; 3 没有修改权 4;没有删除权;
- /// 5,没有打印权; 7 页面权限编号信息错误</param>
- /// <param name="asReturnType">参数 C 关闭;R 重定向 ;P 上一页; U 指定页面 ;N 不显示</param>
- public static void NotPower(int asPowerType, string asReturnType)
- {
- if (asPowerType == 1) { ErrRedirect(-30000001, asReturnType); } //浏览
- if (asPowerType == 2) { ErrRedirect(-30000002, asReturnType); } //添加
- if (asPowerType == 3) { ErrRedirect(-30000003, asReturnType); } //修改
- if (asPowerType == 4) { ErrRedirect(-30000004, asReturnType); } //删除
- if (asPowerType == 5) { ErrRedirect(-30000005, asReturnType); } //打印
- if (asPowerType == 5) { ErrRedirect(-30000006, asReturnType); } //审核
- if (asPowerType == 6) { ErrRedirect(-311271, asReturnType); } //检查是否有浏览新增删除修改的权限
- if (asPowerType == 7) { ErrRedirect(-30000008, asReturnType); } //页面权限编号信息错误
- if (asPowerType == 8) { ErrRedirect(-30000007, asReturnType); } //页面权限编号信息错误
- }
- /// <summary>
- /// 操作错误 提示页面
- /// </summary>
- /// <param name="asPowerType">1,为删除的行为空 ;2 编号为空 ;3 参数传递错误 </param>
- public static void OperationErr(int asPowerType)
- {
- OperationErr(asPowerType, "");
- }
- /// <summary>
- /// 操作错误 提示页面
- /// </summary>
- /// <param name="asOperationType">1,为删除的行为空 ;2 编号为空 ;3 参数传递错误 </param>
- /// <param name="asReturnType"></param>
- public static void OperationErr(int asOperationType, string asReturnType)
- {
- if (asOperationType == 1) { ErrRedirect(-10000101, asReturnType); }
- if (asOperationType == 2) { ErrRedirect(-10000102, asReturnType); }
- if (asOperationType == 3) { ErrRedirect(-10000103, asReturnType); }
- }
- public static void ErrRedirect(int asErrorCode, string asReturnType)
- {
- var returnType = asReturnType.Trim().Length == 0 ? "C" : asReturnType;
- PageRedirect(asErrorCode, returnType);
- }
- public static void PageRedirect(int errorCode, string returnType)
- {
- HttpContext.Current.Response.Redirect("../Pub/PubShowMessage.aspx?al_ErrCode=" + errorCode + "&as_ReturnType=" + returnType);
- }
- public static void LoginOut()
- {
- HttpContext.Current.Session.RemoveAll();
- HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>Form2.submit();</script>");
- HttpContext.Current.Response.End();
- }
- #endregion
- }
- public sealed class Contants
- {
- public const string UserInfoId = "WeiBoYUserInfoIdInSession";
- public const string SysCookieName = "WeiBoYCookieKeyYue";
- public const string UserName = "WeiBoYCookieUserName";
- public const string PassWord = "WeiBoYCookieUserPassWord";
- public const string StatusNew = "new";
- public const string StatusExec = "exec";
- public const string StatusCmp = "cmp";
- public const string CustomerInfoNo = "ServiceTypeCustomerInfoNoSession";
- public const string SendMsgReg = "ServiceTypeSendMsgRegSession";
- public const string SendMsgLogin = "ServiceTypeSendMsgLoginSession";
- public const string SendEamilMsg = "CustomerSendEamilMsgModifyEmailSession";
- public const string AlumnuseInfoId = "AlumnuseInfoIdSession";
- }
- public sealed class Sc
- {
- public const string Select = " SELECT ";
- public const string And = " AND ";
- public const string From = " FROM ";
- public const string Where = " WHERE ";
- public const string Orderby = " ORDER BY ";
- public const string Delete = " DELETE ";
- public const string Update = " UPDATE ";
- public const string Set = " SET ";
- public const string Eq = " = ";
- public const string Or = " OR ";
- public const string Groupby = " GROUP BY ";
- public const string Like = " LIKE ";
- }
- public class UserSession
- {
-
- // Methods
- #region 权限菜单相关方法
- //private Dictionary<string, UIAndPower> _PowHas;
- //private UIAndPowerList _PowerList;
- //public bool CheckPowerNoErrRedirect(PowerType poType)
- //{
- // UserSession loSession = WebLibs.GetUserSession();
- // if (loSession != null)
- // {
- // SonicLog.LogInfo(loSession.UserInfo.UserNo + " --- " + WebLibs.CurPageName + " --- " + poType.ToString());
- // }
- // string pcUIID = UtilStr.UAndT(WebLibs.CurPageName);
- // bool lbRetVal = false;
- // if (this._PowerList.ContainPageName(pcUIID))
- // {
- // UIAndPower power = this._PowerList.getUIAndPowerByPageName(pcUIID);
- // switch (poType)
- // {
- // case PowerType.IsBrowse:
- // lbRetVal = power.IsBrowse;
- // break;
- // case PowerType.IsNew:
- // lbRetVal = power.IsAdd;
- // break;
- // case PowerType.IsEdit:
- // lbRetVal = power.IsUpdate;
- // break;
- // case PowerType.IsDelete:
- // lbRetVal = power.IsDelete;
- // break;
- // case PowerType.IsAudit:
- // lbRetVal = power.IsAudit;
- // break;
- // case PowerType.IsPrint:
- // lbRetVal = power.IsPrint;
- // break;
- // }
- // }
- // return lbRetVal;
- //}
- ///// <summary>
- ///// 权限检查
- ///// </summary>
- ///// <param name="poType">检查的类型</param>
- ///// <returns></returns>
- //public bool CheckPower(PowerType poType)
- //{
- // UserSession loSession = WebLibs.GetUserSession();
- // if (loSession != null)
- // {
- // SonicLog.LogInfo(loSession.UserInfo.UserNo+ " --- " + WebLibs.CurPageName + " --- " + poType.ToString());
- // }
- // string pcUIID = UtilStr.UAndT(WebLibs.CurPageName);
- // bool lbRetVal = false;
- // if (this._PowerList.ContainPageName(pcUIID))
- // {
- // UIAndPower power = this._PowerList.getUIAndPowerByPageName(pcUIID);
- // switch (poType)
- // {
- // case PowerType.IsBrowse:
- // lbRetVal = power.IsBrowse;
- // break;
- // case PowerType.IsNew:
- // lbRetVal = power.IsAdd;
- // break;
- // case PowerType.IsEdit:
- // lbRetVal = power.IsUpdate;
- // break;
- // case PowerType.IsDelete:
- // lbRetVal = power.IsDelete;
- // break;
- // case PowerType.IsAudit:
- // lbRetVal = power.IsAudit;
- // break;
- // case PowerType.IsPrint:
- // lbRetVal = power.IsPrint;
- // break;
- // }
- // }
- // else
- // {
- // JSComm.ShowMessage("该用户没有相应的权限");
- // }
- // return lbRetVal;
- //}
- //public bool CheckPower()
- //{
- // string lcPageName = UtilStr.UAndT(WebLibs.CurPageName);
- // bool lbRetVal = false;
- // if (this._PowerList.ContainPageName(lcPageName))
- // {
- // UIAndPower power = this._PowerList.getUIAndPowerByPageName(lcPageName);
- // if (power.IsBrowse && power.IsAdd && power.IsUpdate && power.IsDelete)
- // {
- // lbRetVal = true;
- // }
- // else
- // WebLibs.NotPower(6);
- // }
- // else
- // {
- // WebLibs.NotPower(7);
- // }
- // return lbRetVal;
- //}
- //private void CreatePowHasDict(DataTable poDataTable)
- //{
- // if (this._PowerList == null)
- // this._PowerList = new UIAndPowerList();
- // else
- // this._PowerList.Clear();
- // if (poDataTable!=null)
- // {
- // try
- // {
- // _PowerList.SetData(poDataTable);
- // }
- // catch (Exception e)
- // {
- // SonicLog.LogException(e);
- // _ErrorMsg = e.Message;
- // }
- // }
- //}
- //public void refreshFunctions()
- //{
- // string lcSql = "select * from " + Tn.v_UserHasAllFunctions_New + " where UserNo='" + this._UserInfo.UserNo + "' order by FunctionID ";
- // snQuery loQuery = DBConn.OpenQuery(lcSql);
- // if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- // {
- // CreatePowHasDict(loQuery.CurrentTable);
- // }
- // else
- // {
- // _ErrorMsg = DBConn.ErrorMsg;
- // SonicLog.LogError(_ErrorMsg);
- // }
- //}
- #endregion
- //List<string> _DenyList = null;
- //private List<string> DenyList
- //{
- // get
- // {
- // if (_DenyList == null)
- // {
- // string lcSql = " select * from " + Tn.v_UserDenyColumns + " where " + v_UserDenyColumns_info.cUserNo + "='" + _UserInfo.UserNo + "'";
- // snQuery loQuery = DBConn.OpenQuery(lcSql);
- // if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- // {
- // _DenyList = new List<string>();
- // loQuery.MoveFirst();
- // for (int i = 0; i < loQuery.RecCount; i++)
- // {
- // string lcTCol = loQuery.GetString("TableId") + "." + loQuery.GetString("ColumnId");
- // lcTCol = UtilStr.UAndT(lcTCol);
- // _DenyList.Add(lcTCol);
- // loQuery.MoveNext();
- // }
- // }
- // }
- // return _DenyList;
- // }
- //}
- //public bool ColDeny(string pcTableId, string pcColumnId)
- //{
- // bool lbRetVal = false;
- // if (DenyList != null)
- // {
- // string lcTCol = pcTableId + "." + pcColumnId;
- // lcTCol = UtilStr.UAndT(lcTCol);
- // lbRetVal = DenyList.Contains(lcTCol);
- // }
- // return lbRetVal;
- //}
- #region 基础属性
- public string ErrorMsg { get; set; } = "";
- //public bool IsAdvance
- //{
- // get { return UtilStr.StrToBool(_UserInfo.IsAdvance); }
- //}
-
- #endregion
- #region
- //IUserInfo _userInfos = null;
- //public IUserInfo UserInfos
- //{
- // get { return _userInfos; }
- // set { _userInfos = value; }
- //}
- //public string GetAuthSql(bool IsPath, bool IsWhere)
- //{
- // string lcRetVal = " 1=1 ";
- // if (!UtilStr.StrToBool(this.UserInfo.IsSys))
- // {
- // RegionGroups_info loRegion = new RegionGroups_info(this.UserInfo.RegionGroupNo,DBConn);
- // if (IsPath)
- // {
- // lcRetVal = " Path Like '" + loRegion.Path + "%' ";
- // }
- // else
- // {
- // string lcSql = " select RegionGroupNo from RegionGroups where Path Like '" + loRegion.Path + "%' ";
- // snQuery loQuery = DBConn.OpenQuery(lcSql);
- // string lcWhere = "";
- // if (loQuery != null && loQuery.IsOpened)
- // {
- // loQuery.MoveFirst();
- // for (int i = 0; i < loQuery.RecCount; i++)
- // {
- // lcWhere += (lcWhere == "" ? "" : ",") + "'" + loQuery.GetString("RegionGroupNo") + "'";
- // loQuery.MoveNext();
- // }
- // }
- // lcRetVal = " RegionGroupNo in (" + lcWhere + ") ";
- // }
- // }
- // if (IsWhere)
- // {
- // lcRetVal = " WHERE " + lcRetVal;
- // }
- // return lcRetVal;
- //}
- //public string GetPersonAuthSql(bool IsPath, bool IsWhere)
- //{
- // string lcRetVal = "";
- // if (!UtilStr.StrToBool(this.UserInfo.IsSys))
- // {
- // PersonGroups_info loRegion = new PersonGroups_info(this.UserInfo.PersonGroupNo, DBConn);
- // if (IsPath)
- // {
- // lcRetVal = " Path Like '" + loRegion.Path + "%' ";
- // }
- // if (IsWhere)
- // {
- // lcRetVal = " WHERE " + lcRetVal;
- // }
- // }
- // return lcRetVal;
- //}
- #endregion
- #region 获得菜单列表的方法
- /// <summary>
- /// 得到用户能查看的菜单所有列表的string型
- /// </summary>
- //public string UserFunctionIdList
- //{
- // get
- // {
- // if (_PowerList != null)
- // {
- // return _PowerList.UserFunctionIdList;
- // }
- // else
- // return "";
- // }
- //}
- //public string GetMenuTable(MenuType poMType)
- //{
- // string lcRetVal = "";
- // string lcSql = "select FunctionID,FunctionName,URL,FatherID ,Depth,IsLeaf,Sort from " + Tn.Sys_Functions + " where 1=1 ";
- // switch (poMType)
- // {
- // case MenuType.Back:
- // lcSql += " and IsBack='Y' ";
- // break;
- // case MenuType.Front:
- // lcSql += " and IsFront='Y' ";
- // break;
- // }
- // lcSql += " and FunctionID in ( " + UserFunctionIdList + " )";
- // lcSql += " order by sort asc ";
- // DataSet loDataSet = DBConn.OpenDataSet(lcSql);
- // if (loDataSet != null && loDataSet.Tables.Count > 0)
- // {
- // lcRetVal = loDataSet.GetXml();
- // }
- // else
- // {
- // JSComm.ShowMessage("该用户尚未配置相关权限,请与有关人员联系!");
- // System.Web.HttpContext.Current.Response.Write("<form id='Form2' method='post' action='../Default.aspx' target='_top' ></form><script>Form2.submit();</script>");
- // System.Web.HttpContext.Current.Response.End();
- // }
- // return lcRetVal;
- //}
- //public DataTable GetMenuTableDate(MenuType poMType)
- //{
- // DataTable loRetVal = null;
- // string lcSql = "select FunctionID,FunctionName,URL,FatherID ,Depth,IsLeaf,Sort from " + Tn.Sys_Functions + " where 1=1 ";
- // switch (poMType)
- // {
- // case MenuType.Back:
- // lcSql += " and IsBack='Y' ";
- // break;
- // case MenuType.Front:
- // lcSql += " and IsFront='Y' ";
- // break;
- // }
- // lcSql += " and FunctionID in ( " + _PowerList.UserFunctionIdList + " )";
- // lcSql += " order by sort asc ";
- // loRetVal = DBConn.OpenDataTable(lcSql);
- // return loRetVal;
- //}
- #endregion
- public void Destroy()
- {
- if (_objSave != null)
- {
- _objSave.Clear();
- _objSave = null;
- }
- }
-
- #region 对象存储
- Dictionary<string, object> _objSave;
- public void SetObj(string pcKey, object pcValue)
- {
- if (_objSave == null)
- _objSave = new Dictionary<string, object>();
- if (_objSave.ContainsKey(pcKey))
- _objSave[pcKey] = pcValue;
- else
- _objSave.Add(pcKey, pcValue);
- }
- public T GetObj<T>(string pcKey)
- {
- return GetObj<T>(pcKey, true);
- }
- /// <summary>
- /// 得到对象
- /// </summary>
- /// <param name="pcKey">索引值</param>
- /// <param name="pbClear">是否情况该对象</param>
- /// <returns></returns>
- public T GetObj<T>(string pcKey, bool pbClear)
- {
- T loRetVal = default(T);
- if (_objSave != null && _objSave.ContainsKey(pcKey))
- {
- if (_objSave[pcKey] is T)
- loRetVal = (T)_objSave[pcKey];
- if (pbClear)
- {
- _objSave.Remove(pcKey);
- }
- }
- return loRetVal;
- }
- /// <summary>
- /// 清空指定对象
- /// </summary>
- public void ClearObj(string pcKey)
- {
- if (_objSave != null)
- {
- if (_objSave.ContainsKey(pcKey))
- {
- _objSave.Remove(pcKey);
- }
- }
- }
- /// <summary>
- /// 清空对象
- /// </summary>
- public void ClearObj()
- {
- if (_objSave != null)
- {
- _objSave.Clear();
- _objSave = null;
- }
- }
- #endregion 对象存储
- }
- public enum MenuType
- {
- /// <summary>
- /// 前台显示
- /// </summary>
- Front = 0,
- /// <summary>
- /// 后台显示
- /// </summary>
- Back = 1,
- /// <summary>
- /// 显示所有
- /// </summary>
- All = 2
- }
- public enum AcountType
- {
- /// <summary>
- /// 系统用户
- /// </summary>
- System = 0,
- /// <summary>
- /// 高级用户
- /// </summary>
- Advance = 1,
- /// <summary>
- /// 普通用户
- /// </summary>
- Common = 2,
- /// <summary>
- /// 高级市场用户
- /// </summary>
- AdvanceMarket = 3,
- /// <summary>
- /// 普通市场用户
- /// </summary>
- CommonMarket = 4
- }
- }
|