管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2022-11-11 275e2b9dec977546dd1a3f75eac29c22e6bb4ed2
1
已添加1个文件
已修改8个文件
164 ■■■■■ 文件已修改
ExportMap/Controllers/ExportController.cs 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/ExportMap.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Models/ExportArgs.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Models/ResponseMsg.cs 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Sources/Template.qpt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Sources/说明.txt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Test.html 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Web.config 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/ExportUtil.cs 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Controllers/ExportController.cs
@@ -12,16 +12,35 @@
    public class ExportController : ApiController
    {
        [HttpPost]
        public string Start([FromBody]ExportArgs args)
        public ResponseMsg<string> Start([FromBody]ExportArgs args)
        {
            if (args == null ||
                string.IsNullOrWhiteSpace(args.layers)||
                (args.xmin == 0 && args.ymin == 0 && args.xmax == 0 && args.ymax == 0))
            try
            {
                return null;
            }
                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("参数不完整");
                }
            return ExportUtil.Generate(args);
                if (!ExportUtil.VerifyToken(args.token))
                {
                    return ResponseMsg<string>.fail("令牌无效");
                }
                string imgPath = ExportUtil.Generate(args);
                if (string.IsNullOrEmpty(imgPath))
                {
                    return ResponseMsg<string>.fail("失败");
                }
                return ResponseMsg<string>.success("成功", imgPath);
            }
            catch (Exception ex)
            {
                return ResponseMsg<string>.fail(ex.Message);
            }
        }
    }
}
ExportMap/ExportMap.csproj
@@ -131,6 +131,7 @@
    </Compile>
    <Compile Include="Models\Decrypt.cs" />
    <Compile Include="Models\ExportArgs.cs" />
    <Compile Include="Models\ResponseMsg.cs" />
    <Compile Include="Models\Secret.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
ExportMap/Models/ExportArgs.cs
@@ -12,6 +12,8 @@
    {
        public ExportArgs() { }
        public String token { set; get; }
        /// <summary>
        /// æ ‡é¢˜
        /// </summary>
ExportMap/Models/ResponseMsg.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LFServer.Models
{
    public class ResponseMsg<T>
    {
        public ResponseMsg()
        {
            time = DateTime.Now.Ticks;
        }
        public ResponseMsg(int code)
            : this()
        {
            this.code = code;
        }
        public int code { set; get; }
        public String msg { set; get; }
        public long count { set; get; }
        public T result { set; get; }
        public long time { set; get; }
        public static ResponseMsg<T> success(String msg, T result, long count = 0)
        {
            ResponseMsg<T> rm = new ResponseMsg<T>(200);
            rm.msg = msg;
            rm.result = result;
            rm.count = count;
            return rm;
        }
        public static ResponseMsg<T> fail(String msg)
        {
            ResponseMsg<T> rm = new ResponseMsg<T>(500);
            rm.msg = msg;
            return rm;
        }
    }
}
ExportMap/Sources/Template.qpt
@@ -92,7 +92,7 @@
    <LabelFont style="常规" description="宋体,14,-1,5,50,0,0,0,0,0,常规"/>
    <FontColor red="0" blue="0" green="0" alpha="255"/>
  </LayoutItem>
  <LayoutItem svgFillColor="255,255,255,255" svgBorderColor="0,0,0,255" opacity="1" itemRotation="0" blendMode="0" frame="false" pictureHeight="10.7409" mapUuid="" templateUuid="{29298722-a58a-42f7-85d1-04564ad9366d}" outlineWidthM="0.3,mm" zValue="7" type="65640" background="false" frameJoinStyle="miter" mode="1" northOffset="0" resizeMode="0" size="11.6809,10.7409,mm" positionLock="true" anchorPoint="0" position="200.5,194.948,mm" referencePoint="0" northMode="0" uuid="{29298722-a58a-42f7-85d1-04564ad9366d}" visibility="1" excludeFromExports="0" groupUuid="" positionOnPage="200.5,194.948,mm" file="E:/terrait/TianJin/ExportMap/ExportMap/Sources/logo.png" pictureWidth="11.4207" id="Logo" pictureRotation="0" svgBorderWidth="0.2">
  <LayoutItem svgFillColor="255,255,255,255" svgBorderColor="0,0,0,255" opacity="1" itemRotation="0" blendMode="0" frame="false" pictureHeight="10.7409" mapUuid="" templateUuid="{29298722-a58a-42f7-85d1-04564ad9366d}" outlineWidthM="0.3,mm" zValue="7" type="65640" background="false" frameJoinStyle="miter" mode="1" northOffset="0" resizeMode="0" size="11.6809,10.7409,mm" positionLock="true" anchorPoint="0" position="200.5,194.948,mm" referencePoint="0" northMode="0" uuid="{29298722-a58a-42f7-85d1-04564ad9366d}" visibility="1" excludeFromExports="0" groupUuid="" positionOnPage="200.5,194.948,mm" file="{sourcesPath}\logo.png" pictureWidth="11.4207" id="Logo" pictureRotation="0" svgBorderWidth="0.2">
    <FrameColor red="0" blue="0" green="0" alpha="255"/>
    <BackgroundColor red="255" blue="255" green="255" alpha="255"/>
    <LayoutObject>
ExportMap/Sources/˵Ã÷.txt
@@ -24,6 +24,7 @@
<Extent xmin="59.058299" ymin="9.565969" ymax="64.123674" xmax="146.815824"/>
<Extent xmin="103.394023" ymin="30.690466" ymax="37.871048" xmax="112.534648"/>
位置和大小:9,18 280,174
================================================================================ åº“简介
格式化:ctrl + alt + l
PyQGIS库的五个包:
ExportMap/Test.html
@@ -5,6 +5,8 @@
  <title></title>
  <script src="js/jquery.1.12.4.js"></script>
  <script>
    var token = "";
    function ajax(url, type, data, dataType, contentType, fn) {
      $.ajax({
        url: url,
@@ -25,6 +27,7 @@
    function exportMap1() {
      var page = $("#selectPage").find("option:selected").text();
      var data = {
        token: token,
        title: "管道基础大数据平台(DW1-01)",
        pageSize: page,
        province: "河北省",
@@ -40,7 +43,7 @@
      };
      ajax("Export/Start", "POST", JSON.stringify(data), null, null, function (rs) {
        alert(rs);
        alert("code = " + rs.code + ", result = " + rs.result);
        console.log(rs);
      });
    }
@@ -48,6 +51,7 @@
    function exportMap2() {
      var page = $("#selectPage").find("option:selected").text();
      var data = {
        token: token,
        title: "管道基础大数据平台(DW1-02)",
        pageSize: page,
        province: "山东省",
@@ -63,7 +67,7 @@
      };
      ajax("Export/Start", "POST", JSON.stringify(data), null, null, function (rs) {
        alert(rs);
        alert("code = " + rs.code + ", result = " + rs.result);
        console.log(rs);
      });
    }
ExportMap/Web.config
@@ -2,7 +2,7 @@
<configuration>
    <appSettings>
    <!-- 192.168.20.39,127.0.0.1 -->
        <add key="lfServer" value="http://127.0.0.1:12316/"/>
        <add key="lfServer" value="http://127.0.0.1:12316"/>
    <add key="exportFolder" value="D:\LF\export"/>
    <add key="pgConn" value="Server=127.0.0.1;Port=5432;Database=langfang;User Id=postgres;Password=postgres;" />
        <add key="webpages:Version" value="3.0.0.0" />
ExportMap/cs/ExportUtil.cs
@@ -1,10 +1,13 @@
using LFServer.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace LFServer.cs
@@ -76,6 +79,17 @@
            get
            {
                return ConfigurationManager.AppSettings["exportFolder"];
            }
        }
        /// <summary>
        /// åŽå°æœåŠ¡åœ°å€
        /// </summary>
        public static string LFServer
        {
            get
            {
                return ConfigurationManager.AppSettings["lfServer"];
            }
        }
@@ -188,7 +202,10 @@
                File.Delete(qptFile);
            }
            return args.imgPath;
            string imgPath = Path.Combine(ExportFolder, args.imgPath);
            bool flag = File.Exists(imgPath);
            return flag ? args.imgPath : null;
        }
        /// <summary>
@@ -219,9 +236,56 @@
                .Replace("{resolution}", args.resolution)
                .Replace("{date}", args.date)
                .Replace("{layers}", args.layers)
                .Replace("{sourcesPath}", SourcesPath)
                .Replace("{imgPath}", imgPath);
            File.WriteAllText(qptFile, xml);
        }
        /// <summary>
        /// éªŒè¯ä»¤ç‰Œ
        /// </summary>
        /// <param name="token">令牌</param>
        /// <returns>是/否有效</returns>
        public static bool VerifyToken(string token)
        {
            try
            {
                string json = GetData(LFServer + "/sign/check?token=" + token.Trim());
                if (string.IsNullOrWhiteSpace(json))
                {
                    return false;
                }
                ResponseMsg<bool> rm = JsonConvert.DeserializeObject<ResponseMsg<bool>>(json);
                return rm != null && rm.code == 200 && rm.result;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// Get获取数据
        /// </summary>
        /// <param name="url">URL</param>
        /// <returns>数据</returns>
        public static string GetData(string url)
        {
            Uri uri = new Uri(url);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
            request.Method = "GET";
            request.ContentType = "application/x-www-form-urlencoded";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
            string str = reader.ReadToEnd();
            reader.Close();
            return str;
        }
    }
}