123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace WebAPIBase.NetCore.BusinessCore
- {
- public class FdcStation
- {
- private FdcUnitStructure fdcUnitStructure;
- private string stationCode;
- private string stationName;
- private string unitCode;
- internal List<FdcUnitRight> unitList = new List<FdcUnitRight>();
- internal Dictionary<string, innerFunction> functionList = new Dictionary<string, innerFunction>();
- public List<int> UserList = new List<int>();
- public string StationCode
- {
- get
- {
- return stationCode;
- }
- set
- {
- stationCode = value;
- }
- }
- public string StationName
- {
- get
- {
- return stationName;
- }
- set
- {
- stationName = value;
- }
- }
- public string UnitCode
- {
- get
- {
- return unitCode;
- }
- set
- {
- unitCode = value;
- }
- }
- internal FdcStation(FdcUnitStructure unitStructure, string code, string name)
- {
- fdcUnitStructure = unitStructure;
- StationCode = code;
- StationName = name;
- }
- public bool HasRight(string functionCode)
- {
- return functionList.ContainsKey(functionCode);
- }
- public bool HasUnitRight(string functionCode, string unitCode)
- {
- if (unitCode == null || unitCode == string.Empty)
- {
- throw new ArgumentException("unit code不能为空");
- }
- if (functionList.ContainsKey(functionCode))
- {
- innerFunction innerFunction = functionList[functionCode];
- foreach (FdcUnitRight unit in innerFunction.UnitList)
- {
- if (unit.unit.isMyChild(unitCode))
- {
- return true;
- }
- }
- }
- return false;
- }
- public bool HasSubUnitRight(string functionCode, string unitCode)
- {
- if (unitCode == null || unitCode == string.Empty)
- {
- throw new ArgumentException("unit code不能为空");
- }
- if (functionList.ContainsKey(functionCode))
- {
- innerFunction innerFunction = functionList[functionCode];
- foreach (FdcUnitRight unit in innerFunction.UnitList)
- {
- if (unit.unit.isMyChild(unitCode))
- {
- return true;
- }
- if (unit.unit.isMyParent(unitCode))
- {
- return true;
- }
- }
- }
- return false;
- }
- public bool HasGroupRight(string functionCode, string groupCode)
- {
- return HasRight(functionCode, "", groupCode);
- }
- public bool HasRight(string functionCode, string unitCode, string groupCode)
- {
- if ((unitCode == null || unitCode == string.Empty) && (groupCode == null || groupCode == string.Empty))
- {
- return HasRight(functionCode);
- }
- bool flag = true;
- if (unitCode == null || unitCode == string.Empty)
- {
- flag = false;
- }
- if (groupCode == null || groupCode == string.Empty)
- {
- return HasUnitRight(functionCode, unitCode);
- }
- if (functionList.ContainsKey(functionCode))
- {
- innerFunction innerFunction = functionList[functionCode];
- FdcFunction functionByCode = fdcUnitStructure.GetFunctionByCode(functionCode);
- if (!functionByCode.UnitRelated && !functionByCode.SystemGroupRelated)
- {
- return true;
- }
- if (functionByCode.UnitRelated && !functionByCode.SystemGroupRelated)
- {
- return HasUnitRight(functionCode, unitCode);
- }
- if (!functionByCode.UnitRelated && functionByCode.SystemGroupRelated)
- {
- flag = false;
- }
- foreach (FdcGroupUnitRight groupUnit in innerFunction.GroupUnitList)
- {
- if ((!flag || groupUnit.unit.isMyChild(unitCode)) && groupUnit.group.isMyChild(groupCode))
- {
- return true;
- }
- }
- }
- return false;
- }
- public RightScope GetUnitRightScope(string unitCode)
- {
- RightScope result = RightScope.无;
- foreach (FdcUnitRight unit in unitList)
- {
- if (unit.IsPerson == 0)
- {
- if (unit.unit.isMyChild(unitCode))
- {
- return RightScope.部门;
- }
- }
- else if (unit.unit.isMyParent(unitCode))
- {
- result = RightScope.个人;
- }
- }
- return result;
- }
- }
- public class FdcUnitRight
- {
- public FdcUnit unit;
- public int IsPerson;
- }
- }
|