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 _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 PageNameList { get { if (_PageNameList == null) { _PageNameList = new List(); 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 { 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 _PageNameUIAndPowerDic = null; public Dictionary PageNameUIAndPowerDic { get { if (_PageNameUIAndPowerDic == null) { _PageNameUIAndPowerDic = new Dictionary(); 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 } }