From 275e2b9dec977546dd1a3f75eac29c22e6bb4ed2 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 11 十一月 2022 09:10:52 +0800 Subject: [PATCH] 1 --- ExportMap/cs/ExportUtil.cs | 66 ++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 1 deletions(-) diff --git a/ExportMap/cs/ExportUtil.cs b/ExportMap/cs/ExportUtil.cs index 6fa1110..32bfe64 100644 --- a/ExportMap/cs/ExportUtil.cs +++ b/ExportMap/cs/ExportUtil.cs @@ -1,10 +1,13 @@ 锘縰sing 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; + } } } -- Gitblit v1.9.3