From e8628464232bba7cfacfcc87de17a84cda480a98 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 16 十一月 2022 13:50:08 +0800 Subject: [PATCH] 1 --- ExportMap/App_Start/WebApiConfig.cs | 6 ExportMap/ExportMap.csproj | 5 ExportMap/Controllers/FloatServerController.cs | 21 ++ ExportMap/lf.html | 392 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 423 insertions(+), 1 deletions(-) diff --git a/ExportMap/App_Start/WebApiConfig.cs b/ExportMap/App_Start/WebApiConfig.cs index 89c15c2..6a18da3 100644 --- a/ExportMap/App_Start/WebApiConfig.cs +++ b/ExportMap/App_Start/WebApiConfig.cs @@ -16,6 +16,12 @@ // Web API routes config.MapHttpAttributeRoutes(); + config.Routes.MapHttpRoute( + name: "FloatServer", + routeTemplate: "floatserver/checkout/{action}/{id}", + defaults: new { controller = "FloatServer", id = RouteParameter.Optional } + ); + // {controller}/{id} config.Routes.MapHttpRoute( name: "DefaultApi", diff --git a/ExportMap/Controllers/FloatServerController.cs b/ExportMap/Controllers/FloatServerController.cs new file mode 100644 index 0000000..4e018b6 --- /dev/null +++ b/ExportMap/Controllers/FloatServerController.cs @@ -0,0 +1,21 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web; +using System.Web.Http; + +namespace ExportMap.Controllers +{ + public class FloatServerController : ApiController + { + [HttpGet] + [HttpPost] + public void license() + { + HttpRequest httpRequest = HttpContext.Current.Request; + HttpResponse httpResponse = HttpContext.Current.Response; + } + } +} diff --git a/ExportMap/ExportMap.csproj b/ExportMap/ExportMap.csproj index 0a685a6..b58d53a 100644 --- a/ExportMap/ExportMap.csproj +++ b/ExportMap/ExportMap.csproj @@ -124,6 +124,7 @@ <ItemGroup> <Compile Include="App_Start\WebApiConfig.cs" /> <Compile Include="Controllers\ExportController.cs" /> + <Compile Include="Controllers\FloatServerController.cs" /> <Compile Include="Controllers\licenseEncryptionController.cs" /> <Compile Include="cs\CacheUtil.cs" /> <Compile Include="cs\CustomMultipartFormDataStreamProvider.cs" /> @@ -187,7 +188,9 @@ </ItemGroup> <ItemGroup> <None Include="Properties\PublishProfiles\Release.pubxml" /> - <Content Include="Sources\Log.config" /> + <Content Include="Sources\Log.config"> + <SubType>Designer</SubType> + </Content> </ItemGroup> <PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> diff --git a/ExportMap/lf.html b/ExportMap/lf.html new file mode 100644 index 0000000..5adeeaf --- /dev/null +++ b/ExportMap/lf.html @@ -0,0 +1,392 @@ +锘�<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <title>LF鎺ュ彛娴嬭瘯</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <script src="js/jquery.1.12.4.js"></script> + <script src="js/rsa.min.js"></script> + <script src="js/rollups.js"></script> + <script> + window.onload = function () { + getPublicKey(); + } + + function getPublicKey() { + $.get(url + "sign/getPublicKey", function (rs) { + if (rs && rs.code == 200) { + window.encrypt = new JSEncrypt(); + encrypt.setPublicKey(rs.result); + } + }); + } + + function ajax(url, type, data, dataType, contentType, fn) { + $.ajax({ + url: url, + type: type, + data: data, + dataType: dataType || "json", // html銆乯son銆乯sonp銆乻cript銆乼ext + contentType: contentType || "application/json", // "application/x-www-form-urlencoded" + success: function (data) { + fn(data); + }, + error: function (e) { + console.error(e); + fn(); + } + }); + } + + function TestCros() { + $.get(url + "Style/selectCount", function (rs) { + alert(rs.result); + }); + } + + function check() { + $.get(url + "sign/check" + token, function (rs) { + alert("code: " + rs.code + ", msg: " + rs.msg + ", result: " + rs.result); + }); + } + + function getCurrentUser() { + $.get(url + "sign/getCurrentUser" + token, function (rs) { + alert("code: " + rs.code + ", msg: " + rs.msg + ", result: " + rs.result.uname); + }); + } + + function logout() { + $.get(url + "sign/logout" + token, function (rs) { + alert("code: " + rs.code + ", msg: " + rs.msg + ", result: " + rs.result); + }); + } + + function updateUsersPwd() { + var data = { + "adminPwd": encrypt.encrypt("Admin@123"), + "newPwd": encrypt.encrypt("Admin@123"), + "ids": [4, 5] + }; + + // JSON.stringify(data),"application/x-www-form-urlencoded" + ajax(url + "user/updateUsersPwd" + token, "POST", JSON.stringify(data), "json", null, function (rs) { + alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); + console.log(rs); + }); + } + + function insertUser() { + var data = { + // + }; + ajax(url + "user/updateUsersPwd" + token, "POST", JSON.stringify(data), "json", null, function (rs) { + alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); + console.log(rs); + }); + } + + function ajxUpload() { + var formData = new FormData(); + var fs = document.getElementById("file1"); + for (var i = 0, c = fs.files.length; i < c; i++) { + formData.append("file", fs.files[i]); // fs.files[i].name + } + + $.ajax(url + "style/upload" + token, { + type: "post", + data: formData, + async: false, + cache: false, + processData: false, + contentType: false, + success: function (rs) { + alert(rs.code + "锛�" + rs.result); + console.log(rs); + }, + error: function (e) { + console.error(e); + } + }); + } + + // 涓婁紶鏁版嵁 + function uploadData() { + var formData = new FormData(); + var fs = document.getElementById("file1"); + for (var i = 0, c = fs.files.length; i < c; i++) { + formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file + } + formData.append("name", "娴嬭瘯"); + formData.append("dirid", "10"); + formData.append("depid", "1"); + formData.append("verid", "1"); + formData.append("type", "gdb"); + formData.append("cs", "CGCS 2000"); + formData.append("scale", "1:1000"); + formData.append("resolution", "0.5m"); + formData.append("gather", "2022-10-03 15:00:00"); + formData.append("descr", "璐ㄩ噺涓嶉敊"); + + $.ajax(url + "uploader/uploadData" + token, { + type: "post", + data: formData, + async: true, + cache: false, + processData: false, + contentType: false, + success: function (rs) { + alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); + console.log(rs); + }, + error: function (e) { + console.error(e); + } + }); + } + + function uploadShpForWKT() { + var formData = new FormData(); + var fs = document.getElementById("shpFiles"); + var exts = [".shp", ".shx", ".dbf", ".prj"]; + + var count = 0; + for (var i = 0, c = fs.files.length; i < c; i++) { + var name = fs.files[i].name.toLocaleLowerCase(); + var ext = name.substring(name.lastIndexOf(".")); + if (exts.indexOf(ext) > -1) { + count++; + formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file + } + } + if (count != 4) { + alert("ShapeFile鏂囦欢閫夋嫨涓嶅叏锛�"); + return; + } + + $.ajax(url + "inquiry/uploadShp" + token, { + type: "post", + data: formData, + async: true, + cache: false, + processData: false, + contentType: false, + success: function (rs) { + alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result.csid + ", " + rs.result.wkt); + console.log(rs); + }, + error: function (e) { + console.error(e); + } + }); + } + + function downloadShp() { + var data = [ + { id: 1, name: "Point-1", props: "{}", wkt: "POINT(95.80461853400004 34.13862467200005)" }, + { id: 2, name: "Linestring-1", props: "{}", wkt: "LINESTRING(04.98985101830993 37.43840773692756,104.99318913447104 37.43883729720358)" }, + { id: 3, name: "Polygon-1", props: "{}", wkt: "POLYGON((104.9907822932683 37.43532941961706,104.99088987736599 37.43532941961706,104.9908670336867 37.4349030213574,104.99078327712658 37.4349030213574,104.9907822932683 37.43532941961706))" } + ]; + + ajax(url + "mark/downloadShp" + token, "POST", JSON.stringify(data), "json", null, function (rs) { + alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); + // 涓嬭浇鏂囦欢 + if (rs && rs.code == 200) { + var a = document.createElement('a'); // 鍒涘缓涓�涓猘鏍囩鍏冪礌 + a.style.display = 'none'; // 璁剧疆鍏冪礌涓嶅彲瑙� + // http://127.0.0.1:12316/mark/downloadFile?guid=5ce046cc05b186332775c03ac6792caf + a.href = url + "mark/downloadFile" + token + "&guid=" + rs.result; + + document.body.appendChild(a); // 鍔犲叆 + a.click(); // 瑙﹀彂鐐瑰嚮,涓嬭浇 + document.body.removeChild(a); // 閲婃斁 + } + }); + + function htmlDownload(data) { + var url = window.URL.createObjectURL(new Blob([data], { type: "application/zip" })); + + var link = document.createElement('a'); + link.style.display = 'none'; + link.href = url; + link.setAttribute('download', "shp.zip"); + document.body.appendChild(link); + link.click(); + + window.URL.revokeObjectURL(url); + document.body.removeChild(link); + } + } + + function testAES() { + var str1 = encrypt("admin"); + var str2 = decrypt(str1); + //console.log("%c%s", "color: red; background: yellow; font-size: 24px;", "admin"); + console.log("admin", str1, str2); + + var str3 = "gAPpDbZ53XfoQfvT8dj/uhBWX5os8kBJQ1LrNvH3VX7byFQdUJMPiEr8Fkj0q2i1pw+L8KFrvR0MLXq2xaO21nlQQXmEPofJxpDQZwEWUIFZsToXo1kLRD3t6WQezxWB8YTzXHM20Ba73x/ZuuezVhOFOq1U8HKf1dXQdv7gBzEB6fWMmFDc3FuH8GDDHv3LfT86Gio9VgMO6ohlrUdf3ZKtTHeLSuzGF4t0RZuX97YBNo25IIzpeTfRTXBxfdxA"; + console.log(decrypt(str3)); + } + + function encrypt(word){ + return CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(word), CryptoJS.enc.Utf8.parse(base64Decode("QSNzX2xGX3NFcnZlX2sueQ==")), { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }).toString(); + } + + function decrypt(word) { + return CryptoJS.enc.Utf8.stringify(CryptoJS.AES.decrypt(word, CryptoJS.enc.Utf8.parse(base64Decode("QSNzX2xGX3NFcnZlX2sueQ==")), { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })).toString(); + } + + function downloadFile() { + var a = document.createElement('a'); // 鍒涘缓涓�涓猘鏍囩鍏冪礌 + a.style.display = 'none'; // 璁剧疆鍏冪礌涓嶅彲瑙� + a.href = url + "mark/downloadFile" + token + "&guid=" + "5ce046cc05b186332775c03ac6792caf"; + + document.body.appendChild(a); // 鍔犲叆 + a.click(); // 瑙﹀彂鐐瑰嚮,涓嬭浇 + document.body.removeChild(a); // 閲婃斁 + } + + function uploadShpForMark() { + var formData = new FormData(); + var fs = document.getElementById("shpFiles"); + var exts = [".shp", ".shx", ".dbf", ".prj"]; + + var count = 0; + for (var i = 0, c = fs.files.length; i < c; i++) { + var name = fs.files[i].name.toLocaleLowerCase(); + var ext = name.substring(name.lastIndexOf(".")); + if (exts.indexOf(ext) > -1) { + count++; + formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file + } + } + if (count != 4) { + alert("ShapeFile鏂囦欢閫夋嫨涓嶅叏锛�"); + return; + } + + $.ajax(url + "mark/uploadShp" + token, { + type: "post", + data: formData, + async: true, + cache: false, + processData: false, + contentType: false, + success: function (rs) { + alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + ", " + JSON.stringify(rs.result)); + console.log(rs); + }, + error: function (e) { + console.error(e); + } + }); + } + </script> + <script> + var url = "http://127.0.0.1:12316/"; + var token = "?token=a5cca7ad-bfe6-43bd-aa62-e19f2ffac6bd"; + + function exportMap1() { + var page = $("#selectPage").find("option:selected").text(); + var data = { + token: token.replace("?token=", ""), + title: "绠¢亾鍩虹澶ф暟鎹钩鍙帮紙DW1-01锛�", + pageSize: page, + province: "娌冲寳鐪�", + scale: "1锛�5涓�", + resolution: "5绫�", + date: "2022.11.09", + layers: "闃�瀹�,绠¢亾涓績绾�,鐭㈤噺娉ㄨ,鐭㈤噺鍥�", + rotation: 0, + xmin: 103.394023, + ymin: 30.690466, + ymax: 37.871048, + xmax: 112.534648 + }; + + ajax(url + "export/insertMap" + token, "POST", JSON.stringify(data), null, null, function (rs) { + console.log(rs); + alert("code = " + rs.code + ", result = " + rs.result); + if (rs.code = 200) downloadMap(rs.result); + }); + } + + function exportMap2() { + var page = $("#selectPage").find("option:selected").text(); + var data = { + token: token.replace("?token=", ""), + title: "绠¢亾鍩虹澶ф暟鎹钩鍙帮紙DW1-02锛�", + pageSize: page, + province: "灞变笢鐪�", + scale: "1锛�20涓�", + resolution: "20绫�", + date: "2022.11.10", + layers: "绔欏満,绠¢亾涓績绾�,楂樺痉褰卞儚娉ㄨ,楂樺痉褰卞儚", + rotation: 0, + xmin: 103.394023, + ymin: 30.690466, + ymax: 37.871048, + xmax: 112.534648 + }; + + ajax(url + "export/insertMap" + token, "POST", JSON.stringify(data), null, null, function (rs) { + console.log(rs); + alert("code = " + rs.code + ", result = " + rs.result); + if (rs.code = 200) downloadMap(rs.result); + }); + } + + function downloadMap(guid) { + var a = document.createElement('a'); // 鍒涘缓涓�涓猘鏍囩鍏冪礌 + a.style.display = 'none'; // 璁剧疆鍏冪礌涓嶅彲瑙� + a.href = url + "mark/downloadFile" + token + "&guid=" + guid; + + document.body.appendChild(a); // 鍔犲叆 + a.click(); // 瑙﹀彂鐐瑰嚮,涓嬭浇 + document.body.removeChild(a); // 閲婃斁 + } + </script> +</head> +<body> + <input type="button" value="TestCros" onclick="TestCros();" /> + <input type="button" value="check" onclick="check();" /> + <input type="button" value="getCurrentUser" onclick="getCurrentUser();" /> + <input type="button" value="logout" onclick="logout();" /> + <input type="button" value="updateUsersPwd" onclick="updateUsersPwd();" /> + <input type="button" value="insertUser" onclick="insertUser();" /> + <input type="button" value="Ajax涓婁紶" onclick="ajxUpload()" /> + <input type="button" value="uploadData" onclick="uploadData();" /> + <input type="button" value="uploadShpForWKT" onclick="uploadShpForWKT();" /> + <input type="button" value="uploadShp" onclick="downloadShp();" /> + <input type="button" value="downloadFile" onclick="downloadFile();" /> + <input type="button" value="uploadShpForMark" onclick="uploadShpForMark();" /> + <br /> + <br /> + + <form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="http://127.0.0.1:12316/file/upload"> + 鏂囦欢涓婁紶锛� + <input id="file1" name="file1" type="file" multiple="multiple" /> + <input id="file2" name="file2" type="file" multiple="multiple" webkitdirectory /> + <input id="shpFiles" name="shpFiles" type="file" multiple="multiple" accept=".shp,.shx,.dbf,.prj" /> + </form> + <br /> + + 鍑哄浘锛�<select id="selectPage"> + <option>A0</option> + <option>A1</option> + <option>A2</option> + <option>A3</option> + <option selected="selected">A4</option> + <option>A5</option> + <option>A6</option> + </select> + <input type="button" value="鍑哄浘-1" onclick="exportMap1()" /> + <input type="button" value="鍑哄浘-2" onclick="exportMap2()" /> +</body> +</html> +<!-- + decrypt("gAPpDbZ53XfoQfvT8dj/uhBWX5os8kBJQ1LrNvH3VX7byFQdUJMPiEr8Fkj0q2i1pw+L8KFrvR0MLXq2xaO21nlQQXmEPofJxpDQZwEWUIFZsToXo1kLRD3t6WQezxWB8YTzXHM20Ba73x/ZuuezVhOFOq1U8HKf1dXQdv7gBzEB6fWMmFDc3FuH8GDDHv3LfT86Gio9VgMO6ohlrUdf3ZKtTHeLSuzGF4t0RZuX97YBNo25IIzpeTfRTXBxfdxA") + "POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))" + + decrypt("6vqSpEI5Uu76H5TiwFjM6KDhY6dOpnFwSnOYNa7y0Wa6iyzrntctmq4HxwyEQdis") + "POINT(95.80461853400004 34.13862467200005)" +--> \ No newline at end of file -- Gitblit v1.9.3