From b73e6de0b85cd54ad9b6226fb357f89389ff3cb8 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 05 八月 2024 09:31:42 +0800
Subject: [PATCH] 1

---
 Turf/Turf.csproj                 |    4 ++
 Turf/cs/R.cs                     |   28 ++++++++++++++
 Turf/cs/Tools.cs                 |    1 
 Turf/App_Start/WebApiConfig.cs   |    2 +
 Turf/cs/Result.cs                |   17 ++++++++
 Turf/Controllers/AiController.cs |   39 +++++++++++++++++++
 Turf/cs/Args.cs                  |   12 ++++++
 7 files changed, 102 insertions(+), 1 deletions(-)

diff --git a/Turf/App_Start/WebApiConfig.cs b/Turf/App_Start/WebApiConfig.cs
index 5120947..4fa8dc4 100644
--- a/Turf/App_Start/WebApiConfig.cs
+++ b/Turf/App_Start/WebApiConfig.cs
@@ -21,6 +21,8 @@
                 defaults: new { id = RouteParameter.Optional }
             );
 
+            //GlobalConfiguration.Configuration.Formatters.Add(new FormMultipartEncodedMediaTypeFormatter());
+
             // 灞忚斀杩斿洖XML鏍煎紡
             GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
 
diff --git a/Turf/Controllers/AiController.cs b/Turf/Controllers/AiController.cs
new file mode 100644
index 0000000..c852293
--- /dev/null
+++ b/Turf/Controllers/AiController.cs
@@ -0,0 +1,39 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Threading;
+using System.Web.Http;
+using Turf.cs;
+
+namespace Turf.Controllers
+{
+    public class AiController : ApiController
+    {
+        [HttpPost]
+        [Route("footprint/predict/2")]
+        [Route("riverface/predict/2")]
+        [Route("roadface/predict/2")]
+        [Route("woodland/predict/2")]
+        public R<Result> footprint([FromBody]Args args)
+        {
+            try
+            {
+                if (null == args || string.IsNullOrEmpty(args.data_dir))
+                {
+                    return new R<Result>(2, "Sorry, the parameter is wrong");
+                }
+
+                Thread.Sleep(7000);
+                Result rs = new Result();
+
+                return new R<Result>(0, "ok", rs);
+            }
+            catch (Exception ex)
+            {
+                return new R<Result>(5, ex.Message);
+            }
+        }
+    }
+}
diff --git a/Turf/Turf.csproj b/Turf/Turf.csproj
index 11488ae..cfd5ac2 100644
--- a/Turf/Turf.csproj
+++ b/Turf/Turf.csproj
@@ -108,8 +108,12 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="App_Start\WebApiConfig.cs" />
+    <Compile Include="Controllers\AiController.cs" />
+    <Compile Include="cs\Args.cs" />
     <Compile Include="cs\ModelHandler.cs" />
     <Compile Include="cs\PostgreHelper.cs" />
+    <Compile Include="cs\R.cs" />
+    <Compile Include="cs\Result.cs" />
     <Compile Include="cs\Tools.cs" />
     <Compile Include="Controllers\CallController.cs" />
     <Compile Include="Global.asax.cs">
diff --git a/Turf/cs/Args.cs b/Turf/cs/Args.cs
new file mode 100644
index 0000000..e23f23d
--- /dev/null
+++ b/Turf/cs/Args.cs
@@ -0,0 +1,12 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Turf.cs
+{
+    public class Args
+    {
+        public string data_dir { set; get; }
+    }
+}
\ No newline at end of file
diff --git a/Turf/cs/R.cs b/Turf/cs/R.cs
new file mode 100644
index 0000000..71ed713
--- /dev/null
+++ b/Turf/cs/R.cs
@@ -0,0 +1,28 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Turf.cs
+{
+    public class R<T>
+    {
+        public int status { set; get; }
+
+        public string message { set; get; }
+
+        public T datas { set; get; }
+
+        public R(int status, String message)
+        {
+            this.status = status;
+            this.message = message;
+        }
+
+        public R(int status, String message, T t)
+            : this(status, message)
+        {
+            this.datas = t;
+        }
+    }
+}
diff --git a/Turf/cs/Result.cs b/Turf/cs/Result.cs
new file mode 100644
index 0000000..86d8544
--- /dev/null
+++ b/Turf/cs/Result.cs
@@ -0,0 +1,17 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Turf.cs
+{
+    public class Result
+    {
+        public string data_type { set; get; }
+
+        public Result()
+        {
+            this.data_type = "geojson";
+        }
+    }
+}
diff --git a/Turf/cs/Tools.cs b/Turf/cs/Tools.cs
index a1dfdb1..4f15779 100644
--- a/Turf/cs/Tools.cs
+++ b/Turf/cs/Tools.cs
@@ -10,7 +10,6 @@
 using System.Text;
 using System.Web;
 using Turf.Models;
-using static Mono.Security.X509.X520;
 
 namespace Turf.cs
 {

--
Gitblit v1.9.3