| | |
| | | } |
| | | } |
| | | |
| | | public int GetIntScalar(string sql, params DbParameter[] args) |
| | | { |
| | | using (NpgsqlConnection con = new NpgsqlConnection(ConStr)) |
| | | { |
| | | if (con.State != ConnectionState.Open) |
| | | { |
| | | con.Open(); |
| | | } |
| | | |
| | | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, con)) |
| | | { |
| | | if (args != null) |
| | | { |
| | | foreach (DbParameter arg in args) |
| | | { |
| | | cmd.Parameters.Add(arg); |
| | | } |
| | | } |
| | | |
| | | object obj = cmd.ExecuteScalar(); |
| | | |
| | | return null == obj ? 0 : Convert.ToInt32(obj); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 执行SQL,返回影响行数 |
| | | /// </summary> |
| | |
| | | private static string insertMetaPubSql = "insert into lf.sys_meta_pub (metaid, pubid, create_user) select {0}, {1}, {2} from (select 1) temp where not exists (select 1 from lf.sys_meta_pub where metaid = {0} and pubid = {1})"; |
| | | |
| | | // 模型-@cnName,model-@enName,自动发布模型-@name,http:// - @url,Tileset-@serve,1-@user,7-@pubid |
| | | //private static string insertLayerSql = "insert into lf.sys_layer (pid, cn_name, en_name, url, type, level, order_num, is_show, create_user, data_type, serve_type, pubid, elev) values ((select coalesce(id, 0) from lf.sys_layer where cn_name = @name limit 1), @cnName, @enName, @url, 2, (select coalesce(level, 0) + 1 from lf.sys_layer where cn_name = @name limit 1), (select coalesce(max(order_num), 0) + 1 from lf.sys_layer where pid = (select id from lf.sys_layer where cn_name = @name limit 1)), 0, @user, @name, @serve, @pubid, @elev);"; |
| | | private static string insertLayerSql = "insert into lf.sys_layer (pid, cn_name, en_name, url, type, level, order_num, is_show, create_user, data_type, serve_type, pubid, elev) values (@pid, @cnName, @enName, @url, 2, (select coalesce(level, 0) + 1 from lf.sys_layer where id = @pid), (select coalesce(max(order_num), 0) + 1 from lf.sys_layer where pid = @pid), 0, @user, @data, @serve, @pubid, @elev)"; |
| | | private static string insertLayerSql = "insert into lf.sys_layer (pid, cn_name, en_name, url, type, level, order_num, is_show, create_user, data_type, serve_type, pubid, elev) values (@pid, @cnName, @enName, @url, 2, (select coalesce(level, 0) + 1 from lf.sys_layer where id = @pid), (select coalesce(max(order_num), 0) + 1 from lf.sys_layer where pid = @pid), 0, @user, @data, @serve, @pubid, @elev) returning id"; |
| | | |
| | | private static string updateMetaSql = "update lf.sys_meta set path = @path where id = @id"; |
| | | |
| | | private static string selectLayerSql = "select id from lf.sys_layer where pid = @pid and cn_name = @name"; |
| | | |
| | | /// <summary> |
| | | /// 是/否发布过 |
| | |
| | | public static int SelectLayerPid(SysMeta meta) |
| | | { |
| | | string sql = GetSelectLayerPidSql(meta); |
| | | int pid = Tools.DBHelper.GetIntScalar(sql); |
| | | |
| | | object obj = Tools.DBHelper.GetScalar(sql); |
| | | List<DbParameter> list = new List<DbParameter>(); |
| | | list.Add(new NpgsqlParameter("@pid", pid)); |
| | | list.Add(new NpgsqlParameter("@name", meta.dirname)); |
| | | |
| | | return null == obj ? 0 : Convert.ToInt32(obj); |
| | | int layerId = Tools.DBHelper.GetIntScalar(selectLayerSql, list.ToArray()); |
| | | if (0 == layerId) |
| | | { |
| | | // |
| | | } |
| | | |
| | | return layerId; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | "verid": 0 |
| | | } |
| | | ]; |
| | | |
| | | |
| | | var xlsFiles = [{ |
| | | "createTime": null, |
| | | "createUser": 1, |
| | | "depcode": "00", |
| | | "dircode": "0A", |
| | | "entity": null, |
| | | "epsgCode": "EPSG:4490", |
| | | "eventid": "de7305ea-8e4c-4bb5-a135-f40ee8a15012", |
| | | "extName": ".xls", |
| | | "guid": "d33145704a27cda67577d7c51dc26c18", |
| | | "isMeta": false, |
| | | "msg": null, |
| | | "name": "三桩一牌.xls", |
| | | "path": "20230428\\三桩一牌.xls", |
| | | "rows": 0, |
| | | "sizes": 0.021, |
| | | "tab": null, |
| | | "type": "xls", |
| | | "verid": 0 |
| | | }, { |
| | | "createTime": null, |
| | | "createUser": 1, |
| | | "depcode": "00", |
| | | "dircode": "0A", |
| | | "entity": null, |
| | | "epsgCode": "EPSG:4490", |
| | | "eventid": "d1091b43-e3a4-4ef2-bc3a-b93396d9d827", |
| | | "extName": ".xls", |
| | | "guid": "34250a66dfc5508dd4e2de16790c5913", |
| | | "isMeta": false, |
| | | "msg": null, |
| | | "name": "数字正射影像图.xlsx", |
| | | "path": "20230428\\数字正射影像图.xlsx", |
| | | "rows": 0, |
| | | "sizes": 0.009, |
| | | "tab": null, |
| | | "type": "xls", |
| | | "verid": 0 |
| | | }]; |
| | |
| | | <script src="js/insertFiles.js"></script> |
| | | <script> |
| | | var app = {}; |
| | | var path = "20230228"; |
| | | var path = "20230425"; |
| | | var url = "http://127.0.0.1:12316/server/"; |
| | | //var token = "c36e4f94-dfde-401e-9967-2c4a449f1300"; |
| | | var token = "e507a96b-ca70-4531-b7ef-b3ecb3fb6094"; |
| | | var token = "dce05aee-5b55-4835-bb45-e128d9c1f145"; |
| | | |
| | | $(function () { |
| | | $("#pathSpan").html(path); |
| | |
| | | }); |
| | | } |
| | | |
| | | // Xls入库 * |
| | | // Xls入库 |
| | | function insertXls() { |
| | | if (app.data == null) return; |
| | | |
| | | var obj = { |
| | | metaEntity: { |
| | | depid: 1, |
| | | dirid: 10, |
| | | verid: 0, |
| | | //type: "file", |
| | | //cs: "CGCS 2000", |
| | | //scale: "1:1000", |
| | | //resolution: "0.5m", |
| | | gather: "2022-10-05 15:00:00", |
| | | descr: "测试Xls", |
| | | }, |
| | | fileEntities: app.data, |
| | | tabEntities: [ |
| | | { filename: "2-2 管线成果表.xlsx", subPath: "20221128010101\2-2 管线成果表.xlsx", tab: null, entity: "mdGdcg", type: "xls" }, |
| | | { filename: "海原县中线成果表.xlsx", subPath: "20221128010101\海原县中线成果表.xlsx", tab: null, entity: "mdZxcg", type: "xls" } |
| | | ] |
| | | }; |
| | | |
| | | ajax(getUrl("dataLoader/insertFiles"), "POST", JSON.stringify(obj), null, null, function (rs) { |
| | | ajax(getUrl("dataUpload/insertFiles"), "POST", JSON.stringify(xlsFiles), null, null, function (rs) { |
| | | console.log(rs); |
| | | app.data = null; |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | }); |
| | | } |
| | |
| | | |
| | | // 测试发布 |
| | | function testPublish() { |
| | | //debugger |
| | | var type = $("#selectPubType").find("option:selected").text().split("(")[0]; |
| | | var vals = $("#selectPubType").find("option:selected").val(); |
| | | console.log("测试发布", type, vals); |
| | | |
| | | var data = { "ids": vals.split(","), "type": type, "name": "DOM_0.2m", "min": 12, "max": 18, depcode: "000305", dircode: "0102" }; |
| | | ajax(getUrl("publish/insertForPub"), "POST", JSON.stringify(data), null, null, function (rs) { |
| | | console.log(rs); |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | }); |
| | | } |
| | | |
| | | // 下载瓦片 |
| | | function downloadTiles() { |
| | | var data = { |
| | | pwd: encrypt.encrypt("Test!321&456"), |
| | | //pubid: 15, xmin: 112.9534213185, ymin: 32.1588839103, xmax: 112.9734893228, ymax: 32.1736306779 |
| | | pubid: 15, xmin: 112.943013, ymin: 32.158525, xmax: 112.974408, ymax: 32.174741 |
| | | }; |
| | | ajax(getUrl("inquiry/downloadTiles"), "POST", JSON.stringify(data), null, null, function (rs) { |
| | | console.log(rs); |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | }); |
| | |
| | | <input value="上传文件" type="button" onclick="uploadFiles();" /> |
| | | <input value="查询文件 *" type="button" onclick="selectFiles();" /> |
| | | <input value="删除文件" type="button" onclick="deleteFiles();" /> |
| | | <!--<input value="Xls入库" type="button" onclick="insertXls();" />--> |
| | | <input value="Xls入库" type="button" onclick="insertXls();" /> |
| | | <input value="读取映射 *" type="button" onclick="readMappers();" /> |
| | | <input value="综合数据入库 *" type="button" onclick="insertAllFiles();" /> |
| | | <input value="空间数据入库 *" type="button" onclick="insertDbFiles();" /> |
| | |
| | | <option value="1525">MPT</option> |
| | | </select> |
| | | <input value="测试发布" type="button" onclick="testPublish();" /> |
| | | <input value="下载瓦片" type="button" onclick="downloadTiles();" /> |
| | | <hr /> |
| | | <br /> |
| | | </form> |