| | |
| | | using System; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEAWCS_DTO.WMSInfo |
| | | { |
| | | public class RequestWMS |
| | | { |
| | | |
| | | private static DateTime _BeginDate; |
| | | private static DateTime _EndDate; |
| | | /// <summary> |
| | | /// åWMSç³è¯·å¹¶è®°å½æ¥å¿ |
| | | /// </summary> |
| | | /// <param name="serviceAddress">请æ±å°å</param> |
| | | /// <param name="requestJson">请æ±åæ°</param> |
| | | /// <param name="contentType"></param> |
| | | /// <param name="headers"></param> |
| | | /// <param name="Remark"></param> |
| | | /// <returns></returns> |
| | | public static WebResponseContent PostWMSLog(string serviceAddress, string requestJson = null, string Remark = null, string contentType = "application/json", Dictionary<string, string>? headers = null) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Stopwatch stopwatch = new Stopwatch(); |
| | | int taskSeconds = 0; |
| | | try |
| | | { |
| | | stopwatch.Start(); |
| | | _BeginDate = DateTime.Now; |
| | | var ResultData = HttpHelper.PostAsync(serviceAddress, requestJson, contentType, headers); |
| | | stopwatch.Stop(); |
| | | _EndDate = DateTime.Now; |
| | | if (ResultData.Result == null) throw new Exception($"{Remark}ååºå¼å¸¸"); |
| | | |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | taskSeconds = (int)Math.Round(stopwatch.Elapsed.TotalSeconds); |
| | | Dt_Interfacerecord interfacerecord = new Dt_Interfacerecord() |
| | | { |
| | | Request = "WCS", |
| | | RequestParam = requestJson, |
| | | Response = "WMS", |
| | | ResponseParam = content.ToJson(), |
| | | Success = content.Status ? 1 : 2, |
| | | BeginDate = _BeginDate, |
| | | ElapsedTime = taskSeconds, |
| | | EndDate = _EndDate, |
| | | Url = serviceAddress, |
| | | }; |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |