Просмотр исходного кода

ParseBlackTime
飞行时间处理 小时分钟包含小写、大写 转换为中文

Lyyyi дней назад: 4
Родитель
Сommit
1ac3a42aa6

BIN
travelExport/Fakes/JsonDiffPatchDotNet.fakes


+ 15 - 22
travelExport/Home.cs

@@ -1457,7 +1457,6 @@ namespace travelExport
                                 //团组餐食信息
                                 var listMeal = db.Grp_RestaurantInfo.Where(x => x.GroupId == diid && x.IsDel == 0).ToList();
 
-
                                 Grp_HotelReservations lastHotel = null;
 
                                 foreach (var item in timeArr)
@@ -1518,7 +1517,6 @@ namespace travelExport
                                         Res_ThreeCode start_Object = null;
                                         Res_ThreeCode end_Object = null;
 
-
                                         foreach (var tabRow in tabSelect)
                                         {
                                             if (nextDayNum == 0)
@@ -3385,35 +3383,30 @@ namespace travelExport
 
         string ParseBlackTime(string time)
         {
-            // 匹配可能只有分钟的情况
-            string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
-            Match match = Regex.Match(time, pattern);
+            if (string.IsNullOrWhiteSpace(time))
+                return "未知时长";
 
-            if (match.Success)
+            string pattern = @"^(?:(\d+)[Hh])?(?:(\d+)[Mm])?$";
+            Match match = Regex.Match(time, pattern, RegexOptions.IgnoreCase);
+
+            if (match.Success && match.Length > 0)
             {
                 string hours = match.Groups[1].Value;
                 string minutes = match.Groups[2].Value;
 
-                // 如果小时部分为空,则只显示分钟
+                if (string.IsNullOrEmpty(hours) && string.IsNullOrEmpty(minutes))
+                    return "未知时长";
+
                 if (string.IsNullOrEmpty(hours))
-                {
                     return $"{minutes}分钟";
-                }
-                // 如果分钟部分为空,则只显示小时
-                else if (string.IsNullOrEmpty(minutes))
-                {
+
+                if (string.IsNullOrEmpty(minutes))
                     return $"{hours}小时";
-                }
-                // 否则显示完整格式
-                else
-                {
-                    return $"{hours}小时{minutes}分钟";
-                }
-            }
-            else
-            {
-                return "未知时长";
+
+                return $"{hours}小时{minutes}分钟";
             }
+
+            return "未知时长";
         }
 
         string ExtractDigitsBeforeDecimal(string input)

+ 1 - 0
travelExport/packages.config

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="Aspose.Words" version="15.1.0" targetFramework="net472" />
   <package id="EntityFramework" version="6.2.0" targetFramework="net472" />
   <package id="EntityFramework.zh-Hans" version="6.2.0" targetFramework="net472" />
   <package id="JsonDiffPatch.Net" version="2.3.0" targetFramework="net472" />

+ 10 - 2
travelExport/travelExport.csproj

@@ -55,8 +55,9 @@
   </PropertyGroup>
   <PropertyGroup />
   <ItemGroup>
-    <Reference Include="Aspose.Words">
-      <HintPath>..\packages\Aspose.Words.dll</HintPath>
+    <Reference Include="Aspose.Words, Version=15.12.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>bin\Debug\Aspose.Words.dll</HintPath>
     </Reference>
     <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
       <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
@@ -67,6 +68,12 @@
     <Reference Include="JsonDiffPatchDotNet, Version=2.3.0.0, Culture=neutral, PublicKeyToken=a407b9994a6d66d5, processorArchitecture=MSIL">
       <HintPath>..\packages\JsonDiffPatch.Net.2.3.0\lib\net45\JsonDiffPatchDotNet.dll</HintPath>
     </Reference>
+    <Reference Include="JsonDiffPatchDotNet.Fakes">
+      <HintPath>FakesAssemblies\JsonDiffPatchDotNet.Fakes.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
     <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
@@ -601,6 +608,7 @@
     <None Include="DB.edmx.diagram">
       <DependentUpon>DB.edmx</DependentUpon>
     </None>
+    <Fakes Include="Fakes\JsonDiffPatchDotNet.fakes" />
     <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>