DockTool/apiOptions.cs

90 lines
3.3 KiB
C#
Raw Normal View History

2024-12-12 14:03:53 +08:00
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace FlyDockTool
{
internal class apiOptions
{
/// <summary>
/// 让此类创建一个API操作的单例类
/// </summary>
public static apiOptions Instance; //申明一个EcgDrawing对象复制Null
private static readonly object LockHelper = new object();
public static string MacAddress;//计算机名称 设备唯一代码,这个代码是LIS系统里添加设备时给设备生成的唯一设备码
public static string MachineCode;//设备型号
public static string MachineID;//设备编码
public static string CurrentDevice;//当前设备
public static apiOptions CreateInstance()
{
if (Instance == null)
lock (LockHelper)
{
if (Instance == null)
Instance = new apiOptions();
}
return Instance;
}
/// <summary>
/// 1.根据MacAddress获取设备信息,请求方式get
/// </summary>
/// <param name="MacAddress">计算机名称</param>
/// <param name="MachineCode">设备型号</param>
/// <returns></returns>
public baseMsgModel getMacAddressInfo()
{
string apiUrl = ConfigurationManager.AppSettings["getMacAddressInfo"];//获取设备信息URL
if (MacAddress.Trim().Length > 0)
apiUrl += "?MacAddress="+ apiOptions.MacAddress;
if (MachineCode.Trim().Length > 0)
apiUrl += "&MachineCode=" + apiOptions.MachineCode;
//string returnDeviceInfoJson=commonOptions.HttpGet(apiUrl);
string returnDeviceInfoJson = commonOptions.HttpGet(apiUrl);
baseMsgModel bmm=JsonConvert.DeserializeObject<baseMsgModel>(returnDeviceInfoJson);
return bmm;
}
/// <summary>
/// 上传检查结果到LIS系统
/// </summary>
/// <param name="ermList"></param>
/// <returns></returns>
public baseMsgModel upLoadExamResult(List<examResultMode> ermList)
{
string apiUrl = ConfigurationManager.AppSettings["upLoadExamResult"];
string examListJson = JsonConvert.SerializeObject(ermList);
string returnJson = commonOptions.PostMoths(apiUrl, examListJson);
baseMsgModel bmm = JsonConvert.DeserializeObject<baseMsgModel>(returnJson);
return bmm;
}
/// <summary>
/// 上传图片结果到LIS系统
/// </summary>
/// <param name="EIPM"></param>
/// <returns></returns>
public baseMsgModel uploadExamImage(List<examImageParaModel> EIPM)
{
string apiUrl = ConfigurationManager.AppSettings["upLoadExamImage"];
string examImageListJson = JsonConvert.SerializeObject(EIPM);
string returnJson = commonOptions.PostMoths(apiUrl, examImageListJson);
baseMsgModel bmm = JsonConvert.DeserializeObject<baseMsgModel>(returnJson);
return bmm;
}
}
}