using DeviceRepair.Models; using DeviceRepair.Models.DeviceRepair; using DeviceRepair.Models.SFC; using System; using System.Collections.Generic; using System.Linq; using TsSFCDevice.Client.Biz.Impl; namespace TsSFCDevice.Client.Biz.Base.Utils { public class SysRuntimeInfo { public readonly string DEVICE_OEM = "BIZ_EQUIP_70"; public readonly string DEVICE_KH = "BIZ_EQUIP_69"; /// /// 当前机器名 /// public string ComputerName { get; set; } #region 当前登陆用户信息 private TsSFCUserInfo m_CurrentUser; public TsSFCUserInfo CurrentUser { get { return m_CurrentUser; } set { m_CurrentUser = value; } } private IList m_CurrentAuths; public IList CurrentAuths { get { return m_CurrentAuths; } set { m_CurrentAuths = value; } } #endregion #region 各种缓存 private IList m_CurrentDeviceCaches; /// /// 设备信息缓存 /// public IList CurrentDeviceCaches { get { if ((m_CurrentDeviceCaches?.Count ?? 0) == 0) { List auths = new List(); if (AuthValidate(DEVICE_OEM)) auths.Add("OEM"); if (AuthValidate(DEVICE_KH)) auths.Add("KH"); DevRepository devDa = new DevRepository(); m_CurrentDeviceCaches = devDa.GetDatas(auths); } return m_CurrentDeviceCaches; } set { m_CurrentDeviceCaches = value; } } public int[] CurrentDeviceAutoIDCaches { get { return CurrentDeviceCaches.Select(x => x.AutoID).ToArray(); } } private IList m_CurrentUsersCaches; /// /// 当前用户信息缓存 /// public IList CurrentUsersCaches { get { if (m_CurrentUsersCaches == null) { UserRepository userDa = new UserRepository(); m_CurrentUsersCaches = userDa.GetDatas(); } return m_CurrentUsersCaches; } set { m_CurrentUsersCaches = value; } } private IList m_CurrentDevRootCaches; public IList CurrentDevRootCaches { get { if ((m_CurrentDevRootCaches?.Count ?? 0) == 0) { List auths = new List(); if (AuthValidate(DEVICE_OEM)) auths.Add("OEM"); if (AuthValidate(DEVICE_KH)) auths.Add("KH"); m_CurrentDevRootCaches = DevRepository.Instance.Get_DEVICE_Route(auths); } return m_CurrentDevRootCaches; } set { m_CurrentDevRootCaches = value; } } private IList m_DeviceWarrantyFormVerCaches; /// /// 设备维修表单信息 /// public IList DeviceWarrantyFormVerCaches { get { if ((m_DeviceWarrantyFormVerCaches?.Count ?? 0) == 0) { m_DeviceWarrantyFormVerCaches = MaintenanceRepository.Instance.Get_DeviceWarrantyFormVer(); } return m_DeviceWarrantyFormVerCaches; } } #endregion #region Methods /// /// 校验用户权限 /// /// /// public bool AuthValidate(string vAuthCode) { return CurrentAuths?.FirstOrDefault(A => { return A.AuthCode == vAuthCode; }) != null; } public bool AuthStartWithValidate(string vAuthCode) { return CurrentAuths?.FirstOrDefault(A => { return A.AuthCode.StartsWith(vAuthCode, StringComparison.OrdinalIgnoreCase); }) != null; } #endregion } }