浏览代码

升级Ava 11.1

宝臣 王 4 月之前
父节点
当前提交
84d3fe680c

+ 13 - 0
.idea/.idea.DutyApp/.idea/.gitignore

@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/contentModel.xml
+/modules.xml
+/projectSettingsUpdater.xml
+/.idea.DutyApp.iml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 10 - 0
.idea/.idea.DutyApp/.idea/avalonia.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AvaloniaProject">
+    <option name="projectPerEditor">
+      <map>
+        <entry key="DutyApp/Customs/MessageBox.axaml" value="DutyApp/DutyApp.csproj" />
+      </map>
+    </option>
+  </component>
+</project>

+ 6 - 0
.idea/.idea.DutyApp/.idea/encodings.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise">
+    <file url="file://$PROJECT_DIR$/DutyApp/Customs/MessageBox.axaml.cs" charset="GBK" />
+  </component>
+</project>

+ 8 - 0
.idea/.idea.DutyApp/.idea/indexLayout.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="UserContentModel">
+    <attachedFolders />
+    <explicitIncludes />
+    <explicitExcludes />
+  </component>
+</project>

+ 17 - 0
.idea/.idea.DutyApp/.idea/material_theme_project_new.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="MaterialThemeProjectNewConfig">
+    <option name="metadata">
+      <MTProjectMetadataState>
+        <option name="migrated" value="true" />
+        <option name="pristineConfig" value="false" />
+        <option name="userId" value="-73138849:190773b7b86:-7ffc" />
+      </MTProjectMetadataState>
+    </option>
+    <option name="titleBarState">
+      <MTProjectTitleBarConfigState>
+        <option name="overrideColor" value="false" />
+      </MTProjectTitleBarConfigState>
+    </option>
+  </component>
+</project>

+ 6 - 0
.idea/.idea.DutyApp/.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 7 - 1
DutyApp/Data/DutyContext.cs

@@ -1,9 +1,11 @@
-using System.IO;
+using System.Diagnostics;
+using System.IO;
 using DutyApp.Models;
 
 using Microsoft.EntityFrameworkCore;
 
 using System.Reflection;
+using Microsoft.Extensions.Logging;
 
 namespace DutyApp.Data
 {
@@ -29,6 +31,10 @@ namespace DutyApp.Data
 
             var currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
             optionsBuilder.UseSqlite($"Data Source={currentPath}/DutyApp.db");
+
+            optionsBuilder
+                .LogTo(message => Debug.WriteLine(message), LogLevel.Information)
+                .EnableSensitiveDataLogging();
         }
 
         protected override void OnModelCreating(ModelBuilder modelBuilder)

+ 5 - 5
DutyApp/DutyApp.csproj

@@ -44,14 +44,14 @@
 	</ItemGroup>
 
 	<ItemGroup>
-		<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.11" />
-		<PackageReference Include="Avalonia.Desktop" Version="11.0.11" />
+		<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.1.0" />
+		<PackageReference Include="Avalonia.Desktop" Version="11.1.0" />
 		<PackageReference Include="Avalonia.Labs.Controls" Version="11.0.10.1" />
-		<PackageReference Include="Avalonia.Svg.Skia" Version="11.0.0.18" />
-		<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.11" />
+		<PackageReference Include="Avalonia.Svg.Skia" Version="11.1.0" />
+		<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0" />
 		<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
 		<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.11" />
-		<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.10.9" />
+		<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0" />
 		<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
 		<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.6" />
 		<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.20" />

+ 23 - 1
DutyApp/ViewModels/InformationViewModel.cs

@@ -150,7 +150,8 @@ namespace DutyApp.ViewModels
                     .DefaultIfEmpty()
                     .FirstOrDefaultAsync();
 
-                var dailyDuty = await _dutyContext.Information.Include(x => x.DailyNews)
+                var dailyDuty = await _dutyContext.Information
+                    .Include(x => x.DailyNews)
                     .FirstOrDefaultAsync(x => x.Date == maxDate);
 
                 if (dailyDuty == null)
@@ -159,6 +160,21 @@ namespace DutyApp.ViewModels
                     return;
                 }
 
+                if (_information != null)
+                {
+                    var result = await MessageBox.Show("导入上次值班信息记录会删除当前信息", "警告", MessageBoxButtons.YesNoCancel);
+                    if (result == MessageBoxResult.Cancel) { return; }
+
+                    var info = await _dutyContext.Information.FirstOrDefaultAsync(x => x.Id == _information.Id);
+                    if (info != null)
+                    {
+                        _dutyContext.Information.Remove(info);
+                        await _dutyContext.SaveChangesAsync();
+
+                        _information = null;
+                    }
+                }
+
                 var temp = dailyDuty.Temperature.Split('>');
                 MaxTemp = int.Parse(temp[1]);
                 MinTemp = int.Parse(temp[0]);
@@ -214,6 +230,12 @@ namespace DutyApp.ViewModels
         {
             if (_dutyContext == null) return;
 
+            if (MaxTemp < MinTemp)
+            {
+                await MessageBox.Show("最高温度不能小于最低温度");
+                return;
+            }
+
             for (var index = 0; index < DailyNews.Count; index++)
             {
                 var dailyNew = DailyNews[index];