123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767 |
- using JsonRpcLite.Services;
- using System;
- using System.Collections.Generic;
- using System.Net.Http;
- using System.Text.Json;
- using Vinno.IUS.Common.Log;
- using Vinno.vCloud.Common.FIS.Remedicals;
- using WingInterfaceLibrary.DTO.Device;
- using WingInterfaceLibrary.DTO.Organization;
- using WingInterfaceLibrary.DTO.RemoteParameters;
- using WingInterfaceLibrary.DTO.ServerInfo;
- using WingInterfaceLibrary.DTO.Storage;
- using WingInterfaceLibrary.Interface;
- using WingInterfaceLibrary.LiveConsultation;
- using WingInterfaceLibrary.Request;
- using WingInterfaceLibrary.Request.Device;
- using WingInterfaceLibrary.Request.Education;
- using WingInterfaceLibrary.Request.Examine;
- using WingInterfaceLibrary.Request.FastestServer;
- using WingInterfaceLibrary.Request.Record;
- using WingInterfaceLibrary.Request.Remote;
- using WingInterfaceLibrary.Request.Storage;
- using WingInterfaceLibrary.Request.Upgrade;
- using WingInterfaceLibrary.Request.User;
- using WingInterfaceLibrary.Result;
- using WingInterfaceLibrary.Result.Education;
- using WingInterfaceLibrary.Result.Examine;
- using WingInterfaceLibrary.Result.Languge;
- using WingInterfaceLibrary.Result.Upgrade;
- namespace Vinno.vCloud.Common.FIS.Helper
- {
- internal static class JsonRpcHelper
- {
- #region IConnectService
- internal static ConnectResultInfo Connect(IConnectService connectService, ConnectRequest connectRequest)
- {
- try
- {
- var result = connectService.ConnectAsync(connectRequest).GetAwaiter().GetResult();
- return new ConnectResultInfo(true, 0, result?.UniqueCode, result?.Token);
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"ConnectAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- return new ConnectResultInfo(false, rpcExcetpion.ErrorCode, string.Empty, string.Empty);
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"ConnectAsync Error,ErrorMsg:{ex}");
- return new ConnectResultInfo(false, -1, string.Empty, string.Empty);
- }
- }
- internal static CacheDeviceDTO GetDeviceByToken(IConnectService connectService, TokenRequest tokenRequest)
- {
- try
- {
- return connectService.GetDeviceByTokenAsync(tokenRequest).GetAwaiter().GetResult(); ;
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetDeviceByTokenAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetDeviceByTokenAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- internal static bool Disconnect(IConnectService connectService, TokenRequest tokenRequest)
- {
- try
- {
- return connectService.DisConnectAsync(tokenRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"DisConnectAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"DisConnectAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static bool SetDeviceIsEncryptedShow(IConnectService connectService, SetDeviceIsEncryptedShowRequest setDeviceIsEncryptedShowRequest)
- {
- try
- {
- return connectService.SetDeviceIsEncryptedShowAsync(setDeviceIsEncryptedShowRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"SetDeviceIsEncryptedShowAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"SetDeviceIsEncryptedShowAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- #endregion IConnectService
- #region IDeviceService
- internal static DeviceServerSettingResult QueryServerConfig(IDeviceService deviceService, TokenRequest tokenRequest)
- {
- try
- {
- return deviceService.QueryServerConfigAsync(tokenRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"QueryServerConfigAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"QueryServerConfigAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- internal static bool ReportLiveState(IDeviceService deviceService, ReportLiveStateRequest reportLiveStateRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService ReportLiveStateAsync:{JsonSerializer.Serialize(reportLiveStateRequest)}");
- return deviceService.ReportLiveStateAsync(reportLiveStateRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"ReportLiveStateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"ReportLiveStateAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static CreateLiveRoomInfoResult CreateLiveRoomInfo(IDeviceService deviceService, CreateLiveRoomInfoRequest createLiveRoomInfoRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService CreateLiveRoomInfoAsync:{JsonSerializer.Serialize(createLiveRoomInfoRequest)}");
- return deviceService.CreateLiveRoomInfoAsync(createLiveRoomInfoRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"CreateLiveRoomInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"CreateLiveRoomInfoAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- internal static List<string> GetBrands(IDeviceService deviceService, GetBrandsRequest getBrandsRequest)
- {
- try
- {
- return deviceService.GetBrandsAsync(getBrandsRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetBrandsAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetBrandsAsync Error,ErrorMsg:{ex}");
- }
- return new List<string>();
- }
- internal static List<string> GetModels(IDeviceService deviceService, GetModelsRequest getModelsRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService GetModelsAsync:{JsonSerializer.Serialize(getModelsRequest)}");
- return deviceService.GetModelsAsync(getModelsRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetModelsAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetModelsAsync Error,ErrorMsg:{ex}");
- }
- return new List<string>();
- }
- internal static List<BrandModelOutputConfigDTO> SyncBrandModelOutputConfig(IDeviceService deviceService, SyncBrandModelOutputConfigRequest syncBrandModelOutputConfigRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService SyncBrandModelOutputConfigAsync:{JsonSerializer.Serialize(syncBrandModelOutputConfigRequest)}");
- return deviceService.SyncBrandModelOutputConfigAsync(syncBrandModelOutputConfigRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"SyncBrandModelOutputConfigAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"SyncBrandModelOutputConfigAsync Error,ErrorMsg:{ex}");
- }
- return new List<BrandModelOutputConfigDTO>();
- }
- internal static ReportVideoDeviceInfoResult ReportVideoDeviceInfo(IDeviceService deviceService, ReportVideoDeviceInfoRequest reportVideoDeviceInfoRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService ReportVideoDeviceInfoAsync:{JsonSerializer.Serialize(reportVideoDeviceInfoRequest)}");
- return deviceService.ReportVideoDeviceInfoAsync(reportVideoDeviceInfoRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"ReportVideoDeviceInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"ReportVideoDeviceInfoAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- internal static bool SendControlParameterByDevice(IDeviceService deviceService, SendControlParameterByDeviceRequest sendControlParameterByDeviceRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService SendControlParameterByDeviceAsync:{JsonSerializer.Serialize(sendControlParameterByDeviceRequest)}");
- return deviceService.SendControlParameterByDeviceAsync(sendControlParameterByDeviceRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"SendControlParameterByDeviceAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"SendControlParameterByDeviceAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static bool AcceptRemoteConnnectionInDeviceService(IDeviceService deviceService, ControlDeviceResponseRequest controlDeviceResponseRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService AcceptRemoteConnnectionAsync:{JsonSerializer.Serialize(controlDeviceResponseRequest)}");
- return deviceService.AcceptRemoteConnnectionAsync(controlDeviceResponseRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"AcceptRemoteConnnectionInDeviceService Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"AcceptRemoteConnnection Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static bool DisconnectRemoteControl(IDeviceService deviceService, RemoteConnectStautsRequest remoteConnectStautsRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService DisconnectRemoteControl:{JsonSerializer.Serialize(remoteConnectStautsRequest)}");
- return deviceService.DisconnectRemoteControl(remoteConnectStautsRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"DisconnectRemoteControl Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"DisconnectRemoteControl Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static bool UploadDeviceDownloadPatchProgressToUser(IDeviceService deviceService, UploadDeviceDownloadPatchProgressToUserRequest uploadDeviceDownloadPatchProgressToUserRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService UploadDeviceDownloadPatchProgressToUserAsync:{JsonSerializer.Serialize(uploadDeviceDownloadPatchProgressToUserRequest)}");
- return deviceService.UploadDeviceDownloadPatchProgressToUserAsync(uploadDeviceDownloadPatchProgressToUserRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"UploadDeviceDownloadPatchProgressToUserAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"UploadDeviceDownloadPatchProgressToUserAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static bool ResponseRemoteLog(IDeviceService deviceService, RemoteLogResponseRequest remoteLogResponseRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService ResponseRemoteLogAsync:{JsonSerializer.Serialize(remoteLogResponseRequest)}");
- return deviceService.ResponseRemoteLogAsync(remoteLogResponseRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"ResponseRemoteLog Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"ResponseRemoteLogAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static bool UploadDevicePrinter(IDeviceService deviceService, UploadDevicePrinterRequest uploadDevicePrinterRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService UploadDevicePrinterAsync:{JsonSerializer.Serialize(uploadDevicePrinterRequest)}");
- return deviceService.UploadDevicePrinterAsync(uploadDevicePrinterRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"UploadDevicePrinterAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"UploadDevicePrinterAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static bool DeviceRemoteConnectHeartRate(IDeviceService deviceService, RemoteConnectHeartRateRequest remoteConnectHeartRateRequest)
- {
- try
- {
- return deviceService.DeviceRemoteConnectHeartRateAsync(remoteConnectHeartRateRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"DeviceRemoteConnectHeartRateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"DeviceRemoteConnectHeartRateAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static bool HeartRate(IDeviceService deviceService, TokenRequest tokenRequest)
- {
- try
- {
- return deviceService.HeartRateAsync(tokenRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"HeartRateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"HeartRateAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static string SendResultToClient(IDeviceService deviceService, SendResultToClientRequest sendResultToClientRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService SendResultToClientAsync:{JsonSerializer.Serialize(sendResultToClientRequest)}");
- return deviceService.SendResultToClientAsync(sendResultToClientRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"SendResultToClientAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"SendResultToClientAsync Error,ErrorMsg:{ex}");
- }
- return "";
- }
- internal static string GetResultFromServer(IDeviceService deviceService, GetResultFromServerRequest getResultFromServerRequest)
- {
- try
- {
- return deviceService.GetResultFromServerAsync(getResultFromServerRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetResultFromServerAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetResultFromServerAsync Error,ErrorMsg:{ex}");
- }
- return "";
- }
- internal static bool DeviceCancelLogDownload(IDeviceService deviceService, DeivceCancelLogDownloadRequest deivceCancelLogDownloadRequest)
- {
- try
- {
- return deviceService.DeviceCancelLogDownloadAsync(deivceCancelLogDownloadRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"DeviceCancelLogDownloadAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"DeviceCancelLogDownloadAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static ProbeApplicationSettingInfoDTO GetProbeApplicationSetting(IDeviceService deviceService, GetControlParametersRequest getControlParametersRequest)
- {
- try
- {
- return deviceService.GetProbeApplicationSettingAsync(getControlParametersRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetProbeApplicationSettingAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetProbeApplicationSettingAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- internal static bool ResponseProbeApplicationSetting(IDeviceService deviceService, ProbeApplicationSettingResultRequest probeApplicationSettingResultRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IDeviceService ResponseProbeApplicationSettingAsync:{JsonSerializer.Serialize(probeApplicationSettingResultRequest)}");
- return deviceService.ResponseProbeApplicationSettingAsync(probeApplicationSettingResultRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"ResponseProbeApplicationSettingAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"ResponseProbeApplicationSettingAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- #endregion IDeviceService
- #region ILiveConsultationService
- internal static bool AcceptRemoteConnnectionInLiveConsultationService(ILiveConsultationService liveConsultationService, ControlDeviceResponseRequest controlDeviceResponseRequest)
- {
- try
- {
- Logger.WriteLineInfo($"ILiveConsultationService AcceptRemoteConnnectionAsync:{JsonSerializer.Serialize(controlDeviceResponseRequest)}");
- return liveConsultationService.AcceptRemoteConnnectionAsync(controlDeviceResponseRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"AcceptRemoteConnnectionInLiveConsultationService Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"AcceptRemoteConnnectionInLiveConsultationService Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static LiveConsultationHeartRateResult HeartRate(ILiveConsultationService liveConsultationService, LiveConsultationHeartRateRequest liveConsultationHeartRateRequest)
- {
- try
- {
- return liveConsultationService.HeartRateAsync(liveConsultationHeartRateRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"LiveConsultation HeartRateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"LiveConsultation HeartRateAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- #endregion ILiveConsultationService
- #region IRemedicalService
- internal static CreateExaminfoResult CreateExamInfo(IRemedicalService remedicalService, CreateExaminfoRequest createExaminfoRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IRemedicalService CreateExamInfoAsync:{JsonSerializer.Serialize(createExaminfoRequest)}");
- return remedicalService.CreateExamInfoAsync(createExaminfoRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"CreateExamInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"CreateExamInfoAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="remedicalService"></param>
- /// <param name="uploadExamDataRequest"></param>
- /// <returns>0为上传成功,-1为上传失败,大于0时为上传失败的代码</returns>
- internal static ResultInfo UploadExamData(IRemedicalService remedicalService, UploadExamDataRequest uploadExamDataRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IRemedicalService UploadExamDataAsync:{JsonSerializer.Serialize(uploadExamDataRequest)}");
- var result = remedicalService.UploadExamDataAsync(uploadExamDataRequest).GetAwaiter().GetResult();
- return new ResultInfo(result, 0);
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"UploadExamDataAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- return new ResultInfo(false, rpcExcetpion.ErrorCode);
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"UploadExamDataAsync Error,ErrorMsg:{ex}");
- return new ResultInfo(false, -1);
- }
- }
- internal static bool DeviceFinishExam(IRemedicalService remedicalService, DeviceFinishExamRequest deviceFinishExamRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IRemedicalService DeviceFinishExamAsync:{JsonSerializer.Serialize(deviceFinishExamRequest)}");
- return remedicalService.DeviceFinishExamAsync(deviceFinishExamRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"DeviceFinishExamAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"DeviceFinishExamAsync Error,ErrorMsg:{ex}");
- }
- return false;
- }
- internal static PageResult<QueryExamListItemResult> QueryExamList(IRemedicalService remedicalService, QueryExamListRequest queryExamListRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IRemedicalService QueryExamListAsync:{JsonSerializer.Serialize(queryExamListRequest)}");
- return remedicalService.QueryExamListAsync(queryExamListRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"QueryExamListAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"QueryExamListAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- internal static QueryExamInfoResult QueryExamInfo(IRemedicalService remedicalService, QueryExamInfoRequest queryExamInfoRequest)
- {
- try
- {
- Logger.WriteLineInfo($"IRemedicalService QueryExamInfoAsync:{JsonSerializer.Serialize(queryExamInfoRequest)}");
- return remedicalService.QueryExamInfoAsync(queryExamInfoRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"QueryExamInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"QueryExamInfoAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- internal static string GetCollcetingRecordCode(IRemedicalService remedicalService, TokenRequest tokenRequest)
- {
- try
- {
- return remedicalService.GetCollcetingRecordCodeAsync(tokenRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"LiveConsultation GetCollcetingRecordCodeAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"LiveConsultation GetCollcetingRecordCodeAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- #endregion IRemedicalService
- #region IVinnoServerService
- internal static List<ServerInfoDTO> GetServerInfoList(IVinnoServerService vinnoServerService, QueryServerInfoRequest queryServerInfoRequest)
- {
- try
- {
- return vinnoServerService.GetServerInfoListAsync(queryServerInfoRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetServerInfoListAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetServerInfoListAsync Error,ErrorMsg:{ex}");
- }
- return new List<ServerInfoDTO>();
- }
- internal static EchoResult Echo(IVinnoServerService vinnoServerService)
- {
- try
- {
- return vinnoServerService.EchoAsync().GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"EchoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (HttpRequestException)
- {
- Logger.WriteLineError($"EchoAsync Error:HttpRequestException");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"EchoAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- #endregion IVinnoServerService
- #region IStorageService
- internal static StorageServiceSettingDTO GetAuthorization(IStorageService storageService, FileServiceRequest fileServiceRequest)
- {
- try
- {
- return storageService.GetAuthorizationAsync(fileServiceRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetAuthorizationAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetAuthorizationAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- internal static StorageServiceSettingDTO GetStorageTestUrl(IStorageService storageService, CheckStorageRequest checkStorageRequest)
- {
- try
- {
- return storageService.GetStorageTestUrlAsync(checkStorageRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetStorageTestUrl Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetStorageTestUrl Error,ErrorMsg:{ex}");
- }
- return null;
- }
- #endregion IStorageService
- #region IUpgradeService
- internal static GetUpgradeInfoResult GetUpgradeInfo(IUpgradeService upgradeService, GetUpgradeInfoRequest getUpgradeInfoRequest)
- {
- try
- {
- return upgradeService.GetUpgradeInfoAsync(getUpgradeInfoRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"GetUpgradeInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"GetUpgradeInfoAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- #endregion IUpgradeService
- #region IEducationService
- internal static LiveHeartRateResult HeartRate(IEducationService educationService, LiveHeartRateRequest liveHeartRateRequest)
- {
- try
- {
- return educationService.HeartRateAsync(liveHeartRateRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"EducationService HeartRateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"EducationService HeartRateAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- #endregion IEducationService
- #region IOrganizationService
- internal static OrganizationDTO GetOrganizationByCode(IOrganizationService organizationService, GetOrganizationByCodeRequest getOrganizationByCodeRequest)
- {
- try
- {
- return organizationService.GetOrganizationByCodeAsync(getOrganizationByCodeRequest).GetAwaiter().GetResult();
- }
- catch (RpcException rpcExcetpion)
- {
- Logger.WriteLineError($"LiveConsultation GetOrganizationByCodeAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
- }
- catch (Exception ex)
- {
- Logger.WriteLineError($"LiveConsultation GetOrganizationByCodeAsync Error,ErrorMsg:{ex}");
- }
- return null;
- }
- #endregion IOrganizationService
- }
- }
|