| | |
| | | using LFServer.Models; |
| | | using ExportMap.cs; |
| | | using LFServer.Models; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取出图目录 |
| | | /// 获取下载目录 |
| | | /// </summary> |
| | | public static string ExportFolder |
| | | public static string DownloadFolder |
| | | { |
| | | get |
| | | { |
| | | return ConfigurationManager.AppSettings["exportFolder"]; |
| | | return ConfigurationManager.AppSettings["downloadFolder"]; |
| | | } |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | public static string GetExportSubFolder() |
| | | { |
| | | string root = ExportFolder; |
| | | string root = DownloadFolder; |
| | | if (!Directory.Exists(root)) |
| | | { |
| | | Directory.CreateDirectory(root); |
| | |
| | | |
| | | string info = so.ReadToEnd(); |
| | | str = se.ReadToEnd(); |
| | | if (p.HasExited == false) |
| | | { |
| | | p.Kill(); |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(info)) LogOut.Debug(info); |
| | | if (!string.IsNullOrEmpty(str)) LogOut.Error(str); |
| | | if (p.HasExited == false) p.Kill(); |
| | | |
| | | si.Close(); |
| | | so.Close(); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.StackTrace); |
| | | str = ex.Message; |
| | | } |
| | | |
| | |
| | | /// 生成 |
| | | /// </summary> |
| | | /// <param name="args">出图参数</param> |
| | | /// <param name="err">错误信息</param> |
| | | /// <returns>图片路径</returns> |
| | | public static string Generate(ExportArgs args) |
| | | public static string Generate(ExportArgs args, ref string err) |
| | | { |
| | | string date = DateStr; |
| | | string sub = GetExportSubFolder(); |
| | |
| | | |
| | | args.SetDefault(); |
| | | CreateTemplate(args); |
| | | string info = ExecPython(PyFile, qgz, args.qpt); |
| | | err = ExecPython(PyFile, qgz, args.qpt); |
| | | |
| | | string qptFile = Path.Combine(SourcesPath, args.qpt); |
| | | if (File.Exists(qptFile)) |
| | |
| | | File.Delete(qptFile); |
| | | } |
| | | |
| | | string imgPath = Path.Combine(ExportFolder, args.imgPath); |
| | | string imgPath = Path.Combine(DownloadFolder, args.imgPath); |
| | | bool flag = File.Exists(imgPath); |
| | | |
| | | return flag ? args.imgPath : null; |
| | |
| | | /// <param name="args">出图参数</param> |
| | | public static void CreateTemplate(ExportArgs args) |
| | | { |
| | | string imgPath = Path.Combine(ExportFolder, args.imgPath); |
| | | string imgPath = Path.Combine(DownloadFolder, args.imgPath); |
| | | string templateFile = Path.Combine(SourcesPath, "Template.qpt"); |
| | | string qptFile = Path.Combine(SourcesPath, args.qpt); |
| | | if (File.Exists(qptFile)) |
| | |
| | | xml = xml |
| | | .Replace("{dpi}", args.dpi.ToString()) |
| | | .Replace("{title}", args.title) |
| | | .Replace("{sourcesPath}", SourcesPath) |
| | | .Replace("{rotation}", args.rotation.ToString()) |
| | | .Replace("{xmin}", args.xmin.ToString()) |
| | | .Replace("{ymin}", args.ymin.ToString()) |
| | |
| | | .Replace("{province}", args.province) |
| | | .Replace("{scale}", args.scale) |
| | | .Replace("{resolution}", args.resolution) |
| | | .Replace("{date}", args.date) |
| | | //.Replace("{date}", args.date) |
| | | .Replace("{date}", DateTime.Now.ToString("yyyy.MM.dd")) |
| | | .Replace("{layers}", args.layers) |
| | | .Replace("{sourcesPath}", SourcesPath) |
| | | .Replace("{imgPath}", imgPath); |
| | | |
| | | File.WriteAllText(qptFile, xml); |
| | |
| | | { |
| | | try |
| | | { |
| | | string json = GetData(LFServer + "/sign/check?token=" + token.Trim()); |
| | | string url = LFServer + "/sign/check?token=" + token.Trim(); |
| | | string json = GetData(url); |
| | | if (string.IsNullOrWhiteSpace(json)) |
| | | { |
| | | return false; |
| | |
| | | |
| | | return rm != null && rm.code == 200 && rm.result; |
| | | } |
| | | catch (Exception ex) |
| | | catch |
| | | { |
| | | return false; |
| | | } |