123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using DevExpress.XtraEditors;
- using DevExpress.XtraTreeList.Data;
- using ExtensionsDev;
- using PosResAnalysis;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.Entity;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using XdCxRhDW.Dto;
- using XdCxRhDW.App.Model;
- using XdCxRhDW.Entity;
- using XdCxRhDW.Repostory;
- namespace XdCxRhDW.App.CorTools
- {
- public partial class XlCalculateForm : DevExpress.XtraEditors.XtraForm
- {
- List<ModelSatEphRes> listEph = new List<ModelSatEphRes>();
- public XlCalculateForm()
- {
- InitializeComponent();
- }
- private async void XlCalculateForm_Load(object sender, EventArgs e)
- {
- gridControl.UseDefault(listEph).UseMultiSelect().UseRowNumber();
- txtStartTime.UseDefault();
- txtEndTime.UseDefault();
- txtTle.UseDoubleClickToSelectAll();
- txtTle.UseDefault().SetData(await XlRepository.GetAllAsync(), nameof(XlInfo.TwoLine));
- }
- private async void btnCalculate_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrWhiteSpace(txtStartTime.Text))
- {
- DxHelper.MsgBoxHelper.ShowError("请填写开始时间");
- return;
- }
- int timeout, spanSeconds = 1;
- if (txtEndTime.DateTime != txtStartTime.DateTime)
- {
- if (!string.IsNullOrEmpty(txtEndTime.Text) && !int.TryParse(txtSpanSeconds.Text, out spanSeconds))
- {
- DxHelper.MsgBoxHelper.ShowError("推算间隔非数字");
- return;
- }
- }
- if (!int.TryParse(txtTimeout.Text, out timeout))
- {
- DxHelper.MsgBoxHelper.ShowError("超时时间非数字");
- return;
- }
- var startTime = Convert.ToDateTime(txtStartTime.EditValue);
- var endTime = Convert.ToDateTime(txtEndTime.EditValue);
- if (!string.IsNullOrEmpty(txtStartTime.Text) && !string.IsNullOrEmpty(txtEndTime.Text))
- {
- if (endTime < startTime)
- {
- DxHelper.MsgBoxHelper.ShowError("开始时间不能大于结束时间");
- return;
- }
- if ((endTime - startTime).TotalHours > 24)
- {
- DxHelper.MsgBoxHelper.ShowError("开始时间和结束时间不能相差超过24小时");
- return;
- }
- }
- if (timeout <= 0) timeout = 30;
- listEph.Clear();
- try
- {
- if (!string.IsNullOrEmpty(txtEndTime.Text) && !string.IsNullOrEmpty(txtSpanSeconds.Text))
- {
- var XlCalcMultDto = new XlCalcMultDto()
- {
- tleStr = txtTle.Text,
- startTime = startTime,
- endTime = endTime,
- spanSeconds = spanSeconds,
- TimeoutSeconds = timeout
- };
- var ephRes = await HttpHelper.PostRequestAsync<List<ModelSatEphRes>>(SysConfig.GetUrl("Xl/CalcMult"), XlCalcMultDto, timeout);
- if (ephRes.code == 200)
- {
- listEph.AddRange(ephRes.data);
- gridView.RefreshData();
- }
- else
- {
- DxHelper.MsgBoxHelper.ShowError(ephRes.msg);
- }
- }
- else
- {
- var XlCalcDto = new XlCalcDto()
- {
- tleStr = txtTle.Text,
- SigTime = txtStartTime.DateTime,
- TimeoutSeconds = timeout
- };
- var ephRes = await HttpHelper.PostRequestAsync<ModelSatEphRes>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto, timeout);
- if (ephRes.code == 200)
- {
- listEph.Add(ephRes.data);
- gridView.RefreshData();
- }
- else
- {
- DxHelper.MsgBoxHelper.ShowError(ephRes.msg);
- }
- }
- }
- catch (TaskCanceledException)
- {
- Serilog.Log.Warning("星历推算Http接口调用超时");
- DxHelper.MsgBoxHelper.ShowInfo("星历推算Http接口调用超时");
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, "星历推算异常");
- DxHelper.MsgBoxHelper.ShowError("星历推算异常");
- }
- Console.ReadLine();
- }
- }
- }
|