| | |
| | | using ExportMap.cs; |
| | | using LFServer.Models; |
| | | using ExportMap.db; |
| | | using ExportMap.Models; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | using System.Text; |
| | | using System.Web; |
| | | |
| | | namespace LFServer.cs |
| | | namespace ExportMap.cs |
| | | { |
| | | public static class ExportUtil |
| | | { |
| | | /// <summary> |
| | | /// 基目录 |
| | | /// </summary> |
| | | public static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory; |
| | | |
| | | /// <summary> |
| | | /// 最大文件数 |
| | | /// </summary> |
| | |
| | | { |
| | | if (string.IsNullOrEmpty(sourcesPath)) |
| | | { |
| | | sourcesPath = Path.Combine(BaseDir, "Sources"); |
| | | sourcesPath = Path.Combine(Tools.BaseDir, "Sources"); |
| | | } |
| | | |
| | | return sourcesPath; |
| | |
| | | args.SetDefault(); |
| | | CreateTemplate(args); |
| | | |
| | | string cmd = string.Format("python {0} -qgz {1} -qpt {2}", PyFile, qgz, args.qpt); |
| | | err = Tool.ExecPython(cmd); |
| | | string cmd = string.Format("python \"{0}\" -qgz {1} -qpt {2}", PyFile, qgz, args.qpt); |
| | | SysTask task = TaskDBHelper.CreateTask(ToXYZArgs(args), "PNG", "在线制图(PNG)"); |
| | | err = Tools.ExecCmd(task, cmd, true, true); |
| | | |
| | | string qptFile = Path.Combine(SourcesPath, args.qpt); |
| | | if (File.Exists(qptFile)) |
| | | { |
| | | File.Delete(qptFile); |
| | | } |
| | | if (File.Exists(qptFile)) File.Delete(qptFile); |
| | | |
| | | string imgPath = Path.Combine(DownloadFolder, args.imgPath); |
| | | bool flag = File.Exists(imgPath); |
| | | |
| | | return flag ? args.imgPath : null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 转换为XYZ参数 |
| | | /// </summary> |
| | | public static XYZArgs ToXYZArgs(ExportArgs ea) |
| | | { |
| | | XYZArgs args = new XYZArgs(); |
| | | args.name = ea.title; |
| | | args.ids = new List<int>(); |
| | | args.depcode = null; |
| | | args.dircode = null; |
| | | args.userId = TaskDBHelper.SelectUserIdByToken(ea.token); |
| | | |
| | | return args; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>数据</returns> |
| | | public static string GetData(string url) |
| | | { |
| | | |
| | | Uri uri = new Uri(url); |
| | | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); |
| | | request.Method = "GET"; |