| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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<AddressEntity> 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<AddressEntity>();
- var result = JsonConvert.DeserializeObject<ResultEntity<ObservableCollection<AddressEntity>>>(json);
- if (!result.success)
- {
- ErrorLog($"{funcName}接口返回失败:{json}", LogEnum.RunError);
- return new ObservableCollection<AddressEntity>();
- }
- if(result.data != null) return result.data;
- ErrorLog($"{funcName}接口返回成功但是无数据 {json}", LogEnum.RunError);
- return new ObservableCollection<AddressEntity>();
- }
- catch (Exception ex)
- {
- ExLog(ex, funcName);
- return new ObservableCollection<AddressEntity>();
- }
- }
- }
- }
|