DeviceManager/TsSFCDevice.Client.Biz/Base/Utils/SysRuntimeInfo.cs

167 lines
4.7 KiB
C#
Raw Permalink Normal View History

2024-07-27 01:44:19 +00:00
using DeviceRepair.Models;
2024-11-09 04:25:57 +00:00
using DeviceRepair.Models.DeviceRepair;
2024-07-27 01:44:19 +00:00
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
{
2024-08-07 05:57:10 +00:00
public readonly string DEVICE_OEM = "BIZ_EQUIP_70";
public readonly string DEVICE_KH = "BIZ_EQUIP_69";
2024-07-27 01:44:19 +00:00
/// <summary>
/// 当前机器名
/// </summary>
public string ComputerName { get; set; }
#region
private TsSFCUserInfo m_CurrentUser;
public TsSFCUserInfo CurrentUser
{
get
{
return m_CurrentUser;
}
set
{
m_CurrentUser = value;
}
}
private IList<TsSFCAuths> m_CurrentAuths;
public IList<TsSFCAuths> CurrentAuths
{
get
{
return m_CurrentAuths;
}
set
{
m_CurrentAuths = value;
}
}
#endregion
#region
private IList<DeviceInformationInfo> m_CurrentDeviceCaches;
/// <summary>
/// 设备信息缓存
/// </summary>
public IList<DeviceInformationInfo> CurrentDeviceCaches
{
get
{
2024-11-09 04:25:57 +00:00
if ((m_CurrentDeviceCaches?.Count ?? 0) == 0)
2024-07-27 01:44:19 +00:00
{
List<string> auths = new List<string>();
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
{
2024-08-02 02:52:45 +00:00
return CurrentDeviceCaches.Select(x => x.AutoID).ToArray();
2024-07-27 01:44:19 +00:00
}
}
private IList<TsSFCUserInfo> m_CurrentUsersCaches;
/// <summary>
/// 当前用户信息缓存
/// </summary>
public IList<TsSFCUserInfo> CurrentUsersCaches
{
get
{
if (m_CurrentUsersCaches == null)
{
UserRepository userDa = new UserRepository();
m_CurrentUsersCaches = userDa.GetDatas();
}
return m_CurrentUsersCaches;
}
set
{
m_CurrentUsersCaches = value;
}
}
2024-08-02 02:52:45 +00:00
private IList<DeviceRouteInfo> m_CurrentDevRootCaches;
public IList<DeviceRouteInfo> CurrentDevRootCaches
{
get
{
2024-11-09 04:25:57 +00:00
if ((m_CurrentDevRootCaches?.Count ?? 0) == 0)
2024-08-02 02:52:45 +00:00
{
List<string> auths = new List<string>();
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;
}
}
2024-11-09 04:25:57 +00:00
private IList<DeviceWarrantyFormVer> m_DeviceWarrantyFormVerCaches;
/// <summary>
/// 设备维修表单信息
/// </summary>
public IList<DeviceWarrantyFormVer> DeviceWarrantyFormVerCaches
{
get
{
if ((m_DeviceWarrantyFormVerCaches?.Count ?? 0) == 0)
{
m_DeviceWarrantyFormVerCaches = MaintenanceRepository.Instance.Get_DeviceWarrantyFormVer();
}
return m_DeviceWarrantyFormVerCaches;
}
}
2024-07-27 01:44:19 +00:00
2024-11-09 04:25:57 +00:00
#endregion
2024-07-27 01:44:19 +00:00
#region Methods
/// <summary>
/// 校验用户权限
/// </summary>
/// <param name="vAuthCode"></param>
/// <returns></returns>
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
}
}