zoulei 1 year ago
parent
commit
963cee2aca

+ 12 - 1
Service/CheckServer/MainForm.cs

@@ -58,7 +58,18 @@ namespace CheckServer
             else
                 posPlatformAddr = ConfigurationManager.AppSettings["PosPlatformAddr"].Trim();
             this.Text = EnumSvrType.CheckSvr.GetEnumDisplayName() + "-" + svrID;
-            var localIp = IpHelper.GetLocalIp();
+            string localIp = null;
+            var rsp = await HttpHelper.GetRequestAsync<string>($"{posPlatformAddr}/api/task/getclientip", 10);
+            if (rsp.code == 0)
+            {
+                LogHelper.Error(rsp.msg);
+                return;
+            }
+            else
+            {
+                localIp = rsp.data;
+            }
+            LogHelper.Info($"本机IP={localIp}");
             Startup.Start(port, $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml", "XdCxRhDW.Dto.xml");
             LogHelper.Info($"服务启动成功.接口地址http://{localIp}:{port}/swagger");
 

+ 12 - 1
Service/CpuCgServer/MainForm.cs

@@ -59,7 +59,18 @@ namespace CpuCgServer
                 posPlatformAddr = ConfigurationManager.AppSettings["PosPlatformAddr"].Trim();
             }
             this.Text = EnumSvrType.CpuCgSvr.GetEnumDisplayName() + "-" + svrID;
-            var localIp = IpHelper.GetLocalIp();
+            string localIp = null;
+            var rsp = await HttpHelper.GetRequestAsync<string>($"{posPlatformAddr}/api/task/getclientip", 10);
+            if (rsp.code == 0)
+            {
+                LogHelper.Error(rsp.msg);
+                return;
+            }
+            else
+            {
+                localIp = rsp.data;
+            }
+            LogHelper.Info($"本机IP={localIp}");
             Startup.Start(port, $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml", "XdCxRhDW.Dto.xml");
             LogHelper.Info($"服务启动成功.接口地址http://{localIp}:{port}/swagger");
 

+ 12 - 1
Service/GpuCgServer/MainForm.cs

@@ -57,7 +57,18 @@ namespace GpuCgServer
             else
                 posPlatformAddr = ConfigurationManager.AppSettings["PosPlatformAddr"].Trim();
             this.Text = EnumSvrType.GpuCgSvr.GetEnumDisplayName() + "-" + svrID;
-            var localIp = IpHelper.GetLocalIp();
+            string localIp = null;
+            var rsp = await HttpHelper.GetRequestAsync<string>($"{posPlatformAddr}/api/task/getclientip", 10);
+            if (rsp.code == 0)
+            {
+                LogHelper.Error(rsp.msg);
+                return;
+            }
+            else
+            {
+                localIp = rsp.data;
+            }
+            LogHelper.Info($"本机IP={localIp}");
             Startup.Start(port, $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml", "XdCxRhDW.Dto.xml");
             LogHelper.Info($"服务启动成功.接口地址http://{localIp}:{port}/swagger");
 

+ 12 - 2
Service/X2D1NoRefTaskServer/MainForm.cs

@@ -35,8 +35,18 @@ namespace X2D1NoRefTaskServer
             var svrID = ConfigurationManager.AppSettings["SvrID"].Trim();
             var posPlatformAddr = ConfigurationManager.AppSettings["PosPlatformAddr"].Trim();
             this.Text = EnumSvrType.X2D1NoRefTask.GetEnumDisplayName() + "-" + svrID;
-            var localIp = IpHelper.GetLocalIp();
-
+            string localIp = null;
+            var rsp = await HttpHelper.GetRequestAsync<string>($"{posPlatformAddr}/api/task/getclientip", 10);
+            if (rsp.code == 0)
+            {
+                LogHelper.Error(rsp.msg);
+                return;
+            }
+            else
+            {
+                localIp = rsp.data;
+            }
+            LogHelper.Info($"本机IP={localIp}");
             Startup.Start(port, $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml", "XdCxRhDW.Dto.xml");
             LogHelper.Info($"服务启动成功.接口地址http://{localIp}:{port}/swagger");
 

+ 12 - 1
Service/X2D1TaskServer54/MainForm.cs

@@ -33,7 +33,18 @@ namespace X3TaskServer54
             var svrID = ConfigurationManager.AppSettings["SvrID"].Trim();
             var posPlatformAddr = ConfigurationManager.AppSettings["PosPlatformAddr"].Trim();
             this.Text = EnumSvrType.X3NoRefHistoryTask.GetEnumDisplayName() + "-" + svrID;
-            var localIp = IpHelper.GetLocalIp();
+            string localIp = null;
+            var rsp = await HttpHelper.GetRequestAsync<string>($"{posPlatformAddr}/api/task/getclientip", 10);
+            if (rsp.code == 0)
+            {
+                LogHelper.Error(rsp.msg);
+                return;
+            }
+            else
+            {
+                localIp = rsp.data;
+            }
+            LogHelper.Info($"本机IP={localIp}");
             Startup.Start(port, $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml", "XdCxRhDW.Dto.xml");
             LogHelper.Info($"服务启动成功.接口地址http://{localIp}:{port}/swagger");
 

+ 47 - 38
XdCxRhDW.Api/AddIns/定位/PosApi.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
+using System.Security.Policy;
 using System.Text;
 using System.Threading.Tasks;
 using XdCxRhDW.Entity;
@@ -305,7 +306,7 @@ namespace XdCxRhDW.Api
             return posRes;
         }
 
-        public static double[] X2D1_PosNoRef_ZL(double[] posRes, CgRes cgRes, StationRes sRes)
+        public static double[] X2D1_PosNoRef_ZL(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
         {
             if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
             {
@@ -369,41 +370,41 @@ namespace XdCxRhDW.Api
                     //目标-邻星-接收站的时间(us)
                     var dt2 = PhysicsHelper.Dto(posXYZ, (cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value), recXYZ) * 1e6;
                     var dto1 = Math.Abs(dt1 - dt2 - cgRes.Dto1.Value);
-                    //if (dto1 > 100)
-                    //{
-                    //    lat += 1;
-                    //    if (flag < 1)
-                    //        flag = 1;
-                    //    continue;
-                    //}
-                    //else if (dto1 > 50)
-                    //{
-                    //    lat += 0.5;
-                    //    if (flag < 2)
-                    //        flag = 2;
-                    //    continue;
-                    //}
-                    //else if (dto1 > 20)
-                    //{
-                    //    lat += 0.2;
-                    //    if (flag < 3)
-                    //        flag = 3;
-                    //    continue;
-                    //}
-                    //else if (dto1 > 5)
-                    //{
-                    //    lat += 0.1;
-                    //    if (flag < 4)
-                    //        flag = 4;
-                    //    continue;
-                    //}
-                    //else if (dto1 > 2)
-                    //{
-                    //    lat += 0.02;
-                    //    if (flag < 5)
-                    //        flag = 5;
-                    //    continue;
-                    //}
+                    if (dto1 > 100)
+                    {
+                        lat += 1;
+                        if (flag < 1)
+                            flag = 1;
+                        continue;
+                    }
+                    if (dto1 > 50)
+                    {
+                        lat += 0.5;
+                        if (flag < 2)
+                            flag = 2;
+                        continue;
+                    }
+                    else if (dto1 > 20)
+                    {
+                        lat += 0.2;
+                        if (flag < 3)
+                            flag = 3;
+                        continue;
+                    }
+                    else if (dto1 > 5)
+                    {
+                        lat += 0.1;
+                        if (flag < 4)
+                            flag = 4;
+                        continue;
+                    }
+                    else if (dto1 > 2)
+                    {
+                        lat += 0.02;
+                        if (flag < 5)
+                            flag = 5;
+                        continue;
+                    }
                     list.Add((lon, lat, dto1, dto2));
                 }
                 if (flag == 1)
@@ -417,9 +418,17 @@ namespace XdCxRhDW.Api
                 else if (flag == 5)
                     lon += 0.02;
             }
+            double[] res;
+            var p1 = list.OrderBy(p => p.Item3 + p.Item4).FirstOrDefault();
+            if (p1 == default)
+                res = new double[7] { 999, 999, 0, 999, 999, 0, -1 };
+            var p2 = list.Where(p => PhysicsHelper.DistanceGeo((p1.Item1, p1.Item2, 0), (p.Item1, p.Item2, 0)) > 10000).OrderBy(p => p.Item3 + p.Item4).FirstOrDefault();
+            if (p2 == default)
+                res = new double[7] { p1.Item1, p1.Item2, 0, 999, 999, 0, -1 };
+            else
+                res = new double[7] { p1.Item1, p1.Item2, 0, p2.Item1, p2.Item2, 0, -1 };
 
-            var val = list.OrderBy(p => p.Item3 + p.Item4).First();
-            return new double[7] { val.Item1, val.Item2, 0, 999, 999, 0, -1 };
+            return res;
         }
 
         /// <summary>

+ 85 - 0
XdCxRhDW.Api/AddIns/时差线/DrawDtoLineHelper.cs

@@ -356,7 +356,92 @@ namespace XdCxRhDW.Api
             var Lines = list.Select(p => (p.Lon, p.Lat));
             return Lines;
         }
+        public static IEnumerable<(double lon, double lat)> DtoLine2XNoRefStartZl(DtoLineTwoStartOption opt)
+        {
+            double startLon = -180;
+            double endLon = 180;
+            double startLat = -80;
+            double endLat = 80;
+            List<(double, double, double)> list2 = new List<(double, double, double)>();
+            var recXYZ = PhysicsHelper.GeoToEcef((opt.MsAnt[0], opt.MsAnt[1], opt.MsAnt[2]));
+            for (double lon = startLon; lon < endLon; lon += 0.01)
+            {
+                List<(double, double, double)> list = new List<(double, double, double)>();
+                int flag = 0;
+                for (double lat = startLat; lat < endLat; lat += 0.01)
+                {
 
+                    var posXYZ = PhysicsHelper.GeoToEcef((lon, lat, 0));
+
+                    //目标-主星-接收站的时间(us)
+                    var dt1 = PhysicsHelper.Dto(posXYZ, (opt.MsEph[0], opt.MsEph[1], opt.MsEph[2]), recXYZ) * 1e6;
+
+                    //目标-邻星-接收站的时间(us)
+                    var dt2 = PhysicsHelper.Dto(posXYZ, (opt.NsEph[0], opt.NsEph[1], opt.NsEph[2]), recXYZ) * 1e6;
+                    var dto = Math.Abs(dt1 - dt2 - opt.TargetDto);
+                    if (dto > 100)
+                    {
+                        lat += 1;
+                        if (flag < 1)
+                            flag = 1;
+                        continue;
+                    }
+                    else if (dto > 50)
+                    {
+                        lat += 0.5;
+                        if (flag < 2)
+                            flag = 2;
+                        continue;
+                    }
+                    else if (dto > 20)
+                    {
+                        lat += 0.2;
+                        if (flag < 3)
+                            flag = 3;
+                        continue;
+                    }
+                    else if (dto > 5)
+                    {
+                        lat += 0.1;
+                        if (flag < 4)
+                            flag = 4;
+                        continue;
+                    }
+                    else if (dto > 2)
+                    {
+                        lat += 0.05;
+                        if (flag < 5)
+                            flag = 5;
+                        continue;
+                    }
+                    flag = 10;
+                    list.Add((lon, lat, dto));
+                }
+                if (list.Any())
+                {
+                    var p1 = list.OrderBy(p => p.Item3).FirstOrDefault();
+                    list2.Add(p1);
+                    //var p2 = list.Where(p => p.Item3 < 0.01 && PhysicsHelper.DistanceGeo((p.Item1, p.Item2, 0), p1) > 5000).OrderBy(p => p.Item3).FirstOrDefault();
+                    //if (p2 != default)
+                    //    list2.Add(p2);
+                }
+                else
+                {
+                    if (flag == 1)
+                        lon += 1;
+                    else if (flag == 2)
+                        lon += 0.5;
+                    else if (flag == 3)
+                        lon += 0.2;
+                    else if (flag == 4)
+                        lon += 0.1;
+                    else if (flag == 5)
+                        lon += 0.05;
+                }
+                list.Clear();
+            }
+            return list2.Select(p => (p.Item1, p.Item2)).OrderBy(p=>PhysicsHelper.DistanceGeo((1,1,0),(1,1,9)));
+        }
 
     }
 }

+ 4 - 1
XdCxRhDW.App/App.config

@@ -23,7 +23,10 @@
 		<add key="SJZX_URL" value="http://192.168.1.7:5889/MapServer" />
 
 		<!--地图定位点聚合-->
-		<add key="UseMapCluster" value="1"/>
+		<add key="UseMapCluster" value="1" />
+
+		<!--两星一地无参定位算法使用最新的版本-->
+		<add key="UseNewPosX2D1NoRef" value="1" />
 
 	</appSettings>
 	<startup>

+ 23 - 4
XdCxRhDW.App/Controllers/PosController.cs

@@ -16,6 +16,7 @@ using XdCxRhDW.WebApi;
 using DPP_YH_Core.Extensions;
 using XdCxRhDW.App.Model;
 using System.Diagnostics;
+using System.Configuration;
 
 namespace XdCxRhDW.App.Controllers
 {
@@ -590,8 +591,17 @@ namespace XdCxRhDW.App.Controllers
                     TarFreqUp = dto.FreqUp,
                     TarFreqDown = dto.FreqDown,
                 });
-                var res = PosApi.X2D1_PosNoRef(cgRes, StationRes, dto.CalcConfidence);
-                PosApi.X2D1_PosNoRef_ZL(res,cgRes, StationRes);
+                double[] res;
+                if (ConfigurationManager.AppSettings["UseNewPosX2D1"] != null
+             && ConfigurationManager.AppSettings["UseNewPosX2D1"].ToLower() != "false"
+             && ConfigurationManager.AppSettings["UseNewPosX2D1"].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,
@@ -726,8 +736,17 @@ namespace XdCxRhDW.App.Controllers
                     TarFreqUp = dto.FreqUp,
                     TarFreqDown = dto.FreqDown,
                 });
-
-                var res = PosApi.X2D1_PosNoRef(cgRes, StationRes, dto.CalcConfidence);
+                double[] res;
+                if (ConfigurationManager.AppSettings["UseNewPosX2D1"] != null
+             && ConfigurationManager.AppSettings["UseNewPosX2D1"].ToLower() != "false"
+             && ConfigurationManager.AppSettings["UseNewPosX2D1"].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,

+ 20 - 0
XdCxRhDW.App/Controllers/TaskController.cs

@@ -15,6 +15,7 @@ using XdCxRhDW.Entity;
 using XdCxRhDW.Repostory;
 using XdCxRhDW.WebApi;
 using System.Threading;
+using Microsoft.Owin;
 
 namespace XdCxRhDW.App.Controllers
 {
@@ -23,6 +24,25 @@ namespace XdCxRhDW.App.Controllers
     /// </summary>
     public class TaskController : BaseController
     {
+        /// <summary>
+        /// 获取客户端IP地址
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        public AjaxResult<string> GetClientIP()
+        {
+            try
+            {
+                var ip = RemoteIp;
+                return Success(ip);
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error(ex, "获取客户端IP出错");
+                return Error<string>("获取客户端IP出错");
+            }
+        }
+
         /// <summary>
         /// 停止任务
         /// </summary>

+ 25 - 4
XdCxRhDW.App/EditForms/X2D1DTOParamEditor.cs

@@ -5,6 +5,7 @@ using System;
 using System.CodeDom;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.Configuration;
 using System.Data;
 using System.Data.Entity;
 using System.Drawing;
@@ -98,6 +99,14 @@ namespace XdCxRhDW.App.EditForms
                 txtRefLocation.Properties.ReadOnly = true;
                 this.txtRefLocation.Text = $"{0},{0}";
             }
+
+            //txtsatStation.Text = "43.7,12.9";
+            //txtcdbStation.Text = "43.7,12.9";
+            //txtDtoSx.Text = "6348.6030";
+            //txtDtoCdb.Text = "246616.0330";
+            //ucEphXYZMain.SetXYZ("a",1,(11265194.9906, 40486056.6399, -2055810.5412),Color.Red);
+            //ucEphXYZAdaj.SetXYZ("b",1,(25525328.3455, 33539987.1755, -49504.0378),Color.Red);
+
             //double tarLon = 46, tarLat = 24;
             //double recLon = 45.9, recLat = 23.9;
             //var tarEcef = PhysicsHelper.GeoToEcef((tarLon, tarLat, 0));
@@ -217,12 +226,15 @@ namespace XdCxRhDW.App.EditForms
                     var xdDtoLine1 = DrawDtoLineHelper.DtoLineXdNoRefEx(dtoLineXd);
                     mapControl1.DrawDtoLineTwo($"[{msat},超短{CDBAnt[0]}°]无参时差线", xdDtoLine1);
 
-                    var xdDtoLine2 = DrawDtoLineHelper.DtoLineXdNoRefZl(dtoLineXd);
-                    mapControl1.DrawDtoLine($"[{msat},超短{CDBAnt[0]}°]无参时差线zl", xdDtoLine2);
+                    //var xdDtoLine2 = DrawDtoLineHelper.DtoLineXdNoRefZl(dtoLineXd);
+                    //mapControl1.DrawDtoLine($"[{msat},超短{CDBAnt[0]}°]无参时差线zl", xdDtoLine2);
 
 
                     var tsDtoLine = DrawDtoLineHelper.DtoLine2XNoRefStart(twoStartOption);
                     mapControl1.DrawDtoLine($"[{msat},{nsat}]时差线", tsDtoLine);
+
+                    //var tsDtoLine2 = DrawDtoLineHelper.DtoLine2XNoRefStartZl(twoStartOption);
+                    //mapControl1.DrawDtoLine($"[{msat},{nsat}]时差线zl", tsDtoLine2);
                 }
             }
             catch (Exception ex)
@@ -344,8 +356,17 @@ namespace XdCxRhDW.App.EditForms
                         Adja1Y = dto.AdjaY,
                         Adja1Z = dto.AdjaZ,
                     };
-                    var res = PosApi.X2D1_PosNoRef(cgRes, StationRes);
-                    res = PosApi.X2D1_PosNoRef_ZL(res,cgRes, StationRes);
+                    double[] res;
+                    if (ConfigurationManager.AppSettings["UseNewPosX2D1"] != null
+            && ConfigurationManager.AppSettings["UseNewPosX2D1"].ToLower() != "false"
+            && ConfigurationManager.AppSettings["UseNewPosX2D1"].ToLower() != "0")
+                    {
+                        res = PosApi.X2D1_PosNoRef_ZL(cgRes, StationRes);
+                    }
+                    else
+                    {
+                        res = PosApi.X2D1_PosNoRef(cgRes, StationRes, dto.CalcConfidence);
+                    }
                     this.txtPosRes.Text = $"{info.PosResType.GetEnumDisplayName()}定位点:[{res[0]:f4},{res[1]:f4}] 镜像点:[{res[3]:f4},{res[4]:f4}]";
                 }
                 else

+ 19 - 1
XdCxRhDW.App/UserControl/CtrlHome.cs

@@ -28,6 +28,7 @@ using XdCxRhDW.Dto;
 using XdCxRhDW.Entity;
 using XdCxRhDW.Repostory;
 using XdCxRhDW.WebApi;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
 
 namespace XdCxRhDW.App.UserControl
 {
@@ -1095,7 +1096,24 @@ namespace XdCxRhDW.App.UserControl
                             CgRes.Adja1X = eph1.X;
                             CgRes.Adja1Y = eph1.Y;
                             CgRes.Adja1Z = eph1.Z;
-                            res = item.PosResType == EnumPosResType.X2D1 ? PosApi.X2D1_Pos(CgRes, StationRes) : PosApi.X2D1_PosNoRef(CgRes, StationRes);
+
+                            if (item.PosResType == EnumPosResType.X2D1)
+                            {
+                                res = PosApi.X2D1_Pos(CgRes, StationRes);
+                            }
+                            else
+                            {
+                                if (ConfigurationManager.AppSettings["UseNewPosX2D1"] != null
+           && ConfigurationManager.AppSettings["UseNewPosX2D1"].ToLower() != "false"
+           && ConfigurationManager.AppSettings["UseNewPosX2D1"].ToLower() != "0")
+                                {
+                                    res = PosApi.X2D1_PosNoRef_ZL(CgRes, StationRes);
+                                }
+                                else
+                                {
+                                    res = PosApi.X2D1_PosNoRef(CgRes, StationRes);
+                                }
+                            }
                             item.PosLon = res[0];
                             item.PosLat = res[1];
                             item.MirrLon = res[3];

+ 6 - 0
XdCxRhDW.App/XdCxRhDW.App.csproj

@@ -90,10 +90,16 @@
     <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="Microsoft.Owin, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll</HintPath>
+    </Reference>
     <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
+    <Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
+      <HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
+    </Reference>
     <Reference Include="PresentationCore" />
     <Reference Include="PresentationFramework" />
     <Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">

+ 2 - 0
XdCxRhDW.App/packages.config

@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
   <package id="EntityFramework" version="6.4.4" targetFramework="net472" />
+  <package id="Microsoft.Owin" version="4.2.2" targetFramework="net472" />
+  <package id="Owin" version="1.0" targetFramework="net472" />
   <package id="Serilog" version="3.1.1" targetFramework="net472" />
   <package id="Serilog.Sinks.Async" version="1.5.0" targetFramework="net472" />
   <package id="Serilog.Sinks.Console" version="5.0.1" targetFramework="net472" />

+ 3 - 1
XdCxRhDW.Framework/IpHelper.cs

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
 using System.Net.NetworkInformation;
 using System.Runtime.InteropServices;
 using System.Configuration;
+using System.Net.Http;
 
 public static class IpHelper
 {
@@ -15,7 +16,7 @@ public static class IpHelper
     /// 获取本地IP
     /// </summary>
     /// <returns></returns>
-    public static string GetLocalIp()
+    public static string GetLocalIp(string platformAddr = null)
     {
         string localIP = null;
         try
@@ -33,6 +34,7 @@ public static class IpHelper
         catch
         {
         }
+
         try
         {
             using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0))

+ 11 - 1
XdCxRhDW.WebApi/BaseController.cs

@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using Microsoft.Owin;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
 using System.Configuration;
@@ -38,6 +39,15 @@ namespace XdCxRhDW.WebApi
         {
             return Path.Combine(this.uploadFolder, fileName);
         }
+
+        protected string RemoteIp
+        {
+            get
+            {
+                var context = (OwinContext)Request.Properties.First().Value;
+                return context.Request.RemoteIpAddress;
+            }
+        }
         /// <summary>
         /// 返回成功
         /// </summary>