96 lines
3.6 KiB
C#
96 lines
3.6 KiB
C#
using CsharpHttpHelper;
|
|
using DeviceRepair.DataAccess;
|
|
using DeviceRepair.Models;
|
|
using DeviceRepair.Utils.Security;
|
|
using System;
|
|
|
|
namespace DeviceRepairAndOptimization.Biz.AM
|
|
{
|
|
public class DeviceManager
|
|
{
|
|
private static DeviceManager manager;
|
|
public static DeviceManager Instance
|
|
{
|
|
get
|
|
{
|
|
if (manager == null)
|
|
manager = new DeviceManager();
|
|
return manager;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据根名称获取设备信息
|
|
/// </summary>
|
|
/// <param name="RootName"></param>
|
|
/// <returns></returns>
|
|
public APIResponseData GetDeviceInfomationContainRootName(string RootName)
|
|
{
|
|
APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = "没有查询到数据!" };
|
|
try
|
|
{
|
|
switch (DeviceRepair.Utils.Config.Configurations.Properties.ConnType?.ToLower())
|
|
{
|
|
case "api":
|
|
|
|
apiResponseData = ApiHelper.Instance.SendMessage(new HttpItem
|
|
{
|
|
URL = $"{ServiceRouteConstValue.GetDeviceInfomationContainRootName}?RootName={HttpHelper.URLEncode(RootName)}",
|
|
Method = "Get",
|
|
ContentType = "application/json; charset=utf-8"
|
|
});
|
|
break;
|
|
case "sql":
|
|
apiResponseData = DeviceAccess.Instance.GetDeviceInfomationContainRootName(RootName);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
apiResponseData.Code = -1;
|
|
apiResponseData.Message = ex.Message;
|
|
}
|
|
return apiResponseData;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通过设备编号查询设备信息
|
|
/// </summary>
|
|
/// <param name="EquipmentID"></param>
|
|
/// <returns></returns>
|
|
public APIResponseData GetPMDeviceInfoModelByEquipmentID(string EquipmentID, string RootName = "OEM")
|
|
{
|
|
APIResponseData apiResponseData = new APIResponseData { Code = -1, Message = "没有查询到数据!" };
|
|
try
|
|
{
|
|
switch (DeviceRepair.Utils.Config.Configurations.Properties.ConnType?.ToLower())
|
|
{
|
|
case "api":
|
|
|
|
apiResponseData = ApiHelper.Instance.SendMessage(new HttpItem
|
|
{
|
|
//URL = ServiceRouteConstValue.GetPMDeviceInfoModelByEquipmentID + "?EquipmentID=" + EncryptionHelper.UrlEncry(EquipmentID),
|
|
URL = $"{ServiceRouteConstValue.GetPMDeviceInfoModelByEquipmentID}?EquipmentID={EncryptionHelper.UrlEncry(EquipmentID)}&RootName={EncryptionHelper.UrlEncry(RootName)}",
|
|
Method = "Get",
|
|
ContentType = "application/json; charset=utf-8"
|
|
});
|
|
break;
|
|
case "sql":
|
|
apiResponseData = DeviceAccess.Instance.GetPMDeviceInfoModelByEquipmentID(EquipmentID, RootName);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
apiResponseData.Code = -1;
|
|
apiResponseData.Message = ex.Message;
|
|
}
|
|
return apiResponseData;
|
|
}
|
|
}
|
|
}
|