Browse Source

Merge branch 'master' of http://139.155.15.221:3000/gongqiuhong/DataSimulation

gongqiuhong 1 year ago
parent
commit
7b78bf6969

+ 9 - 0
DataSimulation.Forms/DataSimulation.Forms.csproj

@@ -151,6 +151,12 @@
     <Compile Include="DxHelper\PopupHelper.cs" />
     <Compile Include="DxHelper\SvgHelper.cs" />
     <Compile Include="DxHelper\WaitHelper.cs" />
+    <Compile Include="EditForms\FlightImport.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="EditForms\FlightImport.Designer.cs">
+      <DependentUpon>FlightImport.cs</DependentUpon>
+    </Compile>
     <Compile Include="EditForms\RefEditor.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -241,6 +247,9 @@
     <Compile Include="UserControl\CtrlXl.Designer.cs">
       <DependentUpon>CtrlXl.cs</DependentUpon>
     </Compile>
+    <EmbeddedResource Include="EditForms\FlightImport.resx">
+      <DependentUpon>FlightImport.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="EditForms\RefEditor.resx">
       <DependentUpon>RefEditor.cs</DependentUpon>
     </EmbeddedResource>

+ 308 - 0
DataSimulation.Forms/EditForms/FlightImport.Designer.cs

@@ -0,0 +1,308 @@
+namespace DataSimulation.Forms.EditForms
+{
+    partial class FlightImport
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.components = new System.ComponentModel.Container();
+            DevExpress.XtraEditors.Controls.EditorButtonImageOptions editorButtonImageOptions1 = new DevExpress.XtraEditors.Controls.EditorButtonImageOptions();
+            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject1 = new DevExpress.Utils.SerializableAppearanceObject();
+            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject2 = new DevExpress.Utils.SerializableAppearanceObject();
+            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject3 = new DevExpress.Utils.SerializableAppearanceObject();
+            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject4 = new DevExpress.Utils.SerializableAppearanceObject();
+            this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
+            this.cbAll = new DevExpress.XtraEditors.ComboBoxEdit();
+            this.btnImport = new DevExpress.XtraEditors.SimpleButton();
+            this.mapControl = new DevExpress.XtraMap.MapControl();
+            this.btnSave = new DevExpress.XtraEditors.SimpleButton();
+            this.txtSpeed = new DevExpress.XtraEditors.ButtonEdit();
+            this.txtFlightName = new DevExpress.XtraEditors.TextEdit();
+            this.Root = new DevExpress.XtraLayout.LayoutControlGroup();
+            this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
+            this.layoutControlItem13 = new DevExpress.XtraLayout.LayoutControlItem();
+            this.layoutControlItem10 = new DevExpress.XtraLayout.LayoutControlItem();
+            this.splitterItem1 = new DevExpress.XtraLayout.SplitterItem();
+            this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
+            this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem();
+            this.layoutControlItem12 = new DevExpress.XtraLayout.LayoutControlItem();
+            this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
+            this.所有航迹 = new DevExpress.XtraLayout.LayoutControlItem();
+            this.dxErrorProvider = new DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider(this.components);
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
+            this.layoutControl1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.cbAll.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.mapControl)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.txtSpeed.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.txtFlightName.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.splitterItem1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem12)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.所有航迹)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // layoutControl1
+            // 
+            this.layoutControl1.Controls.Add(this.cbAll);
+            this.layoutControl1.Controls.Add(this.btnImport);
+            this.layoutControl1.Controls.Add(this.mapControl);
+            this.layoutControl1.Controls.Add(this.btnSave);
+            this.layoutControl1.Controls.Add(this.txtSpeed);
+            this.layoutControl1.Controls.Add(this.txtFlightName);
+            this.layoutControl1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.layoutControl1.Location = new System.Drawing.Point(0, 0);
+            this.layoutControl1.Name = "layoutControl1";
+            this.layoutControl1.Root = this.Root;
+            this.layoutControl1.Size = new System.Drawing.Size(1189, 509);
+            this.layoutControl1.TabIndex = 0;
+            this.layoutControl1.Text = "layoutControl1";
+            // 
+            // cbAll
+            // 
+            this.cbAll.Location = new System.Drawing.Point(12, 29);
+            this.cbAll.Name = "cbAll";
+            this.cbAll.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.cbAll.Size = new System.Drawing.Size(278, 20);
+            this.cbAll.StyleController = this.layoutControl1;
+            this.cbAll.TabIndex = 18;
+            this.cbAll.SelectedValueChanged += new System.EventHandler(this.cbAll_SelectedValueChanged);
+            // 
+            // btnImport
+            // 
+            this.btnImport.Location = new System.Drawing.Point(154, 475);
+            this.btnImport.Name = "btnImport";
+            this.btnImport.Size = new System.Drawing.Size(60, 22);
+            this.btnImport.StyleController = this.layoutControl1;
+            this.btnImport.TabIndex = 17;
+            this.btnImport.Text = "导入航迹";
+            this.btnImport.Click += new System.EventHandler(this.btnFlight_Click);
+            // 
+            // mapControl
+            // 
+            this.mapControl.Location = new System.Drawing.Point(304, 12);
+            this.mapControl.Name = "mapControl";
+            this.mapControl.Size = new System.Drawing.Size(873, 485);
+            this.mapControl.TabIndex = 16;
+            // 
+            // btnSave
+            // 
+            this.btnSave.Location = new System.Drawing.Point(218, 475);
+            this.btnSave.Name = "btnSave";
+            this.btnSave.Size = new System.Drawing.Size(72, 22);
+            this.btnSave.StyleController = this.layoutControl1;
+            this.btnSave.TabIndex = 15;
+            this.btnSave.Text = "保存";
+            this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
+            // 
+            // txtSpeed
+            // 
+            this.txtSpeed.Location = new System.Drawing.Point(12, 111);
+            this.txtSpeed.MaximumSize = new System.Drawing.Size(0, 20);
+            this.txtSpeed.MinimumSize = new System.Drawing.Size(0, 20);
+            this.txtSpeed.Name = "txtSpeed";
+            this.txtSpeed.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "m/s", -1, false, true, false, editorButtonImageOptions1, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject1, serializableAppearanceObject2, serializableAppearanceObject3, serializableAppearanceObject4, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)});
+            this.txtSpeed.Properties.MaskSettings.Set("MaskManagerType", typeof(DevExpress.Data.Mask.NumericMaskManager));
+            this.txtSpeed.Properties.MaskSettings.Set("mask", "f3");
+            this.txtSpeed.Properties.MaxLength = 10;
+            this.txtSpeed.Size = new System.Drawing.Size(278, 20);
+            this.txtSpeed.StyleController = this.layoutControl1;
+            this.txtSpeed.TabIndex = 13;
+            // 
+            // txtFlightName
+            // 
+            this.txtFlightName.Location = new System.Drawing.Point(12, 70);
+            this.txtFlightName.Name = "txtFlightName";
+            this.txtFlightName.Properties.MaxLength = 12;
+            this.txtFlightName.Size = new System.Drawing.Size(278, 20);
+            this.txtFlightName.StyleController = this.layoutControl1;
+            this.txtFlightName.TabIndex = 4;
+            // 
+            // Root
+            // 
+            this.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
+            this.Root.GroupBordersVisible = false;
+            this.Root.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
+            this.layoutControlItem1,
+            this.layoutControlItem13,
+            this.layoutControlItem10,
+            this.splitterItem1,
+            this.emptySpaceItem1,
+            this.emptySpaceItem2,
+            this.layoutControlItem12,
+            this.layoutControlItem2,
+            this.所有航迹});
+            this.Root.Name = "Root";
+            this.Root.Size = new System.Drawing.Size(1189, 509);
+            this.Root.TextVisible = false;
+            // 
+            // layoutControlItem1
+            // 
+            this.layoutControlItem1.Control = this.txtFlightName;
+            this.layoutControlItem1.Location = new System.Drawing.Point(0, 41);
+            this.layoutControlItem1.Name = "layoutControlItem1";
+            this.layoutControlItem1.Size = new System.Drawing.Size(282, 41);
+            this.layoutControlItem1.Text = "航迹名称";
+            this.layoutControlItem1.TextLocation = DevExpress.Utils.Locations.Top;
+            this.layoutControlItem1.TextSize = new System.Drawing.Size(48, 14);
+            // 
+            // layoutControlItem13
+            // 
+            this.layoutControlItem13.Control = this.mapControl;
+            this.layoutControlItem13.Location = new System.Drawing.Point(292, 0);
+            this.layoutControlItem13.Name = "layoutControlItem13";
+            this.layoutControlItem13.Size = new System.Drawing.Size(877, 489);
+            this.layoutControlItem13.TextSize = new System.Drawing.Size(0, 0);
+            this.layoutControlItem13.TextVisible = false;
+            // 
+            // layoutControlItem10
+            // 
+            this.layoutControlItem10.Control = this.txtSpeed;
+            this.layoutControlItem10.Location = new System.Drawing.Point(0, 82);
+            this.layoutControlItem10.Name = "layoutControlItem10";
+            this.layoutControlItem10.Size = new System.Drawing.Size(282, 44);
+            this.layoutControlItem10.Text = "速度";
+            this.layoutControlItem10.TextLocation = DevExpress.Utils.Locations.Top;
+            this.layoutControlItem10.TextSize = new System.Drawing.Size(48, 14);
+            // 
+            // splitterItem1
+            // 
+            this.splitterItem1.AllowHotTrack = true;
+            this.splitterItem1.Location = new System.Drawing.Point(282, 0);
+            this.splitterItem1.Name = "splitterItem1";
+            this.splitterItem1.Size = new System.Drawing.Size(10, 489);
+            // 
+            // emptySpaceItem1
+            // 
+            this.emptySpaceItem1.AllowHotTrack = false;
+            this.emptySpaceItem1.Location = new System.Drawing.Point(0, 463);
+            this.emptySpaceItem1.Name = "emptySpaceItem1";
+            this.emptySpaceItem1.Size = new System.Drawing.Size(142, 26);
+            this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
+            // 
+            // emptySpaceItem2
+            // 
+            this.emptySpaceItem2.AllowHotTrack = false;
+            this.emptySpaceItem2.Location = new System.Drawing.Point(0, 126);
+            this.emptySpaceItem2.Name = "emptySpaceItem2";
+            this.emptySpaceItem2.Size = new System.Drawing.Size(282, 337);
+            this.emptySpaceItem2.TextSize = new System.Drawing.Size(0, 0);
+            // 
+            // layoutControlItem12
+            // 
+            this.layoutControlItem12.Control = this.btnSave;
+            this.layoutControlItem12.Location = new System.Drawing.Point(206, 463);
+            this.layoutControlItem12.MaxSize = new System.Drawing.Size(76, 26);
+            this.layoutControlItem12.MinSize = new System.Drawing.Size(76, 26);
+            this.layoutControlItem12.Name = "layoutControlItem12";
+            this.layoutControlItem12.Size = new System.Drawing.Size(76, 26);
+            this.layoutControlItem12.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
+            this.layoutControlItem12.TextSize = new System.Drawing.Size(0, 0);
+            this.layoutControlItem12.TextVisible = false;
+            // 
+            // layoutControlItem2
+            // 
+            this.layoutControlItem2.Control = this.btnImport;
+            this.layoutControlItem2.Location = new System.Drawing.Point(142, 463);
+            this.layoutControlItem2.Name = "layoutControlItem2";
+            this.layoutControlItem2.Size = new System.Drawing.Size(64, 26);
+            this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
+            this.layoutControlItem2.TextVisible = false;
+            // 
+            // 所有航迹
+            // 
+            this.所有航迹.Control = this.cbAll;
+            this.所有航迹.Location = new System.Drawing.Point(0, 0);
+            this.所有航迹.Name = "所有航迹";
+            this.所有航迹.Size = new System.Drawing.Size(282, 41);
+            this.所有航迹.TextLocation = DevExpress.Utils.Locations.Top;
+            this.所有航迹.TextSize = new System.Drawing.Size(48, 14);
+            // 
+            // dxErrorProvider
+            // 
+            this.dxErrorProvider.ContainerControl = this;
+            // 
+            // FlightImport
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(1189, 509);
+            this.Controls.Add(this.layoutControl1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+            this.Name = "FlightImport";
+            this.Text = "FlightEditor";
+            this.Load += new System.EventHandler(this.Editor_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit();
+            this.layoutControl1.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.cbAll.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.mapControl)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.txtSpeed.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.txtFlightName.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.splitterItem1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem12)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.所有航迹)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider)).EndInit();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private DevExpress.XtraLayout.LayoutControl layoutControl1;
+        private DevExpress.XtraLayout.LayoutControlGroup Root;
+        private DevExpress.XtraEditors.TextEdit txtFlightName;
+        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;
+        private DevExpress.XtraEditors.ButtonEdit txtSpeed;
+        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem10;
+        private DevExpress.XtraEditors.SimpleButton btnSave;
+        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem12;
+        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2;
+        private DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider dxErrorProvider;
+        private DevExpress.XtraMap.MapControl mapControl;
+        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem13;
+        private DevExpress.XtraLayout.SplitterItem splitterItem1;
+        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1;
+        private DevExpress.XtraEditors.SimpleButton btnImport;
+        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2;
+        private DevExpress.XtraEditors.ComboBoxEdit cbAll;
+        private DevExpress.XtraLayout.LayoutControlItem 所有航迹;
+    }
+}

+ 188 - 0
DataSimulation.Forms/EditForms/FlightImport.cs

@@ -0,0 +1,188 @@
+using DataSimulation.Repostory;
+using DataSimulation.Repostory.EFContext;
+using DataSimulation.Repostory.Model;
+using DevExpress.Utils.About;
+using DevExpress.XtraEditors;
+using DevExpress.XtraEditors.Controls;
+using DevExpress.XtraEditors.DXErrorProvider;
+using DxHelper;
+using ExtensionsDev;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Data.Entity;
+using System.Data.Entity.Migrations;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace DataSimulation.Forms.EditForms
+{
+    public partial class FlightImport : DevExpress.XtraEditors.XtraForm
+    {
+        public List<SimulationInfo> Addinfo;
+        private List<SimulationInfo> simulationInfos;
+        private List<FlightInfo> flightInfos;
+        public FlightImport(List<SimulationInfo> simulationInfos)
+        {
+            InitializeComponent();
+            this.Text = "导入航迹";
+            this.simulationInfos = simulationInfos;
+            this.StartPosition = FormStartPosition.CenterParent;
+        }
+
+
+        private void Editor_Load(object sender, EventArgs e)
+        {
+            mapControl.UseDefalutOptions()
+           .UseClearAll()
+           .UseDistanceLine()
+           .UseMarkDot()
+           .UseExportImg()
+           .UseExportXlsx()
+           .UseExportCsv()
+           .UseExportFlightLine()
+           .SetMapLayerType(null);
+        }
+
+
+        private async void btnSave_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                var fligths = mapControl.GetFlightLine<FlightInfo>();
+               
+                Addinfo = new List<SimulationInfo>();
+
+                var sims = fligths.Select(f => new SimulationInfo() { SimulationName = f.FlightName, SimulationSpeed = f.Speed });
+                Addinfo.AddRange(sims);
+
+                using (SimulationPartContext db = SimulationPartContext.GetContext(sims.First().CreateTime))
+                {
+                    var sinfos = db.SimulationInfos.AddRange(Addinfo);
+                    await db.SaveChangesAsync();
+
+                    List<SimulationPonit> ponits = new List<SimulationPonit>();
+                    foreach (var sinfo in sinfos)
+                    {
+                        var flight = fligths.FirstOrDefault(s => s.FlightName == sinfo.SimulationName);
+                        var fpoints = flight.flights.Select(f => new SimulationPonit()
+                        {
+                            SimulationId = sinfo.ID,
+                            SimulationLon = f.FlightLon,
+                            SimulationLat = f.FlightLat,
+                        });
+                        ponits.AddRange(fpoints);
+                    }
+                    db.SimulationPonits.AddRange(ponits);
+
+                    await db.SaveChangesAsync();
+                }
+
+                this.DialogResult = DialogResult.OK;
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, $"{this.Text}异常");
+                DxHelper.MsgBoxHelper.ShowError($"{this.Text}异常");
+            }
+
+        }
+
+        private List<FlightInfo> AnalysisFlight(string filePath)
+        {
+
+            List<FlightInfo> flightInfos = new List<FlightInfo>();
+            try
+            {
+
+                List<FightDataCsv> fights = new List<FightDataCsv>();
+                var allLines = File.ReadAllLines(filePath);
+                int count = 0;
+                foreach (var item in allLines)
+                {
+                    count++;
+                    if (count == 1) continue;
+                    var strs = item.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
+                    if (strs.Length != 4)
+                    {
+                        throw new Exception("格式错误");
+                    }
+                    FightDataCsv fight = new FightDataCsv();
+                    int i = 0;
+                    fight.FlightName = strs[i++];
+                    fight.Speed = Convert.ToDouble(strs[i++]);
+                    fight.FlightLon = Convert.ToDouble(strs[i++]);
+                    fight.FlightLat = Convert.ToDouble(strs[i++]);
+                    fights.Add(fight);
+                }
+                var groupfilghts = fights.GroupBy(f => f.FlightName);
+                foreach (var flight in groupfilghts)
+                {
+                    string name = flight.Key;
+                    if (simulationInfos.Any(m => m.SimulationName == name))
+                    {
+                        name = $"{name}{DateTime.Now:yyyyMMddHHmmss}";
+                    }
+                    double speed = flight.First().Speed;
+                    var fligths = flight.Select(f => new FlightData(f.FlightLon, f.FlightLat)).ToList();
+                    FlightInfo flightInfo = new FlightInfo(name, speed);
+                    flightInfo.flights.AddRange(fligths);
+                    flightInfos.Add(flightInfo);
+                }
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, $"导入航迹解析异常:{ex.Message}");
+                DxHelper.MsgBoxHelper.ShowError($"导入航迹解析异常:{ex.Message}");
+            }
+
+            return flightInfos;
+
+        }
+
+        private void btnFlight_Click(object sender, EventArgs e)
+        {
+            flightInfos = new List<FlightInfo>();
+            XtraOpenFileDialog xtraOpenFileDialog1 = new XtraOpenFileDialog();
+            xtraOpenFileDialog1.Multiselect = false;
+            xtraOpenFileDialog1.Filter = "CSV文件|*.csv";
+            if (xtraOpenFileDialog1.ShowDialog() == DialogResult.OK)
+            {
+                string filePath = xtraOpenFileDialog1.FileName;
+                flightInfos = AnalysisFlight(filePath);
+            }
+            try
+            {
+                cbAll.Properties.Items.AddRange(flightInfos.Select(m => m.FlightName).ToList());
+                if (flightInfos.Count > 0)
+                {
+                    cbAll.SelectedIndex = 0;
+                    mapControl.SetFlightLine(flightInfos);
+                }
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, $"导入航迹异常:{ex.Message}");
+                DxHelper.MsgBoxHelper.ShowError($"导入航迹异常:{ex.Message}");
+            }
+
+        }
+
+        private void cbAll_SelectedValueChanged(object sender, EventArgs e)
+        {
+            if (flightInfos != null && flightInfos.Count > 0)
+            {
+                var name = cbAll.SelectedItem.ToString();
+                var firstFlight = flightInfos.First(f => f.FlightName == name);
+                this.txtFlightName.Text = firstFlight.FlightName;
+                this.txtSpeed.Text = $"{firstFlight.Speed}";
+            }
+
+        }
+    }
+}

+ 123 - 0
DataSimulation.Forms/EditForms/FlightImport.resx

@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="dxErrorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+</root>

+ 4 - 7
DataSimulation.Forms/ExtensionsDev/MapControlEx.cs

@@ -1077,7 +1077,7 @@ public static class MapControlEx
 
     }
 
-    public static MapControl UseExportFlightLine(this MapControl ctrl, bool exportHeader = true)
+    public static MapControl UseExportFlightLine(this MapControl ctrl)
     {
         var innerData = ctrl.Tag as InnerData;
         var btnExportFlightLine = new BarButtonItem() { Caption = "导出航迹" };
@@ -1125,14 +1125,11 @@ public static class MapControlEx
                 {
                     StreamWriter sw = new StreamWriter(dialog.FileName, false, new UTF8Encoding(true));//utf8-bom
 
-                    if (exportHeader)
+                    foreach (var prop in listPorps)
                     {
-                        foreach (var prop in listPorps)
-                        {
-                            sw.Write($"{prop.Header},");
-                        }
-                        sw.WriteLine();
+                        sw.Write($"{prop.Header},");
                     }
+                    sw.WriteLine();
                     WaitHelper.ShowOverlayForm(ctrl);
                     long count = list.Count() * listPorps.Count;
                     int idx = 1;

+ 36 - 34
DataSimulation.Forms/UserControl/CtrlFlight.Designer.cs

@@ -42,13 +42,13 @@
             this.btnEdit = new DevExpress.XtraBars.BarButtonItem();
             this.popupMenu1 = new DevExpress.XtraBars.PopupMenu(this.components);
             this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
+            this.btnImport = new DevExpress.XtraEditors.SimpleButton();
+            this.btnQuery = new DevExpress.XtraEditors.SimpleButton();
+            this.txtFlightName = new DevExpress.XtraEditors.TextEdit();
             this.Root = new DevExpress.XtraLayout.LayoutControlGroup();
             this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
-            this.txtFlightName = new DevExpress.XtraEditors.TextEdit();
             this.ll = new DevExpress.XtraLayout.LayoutControlItem();
-            this.btnQuery = new DevExpress.XtraEditors.SimpleButton();
             this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
-            this.btnImport = new DevExpress.XtraEditors.SimpleButton();
             this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
             this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
             ((System.ComponentModel.ISupportInitialize)(this.gridFlight)).BeginInit();
@@ -57,9 +57,9 @@
             ((System.ComponentModel.ISupportInitialize)(this.popupMenu1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
             this.layoutControl1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.txtFlightName.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtFlightName.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.ll)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
@@ -175,6 +175,37 @@
             this.layoutControl1.TabIndex = 5;
             this.layoutControl1.Text = "layoutControl1";
             // 
+            // btnImport
+            // 
+            this.btnImport.Location = new System.Drawing.Point(567, 12);
+            this.btnImport.Name = "btnImport";
+            this.btnImport.Size = new System.Drawing.Size(68, 22);
+            this.btnImport.StyleController = this.layoutControl1;
+            this.btnImport.TabIndex = 6;
+            this.btnImport.Text = "导入";
+            this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
+            // 
+            // btnQuery
+            // 
+            this.btnQuery.Location = new System.Drawing.Point(495, 12);
+            this.btnQuery.Name = "btnQuery";
+            this.btnQuery.Size = new System.Drawing.Size(68, 22);
+            this.btnQuery.StyleController = this.layoutControl1;
+            this.btnQuery.TabIndex = 5;
+            this.btnQuery.Text = "查询";
+            this.btnQuery.Click += new System.EventHandler(this.btnQuery_Click);
+            // 
+            // txtFlightName
+            // 
+            this.txtFlightName.Location = new System.Drawing.Point(76, 12);
+            this.txtFlightName.MaximumSize = new System.Drawing.Size(0, 22);
+            this.txtFlightName.MenuManager = this.barManager1;
+            this.txtFlightName.MinimumSize = new System.Drawing.Size(0, 22);
+            this.txtFlightName.Name = "txtFlightName";
+            this.txtFlightName.Size = new System.Drawing.Size(400, 20);
+            this.txtFlightName.StyleController = this.layoutControl1;
+            this.txtFlightName.TabIndex = 4;
+            // 
             // Root
             // 
             this.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
@@ -198,15 +229,6 @@
             this.layoutControlItem1.TextSize = new System.Drawing.Size(0, 0);
             this.layoutControlItem1.TextVisible = false;
             // 
-            // txtFlightName
-            // 
-            this.txtFlightName.Location = new System.Drawing.Point(76, 12);
-            this.txtFlightName.MenuManager = this.barManager1;
-            this.txtFlightName.Name = "txtFlightName";
-            this.txtFlightName.Size = new System.Drawing.Size(400, 20);
-            this.txtFlightName.StyleController = this.layoutControl1;
-            this.txtFlightName.TabIndex = 4;
-            // 
             // ll
             // 
             this.ll.Control = this.txtFlightName;
@@ -216,16 +238,6 @@
             this.ll.Text = "航迹名称:";
             this.ll.TextSize = new System.Drawing.Size(52, 14);
             // 
-            // btnQuery
-            // 
-            this.btnQuery.Location = new System.Drawing.Point(495, 12);
-            this.btnQuery.Name = "btnQuery";
-            this.btnQuery.Size = new System.Drawing.Size(68, 22);
-            this.btnQuery.StyleController = this.layoutControl1;
-            this.btnQuery.TabIndex = 5;
-            this.btnQuery.Text = "查询";
-            this.btnQuery.Click += new System.EventHandler(this.btnQuery_Click);
-            // 
             // layoutControlItem2
             // 
             this.layoutControlItem2.Control = this.btnQuery;
@@ -238,16 +250,6 @@
             this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
             this.layoutControlItem2.TextVisible = false;
             // 
-            // btnImport
-            // 
-            this.btnImport.Location = new System.Drawing.Point(567, 12);
-            this.btnImport.Name = "btnImport";
-            this.btnImport.Size = new System.Drawing.Size(68, 22);
-            this.btnImport.StyleController = this.layoutControl1;
-            this.btnImport.TabIndex = 6;
-            this.btnImport.Text = "导入";
-            this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
-            // 
             // layoutControlItem3
             // 
             this.layoutControlItem3.Control = this.btnImport;
@@ -289,9 +291,9 @@
             ((System.ComponentModel.ISupportInitialize)(this.popupMenu1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit();
             this.layoutControl1.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.txtFlightName.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtFlightName.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.ll)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();

+ 36 - 5
DataSimulation.Forms/UserControl/CtrlFlight.cs

@@ -14,6 +14,10 @@ using DataSimulation.Forms.EditForms;
 using DataSimulation.Repostory;
 using System.Collections;
 using System.Threading.Tasks;
+using DevExpress.XtraCharts.Native;
+using DxHelper;
+using System.IO;
+using System.Text;
 
 namespace DataSimulation.Forms.UserControl
 {
@@ -95,7 +99,8 @@ namespace DataSimulation.Forms.UserControl
                 {
                     return;
                 }
-                // this.btnImp.Enabled = false;
+                this.btnQuery.Enabled = this.btnImport.Enabled = false;
+
                 await Task.Run(async () =>
                 {
                     var ids = gridView1.GetSelectedRows();
@@ -129,7 +134,7 @@ namespace DataSimulation.Forms.UserControl
             }
             finally
             {
-                //this.btnImp.Enabled = true;
+                this.btnQuery.Enabled = this.btnImport.Enabled = true;
             }
         }
         private void gridView1_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
@@ -147,12 +152,38 @@ namespace DataSimulation.Forms.UserControl
 
         private void btnImport_Click(object sender, EventArgs e)
         {
-
+            try
+            {
+                FlightImport frm = new FlightImport(list);
+                if (frm.ShowDialog() != DialogResult.OK) return;
+                var addItem = frm.Addinfo;
+                list.AddRange(addItem);
+                gridView1.RefreshData();
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, "导入航迹信息异常");
+                DxHelper.MsgBoxHelper.ShowError("导入航迹信息异常");
+            }
         }
 
-        private void btnQuery_Click(object sender, EventArgs e)
+        private async void btnQuery_Click(object sender, EventArgs e)
         {
-
+            try
+            {
+                list.Clear();
+                string name = txtFlightName.Text.Trim();
+                var simulationCache = await SimulationCache.GetAllAsync();
+                var simulations = simulationCache.Where(m => m.SimulationName.Contains(name));
+                list.AddRange(simulations);
+                gridView1.RefreshData();
+            }
+            catch (Exception ex)
+            {
+                string msg = $"查询航迹:{txtFlightName.Text.Trim()}信息异常";
+                Serilog.Log.Error(ex, msg);
+                DxHelper.MsgBoxHelper.ShowError(msg);
+            }
         }
     }
 }