123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- using SysBaseLibs;
- using SysDataLibs.TableClass;
- namespace SysDataLibs
- {
- public class UIAndPower
- {
- // Fields
- private string _FunctoinId = "";
- private bool _IsAdd = false;
- private bool _IsBrowse = false;
- private bool _IsDelete = false;
- private bool _IsAudit = false;
- private bool _IsPrint = false;
- private bool _IsUpdate = false;
- private string _PageName = "";
- List<string> _PageNameList = null;
- public UIAndPower(DataRow poRow)
- {
- if (poRow != null)
- {
- _FunctoinId = UtilStr.StrFromObj(poRow[Sys_Functions_info.cFunctionID]);
- _IsAdd = Utils.ObjToBool(poRow[Sys_Functions_info.cIsAdd]);
- _IsBrowse = Utils.ObjToBool(poRow[Sys_Functions_info.cIsBrowse]);
- _IsDelete = Utils.ObjToBool(poRow[Sys_Functions_info.cIsDelete]);
- _IsAudit = Utils.ObjToBool(poRow[Sys_Functions_info.cIsAudit]);
- _IsPrint = Utils.ObjToBool(poRow[Sys_Functions_info.cIsPrint]);
- _IsUpdate = Utils.ObjToBool(poRow[Sys_Functions_info.cIsUpdate]);
- _PageName = UtilStr.StrFromObj(poRow[Sys_Functions_info.cPageName]);
- _PageName = UtilStr.UAndT(_PageName);
- }
- }
- public List<string> PageNameList
- {
- get
- {
- if (_PageNameList == null)
- {
- _PageNameList = new List<string>();
- Array loArr = UtilStr.StrToArrayEx(_PageName, ";");
- if (loArr != null && loArr.Length > 0)
- {
- foreach (string lcName in loArr)
- _PageNameList.Add(lcName);
- }
- }
- return _PageNameList;
- }
- }
- // Properties
- public string FunctoinId
- {
- get
- {
- return this._FunctoinId;
- }
- }
- public string PageName
- {
- get { return this._PageName; }
- }
- public bool ContainsPageName(string pcPageName)
- {
- pcPageName = UtilStr.UAndT(pcPageName);
- return PageNameList.Contains(pcPageName);
- }
- public bool IsAdd
- {
- get
- {
- return this._IsAdd;
- }
- }
- public bool IsUpdate
- {
- get
- {
- return this._IsUpdate;
- }
- }
- public bool IsBrowse
- {
- get
- {
- return this._IsBrowse;
- }
- }
- public bool IsDelete
- {
- get
- {
- return this._IsDelete;
- }
- }
- public bool IsPrint
- {
- get
- {
- return this._IsPrint;
- }
- }
- public bool IsAudit
- {
- get
- {
- return this._IsAudit;
- }
- }
- }
- public class UIAndPowerList : List<UIAndPower>
- {
- public UIAndPowerList()
- {
- }
- public void SetData(DataTable poDataTable)
- {
- if (poDataTable != null && poDataTable.Rows != null)
- {
- foreach (DataRow loRow in poDataTable.Rows)
- {
- try
- {
- UIAndPower loPow = new UIAndPower(loRow);
- this.Add(loPow);
- }
- catch (Exception e)
- {
- ThreadLog.LogException(e);
- continue;
- }
- }
- }
- }
- Dictionary<string, UIAndPower> _PageNameUIAndPowerDic = null;
- public Dictionary<string, UIAndPower> PageNameUIAndPowerDic
- {
- get
- {
- if (_PageNameUIAndPowerDic == null)
- {
- _PageNameUIAndPowerDic = new Dictionary<string, UIAndPower>();
- foreach (UIAndPower loPower in this)
- {
- if (loPower.PageNameList.Count > 0)
- {
- foreach (string lcPageName in loPower.PageNameList)
- {
- if (_PageNameUIAndPowerDic.ContainsKey(lcPageName))
- {
- _PageNameUIAndPowerDic[lcPageName] = loPower;
- }
- else
- _PageNameUIAndPowerDic.Add(lcPageName, loPower);
- }
- }
- }
- }
- return _PageNameUIAndPowerDic;
- }
- }
- public bool ContainFunctionID(string pcFunctionID)
- {
- bool lbRetVal = false;
- foreach (UIAndPower loPower in this)
- {
- if (loPower.FunctoinId == pcFunctionID)
- {
- lbRetVal = true;
- break;
- }
- }
- return lbRetVal;
- }
- public bool ContainPageName(string pcPageName)
- {
- pcPageName = UtilStr.UAndT(pcPageName);
- return PageNameUIAndPowerDic.ContainsKey(pcPageName);
- }
- public UIAndPower getUIAndPowerByPageName(string pcPageName)
- {
- UIAndPower loRetVal = null;
- pcPageName = UtilStr.UAndT(pcPageName);
- if (this.PageNameUIAndPowerDic.ContainsKey(pcPageName))
- loRetVal = PageNameUIAndPowerDic[pcPageName];
- return loRetVal;
- }
- public string UserFunctionIdList
- {
- get
- {
- string lcRetVal = "";
- foreach (UIAndPower loUIP in this)
- {
- lcRetVal += (lcRetVal == "" ? "" : ",") + "'" + loUIP.FunctoinId.Trim() + "'";
- }
- return lcRetVal;
- }
- }
- public new void Clear()
- {
- if (_PageNameUIAndPowerDic != null)
- {
- _PageNameUIAndPowerDic.Clear();
- _PageNameUIAndPowerDic = null;
- }
- base.Clear();
- }
- }
- public enum PowerType
- {
- IsBrowse = 0,
- IsAdd = 1,
- IsUpdate = 2,
- IsDelete = 3,
- IsPrint = 4,
- IsAudit = 5
- }
- }
|