zoulei 10 miesięcy temu
rodzic
commit
840e0d1e1d

+ 137 - 121
XdCxRhDW.App/Controllers/PosController.cs

@@ -17,6 +17,7 @@ using DPP_YH_Core.Extensions;
 using XdCxRhDW.App.Model;
 using System.Diagnostics;
 using System.Configuration;
+using System.Data.Entity.Infrastructure;
 
 namespace XdCxRhDW.App.Controllers
 {
@@ -637,142 +638,157 @@ namespace XdCxRhDW.App.Controllers
         [HttpPost]
         public async Task<AjaxResult<PosResDto>> PosX2D1NoXlNoParAsync(X2D1NoXlNoParlPosDto dto)
         {
-            TaskInfo runTask;
-            using (RHDWContext db = new RHDWContext())
+            try
             {
-                if (dto.TaskID == null)
+                TaskInfo runTask;
+                using (RHDWContext db = new RHDWContext())
                 {
-                    runTask = await db.TaskInfos.FirstOrDefaultAsync(p => p.TaskType == EnumTaskType.Group
-                    && p.PosType == EnumPosType.X2D1 && p.TaskState == EnumTaskState.Running);
-                    if (runTask == null)
+                    if (dto.TaskID == null)
                     {
-                        Serilog.Log.Warning($"接收到两星一地无参定位(无星历)参数,由于找不到执行中的任务忽略本次定位");
-                        return Error<PosResDto>($"多模式融合定位平台没有启动两星一地定位任务");
+                        runTask = await db.TaskInfos.FirstOrDefaultAsync(p => p.TaskType == EnumTaskType.Group
+                        && p.PosType == EnumPosType.X2D1 && p.TaskState == EnumTaskState.Running);
+                        if (runTask == null)
+                        {
+                            Serilog.Log.Warning($"接收到两星一地无参定位(无星历)参数,由于找不到执行中的任务忽略本次定位");
+                            return Error<PosResDto>($"多模式融合定位平台没有启动两星一地定位任务");
+                        }
                     }
-                }
-                else
-                {
-                    runTask = await db.TaskInfos.FirstOrDefaultAsync(p => p.ID == dto.TaskID);
-                    if (runTask == null)
+                    else
                     {
-                        Serilog.Log.Warning($"找不到任务,ID={dto.TaskID}");
-                        return Error<PosResDto>($"找不到ID={dto.TaskID}的任务");
+                        runTask = await db.TaskInfos.FirstOrDefaultAsync(p => p.ID == dto.TaskID);
+                        if (runTask == null)
+                        {
+                            Serilog.Log.Warning($"找不到任务,ID={dto.TaskID}");
+                            return Error<PosResDto>($"找不到ID={dto.TaskID}的任务");
+                        }
                     }
                 }
-            }
-            var xl1 = await XlRepository.GetLatestAsync(dto.MainCode, dto.SigTime);
-            if (xl1 == null)
-            {
-                Serilog.Log.Error($"系统缺少编号{dto.MainCode}卫星的星历!");
-                return Error<PosResDto>($"系统缺少编号{dto.MainCode}卫星的星历!");
-            }
-            Serilog.Log.Information($"卫星{dto.MainCode}使用发布时刻为{xl1.TimeUTC:yyyyMMddHHmmss}的星历进行推算");
-            var xl2 = await XlRepository.GetLatestAsync(dto.AdjaCode, dto.SigTime);
-            if (xl2 == null)
-            {
-                Serilog.Log.Error($"系统缺少编号{dto.AdjaCode}卫星的星历!");
-                return Error<PosResDto>($"系统缺少编号{dto.AdjaCode}卫星的星历!");
-            }
-            Serilog.Log.Information($"卫星{dto.AdjaCode}使用发布时刻为{xl2.TimeUTC:yyyyMMddHHmmss}的星历进行推算");
-            var XlCalcDto = new XlCalcDto() { tleStr = xl1.TwoLine, SigTime = dto.SigTime };
-            var ephMain = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
-            if (ephMain.code != 200)
-            {
-                Serilog.Log.Error($"推算卫星{dto.MainCode}的ECEF星历出错.{ephMain.msg}");
-                return Error<PosResDto>($"推算卫星{dto.MainCode}的ECEF星历出错");
-            }
-            var XlCalcDto2 = new XlCalcDto() { tleStr = xl2.TwoLine, SigTime = dto.SigTime };
-            var ephAdja = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto2);
-            if (ephAdja.code != 200)
-            {
-                Serilog.Log.Error($"推算卫星{dto.AdjaCode}的ECEF星历出错.{ephAdja.msg}");
-                return Error<PosResDto>($"推算卫星{dto.AdjaCode}的ECEF星历出错");
-            }
-            using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
-            {
-                var StationRes = db.StationRes.Add(new StationRes()
+                var xl1 = await XlRepository.GetLatestAsync(dto.MainCode, dto.SigTime);
+                if (xl1 == null)
                 {
-                    SatTxLon = dto.SatTxLon,
-                    SatTxLat = dto.SatTxLat,
-                    CdbTxLon = dto.CdbTxLon,
-                    CdbTxLat = dto.CdbTxLat,
-                });
-
-                var ckRes = new CheckRes()
+                    Serilog.Log.Error($"系统缺少编号{dto.MainCode}卫星的星历!");
+                    return Error<PosResDto>($"系统缺少编号{dto.MainCode}卫星的星历!");
+                }
+                Serilog.Log.Information($"卫星{dto.MainCode}使用发布时刻为{xl1.TimeUTC:yyyyMMddHHmmss}的星历进行推算");
+                var xl2 = await XlRepository.GetLatestAsync(dto.AdjaCode, dto.SigTime);
+                if (xl2 == null)
                 {
-                    FileName = dto.CheckRes?.FileName,
-                    SmpStart = dto.CheckRes?.SmpStart,
-                    SmpCount = dto.CheckRes?.SmpCount,
-                    PosCheckType = (EnumPosCheckType?)dto.CheckRes?.PosCheckType,
-                    ModRate = dto.CheckRes?.ModRate,
-                    ModType = dto.CheckRes?.ModType,
-                    UserName = dto.CheckRes?.UserName,
-                    FfcHz = dto.CheckRes?.FfcHz,
-                    Snr = dto.CheckRes?.Snr
-                };
-                db.CheckRes.Add(ckRes);
-
-                var cgRes = db.CgRes.Add(new CgRes()
+                    Serilog.Log.Error($"系统缺少编号{dto.AdjaCode}卫星的星历!");
+                    return Error<PosResDto>($"系统缺少编号{dto.AdjaCode}卫星的星历!");
+                }
+                Serilog.Log.Information($"卫星{dto.AdjaCode}使用发布时刻为{xl2.TimeUTC:yyyyMMddHHmmss}的星历进行推算");
+                var XlCalcDto = new XlCalcDto() { tleStr = xl1.TwoLine, SigTime = dto.SigTime };
+                var ephMain = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
+                if (ephMain.code != 200)
                 {
-                    SigTime = dto.SigTime,
-                    Dto1 = Math.Round(dto.SxDto, 10),
-                    Dfo1 = Math.Round(dto.SxDfo, 10),
-                    Snr1 = Math.Round(dto.SxSnr, 1),
-                    DtoCdb = Math.Round(dto.XdDto, 10),
-                    DfoCdb = Math.Round(dto.XdDfo, 10),
-                    SnrCdb = Math.Round(dto.XdSnr, 1),
-                    StationResID = StationRes.ID,
-                    MainCode = dto.MainCode,
-                    Adja1Code = dto.AdjaCode,
-                    MainXlTime = ephMain.data.TleTime,
-                    Adja1XlTime = ephAdja.data.TleTime,
-                    TaskID = runTask.ID,
-                    MainX = ephMain.data.X,
-                    MainY = ephMain.data.Y,
-                    MainZ = ephMain.data.Z,
-                    Adja1X = ephAdja.data.X,
-                    Adja1Y = ephAdja.data.Y,
-                    Adja1Z = ephAdja.data.Z,
-                    MainVx = ephMain.data.VX,
-                    MainVy = ephMain.data.VY,
-                    MainVz = ephMain.data.VZ,
-                    Adja1Vx = ephAdja.data.VX,
-                    Adja1Vy = ephAdja.data.VY,
-                    Adja1Vz = ephAdja.data.VZ,
-                    TarFreqUp = dto.FreqUp,
-                    TarFreqDown = dto.FreqDown,
-                });
-                double[] res;
-                if (ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"] != null
-             && ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"].ToLower() != "false"
-             && ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"].ToLower() != "0")
+                    Serilog.Log.Error($"推算卫星{dto.MainCode}的ECEF星历出错.{ephMain.msg}");
+                    return Error<PosResDto>($"推算卫星{dto.MainCode}的ECEF星历出错");
+                }
+                var XlCalcDto2 = new XlCalcDto() { tleStr = xl2.TwoLine, SigTime = dto.SigTime };
+                var ephAdja = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto2);
+                if (ephAdja.code != 200)
                 {
-                    res = PosApi.X2D1_PosNoRef_ZL(cgRes, StationRes);
+                    Serilog.Log.Error($"推算卫星{dto.AdjaCode}的ECEF星历出错.{ephAdja.msg}");
+                    return Error<PosResDto>($"推算卫星{dto.AdjaCode}的ECEF星历出错");
                 }
-                else
+                using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
                 {
-                    res = PosApi.X2D1_PosNoRef(cgRes, StationRes, dto.CalcConfidence);
+                    var StationRes = db.StationRes.Add(new StationRes()
+                    {
+                        SatTxLon = dto.SatTxLon,
+                        SatTxLat = dto.SatTxLat,
+                        CdbTxLon = dto.CdbTxLon,
+                        CdbTxLat = dto.CdbTxLat,
+                    });
+
+                    var ckRes = new CheckRes()
+                    {
+                        FileName = dto.CheckRes?.FileName,
+                        SmpStart = dto.CheckRes?.SmpStart,
+                        SmpCount = dto.CheckRes?.SmpCount,
+                        PosCheckType = (EnumPosCheckType?)dto.CheckRes?.PosCheckType,
+                        ModRate = dto.CheckRes?.ModRate,
+                        ModType = dto.CheckRes?.ModType,
+                        UserName = dto.CheckRes?.UserName,
+                        FfcHz = dto.CheckRes?.FfcHz,
+                        Snr = dto.CheckRes?.Snr
+                    };
+                    db.CheckRes.Add(ckRes);
+
+                    var cgRes = db.CgRes.Add(new CgRes()
+                    {
+                        SigTime = dto.SigTime,
+                        Dto1 = Math.Round(dto.SxDto, 10),
+                        Dfo1 = Math.Round(dto.SxDfo, 10),
+                        Snr1 = Math.Round(dto.SxSnr, 1),
+                        DtoCdb = Math.Round(dto.XdDto, 10),
+                        DfoCdb = Math.Round(dto.XdDfo, 10),
+                        SnrCdb = Math.Round(dto.XdSnr, 1),
+                        StationResID = StationRes.ID,
+                        MainCode = dto.MainCode,
+                        Adja1Code = dto.AdjaCode,
+                        MainXlTime = ephMain.data.TleTime,
+                        Adja1XlTime = ephAdja.data.TleTime,
+                        TaskID = runTask.ID,
+                        MainX = ephMain.data.X,
+                        MainY = ephMain.data.Y,
+                        MainZ = ephMain.data.Z,
+                        Adja1X = ephAdja.data.X,
+                        Adja1Y = ephAdja.data.Y,
+                        Adja1Z = ephAdja.data.Z,
+                        MainVx = ephMain.data.VX,
+                        MainVy = ephMain.data.VY,
+                        MainVz = ephMain.data.VZ,
+                        Adja1Vx = ephAdja.data.VX,
+                        Adja1Vy = ephAdja.data.VY,
+                        Adja1Vz = ephAdja.data.VZ,
+                        TarFreqUp = dto.FreqUp,
+                        TarFreqDown = dto.FreqDown,
+                    });
+                    double[] res;
+                    if (ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"] != null
+                 && ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"].ToLower() != "false"
+                 && ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"].ToLower() != "0")
+                    {
+                        res = PosApi.X2D1_PosNoRef_ZL(cgRes, StationRes);
+                    }
+                    else
+                    {
+                        res = PosApi.X2D1_PosNoRef(cgRes, StationRes, dto.CalcConfidence);
+                    }
+                    PosRes posRes = new PosRes()
+                    {
+                        FreqUpHz = (long)cgRes.TarFreqUp.Value,
+                        SigTime = dto.SigTime,
+                        TaskInfoID = runTask.ID,
+                        CgResID = cgRes.ID,
+                        CheckResID = ckRes.ID,
+                        PosLon = res[0],
+                        PosLat = res[1],
+                        MirrLon = res[3],
+                        MirrLat = res[4],
+                        Confidence = (int)res[6],
+                        PosResType = EnumPosResType.X2D1NoRef,
+                    };
+                    if (dto.TheoryDfoCalc && posRes.PosLon != 999)
+                        posRes.TargetState = TheoryDtoDfoApi.TheoryDfo(cgRes, StationRes, posRes, SysConfig.Config.YDPZThreshold);
+                    posRes = db.PosRes.Add(posRes);
+                    await db.SaveChangesAsync();
+                    Messenger.Defalut.Pub("新增定位点", MapModel(posRes));
+                    return Success(MapDto(posRes));
                 }
-                PosRes posRes = new PosRes()
+            }
+            catch (DbUpdateException ex)
+            {
+                string errMsg;
+                using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
                 {
-                    FreqUpHz = (long)cgRes.TarFreqUp.Value,
-                    SigTime = dto.SigTime,
-                    TaskInfoID = runTask.ID,
-                    CgResID = cgRes.ID,
-                    CheckResID = ckRes.ID,
-                    PosLon = res[0],
-                    PosLat = res[1],
-                    MirrLon = res[3],
-                    MirrLat = res[4],
-                    Confidence = (int)res[6],
-                    PosResType = EnumPosResType.X2D1NoRef,
-                };
-                if (dto.TheoryDfoCalc && posRes.PosLon != 999)
-                    posRes.TargetState = TheoryDtoDfoApi.TheoryDfo(cgRes, StationRes, posRes, SysConfig.Config.YDPZThreshold);
-                posRes = db.PosRes.Add(posRes);
-                await db.SaveChangesAsync();
-                Messenger.Defalut.Pub("新增定位点", MapModel(posRes));
-                return Success(MapDto(posRes));
+                     errMsg = db.CheckTableField();
+                }
+                if (!string.IsNullOrWhiteSpace(errMsg))
+                    throw new Exception(errMsg);
+                else
+                    throw;
             }
         }
         #endregion

+ 9 - 17
XdCxRhDW.App/MainForm.cs

@@ -34,6 +34,7 @@ using XdCxRhDW.WebApi;
 using XdCxRhDW.DataEmulation;
 using DxHelper;
 using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.ComTypes;
 
 namespace XdCxRhDW
 {
@@ -141,32 +142,23 @@ namespace XdCxRhDW
             {
                 if (File.Exists(db.DbFile))
                 {
-                    try
+                    FileInfo fInfo = new FileInfo(db.DbFile);
+                    if (fInfo.IsReadOnly)
                     {
-                        using (FileStream fs = new FileStream(db.DbFile, FileMode.Open))
-                        {
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        return $"数据库文件[{db.DbFile}]可能无法写入,请修改其只读属性";
+                        fInfo.IsReadOnly = false;
                     }
+
                 }
-               
+
             }
             using (RHDWLogContext db = new RHDWLogContext())
             {
                 if (File.Exists(db.DbFile))
                 {
-                    try
-                    {
-                        using (FileStream fs = new FileStream(db.DbFile, FileMode.Open))
-                        {
-                        }
-                    }
-                    catch (Exception ex)
+                    FileInfo fInfo = new FileInfo(db.DbFile);
+                    if (fInfo.IsReadOnly)
                     {
-                        return $"数据库文件[{db.DbFile}]可能无法写入,请修改其只读属性";
+                        fInfo.IsReadOnly = false;
                     }
                 }
             }

+ 7 - 2
XdCxRhDW.App/Program.cs

@@ -46,12 +46,17 @@ namespace XdCxRhDW
 
             AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
             {
-                var args = e.ExceptionObject as Exception;
-                Serilog.Log.Error(args, "出现未处理的异常,程序即将退出!");
+                var ex = e.ExceptionObject as Exception;
+                while (ex.InnerException != null)
+                    ex = ex.InnerException;
+                Serilog.Log.Error(ex, "出现未处理的异常,程序即将退出!");
                 DxHelper.MsgBoxHelper.ShowError("出现未处理的异常,程序即将退出!");
             };
             Application.ThreadException += (sender, e) =>
             {
+                var ex = e.Exception;
+                while (ex.InnerException != null)
+                    ex = ex.InnerException;
                 DxHelper.MsgBoxHelper.ShowError($"出现未处理的线程异常!{e.Exception.Message}");
                 Serilog.Log.Error(e.Exception, "出现未处理的线程异常");
             };

+ 5 - 4
XdCxRhDW.Entity/CgRes.cs

@@ -41,7 +41,8 @@ namespace XdCxRhDW.Entity
         /// <summary>
         /// 固定站ID
         /// </summary>
-        public int? FixedStationResID { get; set; }
+        [Display(Name = "固定站ID")]
+        public int? FixedStationID { get; set; }
 
         /// <summary>
         /// 固定站
@@ -270,7 +271,7 @@ namespace XdCxRhDW.Entity
         /// </summary>
         [Display(Name = "邻星1坐标Z")]
         public double? Adja1Z { get; set; }
-
+        
         /// <summary>
         /// 邻星1速度Vx(m/s)
         /// </summary>
@@ -371,8 +372,8 @@ namespace XdCxRhDW.Entity
                 SnrCdb = SnrCdb,
                 StationRes = StationRes,
                 StationResID = StationResID,
-                FixedStation=FixedStation,
-                FixedStationResID=FixedStationResID,
+                //FixedStation=FixedStation,
+                FixedStationID=FixedStationID,
                 TarFreqDown = TarFreqDown,
                 TarFreqUp = TarFreqUp,
                 TaskID = TaskID,

+ 89 - 19
XdCxRhDW.Repostory/EFContext/RHDWContext.cs

@@ -20,6 +20,20 @@ using XdCxRhDW.Entity;
 
 namespace XdCxRhDW.Repostory
 {
+    class DbTableColumnInfo
+    {
+        public string name { get; set; }
+
+        public string type { get; set; }
+
+        public int notnull { get; set; }
+
+        public int pk { get; set; }
+    }
+    class DbTableForeignKeyInfo
+    {
+        public string from { get; set; }
+    }
     public class RHDWLogContext : DbContext
     {
         public string DbFile;
@@ -48,27 +62,11 @@ namespace XdCxRhDW.Repostory
     /// </summary>
     public class RHDWContext : DbContext
     {
-        private class DbTableColumnInfo
-        {
-            public string name { get; set; }
-
-            public string type { get; set; }
-
-            public int notnull { get; set; }
-
-            public int pk { get; set; }
-        }
-        private class DbTableForeignKeyInfo
-        {
-            public string from { get; set; }
-        }
-
         public string DbFile;
         public RHDWContext() : base("DbCon") //配置使用的连接名
         {
             //|DataDirectory|在mvc等程序中代表了App_Data,在普通程序中代表程序根目录
-            var dbFile = Database.Connection.ConnectionString.Replace("Data Source=","").Replace("|DataDirectory|\\", "");
-            this.DbFile = dbFile;
+            this.DbFile = Database.Connection.ConnectionString.Replace("Data Source=", "").Replace("|DataDirectory|\\", "");
         }
 
         public Task<List<T>> SqlQueryAsync<T>(string sql)
@@ -159,7 +157,7 @@ namespace XdCxRhDW.Repostory
                         {
                             typeStr = "datetime";
                         }
-                        return $"Database.db数据库表{table}缺少{prop.Name}字段,类型={typeStr}";
+                        return $"{DbFile}数据库表{table}缺少{prop.Name}字段,类型={typeStr}";
                     }
                     else
                     {
@@ -169,7 +167,7 @@ namespace XdCxRhDW.Repostory
                             var foreignInfo = this.Database.SqlQuery<DbTableForeignKeyInfo>($"PRAGMA foreign_key_list({table})").ToList();
                             if (!foreignInfo.Any(p => p.from == prop.Name))
                             {
-                                return $"Database.db数据库表{table}中{prop.Name}字段不允许为空";
+                                return $"{DbFile}数据库表{table}中{prop.Name}字段不允许为空";
                             }
                         }
                     }
@@ -215,6 +213,7 @@ namespace XdCxRhDW.Repostory
     /// </summary>
     public class RHDWPartContext : DbContext
     {
+        private string DbFile;
         public static RHDWPartContext GetContext(string dbFile, bool createDb = false)
         {
             if (!File.Exists(dbFile) && !createDb)
@@ -240,6 +239,77 @@ namespace XdCxRhDW.Repostory
         private RHDWPartContext(DbConnection con)
         : base(con, true)
         {
+            var dbFile = Database.Connection.ConnectionString.Replace("Data Source=", "").Replace("|DataDirectory|\\", "");
+            this.DbFile = dbFile;
+        }
+
+        public string CheckTableField()
+        {
+            var tables = this.Database.SqlQuery<string>("select name from sqlite_master where type='table' and  name not like 'sqlite%'").ToList();
+            var props = this.GetType().GetProperties();
+            List<Type> entityTypes = new List<Type>();
+            foreach (var prop in props)
+            {
+                bool isDbSet = prop.PropertyType.IsGenericType && typeof(DbSet<>) == prop.PropertyType.GetGenericTypeDefinition();
+                if (isDbSet)
+                {
+                    var entityType = prop.PropertyType.GenericTypeArguments[0];
+                    entityTypes.Add(entityType);
+                }
+            }
+            foreach (var table in tables)
+            {
+                var res = this.Database.SqlQuery<DbTableColumnInfo>($"PRAGMA table_info([{table}])").ToList();
+                var entityType = entityTypes.First(p => p.Name == table);
+                var entityProps = entityType.GetProperties().Where(p =>
+                    p.CanRead
+                    && p.CanWrite
+                    && !p.GetMethod.IsVirtual
+                    && p.GetCustomAttribute<NotMappedAttribute>() == null);
+                foreach (var prop in entityProps)
+                {
+                    var find = res.Find(p => p.name == prop.Name);
+                    if (find == null)
+                    {
+                        string typeStr = "";
+                        var type = prop.PropertyType;
+                        if (prop.PropertyType.IsGenericType)
+                        {
+                            type = prop.PropertyType.GenericTypeArguments[0];
+                        }
+                        if (type == typeof(string))
+                        {
+                            typeStr = "nvarchar";
+                        }
+                        else if (type == typeof(int) || type == typeof(long))
+                        {
+                            typeStr = "int";
+                        }
+                        else if (type == typeof(double) || type == typeof(float))
+                        {
+                            typeStr = "float";
+                        }
+                        else if (type == typeof(DateTime))
+                        {
+                            typeStr = "datetime";
+                        }
+                        return $"{DbFile}数据库表{table}缺少{prop.Name}字段,类型={typeStr}";
+                    }
+                    else
+                    {
+
+                        if (prop.PropertyType != typeof(string) && find.pk == 0 && !prop.PropertyType.IsGenericType && find.notnull == 0)
+                        {
+                            var foreignInfo = this.Database.SqlQuery<DbTableForeignKeyInfo>($"PRAGMA foreign_key_list({table})").ToList();
+                            if (!foreignInfo.Any(p => p.from == prop.Name))
+                            {
+                                return $"{DbFile}数据库表{table}中{prop.Name}字段不允许为空";
+                            }
+                        }
+                    }
+                }
+            }
+            return "";
         }
         protected override void OnModelCreating(DbModelBuilder modelBuilder)
         {

+ 4 - 3
XdCxRhDW.Repostory/XlRepository.cs

@@ -41,18 +41,19 @@ namespace XdCxRhDW.Repostory
         /// <returns></returns>
         public static async Task<XlInfo> GetLatestAsync(int satCode, DateTime sigTime)
         {
+            var sql = $"SELECT min(abs(JULIANDAY(TimeUTC)-JULIANDAY('{sigTime:yyyy-MM-dd HH:mm:ss}')))" +
+                        $" as NearDaySpan,* FROM XlInfo where satcode={satCode}";
             try
             {
                 using (RHDWContext db = new RHDWContext())
                 {
-                  var res= await db.XlInfos.SqlQuery($"SELECT min(abs(JULIANDAY(TimeUTC)-JULIANDAY('{sigTime:yyyy-MM-dd HH:mm:ss}')))" +
-                        $" as NearDaySpan,* FROM XlInfo where satcode={satCode}").FirstOrDefaultAsync();
+                  var res= await db.XlInfos.SqlQuery(sql).FirstOrDefaultAsync();
                     return res;
                 }
             }
             catch (Exception ex)
             {
-                Serilog.Log.Error(ex, $"获取卫星[{satCode}]--{sigTime:yyyyMMddHHmmss}时刻附近的双行根数出错!");
+                Serilog.Log.Error(ex, $"获取卫星[{satCode}]--{sigTime:yyyyMMddHHmmss}时刻附近的双行根数出错!Sql={sql}");
                 return null;
             }
         }

+ 15 - 4
XdCxRhDW.WebApi/Startup.cs

@@ -211,7 +211,7 @@ namespace XdCxRhDW.WebApi
 
                  //控制器本身描述
                  string controllerXmlPath1 = $"{AppDomain.CurrentDomain.BaseDirectory}{Path.GetFileNameWithoutExtension(_controllerXmlName)}.xml";
-                 c.CustomProvider(defaultProvider => new SwaggerControllerDescProvider(defaultProvider,new string[] { webApiXmlPath0, controllerXmlPath1 }));
+                 c.CustomProvider(defaultProvider => new SwaggerControllerDescProvider(defaultProvider, new string[] { webApiXmlPath0, controllerXmlPath1 }));
                  c.OperationFilter<FileUploadOperation>();
                  c.SchemaFilter<SwaggerEnumFilter>();
                  c.SchemaFilter<SwaggerDefalutValueFilter>();
@@ -288,8 +288,19 @@ namespace XdCxRhDW.WebApi
             /// <param name="context">提供使用</param>
             public override void OnException(HttpActionExecutedContext context)
             {
-                if (context.Exception.GetType() != typeof(System.OperationCanceledException))
-                    Serilog.Log.Error(context.Exception, context.Exception.Message);
+                var ex = context.Exception;
+                while (ex.InnerException != null)
+                    ex = ex.InnerException;
+                context.Exception = ex;
+                if (ex.GetType() != typeof(System.OperationCanceledException))
+                {
+                    if (ex.GetType().ToString() == "System.Data.SQLite.SQLiteException")
+                    {
+                        Serilog.Log.Error(context.Exception.Message.Replace("\r\n","."));
+                    }
+                    else
+                        Serilog.Log.Error(context.Exception, context.Exception.Message);
+                }
                 else
                     return;
                 base.OnException(context);
@@ -388,7 +399,7 @@ namespace XdCxRhDW.WebApi
                             }
                         }
                     }
-                    
+
                 }
                 return controllerDescDict;
             }

+ 0 - 1
XdCxRhDw.Dto/PosDto/RHNoXlPosDto.cs

@@ -38,7 +38,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 目标双星时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double SxDto { get; set; }
 
         /// <summary>

+ 0 - 1
XdCxRhDw.Dto/PosDto/RHPosDto.cs

@@ -38,7 +38,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 目标双星时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double SxDto { get; set; }
 
         /// <summary>

+ 0 - 1
XdCxRhDw.Dto/PosDto/X2D1NoParPosDto.cs

@@ -38,7 +38,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 目标双星时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double SxDto { get; set; }
 
         /// <summary>

+ 0 - 1
XdCxRhDw.Dto/PosDto/X2D1NoXlNoParlPosDto.cs

@@ -38,7 +38,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 目标双星时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double SxDto { get; set; }
 
         /// <summary>

+ 0 - 1
XdCxRhDw.Dto/PosDto/X2D1NoXlPosDto.cs

@@ -39,7 +39,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 目标双星时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double SxDto { get; set; }
 
         /// <summary>

+ 0 - 1
XdCxRhDw.Dto/PosDto/X2D1PosDto.cs

@@ -38,7 +38,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 目标双星时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double SxDto { get; set; }
 
         /// <summary>

+ 0 - 1
XdCxRhDw.Dto/PosDto/X2DtoDfoNoXlPosDto.cs

@@ -39,7 +39,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto { get; set; }
 
         /// <summary>

+ 0 - 1
XdCxRhDw.Dto/PosDto/X2DtoDfoPosDto.cs

@@ -39,7 +39,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻1时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto { get; set; }
 
         /// <summary>

+ 0 - 2
XdCxRhDw.Dto/PosDto/X3TwoDfoNoXlPosDto.cs

@@ -45,7 +45,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻1时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto1 { get; set; }
 
         /// <summary>
@@ -61,7 +60,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻2时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto2 { get; set; }
 
         /// <summary>

+ 0 - 2
XdCxRhDw.Dto/PosDto/X3TwoDtoNoParPosDto.cs

@@ -44,7 +44,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻1时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto1 { get; set; }
 
         /// <summary>
@@ -60,7 +59,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻2时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto2 { get; set; }
 
         /// <summary>

+ 0 - 2
XdCxRhDw.Dto/PosDto/X3TwoDtoNoXlNoParPosDto.cs

@@ -44,7 +44,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻1时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto1 { get; set; }
 
         /// <summary>
@@ -60,7 +59,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻2时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto2 { get; set; }
 
         /// <summary>

+ 0 - 2
XdCxRhDw.Dto/PosDto/X3TwoDtoNoXlPosDto.cs

@@ -44,7 +44,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻1时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto1 { get; set; }
 
         /// <summary>
@@ -60,7 +59,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻2时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto2 { get; set; }
 
         /// <summary>

+ 0 - 2
XdCxRhDw.Dto/PosDto/X3TwoDtoPosDto.cs

@@ -44,7 +44,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻1时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto1 { get; set; }
 
         /// <summary>
@@ -60,7 +59,6 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// 主邻2时差(us)
         /// </summary>
-        [RangeDouble(-30000, 30000, IncludeMin = true)]
         public double Dto2 { get; set; }
 
         /// <summary>