2024-05-28 14:36:38 +00:00
|
|
|
|
using DeviceRepair.Models;
|
2024-05-28 15:11:30 +00:00
|
|
|
|
using DeviceRepair.Utils;
|
2024-05-28 14:36:38 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
2024-06-03 17:21:11 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-05-28 14:36:38 +00:00
|
|
|
|
|
|
|
|
|
namespace DeviceRepairAndOptimization
|
|
|
|
|
{
|
|
|
|
|
public static class GlobalInfo
|
|
|
|
|
{
|
|
|
|
|
public static UserInfoModel CurrentUser { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否有权限
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="AuthString"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool HasRole(string AuthString)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentUser == null || CurrentUser.AuthItems == null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return CurrentUser.AuthItems.Any(x => x.AuthCode.Equals(AuthString, StringComparison.CurrentCultureIgnoreCase));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static HeaderModel _OperationInfo;
|
|
|
|
|
public static HeaderModel OperationInfo
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_OperationInfo == null)
|
|
|
|
|
{
|
|
|
|
|
_OperationInfo = new HeaderModel();
|
|
|
|
|
_OperationInfo.ClientMac = ComputerHelper.GetMacAddress;
|
|
|
|
|
_OperationInfo.ClientName = ComputerHelper.GetComputerName;
|
|
|
|
|
_OperationInfo.IPAddress = ComputerHelper.GetIPAddress;
|
|
|
|
|
_OperationInfo.Operator = CurrentUser.AutoID;
|
|
|
|
|
_OperationInfo.OperatorName = CurrentUser.LoginCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _OperationInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string token = "";
|
|
|
|
|
public static Form _RootForm;
|
2024-06-03 17:21:11 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新当前用户权限
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void RefreshAuths()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 更新当前用户权限
|
|
|
|
|
APIResponseData apiResponseData = Biz.UserManager.Instance.GetUserAuthsByUserID(CurrentUser?.AutoID ?? 0);
|
|
|
|
|
if (!apiResponseData.IsSuccess)
|
|
|
|
|
throw new Exception(apiResponseData.Message);
|
|
|
|
|
|
|
|
|
|
CurrentUser.AuthItems = apiResponseData.ToDeserializeObject<List<AuthModel>>();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-28 14:36:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|