gongqiuhong 1 year ago
parent
commit
7a60d4aa7b

BIN
.vs/DataSimulation/v17/.suo


+ 27 - 0
DataSimulation.Repostory/App.config

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <configSections>
+    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+  </configSections>
+  <entityFramework>
+    <providers>
+      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
+    </providers>
+  </entityFramework>
+  <system.data>
+    <DbProviderFactories>
+      <remove invariant="System.Data.SQLite.EF6" />
+      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
+    <remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
+  </system.data>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+</configuration>

+ 45 - 0
DataSimulation.Repostory/BaseModel.cs

@@ -0,0 +1,45 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace DataSimulation.Repostory
+{
+    public abstract class BaseModel
+    {
+
+        public BaseModel()
+        {
+            this.CreateTime = DateTime.Now;
+            this.UpdateTime = DateTime.Now;
+        }
+        [Key]   // 主键
+        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]       // 自增列
+        [Display(Name ="编号")]
+        public int ID { get; set; }
+
+        [Display(Name = "创建时间")]
+        public DateTime CreateTime { get; set; }
+
+        [Display(Name = "更新时间")]
+        public DateTime UpdateTime { get; set; }
+
+    }
+    public abstract class BaseModel<TID>
+    {
+
+        public BaseModel()
+        {
+            this.CreateTime = DateTime.Now;
+            this.UpdateTime = DateTime.Now;
+        }
+        [Display(Name = "编号")]
+        public TID ID { get; set; }
+
+        [Display(Name = "创建时间")]
+        public DateTime CreateTime { get; set; }
+
+        [Display(Name = "更新时间")]
+        public DateTime UpdateTime { get; set; }
+
+    }
+}

+ 115 - 0
DataSimulation.Repostory/DataSimulation.Repostory.csproj

@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{61D871DE-8837-49A9-B141-C03A690A53AF}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>DataSimulation.Dto</RootNamespace>
+    <AssemblyName>DataSimulation.Dto</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+    </Reference>
+    <Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
+      <HintPath>..\packages\Serilog.3.1.1\lib\net471\Serilog.dll</HintPath>
+    </Reference>
+    <Reference Include="SQLite.CodeFirst, Version=1.7.0.36, Culture=neutral, PublicKeyToken=eb96ba0a78d831a7, processorArchitecture=MSIL">
+      <HintPath>..\packages\SQLite.CodeFirst.1.7.0.36\lib\net45\SQLite.CodeFirst.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
+    </Reference>
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Data.SQLite, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
+      <HintPath>..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\lib\net46\System.Data.SQLite.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Data.SQLite.EF6, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Data.SQLite.EF6.1.0.118.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Data.SQLite.Linq, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Data.SQLite.Linq.1.0.118.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Diagnostics.DiagnosticSource, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Numerics" />
+    <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="BaseModel.cs" />
+    <Compile Include="EFContext\SimulationContext.cs" />
+    <Compile Include="EFContext\SqliteInterceptor.cs" />
+    <Compile Include="Model\AntInfo.cs" />
+    <Compile Include="Model\ModelEnum.cs" />
+    <Compile Include="Model\RefInfo.cs" />
+    <Compile Include="Model\SatInfo.cs" />
+    <Compile Include="Model\SimulationInfo.cs" />
+    <Compile Include="Model\SysSetings.cs" />
+    <Compile Include="Model\TaskInfo.cs" />
+    <Compile Include="Model\XlInfo.cs" />
+    <Compile Include="PosData.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="XlCache.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
+    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
+    <Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
+  </Target>
+  <Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
+  <Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
+</Project>

+ 6 - 0
DataSimulation.Repostory/DataSimulation.Repostory.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ShowAllFiles</ProjectView>
+  </PropertyGroup>
+</Project>

+ 128 - 0
DataSimulation.Repostory/EFContext/SimulationContext.cs

@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SQLite.CodeFirst;
+using System.Data.Entity.ModelConfiguration.Conventions;
+using System.Data.Entity.Infrastructure.Interception;
+using DataSimulation.Repostory.Model;
+using System.IO;
+using System.Data.Common;
+using System.Data.Entity.Infrastructure;
+using System.Reflection;
+using System.Data.SQLite.EF6;
+using System.Data.SQLite;
+using System.Data.Entity.Core.Common;
+using System.Data.Entity.Core.EntityClient;
+using static System.Net.WebRequestMethods;
+using DataSimulation.Dto.Model;
+
+namespace DataSimulation.Repostory.EFContext
+{
+
+    /// <summary>
+    /// 基础表上下文(id为int)
+    /// </summary>
+    public class SimulationContext : DbContext
+    {
+        public SimulationContext() : base("DbCon") //配置使用的连接名
+        {
+
+        }
+
+        protected override void OnModelCreating(DbModelBuilder modelBuilder)
+        {
+            this.Database.Log = msg =>
+            {
+            };
+            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
+            modelBuilder.Configurations.AddFromAssembly(typeof(SimulationContext).Assembly);//自动加载SqliteConfiguration
+
+            var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists<SimulationContext>(modelBuilder);
+            Database.SetInitializer(sqliteConnectionInitializer);
+            DbInterception.Add(new SqliteInterceptor());//拦截器
+            base.OnModelCreating(modelBuilder);
+        }
+
+
+        public DbSet<SatInfo> SatInfos { get; set; }
+
+        public DbSet<AntInfo> AntInfos { get; set; }
+
+        public DbSet<RefInfo> RefInfos { get; set; }
+
+        public DbSet<XlInfo> XlInfos { get; set; }
+
+        public DbSet<SimulationInfo> SimulationInfos { get; set; }
+
+        public DbSet<TaskInfo> TaskInfos { set; get; }
+
+        public DbSet<SysSetings> SysSetings { get; set; }
+
+
+    }
+
+    /// <summary>
+    /// 分区表上下文(id为long)
+    /// </summary>
+    //[DbConfigurationType(typeof(SqliteConfiguration))]
+    public class SimulationPartContext : DbContext
+    {
+        public static SimulationPartContext GetContext(string dbFile)
+        {
+            var connectionString = $@"Data Source={dbFile}";
+            SQLiteConnection con = new SQLiteConnection(connectionString);
+            return new SimulationPartContext(con);
+        }
+
+        public static SimulationPartContext GetContext(DateTime partTime)
+        {
+            var connectionString = $@"Data Source=|DataDirectory|\DbPart\{partTime.Year}\{partTime:MMdd}.db";
+            SQLiteConnection con = new SQLiteConnection(connectionString);
+            return new SimulationPartContext(con);
+        }
+
+        private SimulationPartContext(DbConnection con)
+        : base(con, true)
+        {
+        }
+
+
+        protected override void OnModelCreating(DbModelBuilder modelBuilder)
+        {
+            this.Database.Log = msg =>
+            {
+            };
+
+            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
+            modelBuilder.Configurations.AddFromAssembly(typeof(SimulationPartContext).Assembly);
+
+            var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists<SimulationPartContext>(modelBuilder);
+            Database.SetInitializer(sqliteConnectionInitializer);
+            DbInterception.Add(new SqliteInterceptor());//拦截器
+            base.OnModelCreating(modelBuilder);
+        }
+        public DbSet<XlInfo> XlInfos { set; get; }
+        //public DbSet<StationRes> StationRes { get; set; }
+        //public DbSet<CxRes> CxRes { get; set; }
+        //public DbSet<CgRes> CgRes { get; set; }
+        //public DbSet<CgXgfRes> CgXgfRes { get; set; }
+
+        //public DbSet<PosRes> PosRes { get; set; }
+
+    }
+
+
+    public class SqliteConfiguration : DbConfiguration
+    {
+        public SqliteConfiguration()
+        {
+            SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance);
+            SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance);
+            SetProviderServices("System.Data.SQLite", (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)));
+
+        }
+    }
+}

+ 74 - 0
DataSimulation.Repostory/EFContext/SqliteInterceptor.cs

@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Common;
+using System.Data.Entity.Infrastructure.Interception;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Repostory.EFContext
+{
+    /// <summary>
+    /// Sqlite拦截器.
+    /// contains或indexOf成的CHARINDEX函数在sqlite里面并不支持,需要拦截转换成LIKE语句
+    /// </summary>
+    public class SqliteInterceptor : IDbCommandInterceptor
+    {
+        private static Regex replaceRegex = new Regex(@"\(CHARINDEX\((.*?),\s?(.*?)\)\)\s*?>\s*?0");
+
+        public void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
+        {
+        }
+
+        public void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
+        {
+        }
+
+        public void ReaderExecuted(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
+        {
+        }
+
+        public void ReaderExecuting(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
+        {
+            ReplaceCharIndexFunc(command);
+        }
+
+        public void ScalarExecuted(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
+        {
+        }
+
+        public void ScalarExecuting(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
+        {
+            ReplaceCharIndexFunc(command);
+        }
+
+        private void ReplaceCharIndexFunc(DbCommand command)
+        {
+            bool isMatch = false;
+            var text = replaceRegex.Replace(command.CommandText, (match) =>
+            {
+                if (match.Success)
+                {
+                    string paramsKey = match.Groups[1].Value;
+                    string paramsColumnName = match.Groups[2].Value;
+                    //replaceParams
+                    foreach (DbParameter param in command.Parameters)
+                    {
+                        if (param.ParameterName == paramsKey.Substring(1))
+                        {
+                            param.Value = string.Format("%{0}%", param.Value);
+                            break;
+                        }
+                    }
+                    isMatch = true;
+                    return string.Format("{0} LIKE {1}", paramsColumnName, paramsKey);
+                }
+                else
+                    return match.Value;
+            });
+            if (isMatch)
+                command.CommandText = text;
+        }
+    }
+}

+ 27 - 0
DataSimulation.Repostory/Model/AntInfo.cs

@@ -0,0 +1,27 @@
+using DataSimulation.Repostory;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Dto.Model
+{
+    /// <summary>
+    /// 天线信息
+    /// </summary>
+    [Table("AntInfo")]
+    public class AntInfo : BaseModel<long>
+    {
+        [Display(Name = "天线名称")]
+        public string AntName { get; set; }
+
+        [Display(Name = "天线经度")]
+        public double AntLon { get; set; }
+
+        [Display(Name = "天线纬度")]
+        public double AntLAlt { get; set; }
+    }
+}

+ 29 - 0
DataSimulation.Repostory/Model/ModelEnum.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Repostory.Model
+{
+    public enum EnumTaskState
+    {
+        [Display(Name = "未执行")]
+        Stopped,
+
+        [Display(Name = "执行中")]
+        Running
+    }
+    /// <summary>
+    /// 仿真类型
+    /// </summary>
+    public enum EnumSimulationType
+    {
+        [Display(Name = "三星双时差")]
+        X3TwoDto
+
+    }
+
+}

+ 24 - 0
DataSimulation.Repostory/Model/RefInfo.cs

@@ -0,0 +1,24 @@
+using DataSimulation.Repostory;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Dto.Model
+{
+    [Table("RefInfo")]
+    public class RefInfo : BaseModel<long>
+    {
+        [Display(Name = "参考站名称")]
+        public string RefName { get; set; }
+
+        [Display(Name = "参考站经度")]
+        public double RefLon { get; set; }
+
+        [Display(Name = "参考站纬度")]
+        public double RefAlt { get; set; }
+    }
+}

+ 35 - 0
DataSimulation.Repostory/Model/SatInfo.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Repostory.Model
+{
+    [Table("SatInfo")]
+    public class SatInfo : BaseModel<long>
+    {
+        [Display(Name = "卫星编号")]
+        public int SatCode { get; set; }
+
+        [Display(Name = "卫星名称")]
+        public string SatName { get; set; }
+
+        [Display(Name = "轨道经度")]
+        public double? SatLon { get; set; }
+
+        [Display(Name = "卫星")]
+        public string Sat
+        {
+            get
+            {
+                if (SatLon == null)
+                    return $"{SatName}({SatCode})";
+                else
+                    return $"[{SatLon}°]{SatName}({SatCode})";
+            }
+        }
+    }
+}

+ 24 - 0
DataSimulation.Repostory/Model/SimulationInfo.cs

@@ -0,0 +1,24 @@
+using DataSimulation.Repostory;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Dto.Model
+{
+    /// <summary>
+    /// 仿真航迹数据信息
+    /// </summary>
+    [Table("SimulationInfo")]
+    public class SimulationInfo : BaseModel<long>
+    {
+        [Display(Name = "仿真经度")]
+        public double SimulationLon { get; set; }
+
+        [Display(Name = "仿真纬度")]
+        public double SimulationAlt { get; set; }
+    }
+}

+ 18 - 0
DataSimulation.Repostory/Model/SysSetings.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Repostory.Model
+{
+    [Table("SysSetings")]
+    public class SysSetings : BaseModel
+    {
+        public int HttpPort { get; set; }
+        public string XLDirectory { get; set; }
+        public string MapService { get; set; }
+    }
+}

+ 57 - 0
DataSimulation.Repostory/Model/TaskInfo.cs

@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Runtime.Remoting.Metadata.W3cXsd2001;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Repostory.Model
+{
+
+    [Table("TaskInfo")]   // 标识数据库创建的表名
+    public class TaskInfo : BaseModel<long>
+    {
+        [Display(Name = "任务状态", AutoGenerateField = false)]
+        public EnumTaskState TaskState { get; set; } = EnumTaskState.Stopped;
+
+        [Required]
+        [Display(Name = "任务名称")]
+        public string TaskName { get; set; }
+
+        [Display(Name = "仿真类型")]
+        public EnumSimulationType SimulationType { get; set; }
+
+        [Display(Name = "仿真时间")]
+        public DateTime SimulationTime { get; set; }
+
+        [Display(Name = "主星", AutoGenerateField = false)]
+        public int MainSat { get; set; }
+
+        [Display(Name = "邻星1", AutoGenerateField = false)]
+        public int? Adja1Sat { get; set; }
+
+        [Display(Name = "邻星2", AutoGenerateField = false)]
+        public int? Adja2Sat { get; set; }
+
+        [Display(Name = "天线编号", AutoGenerateField = false)]
+        public long AntID { get; set; }
+
+        [Display(Name = "参考站编号", AutoGenerateField = false)]
+        public long RefID { get; set; }
+
+        [Display(Name = "仿真编号", AutoGenerateField = false)]
+        public long SimulationID { get; set; }
+
+        [Display(Name = "上行频点(Hz)")]
+        public long Freq { get; set; }
+
+        [Display(Name = "信号带宽(Hz)")]
+        public long Band { get; set; }
+
+        [Display(Name = "速度(m/s)")]
+        public long Speed { get; set; }
+
+    }
+}

+ 36 - 0
DataSimulation.Repostory/Model/XlInfo.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Repostory.Model
+{
+    [Table("XlInfo")]
+    public class XlInfo : BaseModel<long>
+    {
+        [Display(Name = "卫星编号",AutoGenerateField = false)]
+        public int SatCode { get; set; }
+        [Display(Name = "卫星名称",AutoGenerateField = false)]
+
+        public string SatName { get; set; }
+
+        [Display(Name = "卫星")]
+        public string Sat => $"{SatName}({SatCode})";
+
+        [Display(Name = "发布时间(北京)")]
+        public DateTime TimeBJ { get; set; }
+
+        [Display(Name = "双行根数1")]
+        public string Line1 { get; set; }
+
+        [Display(Name = "双行根数2")]
+        public string Line2 { get; set; }
+        [Display(AutoGenerateField = false)]
+
+        public string TwoLine => $"{Line1};{Line2}";
+
+    }
+}

+ 172 - 0
DataSimulation.Repostory/PosData.cs

@@ -0,0 +1,172 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Repostory
+{
+    /// <summary>
+    /// 指示某个属性需要导出
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
+    public class ExportCellAttribute : Attribute
+    {
+        /// <summary>
+        /// 指示某个属性需要导出
+        /// </summary>
+        public ExportCellAttribute()
+        {
+        }
+
+        /// <summary>
+        /// 指示某个属性需要导出
+        /// </summary>
+        /// <param name="format">浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串</param>
+        public ExportCellAttribute(string format)
+        {
+            this.Format = format;
+        }
+        /// <summary>
+        /// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
+        /// </summary>
+        public string Format { get; set; }
+
+        /// <summary>
+        /// 列的排列顺序,未指定的ColumnIndex的按照属性顺序排在之后
+        /// </summary>
+        public int ColumnIndex { get; set; } = -1;
+
+    }
+
+
+    /// <summary>
+    /// 指示某个属性在ToolTip中显示
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
+    public class ToolTipAttribute : Attribute
+    {
+        /// <summary>
+        /// 指示某个属性在ToolTip中显示
+        /// </summary>
+        public ToolTipAttribute()
+        {
+        }
+
+        /// <summary>
+        /// 指示某个属性在ToolTip中显示
+        /// </summary>
+        /// <param name="format">浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串</param>
+        public ToolTipAttribute(string format)
+        {
+            this.Format = format;
+        }
+        /// <summary>
+        /// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
+        /// </summary>
+        public string Format { get; set; }
+
+        /// <summary>
+        /// ToolTip从上到下的排列顺序,未指定的Index将按照属性顺序排在之后
+        /// </summary>
+        public int Index { get; set; } = 10000;
+    }
+
+    /// <summary>
+    /// 定位点绑定到地图的对象
+    /// </summary>
+    public class PosData : BaseModel<long>
+    {
+        /// <summary>
+        /// 信号时刻
+        /// </summary>
+        [Display(Name = "信号时刻")]
+        [DisplayFormat(DataFormatString = "yyyy-MM-dd HH:mm:ss.fff")]
+        [ExportCell(ColumnIndex = 0)]//如果导出了SigTime,则内部会自动按照SigTime降序排列后再导出
+        [ToolTip(Index = 0)]
+        public DateTime SigTime { get; set; }
+
+        /// <summary>
+        /// 定位经度
+        /// </summary>
+        [Display(Name = "定位经度", AutoGenerateField = false)]
+        [ExportCell("f4")]
+        [ToolTip("f4")]
+        public double PosLon { get; set; }
+
+        /// <summary>
+        /// 定位纬度
+        /// </summary>
+        [Display(Name = "定位纬度", AutoGenerateField = false)]
+        [ExportCell("f4")]
+        [ToolTip("f4")]
+        public double PosLat { get; set; }
+
+
+        /// <summary>
+        /// 定位经度
+        /// </summary>
+        [Display(Name = "镜像经度", AutoGenerateField = false)]
+        [ExportCell("f4")]
+        [ToolTip("f4")]
+        public double MirrLon { get; set; }
+
+        /// <summary>
+        /// 定位纬度
+        /// </summary>
+        [Display(Name = "镜像纬度", AutoGenerateField = false)]
+        [ExportCell("f4")]
+        [ToolTip("f4")]
+        public double MirrLat { get; set; }
+
+        /// <summary>
+        /// 当前点是否被选中(默认false)
+        /// </summary>
+        [Display(Name = "是否选中", AutoGenerateField = false)]
+        [NotMapped]
+        public bool Selected { get; set; }
+
+        /// <summary>
+        /// 当前点是否可见(默认true)
+        /// </summary>
+        [Display(Name = "是否可见", AutoGenerateField = false)]
+        [NotMapped]
+        public bool Visible { get; set; } = true;
+
+        /// <summary>
+        /// 用于生成颜色的一个key,相同的key具有相同的颜色,当ColorKey为html颜色时则使用此颜色(如#A1B2FF),默认红色#CC3333
+        /// </summary>、
+        [Display(Name = "颜色标记", AutoGenerateField = false)]
+        [NotMapped]
+        public string ColorKey { get; set; } = "#CC3333";
+
+        /// <summary>
+        /// 判断定位点是否在一个框选的矩形区域内
+        /// </summary>
+        /// <param name="startLon"></param>
+        /// <param name="startLat"></param>
+        /// <param name="endLon"></param>
+        /// <param name="endLat"></param>
+        /// <returns></returns>
+        public bool InRectangle(double startLon, double startLat, double endLon, double endLat)
+        {
+            return PosLon >= startLon && PosLon <= endLon && PosLat >= startLat && PosLat <= endLat;
+        }
+
+        /// <summary>
+        /// 内部调用的属性
+        /// </summary>
+        [Display(AutoGenerateField = false)]
+        [NotMapped]
+        public int ClusterCount { get; set; } = 1;
+
+        /// <summary>
+        /// 内部调用的属性
+        /// </summary>
+        [Display(AutoGenerateField = false)]
+        [NotMapped]
+        public int ClusterKey { get; set; } = int.MinValue;
+    }
+}

+ 36 - 0
DataSimulation.Repostory/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("DataSimulation.Dto")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("DataSimulation.Dto")]
+[assembly: AssemblyCopyright("Copyright ©  2024")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("61d871de-8837-49a9-b141-c03a690a53af")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 77 - 0
DataSimulation.Repostory/XlCache.cs

@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DataSimulation.Repostory.EFContext;
+using DataSimulation.Repostory.Model;
+
+namespace DataSimulation.Repostory
+{
+    public static class XlCache
+    {
+        /// <summary>
+        /// 获取数据库所有双行根数
+        /// </summary>
+        /// <param name="maxCount">最大条数.超过此条数时不再继续查询,为0则不限制条数</param>
+        /// <returns></returns>
+        public static async Task<List<XlInfo>> GetAllAsync(int maxCount = 2000)
+        {
+            try
+            {
+                List<XlInfo> list = new List<XlInfo>();
+                var dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DbPart");
+                if (!Directory.Exists(dir)) return list;
+                var yearDirs = Directory.EnumerateDirectories(dir).OrderByDescending(p => Convert.ToInt32(new DirectoryInfo(p).Name));//年目录,倒叙排列
+                foreach (var yearDir in yearDirs)
+                {
+                    //每一天的db文件,倒序排列
+                    var dayFiles = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, yearDir), "*.db").OrderByDescending(p => Convert.ToInt32(new DirectoryInfo(p).Name.Substring(0, 4)));
+                    foreach (var dayFile in dayFiles)
+                    {
+                        using (SimulationPartContext db = SimulationPartContext.GetContext(dayFile))
+                        {
+                            list.AddRange(await db.XlInfos.ToListAsync());
+                            if (maxCount > 0 && list.Count >= maxCount)
+                                return list;
+                        }
+                    }
+                }
+                return list;
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, "加载星历信息异常");
+                return null;
+            }
+        }
+
+
+        /// <summary>
+        /// 获取某个星某个时刻最近的双行根(可能返回null)
+        /// </summary>
+        /// <param name="satCode">卫星编号</param>
+        /// <param name="timeBj">时刻</param>
+        /// <returns></returns>
+        public static async Task<XlInfo> GetLatestAsync(int satCode, DateTime timeBj)
+        {
+            try
+            {
+
+                var list = await GetAllAsync(0);
+                if (!list.Any()) return null;
+                var mainXl = list.Where(w => w.SatCode == satCode);
+                var minSec = mainXl.Min(p => Math.Abs((p.TimeBJ - timeBj).TotalSeconds));
+                var find = mainXl.FirstOrDefault(p => Math.Abs((p.TimeBJ - timeBj).TotalSeconds) == minSec);
+                return find;
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, $"获取卫星[{satCode}]--{timeBj:yyyyMMddHHmmss}时刻附近的双行根数出错!");
+                return null;
+            }
+        }
+    }
+}

+ 16 - 0
DataSimulation.Repostory/packages.config

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="EntityFramework" version="6.4.4" targetFramework="net472" />
+  <package id="Serilog" version="3.1.1" targetFramework="net472" />
+  <package id="SQLite.CodeFirst" version="1.7.0.36" targetFramework="net472" />
+  <package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.118.0" targetFramework="net472" />
+  <package id="System.Buffers" version="4.5.1" targetFramework="net472" />
+  <package id="System.Data.SQLite" version="1.0.118.0" targetFramework="net472" />
+  <package id="System.Data.SQLite.Core" version="1.0.118.0" targetFramework="net472" />
+  <package id="System.Data.SQLite.EF6" version="1.0.118.0" targetFramework="net472" />
+  <package id="System.Data.SQLite.Linq" version="1.0.118.0" targetFramework="net472" />
+  <package id="System.Diagnostics.DiagnosticSource" version="7.0.2" targetFramework="net472" />
+  <package id="System.Memory" version="4.5.5" targetFramework="net472" />
+  <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
+  <package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
+</packages>