From a3d3b0ea3f49a482b8938ee5ad450d917ad509ec Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 03 二月 2023 15:07:25 +0800 Subject: [PATCH] 1 --- DataLoader/App.config | 2 DataLoader/Log.config | 37 ++++ DataLoader/MainWindow.xaml.cs | 7 DataLoader/CS/LogOut.cs | 132 ++++++++++++++ DataLoader/CS/Importor.cs | 5 DataLoader/MainWindow.xaml | 4 ExportMap/up.html | 172 ++---------------- DataLoader/DataLoader.csproj | 11 + DataLoader/dll/log4net4.dll | 0 ExportMap/js/insertFiles.js | 119 +++++++++++++ DataLoader/htmls/login.html | 2 11 files changed, 332 insertions(+), 159 deletions(-) diff --git a/DataLoader/App.config b/DataLoader/App.config index 59c9ee9..d63f503 100644 --- a/DataLoader/App.config +++ b/DataLoader/App.config @@ -1,7 +1,7 @@ 锘�<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> - <add key="pgConn" value="Server=192.168.20.83;Port=5433;Database=moon;User Id=postgres;Password=postgres;"/> + <add key="pgConn" value="Server=127.0.0.1;Port=5433;Database=langfang;User Id=postgres;Password=postgres;"/> </appSettings> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> diff --git a/DataLoader/CS/Importor.cs b/DataLoader/CS/Importor.cs index 0520b40..464bbc6 100644 --- a/DataLoader/CS/Importor.cs +++ b/DataLoader/CS/Importor.cs @@ -29,7 +29,7 @@ public static string GetFilePathByGuid(string guid) { - string sql = "select path from lf.sys_meta_file where guid = @guid limit 1"; + string sql = "select path from lf.sys_meta where guid = @guid limit 1"; DbParameter dp = new NpgsqlParameter("@guid", guid); object obj = Helper.GetScalar(sql, dp); @@ -39,7 +39,7 @@ public static bool IsFileExists(string guid) { - string sql = "select count(*) from lf.sys_meta_file where guid = @guid limit 1"; + string sql = "select count(*) from lf.sys_meta where guid = @guid"; DbParameter dp = new NpgsqlParameter("@guid", guid); object obj = Helper.GetScalar(sql, dp); @@ -118,6 +118,7 @@ } catch (Exception ex) { + LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); vd.Status = "澶辫触锛�"; } } diff --git a/DataLoader/CS/LogOut.cs b/DataLoader/CS/LogOut.cs new file mode 100644 index 0000000..a90e1d1 --- /dev/null +++ b/DataLoader/CS/LogOut.cs @@ -0,0 +1,132 @@ +锘縰sing System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace DataLoader.CS +{ + /// <summary> + /// 鏃ュ織杈撳嚭绫� + /// </summary> + public class LogOut + { + /// <summary> + /// 鏃ュ織 + /// </summary> + protected static readonly log4net.ILog _log; + + /// <summary> + /// 闈欐�佹瀯閫犲嚱鏁� + /// </summary> + static LogOut() + { + try + { + _log = log4net.LogManager.GetLogger("log4net"); + + //HttpContext.Current.Request.PhysicalApplicationPath + //string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources\\Log.config"); + //string fileName = Path.Combine(Application.StartupPath, "Log.config"); + string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log.config"); + + log4net.Config.XmlConfigurator.Configure(new FileInfo(fileName)); + } + catch + { + } + } + + /// <summary> + /// 璋冭瘯 + /// </summary> + /// <param name="message">鏃ュ織</param> + public static void Debug(string message) + { + try + { + if (_log.IsDebugEnabled) + { + _log.Debug("璋冭瘯锛�" + message + "\r\n\r\n"); + } + } + catch + { + } + } + + /// <summary> + /// 淇℃伅 + /// </summary> + /// <param name="message">鏃ュ織</param> + public static void Info(string message) + { + try + { + if (_log.IsInfoEnabled) + { + _log.Info("淇℃伅锛�" + message + "\r\n\r\n"); + } + } + catch + { + } + } + + /// <summary> + /// 璀﹀憡 + /// </summary> + /// <param name="message">鏃ュ織</param> + public static void Warn(string message) + { + try + { + if (_log.IsWarnEnabled) + { + _log.Warn("璀﹀憡锛�" + message + "\r\n\r\n"); + } + } + catch + { + } + } + + /// <summary> + /// 閿欒 + /// </summary> + /// <param name="message">鏃ュ織</param> + public static void Error(string message) + { + try + { + if (_log.IsErrorEnabled) + { + _log.Error("閿欒锛�" + message + "\r\n\r\n"); + } + } + catch + { + } + } + + /// <summary> + /// 鑷村懡 + /// </summary> + /// <param name="message">鏃ュ織</param> + public static void Fatal(string message) + { + try + { + if (_log.IsFatalEnabled) + { + _log.Fatal("鑷村懡锛�" + message + "\r\n\r\n"); + } + } + catch + { + } + } + } +} diff --git a/DataLoader/DataLoader.csproj b/DataLoader/DataLoader.csproj index a5033bd..4f53b84 100644 --- a/DataLoader/DataLoader.csproj +++ b/DataLoader/DataLoader.csproj @@ -48,6 +48,10 @@ <Reference Include="CefSharp.Wpf, Version=108.4.130.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL"> <HintPath>..\packages\CefSharp.Wpf.108.4.130\lib\net452\CefSharp.Wpf.dll</HintPath> </Reference> + <Reference Include="log4net4, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>dll\log4net4.dll</HintPath> + </Reference> <Reference Include="Mono.Security"> <HintPath>..\JavaCode\DLL\Mono.Security.dll</HintPath> </Reference> @@ -88,6 +92,7 @@ <SubType>Code</SubType> </Compile> <Compile Include="CS\Importor.cs" /> + <Compile Include="CS\LogOut.cs" /> <Compile Include="CS\MD5Helper.cs" /> <Compile Include="Model\Tool.cs" /> <Compile Include="CS\ModelHandler.cs" /> @@ -121,6 +126,9 @@ <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> + <EmbeddedResource Include="Log.config"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> <None Include="packages.config"> <SubType>Designer</SubType> </None> @@ -144,6 +152,9 @@ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </EmbeddedResource> </ItemGroup> + <ItemGroup> + <Content Include="dll\log4net4.dll" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> diff --git a/DataLoader/Log.config b/DataLoader/Log.config new file mode 100644 index 0000000..38d4d47 --- /dev/null +++ b/DataLoader/Log.config @@ -0,0 +1,37 @@ +锘�<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <!--鏃ュ織閰嶇疆閮ㄥ垎--> + <configSections> + <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/> + </configSections> + <!--绔欑偣鏃ュ織閰嶇疆閮ㄥ垎--> + <log4net> + <root> + <!-- 鏃ュ織绛夌骇锛欰LL|DEBUG|INFO|WARN|ERROR|FATAL|OFF --> + <priority value="INFO"/> + <appender-ref ref="RollingFileAppender"/> + </root> + <appender name="TraceAppender" type="log4net.Appender.TraceAppender"> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%date%newline%message"/> + </layout> + </appender> + <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%date%newline%message"/> + </layout> + </appender> + <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> + <file value="log.txt"/> + <appendToFile value="true"/> + <maxSizeRollBackups value="5"/> + <maximumFileSize value="10MB"/> + <rollingStyle value="Size"/> + <staticLogFileName value="true"/> + <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%date%newline%message"/> + </layout> + </appender> + </log4net> +</configuration> \ No newline at end of file diff --git a/DataLoader/MainWindow.xaml b/DataLoader/MainWindow.xaml index 6aca7bf..9b73d3d 100644 --- a/DataLoader/MainWindow.xaml +++ b/DataLoader/MainWindow.xaml @@ -46,9 +46,9 @@ </Grid.ColumnDefinitions> <Label Grid.Row="0" Grid.Column="0" Content="鐢ㄦ埛ID锛�" VerticalAlignment="Center" HorizontalAlignment="Right" /> - <TextBox x:Name="tbUid" Grid.Row="0" Grid.Column="1" Style="{StaticResource tb}" IsReadOnly="True"/> + <TextBox x:Name="tbUid" Grid.Row="0" Grid.Column="1" Style="{StaticResource tb}"/> <Label Grid.Row="0" Grid.Column="2" Content="浠ょ墝锛�" VerticalAlignment="Center" HorizontalAlignment="Right" /> - <TextBox x:Name="tbToken" Grid.Row="0" Grid.Column="3" Style="{StaticResource tb}" IsReadOnly="True"/> + <TextBox x:Name="tbToken" Grid.Row="0" Grid.Column="3" Style="{StaticResource tb}"/> <Button Grid.Row="0" Grid.Column="4" Content="鐧� 褰�" Style="{StaticResource btn}" Click="Login_MouseLeftButtonDown"/> <Label Grid.Row="1" Grid.Column="0" Content="鏁版嵁鐩綍锛�" VerticalAlignment="Center" HorizontalAlignment="Right" /> diff --git a/DataLoader/MainWindow.xaml.cs b/DataLoader/MainWindow.xaml.cs index 24228ef..dbda5b5 100644 --- a/DataLoader/MainWindow.xaml.cs +++ b/DataLoader/MainWindow.xaml.cs @@ -22,9 +22,9 @@ public event PropertyChangedEventHandler PropertyChanged; - private string _sourcePath = "D:\\opting\\寰楁枃鏁版嵁"; // "D:\\LF\\data\\mdb"; + private string _sourcePath = @"D:\LF\data\mdb"; - private string _targetPath = "D:\\LF\\upload"; + private string _targetPath = @"\\LAPTOP-DRTGLTU2\share"; private LoginWin win; @@ -78,6 +78,7 @@ //String file = "E:\\data\\mpt\\A4mpt20131125.mpt"; //string md5 = MD5Helper.GetMD5Hash(file); + LogOut.Info("************ 搴旂敤绋嬪簭鍚姩鎴愬姛锛� ************"); } // 鐧诲綍 @@ -93,7 +94,7 @@ if (win != null) win.Close(); this.Show(); - this.tbUid.Text = Tool.UserId.ToString() + "-" + Tool.Uname; + this.tbUid.Text = Tool.UserId.ToString(); this.tbToken.Text = Tool.Token; this.btnLoad.IsEnabled = true; diff --git a/DataLoader/dll/log4net4.dll b/DataLoader/dll/log4net4.dll new file mode 100644 index 0000000..bffd524 --- /dev/null +++ b/DataLoader/dll/log4net4.dll Binary files differ diff --git a/DataLoader/htmls/login.html b/DataLoader/htmls/login.html index 54500a6..621c894 100644 --- a/DataLoader/htmls/login.html +++ b/DataLoader/htmls/login.html @@ -41,7 +41,7 @@ </section> </div> <script> - var url = "http://192.168.20.83:12316/server/"; + var url = "http://127.0.0.1:12316/server/"; var isBusy = false; diff --git a/ExportMap/js/insertFiles.js b/ExportMap/js/insertFiles.js index f773ff5..2cf4b6a 100644 --- a/ExportMap/js/insertFiles.js +++ b/ExportMap/js/insertFiles.js @@ -588,4 +588,121 @@ "type": "laz", "verid": 0 } -]; \ No newline at end of file +]; + +var dbFiles = [ + { + "createTime": null, + "createUser": 1, + "depid": 38, + "dirid": 163, + "entity": "dlg25wboul", + "epsgCode": "EPSG:4490", + "eventid": "19be2b93-937f-462b-bba0-e6882024ebe8", + "extName": ".gdb", + "guid": "6b59075f0ff6611b815616bedc8b6af3", + "msg": null, + "name": "pg.gdb", + "path": "20230127_zip\\test.gdb\\pg.gdb", + "rows": 0, + "sizes": 0.194, + "tab": "dlg_25w_boul", + "type": "gdb", + "verid": 0 + }, + { + "createTime": null, + "createUser": 1, + "depid": 38, + "dirid": 163, + "entity": "dlg25wresa", + "epsgCode": "EPSG:4490", + "eventid": "e6bcaff7-3777-45ec-b716-45458f648807", + "extName": ".gdb", + "guid": "6b59075f0ff6611b815616bedc8b6af3", + "msg": null, + "name": "pg.gdb", + "path": "20230127_zip\\test.gdb\\pg.gdb", + "rows": 0, + "sizes": 0.194, + "tab": "dlg_25w_resa", + "type": "gdb", + "verid": 0 + }, + { + "createTime": null, + "createUser": 1, + "depid": 38, + "dirid": 163, + "entity": "dlgagnp", + "epsgCode": "EPSG:4490", + "eventid": "17c6b466-01ff-47b9-b775-e6e4d25f7c7c", + "extName": ".gdb", + "guid": "6b59075f0ff6611b815616bedc8b6af3", + "msg": null, + "name": "pg.gdb", + "path": "20230127_zip\\test.gdb\\pg.gdb", + "rows": 0, + "sizes": 0.194, + "tab": "dlg_agnp", + "type": "gdb", + "verid": 0 + }, + { + "createTime": null, + "createUser": 1, + "depid": 38, + "dirid": 163, + "entity": "dlg25wboul", + "epsgCode": "EPSG:4490", + "eventid": "108f1f92-0722-4067-a442-10ee5b6c1cc2", + "extName": ".shp", + "guid": "d1da4cc853172da980dd36e9d8e26b24", + "msg": null, + "name": "dlg_25w_boul.shp", + "path": "20230127_zip\\test.shp\\pgShp\\dlg_25w_boul.shp", + "rows": 0, + "sizes": 0.003, + "tab": "dlg_25w_boul", + "type": "shp", + "verid": 0 + }, + { + "createTime": null, + "createUser": 1, + "depid": 38, + "dirid": 163, + "entity": "dlg25wresa", + "epsgCode": "EPSG:4490", + "eventid": "2e991281-f096-43a5-a4e8-4173c25b2891", + "extName": ".shp", + "guid": "44bb08c1a69b7ba2b3a8096e22d067f3", + "msg": null, + "name": "dlg_25w_resa.shp", + "path": "20230127_zip\\test.shp\\pgShp\\dlg_25w_resa.shp", + "rows": 0, + "sizes": 0.007, + "tab": "dlg_25w_resa", + "type": "shp", + "verid": 0 + }, + { + "createTime": null, + "createUser": 1, + "depid": 38, + "dirid": 163, + "entity": "dlgagnp", + "epsgCode": "EPSG:4490", + "eventid": "8fc608a9-71b7-4c5f-96e2-baeae26aeda6", + "extName": ".shp", + "guid": "20e9c84639279604e9539f8003a49747", + "msg": null, + "name": "dlg_agnp.shp", + "path": "20230127_zip\\test.shp\\pgShp\\dlg_agnp.shp", + "rows": 0, + "sizes": 0.001, + "tab": "dlg_agnp", + "type": "shp", + "verid": 0 + } +]; diff --git a/ExportMap/up.html b/ExportMap/up.html index d1c4137..e57d8b2 100644 --- a/ExportMap/up.html +++ b/ExportMap/up.html @@ -11,7 +11,7 @@ var app = {}; var path = "20230127"; var url = "http://127.0.0.1:12316/server/"; - var token = "87ce1d1e-3d83-4ffc-bf0d-312ecd823346"; + var token = "b2d58c3c-9d98-4e7f-a9c5-7682cc83bc38"; $(function () { $("#pathSpan").html(path); @@ -215,152 +215,9 @@ alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); }); } - - // Shp鍏ュ簱 - function insertShps() { - 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: [ - { - "entity": "dlg25wboul", - "fileName": "test.shp.zip", - "subPath": "20221128010101_zip\\test.shp\\pgShp\\dlg_25w_boul.shp", - "tab": "dlg_25w_boul.shp", - "type": "shp" - }, - { - "entity": "dlg25wresa", - "fileName": "test.shp.zip", - "subPath": "20221128010101_zip\\test.shp\\pgShp\\dlg_25w_resa.shp", - "tab": "dlg_25w_resa.shp", - "type": "shp" - }, - { - "entity": "dlgagnp", - "fileName": "test.shp.zip", - "subPath": "20221128010101_zip\\test.shp\\pgShp\\dlg_agnp.shp", - "tab": "dlg_agnp.shp", - "type": "shp" - }] - }; - - ajax(getUrl("dataLoader/insertFiles"), "POST", JSON.stringify(obj), null, null, function (rs) { - console.log(rs); - app.data = null; - alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); - }); - } - - // GDB鍏ュ簱 - function insertGdb() { - 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: [ - { - "entity": "dlg25wboul", - "fileName": "test.gdb.zip", - "subPath": "20221128010101_zip\\test.gdb\\pg.gdb", - "tab": "dlg_25w_boul", - "type": "gdb" - }, - { - "entity": "dlg25wresa", - "fileName": "test.gdb.zip", - "subPath": "20221128010101_zip\\test.gdb\\pg.gdb", - "tab": "dlg_25w_resa", - "type": "gdb" - }, - { - "entity": "dlgagnp", - "fileName": "test.gdb.zip", - "subPath": "20221128010101_zip\\test.gdb\\pg.gdb", - "tab": "dlg_agnp", - "type": "gdb" - }] - }; - - ajax(getUrl("dataLoader/insertFiles"), "POST", JSON.stringify(obj), null, null, function (rs) { - console.log(rs); - app.data = null; - alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); - }); - } - - // MDB - function insertMdb() { - 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: [ - { - "entity": "dlg25wboul", - "fileName": "test.mdb", - "subPath": "20221128010101\\test.mdb", - "tab": "dlg_25w_boul", - "type": "mdb" - }, - { - "entity": "dlg25wresa", - "fileName": "test.mdb", - "subPath": "20221128010101\\test.mdb", - "tab": "dlg_25w_resa", - "type": "mdb" - }/*, - { - "entity": "dlgagnp", - "fileName": "test.mdb", - "subPath": "20221128010101\\test.mdb", - "tab": "dlg_agnp", - "type": "mdb" - }*/] - }; - - ajax(getUrl("dataLoader/insertFiles"), "POST", JSON.stringify(obj), null, null, function (rs) { - console.log(rs); - app.data = null; - alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); - }); - } </script> <script> + // 涓婁紶闄勪欢 function uploadAttach() { var formData = new FormData(); var fs = document.getElementById("file3"); @@ -495,6 +352,24 @@ }); } + // 澶氭枃浠跺叆搴� + function insertMultiFiles() { + if (!app.mappers) return; + ajax(getUrl("dataUpload/insertFiles"), "POST", JSON.stringify(app.mappers), null, null, function (rs) { + console.log(rs); + app.mappers = null; + alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); + }); + } + + // 绌洪棿鏁版嵁鍏ュ簱 + function insertDbFiles() { + ajax(getUrl("dataUpload/insertFiles"), "POST", JSON.stringify(dbFiles), null, null, function (rs) { + console.log(rs); + alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); + }); + } + // 璇锋眰绠$嚎鍒嗘瀽 function selectPipeAnalysis() { var data = { @@ -541,12 +416,11 @@ <input value="涓婁紶鏂囦欢" type="button" onclick="uploadFiles2();" /> <input value="鏌ヨ鏂囦欢 *" type="button" onclick="selectFiles2();" /> <input value="鍒犻櫎鏂囦欢" type="button" onclick="deleteFiles2();" /> - <input value="璇诲彇鏄犲皠 *" type="button" onclick="readMappers();" /> <input value="Xls鍏ュ簱" type="button" onclick="insertXls();" /> - <input value="Shp鍏ュ簱" type="button" onclick="insertShps();" /> - <input value="Gdb鍏ュ簱" type="button" onclick="insertGdb();" /> - <input value="Mdb鍏ュ簱" type="button" onclick="insertMdb();" /> + <input value="璇诲彇鏄犲皠 *" type="button" onclick="readMappers();" /> <input value="缁煎悎鏁版嵁鍏ュ簱 *" type="button" onclick="insertAllFiles();" /> + <input value="绌洪棿鏁版嵁鍏ュ簱 *" type="button" onclick="insertDbFiles();" /> + <input value="澶氭枃浠跺叆搴� *" type="button" onclick="insertMultiFiles();" /> <hr /> <br /> -- Gitblit v1.9.3