| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | </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> |
| | |
| | | { |
| | | public ExportArgs() { } |
| | | |
| | | public String token { set; get; } |
| | | |
| | | /// <summary> |
| | | /// æ é¢ |
| | | /// </summary> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | |
| | | <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> |
| | |
| | | |
| | | <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åºçäºä¸ªå
ï¼ |
| | |
| | | <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, |
| | |
| | | function exportMap1() { |
| | | var page = $("#selectPage").find("option:selected").text(); |
| | | var data = { |
| | | token: token, |
| | | title: "管éåºç¡å¤§æ°æ®å¹³å°ï¼DW1-01ï¼", |
| | | pageSize: page, |
| | | province: "æ²³åç", |
| | |
| | | }; |
| | | |
| | | ajax("Export/Start", "POST", JSON.stringify(data), null, null, function (rs) { |
| | | alert(rs); |
| | | alert("code = " + rs.code + ", result = " + rs.result); |
| | | console.log(rs); |
| | | }); |
| | | } |
| | |
| | | function exportMap2() { |
| | | var page = $("#selectPage").find("option:selected").text(); |
| | | var data = { |
| | | token: token, |
| | | title: "管éåºç¡å¤§æ°æ®å¹³å°ï¼DW1-02ï¼", |
| | | pageSize: page, |
| | | province: "å±±ä¸ç", |
| | |
| | | }; |
| | | |
| | | ajax("Export/Start", "POST", JSON.stringify(data), null, null, function (rs) { |
| | | alert(rs); |
| | | alert("code = " + rs.code + ", result = " + rs.result); |
| | | console.log(rs); |
| | | }); |
| | | } |
| | |
| | | <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" /> |
| | |
| | | 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 |
| | |
| | | get |
| | | { |
| | | return ConfigurationManager.AppSettings["exportFolder"]; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åå°æå¡å°å |
| | | /// </summary> |
| | | public static string LFServer |
| | | { |
| | | get |
| | | { |
| | | return ConfigurationManager.AppSettings["lfServer"]; |
| | | } |
| | | } |
| | | |
| | |
| | | File.Delete(qptFile); |
| | | } |
| | | |
| | | return args.imgPath; |
| | | string imgPath = Path.Combine(ExportFolder, args.imgPath); |
| | | bool flag = File.Exists(imgPath); |
| | | |
| | | return flag ? args.imgPath : null; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | .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; |
| | | } |
| | | } |
| | | } |