C00225155-02/C00225155/MegaRobo.C00225155/MegaRobo.C00225155.ControlD.../AAC API/AACWebApiService.cs

940 lines
32 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using MegaRobo.C00225155.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.ServiceModel;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace MegaRobo.C00225155.ControlDevices
{
public class AACWebApiService
{
public string _baseUrl { get; set; }
public string AuthToken { get; set; }
public HttpOperateHelper httpClient { get; set; }
public JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions()
{
PropertyNameCaseInsensitive = true
};
#region Authentication
/// <summary>
/// 登录系统并获取Token
/// </summary>
/// <param name="userName">用户名</param>
/// <param name="userPassword">密码</param>
/// <returns>包含Token的响应模型</returns>
public async Task<Response<LoginResponse>> Login(string userName, string userPassword)
{
var requestUrl = $"{_baseUrl}/api/v1/Authentication?userName={userName}&userPassword={userPassword}";
try
{
return await httpClient.PutAsync<LoginResponse>(requestUrl, null);
}
catch (HttpRequestException ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
#endregion
#region Instrument
/// <summary>
/// 开启/关闭模块相关启用状态
/// </summary>
/// <param name="instrumentid">仪器Id</param>
/// <param name="moduleIdentity">仪器模块Id</param>
/// <param name="state">要设置的状态 0: Standby/off 1: on</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> State(int instrumentid, string moduleIdentity,int state)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/Module/State?cdsId={instrumentid}&moduleIdentity={moduleIdentity}&state={state}";
try
{
return await httpClient.PutAsync<bool>(requestUrl, null);
}
catch (HttpRequestException ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 重置LC馏分收集器容器
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="containerName"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<string>> LCContainerReset(int instrumentid, string containerName)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/FractionCollector/SubDevice/Drawer/Container/Volume/Reset?cdsId={instrumentid}&containerName={containerName}";
try
{
return await httpClient.PutAsync<string>(requestUrl, null);
}
catch (HttpRequestException ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 重置LC馏分收集器子设备
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="containerName"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<string>> LCSubDeviceReset(int instrumentid, string subDeviceName)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/FractionCollector/SubDevice/Volume/Reset?cdsId={instrumentid}&subDeviceName={subDeviceName}";
try
{
return await httpClient.PutAsync<string>(requestUrl, null);
}
catch (HttpRequestException ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 重置进样器
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> InjectorReset(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Injector/Reset?cdsId={instrumentid}";
try
{
return await httpClient.PutAsync<bool>(requestUrl, null);
}
catch (HttpRequestException ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// LC G7167全部复位
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> HomeAll(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/G7167/HomeAll?cdsId={instrumentid}";
try
{
return await httpClient.PutAsync<bool>(requestUrl, null);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 重置LC馏分收集器子设备下单某个抽屉
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="subDeviceName"></param>
/// <param name="drawerIndex">抽屉序号从1开始如果传小于等于0的值表示重置整个子设备.对于回收收集器只支持1</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<string>> LCSubDeviceDrawerReset(int instrumentid, string subDeviceName,int drawerIndex)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/FractionCollector/SubDevice/Drawer/Volume/Reset?cdsId={instrumentid}&subDeviceName={subDeviceName}&drawerIndex={drawerIndex}";
try
{
return await httpClient.PutAsync<string>(requestUrl, null);
}
catch (Exception ex)
{
// 处理网络异常(如连接失败、超时等)
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 读取LC馏分收集器溶剂体积
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="subDeviceName"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<LCContainerVolume>> GetLCContainerVolume(int instrumentid, string subDeviceName)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/FractionCollector/SubDevice/Volume?cdsId={instrumentid}&subDeviceName={subDeviceName}";
try
{
return await httpClient.GetAsync<LCContainerVolume>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 获取LC馏分收集器主设备的子模块列表
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<Features>> GetLCFeature(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/FractionCollector/SubDevices?cdsId={instrumentid}";
try
{
return await httpClient.GetAsync<Features>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 读取LC馏分模块抽屉状态
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="deviceType"></param>
/// <param name="deviceSN"></param>
/// <param name="moduleId"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<DrawerState>> GetLCDrawerStatus(int instrumentid, string deviceType,string deviceSN,string moduleId)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/FractionCollector/ModuleDrawerStatus?cdsId={instrumentid}&deviceType={deviceType}&deviceSN={deviceSN}&moduleId={moduleId}";
try
{
return await httpClient.GetAsync<DrawerState>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 获取收集器模块的模块类型
/// </summary>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<List<string>>> GetModuleTypes()
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/FractionCollector/ModuleTypes";
try
{
return await httpClient.GetAsync<List<string>>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
public async Task<Response<LCG7167DrawerState>> GetLCG7167DrawerState(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/G7167/DrawerState?cdsId={instrumentid}";
try
{
return await httpClient.GetAsync<LCG7167DrawerState>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 读取GC模块常用信息
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<GCModuleInfo>> GetGCModuleInfo(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/GC/Module/Info?cdsId={instrumentid}";
try
{
return await httpClient.GetAsync<GCModuleInfo>(requestUrl);
}
catch (Exception ex)
{
// 处理网络异常(如连接失败、超时等)
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 读取LC模块常用信息
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<LCModuleInfo>> GetLCModuleInfo(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Module/Info?cdsId={instrumentid}";
try
{
return await httpClient.GetAsync<LCModuleInfo>(requestUrl);
}
catch (Exception ex)
{
// 处理网络异常(如连接失败、超时等)
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 取消当前仪器运行的job
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> CancelCurrentJob(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/Action/Cancel/CurrentJob?cdsId={instrumentid}";
try
{
return await httpClient.PutAsync<bool>(requestUrl, null);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 暂停仪器运行
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> PauseCurrentJob(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/Action/Pause?cdsId={instrumentid}";
try
{
return await httpClient.PutAsync<bool>(requestUrl, null);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 恢复仪器重新运行
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> ResumeCurrentJob(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/Action/Resume?cdsId={instrumentid}";
try
{
return await httpClient.PutAsync<bool>(requestUrl, null);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
public async Task<Response<EmptyData>> ShutDownJob(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/Job/Shutdown?cdsId={instrumentid}";
try
{
return await httpClient.PostAsync<EmptyData>(requestUrl, null);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 读取LC泵溶剂体积
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<BottleVolumesResponse>> BottleVolume(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/BottleVolume?cdsId={instrumentid}";
try
{
return await httpClient.PutAsync<BottleVolumesResponse>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 设置LC泵溶剂体积
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="data"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> SetBottleVolume(int instrumentid, BottleVolumesResponse data)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/BottleVolume?cdsId={instrumentid}";
try
{
return await httpClient.PutAsync<bool>(requestUrl, data);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 读取LC泵准备状态信息
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<purgeState>> PreparationState(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/PreparationState?cdsId={instrumentid}";
try
{
return await httpClient.GetAsync<purgeState>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 开始LC泵清洗
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="data"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> PumpClean(int instrumentid, purgeCleaningParam data)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/Purge?cdsId={instrumentid}";
try
{
return await httpClient.PostAsync<bool>(requestUrl, data);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 关闭LC泵清洗
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> StopPumpClean(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/Purge?cdsId={instrumentid}";
try
{
return await httpClient.DeleteAsync<bool>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 开始LC泵调节
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="conditionTime"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> PumpCondition(int instrumentid,double conditionTime)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/Condition?cdsId={instrumentid}&conditionTime={conditionTime}";
try
{
return await httpClient.PostAsync<bool>(requestUrl, null);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 关闭LC泵调节
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> StopPumpCondition(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/Condition?cdsId={instrumentid}";
try
{
return await httpClient.DeleteAsync<bool>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 开始LC泵注入
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> PumpPrime(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/Prime?cdsId={instrumentid}";
try
{
return await httpClient.PostAsync<bool>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 关闭LC泵注入
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> StopPumpPrime(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/Prime?cdsId={instrumentid}";
try
{
return await httpClient.DeleteAsync<bool>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 读取LC泵废液体积
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<wasteVolume>> WasteBottleVolume(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Pump/WasteBottleVolume?cdsId={instrumentid}";
try
{
return await httpClient.GetAsync<wasteVolume>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 读取LC进样器溶剂体积
/// </summary>
/// <param name="instrumentid"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<List<bottleVolume>>> PrepSampleBottleVolume(int instrumentid)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/PrepSampler/BottleVolume?cdsId={instrumentid}";
try
{
return await httpClient.GetAsync<List<bottleVolume>>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 设置LC进样器溶剂体积
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="data"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> SetPrepSampleBottleVolume(int instrumentid, List<bottleVolume> data)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/PrepSampler/BottleVolume?cdsId={instrumentid}";
try
{
return await httpClient.PutAsync<bool>(requestUrl,data);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 获取样品盘信息
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="injectorPlateName"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<PlateInfo>> GetPlateExtraInfo(int instrumentid,string injectorPlateName)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Injector/Plate/ExtraInfo?cdsId={instrumentid}&injectorPlateName={injectorPlateName}";
try
{
return await httpClient.GetAsync<PlateInfo>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 替换进样器盘子
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="injectorPlateName"></param>
/// <param name="openLabContainerDisplayName"></param>
/// <param name="keepAnalysisTargets"></param>
/// <param name="replaceFCFlag"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<List<platePlacement>>> PutPlatePlacement(int instrumentid, string injectorPlateName, string openLabContainerDisplayName, bool keepAnalysisTargets, bool replaceFCFlag)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Injector/Plate/Replacement?cdsId={instrumentid}&injectorPlateName={injectorPlateName}&keepAnalysisTargets={keepAnalysisTargets}&replaceFCFlag={replaceFCFlag}";
try
{
return await httpClient.PutAsync<List<platePlacement>>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 替换馏分收集器盘子
/// </summary>
/// <param name="instrumentid"></param>
/// <param name="fractionCollectorPlateName"></param>
/// <param name="openLabContainerDisplayName"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<List<platePlacement>>> PutLCPlatePlacement(int instrumentid, string fractionCollectorPlateName, string openLabContainerDisplayName)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/FractionCollector/Plate/Replacement?cdsId={instrumentid}&fractionCollectorPlateName={fractionCollectorPlateName}&openLabContainerDisplayName={openLabContainerDisplayName}";
try
{
return await httpClient.PutAsync<List<platePlacement>>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 开启/关闭模块相关启用状态
/// </summary>
/// <param name="instrumentid">仪器Id</param>
/// <param name="moduleIdentity">仪器模块Id</param>
/// <param name="state">要设置的状态 0: Standby/off 1: on</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> LCModuleState(int instrumentid, string moduleIdentity, int state)
{
var requestUrl = $"{_baseUrl}/api/v1/Instrument/LC/Module/State?cdsId={instrumentid}&moduleIdentity={moduleIdentity}&state={state}";
try
{
return await httpClient.PutAsync<bool>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
#endregion
#region Sample
/// <summary>
/// 按批次设置Sample数据
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<int>> Sample(List<limsSamples> data)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample/batch";
try
{
return await httpClient.PostAsync<int>(requestUrl,data);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 增加一个新样品
/// </summary>
/// <param name="sample"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<int>> AddOneSample(limsSamples sample)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample";
try
{
return await httpClient.PostAsync<int>(requestUrl, sample);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 根据id删除大样品数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<int>> DeleteBigSample(string id)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample?id={id}";
try
{
return await httpClient.DeleteAsync<int>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 根据id获取Sample数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<limsSamples>> GetSampleById(string id)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample/id?id={id}";
try
{
return await httpClient.DeleteAsync<limsSamples>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 根据id更新Sample数据
/// </summary>
/// <param name="id"></param>
/// <param name="sample"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<int>> RefreshSampleById(string id,limsSamples sample)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample/id?id={id}";
try
{
return await httpClient.PutAsync<int>(requestUrl, sample);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 根据barcode查询大样品数据
/// </summary>
/// <param name="barcode"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<limsSamples>> ReserchSampleByBarcode(string barcode)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample/barcode?barcode={barcode}";
try
{
return await httpClient.GetAsync<limsSamples>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
public async Task<Response<limsSamples>> RefreshSampleByBarcode(string barcode)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample/barcode?barcode={barcode}";
try
{
return await httpClient.PutAsync<limsSamples>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
public async Task<Response<int>> DeleteSampleByBarcode(string barcode)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample/barcode?barcode={barcode}";
try
{
return await httpClient.DeleteAsync<int>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 根据BatchId获取Sample数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<limsSamples>> GetSampleByBatchId(string batchId)
{
var requestUrl = $"{_baseUrl}/api/v1/Sample/batchId?batchId={batchId}";
try
{
return await httpClient.DeleteAsync<limsSamples>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
#endregion
#region SampleTestItem
public async Task<Response<SampleItem>> GetSampleItemByBarcode(string barcode)
{
var requestUrl = $"{_baseUrl}/api/v1/SampleTestItem/barcode?barcode={barcode}";
try
{
return await httpClient.GetAsync<SampleItem>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
public async Task<Response<int>> RefreshSampleItemByBarcode(string barcode,SampleItem sampleItem)
{
var requestUrl = $"{_baseUrl}/api/v1/SampleTestItem/barcode?barcode={barcode}";
try
{
return await httpClient.PutAsync<int>(requestUrl,sampleItem);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
public async Task<Response<int>> DeleteSampleItemByBarcode(string barcode)
{
var requestUrl = $"{_baseUrl}/api/v1/SampleTestItem/barcode?barcode={barcode}";
try
{
return await httpClient.DeleteAsync<int>(requestUrl);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
/// <summary>
/// 增加测试瓶数据
/// </summary>
/// <param name="sampleBarcode"></param>
/// <param name="sampleItem"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<int>> AddSampleItemByBarcode(string sampleBarcode,SampleItem sampleItem)
{
var requestUrl = $"{_baseUrl}/api/v1/SampleTestItem?sampleBarcode={sampleBarcode}";
try
{
return await httpClient.PostAsync<int>(requestUrl,sampleItem);
}
catch (Exception ex)
{
throw new Exception($"{ex.Message}", ex);
}
}
#endregion
#region Store
#endregion
#region SystemInfo
#endregion
#region WorkPlan
#endregion
#region InstrumentAnalysisRun
#endregion
#region EventHandler
#endregion
}
}