| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- using ivf_tl_Entity.Entity.HouseSetting;
- using ivf_tl_Entity.Entity.Result;
- using ivf_tl_Entity.Enums;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ivf_tl_Service.HttpProvider
- {
- public class HouseProvider
- {
- LogService LogService { get; set; }
- HttpServiceCall httpServiceCall1 { get; set; }
- public HouseProvider(HttpServiceCall _httpServiceCall, LogService _logService)
- {
- httpServiceCall1 = _httpServiceCall;
- LogService = _logService;
- }
- private void ExLog(Exception ex, string name)
- {
- LogService.ExceptionLog(ex, $"HouseProvider.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- LogService.TLLog($"HouseProvider.{message}", logType);
- }
- /// <summary>
- /// 获取对焦参数设置
- /// </summary>
- /// <param name="tlsn"></param>
- public List<AutoFocusHouseInfo> GetFocusSettingApi(string tlsn)
- {
- string funcName = "GetFocusSettingApi";
- try
- {
- string url = "/api/tl/control/setting/house/focus/setting";
- Dictionary<string, string> body = new Dictionary<string, string>();
- body.Add("tlSn", tlsn);
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return new List<AutoFocusHouseInfo>();
- ResultEntity<List<AutoFocusHouseInfo>> rs = JsonConvert.DeserializeObject<ResultEntity<List<AutoFocusHouseInfo>>>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError);
- return new List<AutoFocusHouseInfo>();
- }
- if (rs.data != null) return rs.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new List<AutoFocusHouseInfo>();
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return new List<AutoFocusHouseInfo>();
- }
- }
- /// <summary>
- /// 获取指定tlSn的tl通用设置
- /// </summary>
- /// <param name="tlsn"></param>
- public TLSettingCommon GetSettingCommonApi(string tlsn)
- {
- string funcName = "GetSettingCommonApi";
- try
- {
- string url = "/api/tl/control/setting/common";
- Dictionary<string, string> body = new Dictionary<string, string>();
- body.Add("tlSn", tlsn);
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return new TLSettingCommon();
- ResultEntity<TLSettingCommon> rs = JsonConvert.DeserializeObject<ResultEntity<TLSettingCommon>>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError);
- return new TLSettingCommon();
- }
- if (rs.data != null) return rs.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new TLSettingCommon();
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return new TLSettingCommon();
- }
- }
- /// <summary>
- /// 更新指定tlSn通用设置
- /// </summary>
- /// <param name="body"></param>
- /// <returns></returns>
- public bool UpdateSettingCommonApi(string body)
- {
- string funcName = "UpdateSettingCommonApi";
- try
- {
- string url = "/api/tl/control/setting/common/update";
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return false;
- ResultEntity rs = JsonConvert.DeserializeObject<ResultEntity>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return false;
- }
- }
- /// <summary>
- /// 获取指定tlSn的系统设置
- /// </summary>
- /// <param name="tlsn"></param>
- /// <returns></returns>
- public TLSettingModel GetSettingSystemApi(string tlsn)
- {
- string funcName = "GetSettingSystemApi";
- try
- {
- string url = "/api/tl/control/setting/system";
- Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
- keyValuePairs.Add("tlSn", tlsn);
- string resultString = httpServiceCall1.callWebService(url, keyValuePairs);
- if (string.IsNullOrEmpty(resultString)) return new TLSettingModel();
- ResultEntity<TLSettingModel> rs = JsonConvert.DeserializeObject<ResultEntity<TLSettingModel>>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError);
- return new TLSettingModel();
- }
- if (rs.data != null) return rs.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new TLSettingModel();
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return new TLSettingModel();
- }
- }
- /// <summary>
- /// 更新tlSn的系统设置
- /// </summary>
- /// <param name="body"></param>
- /// <returns></returns>
- public bool UpdateSettingSystemApi(string body)
- {
- string funcName = "UpdateSettingSystemApi";
- try
- {
- string url = "/api/tl/control/setting/system/update";
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return false;
- ResultEntity rs = JsonConvert.DeserializeObject<ResultEntity>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return false;
- }
- }
- /// <summary>
- /// 获取指定tlSn的舱室配置
- /// </summary>
- /// <param name="tlSn"></param>
- /// <returns></returns>
- public List<HouseInfo> GetSettingHouseApi(string tlSn)
- {
- string funcName = "GetSettingHouseApi";
- try
- {
- string url = "/api/tl/control/setting/house";
- string body = JsonConvert.SerializeObject(new { tlSn = tlSn, size = 100, current = 1 });
- string resultString = httpServiceCall1.callWebService(url, body);
- if (string.IsNullOrEmpty(resultString)) return new List<HouseInfo>();
- ResultEntity<SettingHouseData> rs = JsonConvert.DeserializeObject<ResultEntity<SettingHouseData>>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError);
- return new List<HouseInfo>();
- }
- if (rs.data != null && rs.data.records != null) return rs.data.records;
- ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
- return new List<HouseInfo>();
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return new List<HouseInfo>();
- }
- }
- public bool UploadLogoApi(byte[] logoBtye, string fileName, string tlsn)
- {
- string funcName = "UploadLogoApi";
- try
- {
- string url = "/api/tl/control/setting/common/updateLogoFile";
- Dictionary<string, string> body = new Dictionary<string, string> { { "tlSn", tlsn } };
- string resultString = httpServiceCall1.callWebServiceUpLoad(url, body, logoBtye, fileName);
- if (string.IsNullOrEmpty(resultString)) return false;
- ResultEntity rs = JsonConvert.DeserializeObject<ResultEntity>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return false;
- }
- }
- public bool ClearLogoApi(string tlsn)
- {
- string funcName = "ClearLogoApi";
- try
- {
- string url = "/api/tl/control/setting/common/deleteLogoFile";
- string resultString = httpServiceCall1.callWebService(url, new Dictionary<string, string> { { "tlSn",tlsn} });
- if (string.IsNullOrEmpty(resultString)) return false;
- ResultEntity rs = JsonConvert.DeserializeObject<ResultEntity>(resultString);
- if (!rs.success)
- {
- ErrorLog($"{funcName}接口返回失败:{resultString}", LogEnum.RunError);
- return false;
- }
- return true;
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return false;
- }
- }
- }
- }
|