using ivf_tl_Entity.ControlEntity; using ivf_tl_Entity.Entity.balance; using ivf_tl_Entity.Entity.Result; using ivf_tl_Entity.Enums; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace ivf_tl_Service.HttpProvider { public class RegionProvider { LogService LogService { get; set; } HttpServiceCall httpServiceCall1 { get; set; } public RegionProvider(HttpServiceCall _httpServiceCall, LogService _logService) { httpServiceCall1 = _httpServiceCall; LogService = _logService; } private void ExLog(Exception ex, string name) { LogService.ExceptionLog(ex, $"RegionProvider.{name}", LogEnum.RunException); } private void ErrorLog(string message, LogEnum logType) { LogService.TLLog($"RegionProvider.{message}", logType); } public ObservableCollection GetRegionData() { string funcName = "GetRegionData"; try { string url = "/api/tl/control/data/getReign"; string json = httpServiceCall1.callWebService(url,true); if (string.IsNullOrEmpty(json)) return new ObservableCollection(); var result = JsonConvert.DeserializeObject>>(json); if (!result.success) { ErrorLog($"{funcName}接口返回失败:{json}", LogEnum.RunError); return new ObservableCollection(); } if(result.data != null) return result.data; ErrorLog($"{funcName}接口返回成功但是无数据 {json}", LogEnum.RunError); return new ObservableCollection(); } catch (Exception ex) { ExLog(ex, funcName); return new ObservableCollection(); } } } }