JsonRpcHelper.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. using JsonRpcLite.Services;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Net.Http;
  5. using System.Text.Json;
  6. using Vinno.IUS.Common.Log;
  7. using Vinno.vCloud.Common.FIS.Remedicals;
  8. using WingInterfaceLibrary.DTO.Device;
  9. using WingInterfaceLibrary.DTO.Organization;
  10. using WingInterfaceLibrary.DTO.RemoteParameters;
  11. using WingInterfaceLibrary.DTO.ServerInfo;
  12. using WingInterfaceLibrary.DTO.Storage;
  13. using WingInterfaceLibrary.Interface;
  14. using WingInterfaceLibrary.LiveConsultation;
  15. using WingInterfaceLibrary.Request;
  16. using WingInterfaceLibrary.Request.Device;
  17. using WingInterfaceLibrary.Request.Education;
  18. using WingInterfaceLibrary.Request.Examine;
  19. using WingInterfaceLibrary.Request.FastestServer;
  20. using WingInterfaceLibrary.Request.Record;
  21. using WingInterfaceLibrary.Request.Remote;
  22. using WingInterfaceLibrary.Request.Storage;
  23. using WingInterfaceLibrary.Request.Upgrade;
  24. using WingInterfaceLibrary.Request.User;
  25. using WingInterfaceLibrary.Result;
  26. using WingInterfaceLibrary.Result.Education;
  27. using WingInterfaceLibrary.Result.Examine;
  28. using WingInterfaceLibrary.Result.Languge;
  29. using WingInterfaceLibrary.Result.Upgrade;
  30. namespace Vinno.vCloud.Common.FIS.Helper
  31. {
  32. internal static class JsonRpcHelper
  33. {
  34. #region IConnectService
  35. internal static ConnectResultInfo Connect(IConnectService connectService, ConnectRequest connectRequest)
  36. {
  37. try
  38. {
  39. var result = connectService.ConnectAsync(connectRequest).GetAwaiter().GetResult();
  40. return new ConnectResultInfo(true, 0, result?.UniqueCode, result?.Token);
  41. }
  42. catch (RpcException rpcExcetpion)
  43. {
  44. Logger.WriteLineError($"ConnectAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  45. return new ConnectResultInfo(false, rpcExcetpion.ErrorCode, string.Empty, string.Empty);
  46. }
  47. catch (Exception ex)
  48. {
  49. Logger.WriteLineError($"ConnectAsync Error,ErrorMsg:{ex}");
  50. return new ConnectResultInfo(false, -1, string.Empty, string.Empty);
  51. }
  52. }
  53. internal static CacheDeviceDTO GetDeviceByToken(IConnectService connectService, TokenRequest tokenRequest)
  54. {
  55. try
  56. {
  57. return connectService.GetDeviceByTokenAsync(tokenRequest).GetAwaiter().GetResult(); ;
  58. }
  59. catch (RpcException rpcExcetpion)
  60. {
  61. Logger.WriteLineError($"GetDeviceByTokenAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  62. }
  63. catch (Exception ex)
  64. {
  65. Logger.WriteLineError($"GetDeviceByTokenAsync Error,ErrorMsg:{ex}");
  66. }
  67. return null;
  68. }
  69. internal static bool Disconnect(IConnectService connectService, TokenRequest tokenRequest)
  70. {
  71. try
  72. {
  73. return connectService.DisConnectAsync(tokenRequest).GetAwaiter().GetResult();
  74. }
  75. catch (RpcException rpcExcetpion)
  76. {
  77. Logger.WriteLineError($"DisConnectAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  78. }
  79. catch (Exception ex)
  80. {
  81. Logger.WriteLineError($"DisConnectAsync Error,ErrorMsg:{ex}");
  82. }
  83. return false;
  84. }
  85. internal static bool SetDeviceIsEncryptedShow(IConnectService connectService, SetDeviceIsEncryptedShowRequest setDeviceIsEncryptedShowRequest)
  86. {
  87. try
  88. {
  89. return connectService.SetDeviceIsEncryptedShowAsync(setDeviceIsEncryptedShowRequest).GetAwaiter().GetResult();
  90. }
  91. catch (RpcException rpcExcetpion)
  92. {
  93. Logger.WriteLineError($"SetDeviceIsEncryptedShowAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  94. }
  95. catch (Exception ex)
  96. {
  97. Logger.WriteLineError($"SetDeviceIsEncryptedShowAsync Error,ErrorMsg:{ex}");
  98. }
  99. return false;
  100. }
  101. #endregion IConnectService
  102. #region IDeviceService
  103. internal static DeviceServerSettingResult QueryServerConfig(IDeviceService deviceService, TokenRequest tokenRequest)
  104. {
  105. try
  106. {
  107. return deviceService.QueryServerConfigAsync(tokenRequest).GetAwaiter().GetResult();
  108. }
  109. catch (RpcException rpcExcetpion)
  110. {
  111. Logger.WriteLineError($"QueryServerConfigAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  112. }
  113. catch (Exception ex)
  114. {
  115. Logger.WriteLineError($"QueryServerConfigAsync Error,ErrorMsg:{ex}");
  116. }
  117. return null;
  118. }
  119. internal static bool ReportLiveState(IDeviceService deviceService, ReportLiveStateRequest reportLiveStateRequest)
  120. {
  121. try
  122. {
  123. Logger.WriteLineInfo($"IDeviceService ReportLiveStateAsync:{JsonSerializer.Serialize(reportLiveStateRequest)}");
  124. return deviceService.ReportLiveStateAsync(reportLiveStateRequest).GetAwaiter().GetResult();
  125. }
  126. catch (RpcException rpcExcetpion)
  127. {
  128. Logger.WriteLineError($"ReportLiveStateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  129. }
  130. catch (Exception ex)
  131. {
  132. Logger.WriteLineError($"ReportLiveStateAsync Error,ErrorMsg:{ex}");
  133. }
  134. return false;
  135. }
  136. internal static CreateLiveRoomInfoResult CreateLiveRoomInfo(IDeviceService deviceService, CreateLiveRoomInfoRequest createLiveRoomInfoRequest)
  137. {
  138. try
  139. {
  140. Logger.WriteLineInfo($"IDeviceService CreateLiveRoomInfoAsync:{JsonSerializer.Serialize(createLiveRoomInfoRequest)}");
  141. return deviceService.CreateLiveRoomInfoAsync(createLiveRoomInfoRequest).GetAwaiter().GetResult();
  142. }
  143. catch (RpcException rpcExcetpion)
  144. {
  145. Logger.WriteLineError($"CreateLiveRoomInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  146. }
  147. catch (Exception ex)
  148. {
  149. Logger.WriteLineError($"CreateLiveRoomInfoAsync Error,ErrorMsg:{ex}");
  150. }
  151. return null;
  152. }
  153. internal static List<string> GetBrands(IDeviceService deviceService, GetBrandsRequest getBrandsRequest)
  154. {
  155. try
  156. {
  157. return deviceService.GetBrandsAsync(getBrandsRequest).GetAwaiter().GetResult();
  158. }
  159. catch (RpcException rpcExcetpion)
  160. {
  161. Logger.WriteLineError($"GetBrandsAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  162. }
  163. catch (Exception ex)
  164. {
  165. Logger.WriteLineError($"GetBrandsAsync Error,ErrorMsg:{ex}");
  166. }
  167. return new List<string>();
  168. }
  169. internal static List<string> GetModels(IDeviceService deviceService, GetModelsRequest getModelsRequest)
  170. {
  171. try
  172. {
  173. Logger.WriteLineInfo($"IDeviceService GetModelsAsync:{JsonSerializer.Serialize(getModelsRequest)}");
  174. return deviceService.GetModelsAsync(getModelsRequest).GetAwaiter().GetResult();
  175. }
  176. catch (RpcException rpcExcetpion)
  177. {
  178. Logger.WriteLineError($"GetModelsAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  179. }
  180. catch (Exception ex)
  181. {
  182. Logger.WriteLineError($"GetModelsAsync Error,ErrorMsg:{ex}");
  183. }
  184. return new List<string>();
  185. }
  186. internal static List<BrandModelOutputConfigDTO> SyncBrandModelOutputConfig(IDeviceService deviceService, SyncBrandModelOutputConfigRequest syncBrandModelOutputConfigRequest)
  187. {
  188. try
  189. {
  190. Logger.WriteLineInfo($"IDeviceService SyncBrandModelOutputConfigAsync:{JsonSerializer.Serialize(syncBrandModelOutputConfigRequest)}");
  191. return deviceService.SyncBrandModelOutputConfigAsync(syncBrandModelOutputConfigRequest).GetAwaiter().GetResult();
  192. }
  193. catch (RpcException rpcExcetpion)
  194. {
  195. Logger.WriteLineError($"SyncBrandModelOutputConfigAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  196. }
  197. catch (Exception ex)
  198. {
  199. Logger.WriteLineError($"SyncBrandModelOutputConfigAsync Error,ErrorMsg:{ex}");
  200. }
  201. return new List<BrandModelOutputConfigDTO>();
  202. }
  203. internal static ReportVideoDeviceInfoResult ReportVideoDeviceInfo(IDeviceService deviceService, ReportVideoDeviceInfoRequest reportVideoDeviceInfoRequest)
  204. {
  205. try
  206. {
  207. Logger.WriteLineInfo($"IDeviceService ReportVideoDeviceInfoAsync:{JsonSerializer.Serialize(reportVideoDeviceInfoRequest)}");
  208. return deviceService.ReportVideoDeviceInfoAsync(reportVideoDeviceInfoRequest).GetAwaiter().GetResult();
  209. }
  210. catch (RpcException rpcExcetpion)
  211. {
  212. Logger.WriteLineError($"ReportVideoDeviceInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  213. }
  214. catch (Exception ex)
  215. {
  216. Logger.WriteLineError($"ReportVideoDeviceInfoAsync Error,ErrorMsg:{ex}");
  217. }
  218. return null;
  219. }
  220. internal static bool SendControlParameterByDevice(IDeviceService deviceService, SendControlParameterByDeviceRequest sendControlParameterByDeviceRequest)
  221. {
  222. try
  223. {
  224. Logger.WriteLineInfo($"IDeviceService SendControlParameterByDeviceAsync:{JsonSerializer.Serialize(sendControlParameterByDeviceRequest)}");
  225. return deviceService.SendControlParameterByDeviceAsync(sendControlParameterByDeviceRequest).GetAwaiter().GetResult();
  226. }
  227. catch (RpcException rpcExcetpion)
  228. {
  229. Logger.WriteLineError($"SendControlParameterByDeviceAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  230. }
  231. catch (Exception ex)
  232. {
  233. Logger.WriteLineError($"SendControlParameterByDeviceAsync Error,ErrorMsg:{ex}");
  234. }
  235. return false;
  236. }
  237. internal static bool AcceptRemoteConnnectionInDeviceService(IDeviceService deviceService, ControlDeviceResponseRequest controlDeviceResponseRequest)
  238. {
  239. try
  240. {
  241. Logger.WriteLineInfo($"IDeviceService AcceptRemoteConnnectionAsync:{JsonSerializer.Serialize(controlDeviceResponseRequest)}");
  242. return deviceService.AcceptRemoteConnnectionAsync(controlDeviceResponseRequest).GetAwaiter().GetResult();
  243. }
  244. catch (RpcException rpcExcetpion)
  245. {
  246. Logger.WriteLineError($"AcceptRemoteConnnectionInDeviceService Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  247. }
  248. catch (Exception ex)
  249. {
  250. Logger.WriteLineError($"AcceptRemoteConnnection Error,ErrorMsg:{ex}");
  251. }
  252. return false;
  253. }
  254. internal static bool DisconnectRemoteControl(IDeviceService deviceService, RemoteConnectStautsRequest remoteConnectStautsRequest)
  255. {
  256. try
  257. {
  258. Logger.WriteLineInfo($"IDeviceService DisconnectRemoteControl:{JsonSerializer.Serialize(remoteConnectStautsRequest)}");
  259. return deviceService.DisconnectRemoteControl(remoteConnectStautsRequest).GetAwaiter().GetResult();
  260. }
  261. catch (RpcException rpcExcetpion)
  262. {
  263. Logger.WriteLineError($"DisconnectRemoteControl Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  264. }
  265. catch (Exception ex)
  266. {
  267. Logger.WriteLineError($"DisconnectRemoteControl Error,ErrorMsg:{ex}");
  268. }
  269. return false;
  270. }
  271. internal static bool UploadDeviceDownloadPatchProgressToUser(IDeviceService deviceService, UploadDeviceDownloadPatchProgressToUserRequest uploadDeviceDownloadPatchProgressToUserRequest)
  272. {
  273. try
  274. {
  275. Logger.WriteLineInfo($"IDeviceService UploadDeviceDownloadPatchProgressToUserAsync:{JsonSerializer.Serialize(uploadDeviceDownloadPatchProgressToUserRequest)}");
  276. return deviceService.UploadDeviceDownloadPatchProgressToUserAsync(uploadDeviceDownloadPatchProgressToUserRequest).GetAwaiter().GetResult();
  277. }
  278. catch (RpcException rpcExcetpion)
  279. {
  280. Logger.WriteLineError($"UploadDeviceDownloadPatchProgressToUserAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  281. }
  282. catch (Exception ex)
  283. {
  284. Logger.WriteLineError($"UploadDeviceDownloadPatchProgressToUserAsync Error,ErrorMsg:{ex}");
  285. }
  286. return false;
  287. }
  288. internal static bool ResponseRemoteLog(IDeviceService deviceService, RemoteLogResponseRequest remoteLogResponseRequest)
  289. {
  290. try
  291. {
  292. Logger.WriteLineInfo($"IDeviceService ResponseRemoteLogAsync:{JsonSerializer.Serialize(remoteLogResponseRequest)}");
  293. return deviceService.ResponseRemoteLogAsync(remoteLogResponseRequest).GetAwaiter().GetResult();
  294. }
  295. catch (RpcException rpcExcetpion)
  296. {
  297. Logger.WriteLineError($"ResponseRemoteLog Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  298. }
  299. catch (Exception ex)
  300. {
  301. Logger.WriteLineError($"ResponseRemoteLogAsync Error,ErrorMsg:{ex}");
  302. }
  303. return false;
  304. }
  305. internal static bool UploadDevicePrinter(IDeviceService deviceService, UploadDevicePrinterRequest uploadDevicePrinterRequest)
  306. {
  307. try
  308. {
  309. Logger.WriteLineInfo($"IDeviceService UploadDevicePrinterAsync:{JsonSerializer.Serialize(uploadDevicePrinterRequest)}");
  310. return deviceService.UploadDevicePrinterAsync(uploadDevicePrinterRequest).GetAwaiter().GetResult();
  311. }
  312. catch (RpcException rpcExcetpion)
  313. {
  314. Logger.WriteLineError($"UploadDevicePrinterAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  315. }
  316. catch (Exception ex)
  317. {
  318. Logger.WriteLineError($"UploadDevicePrinterAsync Error,ErrorMsg:{ex}");
  319. }
  320. return false;
  321. }
  322. internal static bool DeviceRemoteConnectHeartRate(IDeviceService deviceService, RemoteConnectHeartRateRequest remoteConnectHeartRateRequest)
  323. {
  324. try
  325. {
  326. return deviceService.DeviceRemoteConnectHeartRateAsync(remoteConnectHeartRateRequest).GetAwaiter().GetResult();
  327. }
  328. catch (RpcException rpcExcetpion)
  329. {
  330. Logger.WriteLineError($"DeviceRemoteConnectHeartRateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  331. }
  332. catch (Exception ex)
  333. {
  334. Logger.WriteLineError($"DeviceRemoteConnectHeartRateAsync Error,ErrorMsg:{ex}");
  335. }
  336. return false;
  337. }
  338. internal static bool HeartRate(IDeviceService deviceService, TokenRequest tokenRequest)
  339. {
  340. try
  341. {
  342. return deviceService.HeartRateAsync(tokenRequest).GetAwaiter().GetResult();
  343. }
  344. catch (RpcException rpcExcetpion)
  345. {
  346. Logger.WriteLineError($"HeartRateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  347. }
  348. catch (Exception ex)
  349. {
  350. Logger.WriteLineError($"HeartRateAsync Error,ErrorMsg:{ex}");
  351. }
  352. return false;
  353. }
  354. internal static string SendResultToClient(IDeviceService deviceService, SendResultToClientRequest sendResultToClientRequest)
  355. {
  356. try
  357. {
  358. Logger.WriteLineInfo($"IDeviceService SendResultToClientAsync:{JsonSerializer.Serialize(sendResultToClientRequest)}");
  359. return deviceService.SendResultToClientAsync(sendResultToClientRequest).GetAwaiter().GetResult();
  360. }
  361. catch (RpcException rpcExcetpion)
  362. {
  363. Logger.WriteLineError($"SendResultToClientAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  364. }
  365. catch (Exception ex)
  366. {
  367. Logger.WriteLineError($"SendResultToClientAsync Error,ErrorMsg:{ex}");
  368. }
  369. return "";
  370. }
  371. internal static string GetResultFromServer(IDeviceService deviceService, GetResultFromServerRequest getResultFromServerRequest)
  372. {
  373. try
  374. {
  375. return deviceService.GetResultFromServerAsync(getResultFromServerRequest).GetAwaiter().GetResult();
  376. }
  377. catch (RpcException rpcExcetpion)
  378. {
  379. Logger.WriteLineError($"GetResultFromServerAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  380. }
  381. catch (Exception ex)
  382. {
  383. Logger.WriteLineError($"GetResultFromServerAsync Error,ErrorMsg:{ex}");
  384. }
  385. return "";
  386. }
  387. internal static bool DeviceCancelLogDownload(IDeviceService deviceService, DeivceCancelLogDownloadRequest deivceCancelLogDownloadRequest)
  388. {
  389. try
  390. {
  391. return deviceService.DeviceCancelLogDownloadAsync(deivceCancelLogDownloadRequest).GetAwaiter().GetResult();
  392. }
  393. catch (RpcException rpcExcetpion)
  394. {
  395. Logger.WriteLineError($"DeviceCancelLogDownloadAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  396. }
  397. catch (Exception ex)
  398. {
  399. Logger.WriteLineError($"DeviceCancelLogDownloadAsync Error,ErrorMsg:{ex}");
  400. }
  401. return false;
  402. }
  403. internal static ProbeApplicationSettingInfoDTO GetProbeApplicationSetting(IDeviceService deviceService, GetControlParametersRequest getControlParametersRequest)
  404. {
  405. try
  406. {
  407. return deviceService.GetProbeApplicationSettingAsync(getControlParametersRequest).GetAwaiter().GetResult();
  408. }
  409. catch (RpcException rpcExcetpion)
  410. {
  411. Logger.WriteLineError($"GetProbeApplicationSettingAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  412. }
  413. catch (Exception ex)
  414. {
  415. Logger.WriteLineError($"GetProbeApplicationSettingAsync Error,ErrorMsg:{ex}");
  416. }
  417. return null;
  418. }
  419. internal static bool ResponseProbeApplicationSetting(IDeviceService deviceService, ProbeApplicationSettingResultRequest probeApplicationSettingResultRequest)
  420. {
  421. try
  422. {
  423. Logger.WriteLineInfo($"IDeviceService ResponseProbeApplicationSettingAsync:{JsonSerializer.Serialize(probeApplicationSettingResultRequest)}");
  424. return deviceService.ResponseProbeApplicationSettingAsync(probeApplicationSettingResultRequest).GetAwaiter().GetResult();
  425. }
  426. catch (RpcException rpcExcetpion)
  427. {
  428. Logger.WriteLineError($"ResponseProbeApplicationSettingAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  429. }
  430. catch (Exception ex)
  431. {
  432. Logger.WriteLineError($"ResponseProbeApplicationSettingAsync Error,ErrorMsg:{ex}");
  433. }
  434. return false;
  435. }
  436. #endregion IDeviceService
  437. #region ILiveConsultationService
  438. internal static bool AcceptRemoteConnnectionInLiveConsultationService(ILiveConsultationService liveConsultationService, ControlDeviceResponseRequest controlDeviceResponseRequest)
  439. {
  440. try
  441. {
  442. Logger.WriteLineInfo($"ILiveConsultationService AcceptRemoteConnnectionAsync:{JsonSerializer.Serialize(controlDeviceResponseRequest)}");
  443. return liveConsultationService.AcceptRemoteConnnectionAsync(controlDeviceResponseRequest).GetAwaiter().GetResult();
  444. }
  445. catch (RpcException rpcExcetpion)
  446. {
  447. Logger.WriteLineError($"AcceptRemoteConnnectionInLiveConsultationService Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  448. }
  449. catch (Exception ex)
  450. {
  451. Logger.WriteLineError($"AcceptRemoteConnnectionInLiveConsultationService Error,ErrorMsg:{ex}");
  452. }
  453. return false;
  454. }
  455. internal static LiveConsultationHeartRateResult HeartRate(ILiveConsultationService liveConsultationService, LiveConsultationHeartRateRequest liveConsultationHeartRateRequest)
  456. {
  457. try
  458. {
  459. return liveConsultationService.HeartRateAsync(liveConsultationHeartRateRequest).GetAwaiter().GetResult();
  460. }
  461. catch (RpcException rpcExcetpion)
  462. {
  463. Logger.WriteLineError($"LiveConsultation HeartRateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  464. }
  465. catch (Exception ex)
  466. {
  467. Logger.WriteLineError($"LiveConsultation HeartRateAsync Error,ErrorMsg:{ex}");
  468. }
  469. return null;
  470. }
  471. #endregion ILiveConsultationService
  472. #region IRemedicalService
  473. internal static CreateExaminfoResult CreateExamInfo(IRemedicalService remedicalService, CreateExaminfoRequest createExaminfoRequest)
  474. {
  475. try
  476. {
  477. Logger.WriteLineInfo($"IRemedicalService CreateExamInfoAsync:{JsonSerializer.Serialize(createExaminfoRequest)}");
  478. return remedicalService.CreateExamInfoAsync(createExaminfoRequest).GetAwaiter().GetResult();
  479. }
  480. catch (RpcException rpcExcetpion)
  481. {
  482. Logger.WriteLineError($"CreateExamInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  483. }
  484. catch (Exception ex)
  485. {
  486. Logger.WriteLineError($"CreateExamInfoAsync Error,ErrorMsg:{ex}");
  487. }
  488. return null;
  489. }
  490. /// <summary>
  491. ///
  492. /// </summary>
  493. /// <param name="remedicalService"></param>
  494. /// <param name="uploadExamDataRequest"></param>
  495. /// <returns>0为上传成功,-1为上传失败,大于0时为上传失败的代码</returns>
  496. internal static ResultInfo UploadExamData(IRemedicalService remedicalService, UploadExamDataRequest uploadExamDataRequest)
  497. {
  498. try
  499. {
  500. Logger.WriteLineInfo($"IRemedicalService UploadExamDataAsync:{JsonSerializer.Serialize(uploadExamDataRequest)}");
  501. var result = remedicalService.UploadExamDataAsync(uploadExamDataRequest).GetAwaiter().GetResult();
  502. return new ResultInfo(result, 0);
  503. }
  504. catch (RpcException rpcExcetpion)
  505. {
  506. Logger.WriteLineError($"UploadExamDataAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  507. return new ResultInfo(false, rpcExcetpion.ErrorCode);
  508. }
  509. catch (Exception ex)
  510. {
  511. Logger.WriteLineError($"UploadExamDataAsync Error,ErrorMsg:{ex}");
  512. return new ResultInfo(false, -1);
  513. }
  514. }
  515. internal static bool DeviceFinishExam(IRemedicalService remedicalService, DeviceFinishExamRequest deviceFinishExamRequest)
  516. {
  517. try
  518. {
  519. Logger.WriteLineInfo($"IRemedicalService DeviceFinishExamAsync:{JsonSerializer.Serialize(deviceFinishExamRequest)}");
  520. return remedicalService.DeviceFinishExamAsync(deviceFinishExamRequest).GetAwaiter().GetResult();
  521. }
  522. catch (RpcException rpcExcetpion)
  523. {
  524. Logger.WriteLineError($"DeviceFinishExamAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  525. }
  526. catch (Exception ex)
  527. {
  528. Logger.WriteLineError($"DeviceFinishExamAsync Error,ErrorMsg:{ex}");
  529. }
  530. return false;
  531. }
  532. internal static PageResult<QueryExamListItemResult> QueryExamList(IRemedicalService remedicalService, QueryExamListRequest queryExamListRequest)
  533. {
  534. try
  535. {
  536. Logger.WriteLineInfo($"IRemedicalService QueryExamListAsync:{JsonSerializer.Serialize(queryExamListRequest)}");
  537. return remedicalService.QueryExamListAsync(queryExamListRequest).GetAwaiter().GetResult();
  538. }
  539. catch (RpcException rpcExcetpion)
  540. {
  541. Logger.WriteLineError($"QueryExamListAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  542. }
  543. catch (Exception ex)
  544. {
  545. Logger.WriteLineError($"QueryExamListAsync Error,ErrorMsg:{ex}");
  546. }
  547. return null;
  548. }
  549. internal static QueryExamInfoResult QueryExamInfo(IRemedicalService remedicalService, QueryExamInfoRequest queryExamInfoRequest)
  550. {
  551. try
  552. {
  553. Logger.WriteLineInfo($"IRemedicalService QueryExamInfoAsync:{JsonSerializer.Serialize(queryExamInfoRequest)}");
  554. return remedicalService.QueryExamInfoAsync(queryExamInfoRequest).GetAwaiter().GetResult();
  555. }
  556. catch (RpcException rpcExcetpion)
  557. {
  558. Logger.WriteLineError($"QueryExamInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  559. }
  560. catch (Exception ex)
  561. {
  562. Logger.WriteLineError($"QueryExamInfoAsync Error,ErrorMsg:{ex}");
  563. }
  564. return null;
  565. }
  566. internal static string GetCollcetingRecordCode(IRemedicalService remedicalService, TokenRequest tokenRequest)
  567. {
  568. try
  569. {
  570. return remedicalService.GetCollcetingRecordCodeAsync(tokenRequest).GetAwaiter().GetResult();
  571. }
  572. catch (RpcException rpcExcetpion)
  573. {
  574. Logger.WriteLineError($"LiveConsultation GetCollcetingRecordCodeAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  575. }
  576. catch (Exception ex)
  577. {
  578. Logger.WriteLineError($"LiveConsultation GetCollcetingRecordCodeAsync Error,ErrorMsg:{ex}");
  579. }
  580. return null;
  581. }
  582. #endregion IRemedicalService
  583. #region IVinnoServerService
  584. internal static List<ServerInfoDTO> GetServerInfoList(IVinnoServerService vinnoServerService, QueryServerInfoRequest queryServerInfoRequest)
  585. {
  586. try
  587. {
  588. return vinnoServerService.GetServerInfoListAsync(queryServerInfoRequest).GetAwaiter().GetResult();
  589. }
  590. catch (RpcException rpcExcetpion)
  591. {
  592. Logger.WriteLineError($"GetServerInfoListAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  593. }
  594. catch (Exception ex)
  595. {
  596. Logger.WriteLineError($"GetServerInfoListAsync Error,ErrorMsg:{ex}");
  597. }
  598. return new List<ServerInfoDTO>();
  599. }
  600. internal static EchoResult Echo(IVinnoServerService vinnoServerService)
  601. {
  602. try
  603. {
  604. return vinnoServerService.EchoAsync().GetAwaiter().GetResult();
  605. }
  606. catch (RpcException rpcExcetpion)
  607. {
  608. Logger.WriteLineError($"EchoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  609. }
  610. catch (HttpRequestException)
  611. {
  612. Logger.WriteLineError($"EchoAsync Error:HttpRequestException");
  613. }
  614. catch (Exception ex)
  615. {
  616. Logger.WriteLineError($"EchoAsync Error,ErrorMsg:{ex}");
  617. }
  618. return null;
  619. }
  620. #endregion IVinnoServerService
  621. #region IStorageService
  622. internal static StorageServiceSettingDTO GetAuthorization(IStorageService storageService, FileServiceRequest fileServiceRequest)
  623. {
  624. try
  625. {
  626. return storageService.GetAuthorizationAsync(fileServiceRequest).GetAwaiter().GetResult();
  627. }
  628. catch (RpcException rpcExcetpion)
  629. {
  630. Logger.WriteLineError($"GetAuthorizationAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  631. }
  632. catch (Exception ex)
  633. {
  634. Logger.WriteLineError($"GetAuthorizationAsync Error,ErrorMsg:{ex}");
  635. }
  636. return null;
  637. }
  638. internal static StorageServiceSettingDTO GetStorageTestUrl(IStorageService storageService, CheckStorageRequest checkStorageRequest)
  639. {
  640. try
  641. {
  642. return storageService.GetStorageTestUrlAsync(checkStorageRequest).GetAwaiter().GetResult();
  643. }
  644. catch (RpcException rpcExcetpion)
  645. {
  646. Logger.WriteLineError($"GetStorageTestUrl Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  647. }
  648. catch (Exception ex)
  649. {
  650. Logger.WriteLineError($"GetStorageTestUrl Error,ErrorMsg:{ex}");
  651. }
  652. return null;
  653. }
  654. #endregion IStorageService
  655. #region IUpgradeService
  656. internal static GetUpgradeInfoResult GetUpgradeInfo(IUpgradeService upgradeService, GetUpgradeInfoRequest getUpgradeInfoRequest)
  657. {
  658. try
  659. {
  660. return upgradeService.GetUpgradeInfoAsync(getUpgradeInfoRequest).GetAwaiter().GetResult();
  661. }
  662. catch (RpcException rpcExcetpion)
  663. {
  664. Logger.WriteLineError($"GetUpgradeInfoAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  665. }
  666. catch (Exception ex)
  667. {
  668. Logger.WriteLineError($"GetUpgradeInfoAsync Error,ErrorMsg:{ex}");
  669. }
  670. return null;
  671. }
  672. #endregion IUpgradeService
  673. #region IEducationService
  674. internal static LiveHeartRateResult HeartRate(IEducationService educationService, LiveHeartRateRequest liveHeartRateRequest)
  675. {
  676. try
  677. {
  678. return educationService.HeartRateAsync(liveHeartRateRequest).GetAwaiter().GetResult();
  679. }
  680. catch (RpcException rpcExcetpion)
  681. {
  682. Logger.WriteLineError($"EducationService HeartRateAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  683. }
  684. catch (Exception ex)
  685. {
  686. Logger.WriteLineError($"EducationService HeartRateAsync Error,ErrorMsg:{ex}");
  687. }
  688. return null;
  689. }
  690. #endregion IEducationService
  691. #region IOrganizationService
  692. internal static OrganizationDTO GetOrganizationByCode(IOrganizationService organizationService, GetOrganizationByCodeRequest getOrganizationByCodeRequest)
  693. {
  694. try
  695. {
  696. return organizationService.GetOrganizationByCodeAsync(getOrganizationByCodeRequest).GetAwaiter().GetResult();
  697. }
  698. catch (RpcException rpcExcetpion)
  699. {
  700. Logger.WriteLineError($"LiveConsultation GetOrganizationByCodeAsync Error,ErrorCode:{rpcExcetpion.ErrorCode},ErrorMsg:{rpcExcetpion.InternalMessage} ");
  701. }
  702. catch (Exception ex)
  703. {
  704. Logger.WriteLineError($"LiveConsultation GetOrganizationByCodeAsync Error,ErrorMsg:{ex}");
  705. }
  706. return null;
  707. }
  708. #endregion IOrganizationService
  709. }
  710. }