From 0747d6d46796671408d6325f664be3404f57aaa6 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 18 七月 2024 14:15:11 +0800 Subject: [PATCH] 添加工具类 --- SimuTools/dlls/log4net4.dll | 0 SimuTools/dlls/osr_wrap.dll | 0 SimuTools/SimuTools.csproj | 26 ++++ SimuTools/dlls/gdal_csharp.dll | 0 SimuTools/dlls/gdalconst_csharp.dll | 0 SimuTools/App.config | 13 + SimuTools/dlls/osr_csharp.dll | 0 SimuTools/dlls/ogr_wrap.dll | 0 SimuTools/FrmMain.cs | 8 + SimuTools/Properties/Resources.Designer.cs | 52 +++----- SimuTools/dlls/gdal_wrap.dll | 0 SimuTools/FrmMain.Designer.cs | 19 -- SimuTools/Log.config | 37 ++++++ SimuTools/Tools/LogOut.cs | 132 ++++++++++++++++++++++ SimuTools/dlls/gdalconst_wrap.dll | 0 SimuTools/dlls/ogr_csharp.dll | 0 SimuTools/Properties/Settings.Designer.cs | 28 ++-- 17 files changed, 246 insertions(+), 69 deletions(-) diff --git a/SimuTools/App.config b/SimuTools/App.config index 88fa402..57493a4 100644 --- a/SimuTools/App.config +++ b/SimuTools/App.config @@ -1,6 +1,9 @@ -锘�<?xml version="1.0" encoding="utf-8" ?> +锘�<?xml version="1.0"?> <configuration> - <startup> - <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> - </startup> -</configuration> \ No newline at end of file + <appSettings> + <add key="sizes" value="64,128,256,512,1024,2048"/> + </appSettings> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> + </startup> +</configuration> diff --git a/SimuTools/FrmMain.Designer.cs b/SimuTools/FrmMain.Designer.cs index 953b7bd..edb2709 100644 --- a/SimuTools/FrmMain.Designer.cs +++ b/SimuTools/FrmMain.Designer.cs @@ -37,7 +37,6 @@ this.txtFlowPath = new System.Windows.Forms.TextBox(); this.lblFlow = new System.Windows.Forms.Label(); this.btnFlowPath = new System.Windows.Forms.Button(); - this.tabLogs = new System.Windows.Forms.ListBox(); this.btnRun = new System.Windows.Forms.Button(); this.SuspendLayout(); // @@ -134,22 +133,11 @@ this.btnFlowPath.UseVisualStyleBackColor = true; this.btnFlowPath.Click += new System.EventHandler(this.btnFlowPath_Click); // - // tabLogs - // - this.tabLogs.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.tabLogs.FormattingEnabled = true; - this.tabLogs.ItemHeight = 16; - this.tabLogs.Location = new System.Drawing.Point(27, 176); - this.tabLogs.Name = "tabLogs"; - this.tabLogs.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple; - this.tabLogs.Size = new System.Drawing.Size(670, 340); - this.tabLogs.TabIndex = 56; - // // btnRun // this.btnRun.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnRun.ForeColor = System.Drawing.SystemColors.Highlight; - this.btnRun.Location = new System.Drawing.Point(27, 540); + this.btnRun.Location = new System.Drawing.Point(27, 172); this.btnRun.Name = "btnRun"; this.btnRun.Size = new System.Drawing.Size(670, 26); this.btnRun.TabIndex = 57; @@ -161,9 +149,8 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(735, 594); + this.ClientSize = new System.Drawing.Size(735, 222); this.Controls.Add(this.btnRun); - this.Controls.Add(this.tabLogs); this.Controls.Add(this.txtFlowPath); this.Controls.Add(this.lblFlow); this.Controls.Add(this.btnFlowPath); @@ -176,6 +163,7 @@ this.Name = "FrmMain"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "鍐呮稘浠跨湡宸ュ叿"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing); this.Load += new System.EventHandler(this.FrmMain_Load); this.ResumeLayout(false); this.PerformLayout(); @@ -193,7 +181,6 @@ private System.Windows.Forms.TextBox txtFlowPath; private System.Windows.Forms.Label lblFlow; private System.Windows.Forms.Button btnFlowPath; - private System.Windows.Forms.ListBox tabLogs; private System.Windows.Forms.Button btnRun; } } diff --git a/SimuTools/FrmMain.cs b/SimuTools/FrmMain.cs index 3cb3d5c..c81923b 100644 --- a/SimuTools/FrmMain.cs +++ b/SimuTools/FrmMain.cs @@ -1,4 +1,5 @@ -锘縰sing System; +锘縰sing SimuTools.Tools; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -19,7 +20,12 @@ private void FrmMain_Load(object sender, EventArgs e) { + LogOut.Info("鍚姩绋嬪簭..."); + } + private void FrmMain_FormClosing(object sender, FormClosingEventArgs e) + { + LogOut.Info("鍏抽棴绋嬪簭..."); } private void btnTerrainPath_Click(object sender, EventArgs e) diff --git a/SimuTools/Log.config b/SimuTools/Log.config new file mode 100644 index 0000000..38d4d47 --- /dev/null +++ b/SimuTools/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/SimuTools/Properties/Resources.Designer.cs b/SimuTools/Properties/Resources.Designer.cs index 8d1ae97..2470628 100644 --- a/SimuTools/Properties/Resources.Designer.cs +++ b/SimuTools/Properties/Resources.Designer.cs @@ -1,17 +1,17 @@ 锘�//------------------------------------------------------------------------------ // <auto-generated> // 姝や唬鐮佺敱宸ュ叿鐢熸垚銆� -// 杩愯鏃剁増鏈�: 4.0.30319.42000 +// 杩愯鏃剁増鏈�:4.0.30319.42000 // // 瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋� -// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢涓㈠け銆� +// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢浼氫涪澶便�� // </auto-generated> //------------------------------------------------------------------------------ -namespace SimuTools.Properties -{ - - +namespace SimuTools.Properties { + using System; + + /// <summary> /// 涓�涓己绫诲瀷鐨勮祫婧愮被锛岀敤浜庢煡鎵炬湰鍦板寲鐨勫瓧绗︿覆绛夈�� /// </summary> @@ -22,48 +22,40 @@ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// <summary> - /// 杩斿洖姝ょ被浣跨敤鐨勩�佺紦瀛樼殑 ResourceManager 瀹炰緥銆� + /// 杩斿洖姝ょ被浣跨敤鐨勭紦瀛樼殑 ResourceManager 瀹炰緥銆� /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SimuTools.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// <summary> - /// 涓烘墍鏈夎祫婧愭煡鎵鹃噸鍐欏綋鍓嶇嚎绋嬬殑 CurrentUICulture 灞炴�э紝 - /// 鏂规硶鏄娇鐢ㄦ寮虹被鍨嬭祫婧愮被銆� + /// 浣跨敤姝ゅ己绫诲瀷璧勬簮绫伙紝涓烘墍鏈夎祫婧愭煡鎵� + /// 閲嶅啓褰撳墠绾跨▼鐨� CurrentUICulture 灞炴�с�� /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/SimuTools/Properties/Settings.Designer.cs b/SimuTools/Properties/Settings.Designer.cs index 36af658..582827e 100644 --- a/SimuTools/Properties/Settings.Designer.cs +++ b/SimuTools/Properties/Settings.Designer.cs @@ -1,28 +1,24 @@ 锘�//------------------------------------------------------------------------------ // <auto-generated> -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 姝や唬鐮佺敱宸ュ叿鐢熸垚銆� +// 杩愯鏃剁増鏈�:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋� +// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢浼氫涪澶便�� // </auto-generated> //------------------------------------------------------------------------------ -namespace SimuTools.Properties -{ - - +namespace SimuTools.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/SimuTools/SimuTools.csproj b/SimuTools/SimuTools.csproj index 89db344..0a9e3ba 100644 --- a/SimuTools/SimuTools.csproj +++ b/SimuTools/SimuTools.csproj @@ -9,8 +9,9 @@ <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>SimuTools</RootNamespace> <AssemblyName>SimuTools</AssemblyName> - <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> + <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> + <TargetFrameworkProfile /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> @@ -32,6 +33,10 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="log4net4, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>dlls\log4net4.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> @@ -52,6 +57,7 @@ </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Tools\LogOut.cs" /> <EmbeddedResource Include="FrmMain.resx"> <DependentUpon>FrmMain.cs</DependentUpon> </EmbeddedResource> @@ -63,7 +69,11 @@ <Compile Include="Properties\Resources.Designer.cs"> <AutoGen>True</AutoGen> <DependentUpon>Resources.resx</DependentUpon> + <DesignTime>True</DesignTime> </Compile> + <EmbeddedResource Include="Log.config"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> @@ -77,6 +87,20 @@ <ItemGroup> <None Include="App.config" /> </ItemGroup> + <ItemGroup> + <Content Include="dlls\gdalconst_csharp.dll" /> + <Content Include="dlls\gdalconst_wrap.dll" /> + <Content Include="dlls\gdal_csharp.dll" /> + <Content Include="dlls\gdal_wrap.dll" /> + <Content Include="dlls\log4net4.dll" /> + <Content Include="dlls\ogr_csharp.dll" /> + <Content Include="dlls\ogr_wrap.dll" /> + <Content Include="dlls\osr_csharp.dll" /> + <Content Include="dlls\osr_wrap.dll" /> + </ItemGroup> + <ItemGroup> + <Folder Include="Domain\" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/SimuTools/Tools/LogOut.cs b/SimuTools/Tools/LogOut.cs new file mode 100644 index 0000000..cd78d39 --- /dev/null +++ b/SimuTools/Tools/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 SimuTools.Tools +{ + /// <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/SimuTools/dlls/gdal_csharp.dll b/SimuTools/dlls/gdal_csharp.dll new file mode 100644 index 0000000..e64ba94 --- /dev/null +++ b/SimuTools/dlls/gdal_csharp.dll Binary files differ diff --git a/SimuTools/dlls/gdal_wrap.dll b/SimuTools/dlls/gdal_wrap.dll new file mode 100644 index 0000000..71c441b --- /dev/null +++ b/SimuTools/dlls/gdal_wrap.dll Binary files differ diff --git a/SimuTools/dlls/gdalconst_csharp.dll b/SimuTools/dlls/gdalconst_csharp.dll new file mode 100644 index 0000000..32e34e0 --- /dev/null +++ b/SimuTools/dlls/gdalconst_csharp.dll Binary files differ diff --git a/SimuTools/dlls/gdalconst_wrap.dll b/SimuTools/dlls/gdalconst_wrap.dll new file mode 100644 index 0000000..9c8c331 --- /dev/null +++ b/SimuTools/dlls/gdalconst_wrap.dll Binary files differ diff --git a/SimuTools/dlls/log4net4.dll b/SimuTools/dlls/log4net4.dll new file mode 100644 index 0000000..bffd524 --- /dev/null +++ b/SimuTools/dlls/log4net4.dll Binary files differ diff --git a/SimuTools/dlls/ogr_csharp.dll b/SimuTools/dlls/ogr_csharp.dll new file mode 100644 index 0000000..1a0f6fa --- /dev/null +++ b/SimuTools/dlls/ogr_csharp.dll Binary files differ diff --git a/SimuTools/dlls/ogr_wrap.dll b/SimuTools/dlls/ogr_wrap.dll new file mode 100644 index 0000000..f451299 --- /dev/null +++ b/SimuTools/dlls/ogr_wrap.dll Binary files differ diff --git a/SimuTools/dlls/osr_csharp.dll b/SimuTools/dlls/osr_csharp.dll new file mode 100644 index 0000000..d425841 --- /dev/null +++ b/SimuTools/dlls/osr_csharp.dll Binary files differ diff --git a/SimuTools/dlls/osr_wrap.dll b/SimuTools/dlls/osr_wrap.dll new file mode 100644 index 0000000..6d5a86c --- /dev/null +++ b/SimuTools/dlls/osr_wrap.dll Binary files differ -- Gitblit v1.9.3