管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2024-08-16 af2c84bc9eb5afb47cf3b8849bb126387d86d755
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
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
    {
        private string getDataCache()
        {
            return ConfigurationManager.AppSettings["dataCache"];
        }
 
        [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(10000);
                String target = Path.Combine(getDataCache(), args.data_dir, "results");
                if (!Directory.Exists(target)) Directory.CreateDirectory(target);
 
                String source = Path.Combine(getDataCache(), "1722828277901", "results");
                string[] files = Directory.GetFiles(source, "*.geojson");
                foreach (string file in files)
                {
                    string newFile = Path.Combine(target, Path.GetFileName(file));
                    File.Copy(file, newFile, true);
                }
 
                Result rs = new Result();
 
                return new R<Result>(0, "ok", rs);
            }
            catch (Exception ex)
            {
                return new R<Result>(5, ex.Message);
            }
        }
    }
}