管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2023-07-29 f4c25e70497a233caba9e208c13f1b663bf0623f
删除服务时物理删除发布文件
已修改5个文件
89 ■■■■■ 文件已修改
ExportMap/Controllers/ConvertController.cs 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/TerraUtils.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/Tools.cs 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/db/PubDBHelper.cs 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/export.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Controllers/ConvertController.cs
@@ -219,6 +219,34 @@
        }
        /// <summary>
        /// 删除文件
        /// </summary>
        [HttpPost]
        public ResponseMsg<string> DeleteFiles([FromBody]XYZArgs args)
        {
            try
            {
                ResponseMsg<string> msg = checkArgs(args, true);
                if (null != msg) return msg;
                string err = null;
                List<int> rs = Tools.DeleteFiles(args, ref err);
                if (null == rs || rs.Count == 0)
                {
                    return ResponseMsg<string>.fail(null == err ? "失败" : err);
                }
                return ResponseMsg<string>.success("成功", string.Join(",", rs), rs.Count);
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
                return ResponseMsg<string>.fail(ex.Message);
            }
        }
        /// <summary>
        /// 检查参数
        /// </summary>
        private ResponseMsg<string> checkArgs(XYZArgs args, bool checkDir = false)
ExportMap/cs/TerraUtils.cs
@@ -261,8 +261,8 @@
                {
                    if (!ids.Contains(m.id)) PubDBHelper.InsertMetaPub(m.id, pubid, args.userId);
                }
                string json = GetPointZ(args);
                if (!string.IsNullOrEmpty(json)) PubDBHelper.UpdatePublishCoord(pubid, json);
                string geom = GetPointZ(args);
                if (!string.IsNullOrEmpty(geom)) PubDBHelper.UpdatePublishGeom(pubid, geom);
                return pubid;
            }
ExportMap/cs/Tools.cs
@@ -288,6 +288,41 @@
            }
        }
        /// <summary>
        /// 删除文件
        /// </summary>
        public static List<int> DeleteFiles(XYZArgs args, ref string err)
        {
            List<SysPublish> pubs = PubDBHelper.SelectPublishs(args.ids);
            if (null == pubs || pubs.Count == 0) return null;
            List<int> list = new List<int>();
            foreach (SysPublish pub in pubs)
            {
                try
                {
                    if (string.IsNullOrEmpty(pub.url) || string.IsNullOrEmpty(pub.path)) continue;
                    String path = SGUtils.LFData + "\\" + pub.path.Replace("\\tileset.json", "");
                    if (pub.url.Contains("/SG/") || !Directory.Exists(path))
                    {
                        list.Add(pub.id);
                        continue;
                    }
                    DelPath(path);
                    list.Add(pub.id);
                }
                catch (Exception ex)
                {
                    LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
                    err = ex.Message;
                }
            }
            return list;
        }
        [DllImport("ReadLas.dll")]
        public extern static int get_las_cs(string file_name);
    }
ExportMap/db/PubDBHelper.cs
@@ -98,10 +98,10 @@
        /// <summary>
        /// 更新发布数据的坐标
        /// </summary>
        public static int UpdatePublishCoord(int pid, string json)
        public static int UpdatePublishGeom(int pid, string geom)
        {
            string sql = string.Format("update lf.sys_publish set json = @json where id = {0}", pid);
            DbParameter dp = new NpgsqlParameter("@json", json);
            string sql = string.Format("update lf.sys_publish set geom = @geom where id = {0}", pid);
            DbParameter dp = new NpgsqlParameter("@geom", geom);
            return Tools.DBHelper.ExecuteNonQuery(sql, dp);
        }
@@ -275,6 +275,18 @@
        }
        /// <summary>
        /// 查询发布数据
        /// </summary>
        public static List<SysPublish> SelectPublishs(List<int> ids)
        {
            string sql = string.Format("select id, name, url, path, type, status, dirid, depid, min, max, json, create_user, create_time, update_user, update_time, st_astext(geom) geom, bak from lf.sys_publish where id in ({0}) order by id desc", string.Join(",", ids));
            DataTable dt = Tools.DBHelper.GetDataTable(sql);
            List<SysPublish> list = ModelHandler.FillModel<SysPublish>(dt);
            return list;
        }
        /// <summary>
        /// 获取参数列表
        /// </summary>
        public static List<DbParameter> GetParams<T>(string sql, T t)
ExportMap/export.html
@@ -10,7 +10,7 @@
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="js/jquery.1.12.4.js"></script>
  <script>
    var token = "5f98316d-de91-4850-a20f-44080a278115";
    var token = "dba75438-71f2-4a67-91ef-8919cd9b16cc";
    // Ajax
    function ajax(url, type, data, dataType, contentType, fn) {
@@ -127,7 +127,7 @@
    
    // 测试Terra:10526,10527
    function toTerra() {
      var data = { token: token, ids: [10526, 10527], min: 0, max: 18, depcode: "00", dircode: "09", userId: 1, name: "BN_GD" };
      var data = { token: token, ids: [10531], min: 0, max: 18, depcode: "00", dircode: "090000", userId: 1, name: "中缅" };
      ajax("Convert/ToTerra", "POST", JSON.stringify(data), null, null, function (rs) {
        alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result);
        console.log(rs);