管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-09-07 8d7a67ab1d635cb954337d8a767878ae526dd3dc
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
using ExportMap.cs;
using ExportMap.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
 
namespace ExportMap.Controllers
{
    public class ExportController : ApiController
    {
        [HttpPost]
        public ResponseMsg<string> Start([FromBody]ExportArgs args)
        {
            try
            {
                if (args == null ||
                    string.IsNullOrWhiteSpace(args.layers) ||
                    string.IsNullOrWhiteSpace(args.token) ||
                    (args.xmin == 0 && args.ymin == 0 && args.xmax == 0 && args.ymax == 0))
                {
                    return ResponseMsg<string>.fail("参数不完整");
                }
 
                if (!ExportUtil.VerifyToken(args.token))
                {
                    return ResponseMsg<string>.fail("令牌无效");
                }
 
                string err = null;
                string imgPath = ExportUtil.Generate(args, ref err);
                if (string.IsNullOrEmpty(imgPath))
                {
                    return ResponseMsg<string>.fail(null == err ? "生成失败" : err);
                }
 
                return ResponseMsg<string>.success("成功", imgPath);
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
                return ResponseMsg<string>.fail(ex.Message);
            }
        }
    }
}