浏览代码

添加年配置项

yuanrf 4 月之前
父节点
当前提交
15b64ad2dd
共有 3 个文件被更改,包括 10 次插入2 次删除
  1. 3 0
      travelExport/App.config
  2. 6 2
      travelExport/Home.cs
  3. 1 0
      travelExport/travelExport.csproj

+ 3 - 0
travelExport/App.config

@@ -16,6 +16,9 @@
       <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
     </providers>
   </entityFramework>
+	<appSettings>
+		<add key="ConfigYear" value="2025"/>
+	</appSettings>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>

+ 6 - 2
travelExport/Home.cs

@@ -16,6 +16,7 @@ using System.Threading;
 using travelExport.utility;
 using DiffMatchPatch;
 using Aspose.Words.Tables;
+using System.Configuration;
 
 namespace travelExport
 {
@@ -2539,8 +2540,11 @@ namespace travelExport
                                 int month = Convert.ToInt32(GetLonger(monthEn));
                                 //日
                                 int day = Convert.ToInt32(Info[1].Substring(2, 2));
-
-                                var time = new DateTime(2024, month, day); //
+                                //年
+                                string ConfigYear = ConfigurationManager.AppSettings["ConfigYear"];
+                                int YearInt = DateTime.Now.Year;
+                                int.TryParse(ConfigYear, out YearInt);
+                                var time = new DateTime(YearInt, month, day); 
 
                                 var isExist = Info.Contains("[中转]");
                                 if (!isExist)

+ 1 - 0
travelExport/travelExport.csproj

@@ -50,6 +50,7 @@
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Configuration" />
     <Reference Include="System.Core" />
     <Reference Include="System.Runtime.Serialization" />
     <Reference Include="System.Security" />