mirror of
http://git.xinwangdao.com/cnnc-embedded-parts-detect/detect.git
synced 2025-06-24 05:24:12 +08:00
fixed
This commit is contained in:
parent
68928a0f41
commit
c11b68ed7c
1
.idea/.idea.detect/.idea/avalonia.xml
generated
1
.idea/.idea.detect/.idea/avalonia.xml
generated
@ -12,6 +12,7 @@
|
||||
<entry key="detect.gui/Views/DetectTaskView.axaml" value="detect.gui/detect.gui.csproj" />
|
||||
<entry key="detect.gui/Views/DeviceView.axaml" value="detect.gui/detect.gui.csproj" />
|
||||
<entry key="detect.gui/Views/HomeView.axaml" value="detect.gui/detect.gui.csproj" />
|
||||
<entry key="detect.gui/Views/ImportWindow.axaml" value="detect.gui/detect.gui.csproj" />
|
||||
<entry key="detect.gui/Views/LogView.axaml" value="detect.gui/detect.gui.csproj" />
|
||||
<entry key="detect.gui/Views/MainView.axaml" value="detect.gui/detect.gui.csproj" />
|
||||
<entry key="detect.gui/Views/MainWindow.axaml" value="detect.gui/detect.gui.csproj" />
|
||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using detect.device;
|
||||
using detect.gui.Commons;
|
||||
using detect.gui.Models.Entities;
|
||||
using detect.gui.Services.Detect;
|
||||
using Serilog;
|
||||
@ -143,8 +142,8 @@ public class DeviceClientService
|
||||
Log.Information("DeviceEvent-[{Name}]-{Address}:{@Result}", e.Name, (sender as DeviceClientSocket)!.Address, e.Result);
|
||||
if (e.Name == detect.device.DeviceEvent.EventDeviceConnected)
|
||||
{
|
||||
var sysInfo = GetDeviceInfo(1).GetAwaiter().GetResult();
|
||||
Log.Information("device info: {@Info}", sysInfo);
|
||||
// var sysInfo = GetDeviceInfo(1).GetAwaiter().GetResult();
|
||||
// Log.Information("device info: {@Info}", sysInfo);
|
||||
// test
|
||||
// AssignTasks(new long[] { 1 }).GetAwaiter();
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Platform;
|
||||
using detect.gui.Services;
|
||||
@ -24,13 +23,14 @@ public partial class WebBrowserWindow : Window
|
||||
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
|
||||
ExtendClientAreaTitleBarHeightHint = -1;
|
||||
SystemDecorations = SystemDecorations.None;
|
||||
ShowInTaskbar = false;
|
||||
Topmost = true;
|
||||
// ShowInTaskbar = false;
|
||||
// Topmost = true;
|
||||
CanResize = false;
|
||||
|
||||
var webview = this.Get<WebView>("WebView");
|
||||
var service = Locator.Current.GetService<DeviceClientService>();
|
||||
webview.RegisterJavascriptObject("DeviceClientService", service);
|
||||
webview.RegisterJavascriptObject("WebViewService", new WebViewService(this));
|
||||
Log.Information("WebView Initialized.");
|
||||
}
|
||||
|
||||
|
68
detect.gui/Views/WebViewService.cs
Normal file
68
detect.gui/Views/WebViewService.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Text.Unicode;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using OfficeOpenXml;
|
||||
|
||||
namespace detect.gui.Views;
|
||||
|
||||
public class WebViewService(Window? w)
|
||||
{
|
||||
public Window? Self { get; set; } = w;
|
||||
|
||||
[Obsolete("过时的")]
|
||||
public async Task<string?> ImportExcel()
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Title = "打开文件",
|
||||
AllowMultiple = false,
|
||||
Filters =
|
||||
[
|
||||
new FileDialogFilter { Name = "Excel Files", Extensions = { "*.xls; *.xlsx" } }
|
||||
]
|
||||
};
|
||||
var result = await dialog.ShowAsync(Self!);
|
||||
if (result is not { Length: 1 }) return null;
|
||||
try
|
||||
{
|
||||
var ccc = ConvertExcelToJson(result[0]);
|
||||
return ConvertExcelToJson(result[0]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ConvertExcelToJson(string excelFilePath)
|
||||
{
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
var fileInfo = new FileInfo(excelFilePath);
|
||||
using var package = new ExcelPackage(fileInfo);
|
||||
var worksheet = package.Workbook.Worksheets[0];
|
||||
var rowCount = worksheet.Dimension.Rows;
|
||||
var colCount = worksheet.Dimension.Columns;
|
||||
|
||||
var data = new List<Dictionary<string, object>>();
|
||||
var headers = Enumerable.Range(1, colCount)
|
||||
.Select(col => worksheet.Cells[1, col].Text)
|
||||
.ToList();
|
||||
for (var row = 2; row <= rowCount; row++)
|
||||
{
|
||||
var rowData = new Dictionary<string, object>();
|
||||
for (var col = 1; col <= colCount; col++)
|
||||
{
|
||||
rowData[headers[col - 1]] = worksheet.Cells[row, col].Text;
|
||||
}
|
||||
|
||||
data.Add(rowData);
|
||||
}
|
||||
return JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = true, Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) });
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="OfficeOpenXml.Extension.AspNetCore" Version="1.0.0" />
|
||||
<PackageReference Include="RestSharp" Version="112.0.0" />
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
|
@ -4,6 +4,9 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AControl_002Ecs_002Fl_003AC_0021_003FUsers_003Fxiongwei_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Ff963a2a29ea2bb2d4ad8737293b45c4edbd94e55219dc42cf68343d6d91d9_003FControl_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADependencyResolverMixins_002Ecs_002Fl_003AC_0021_003FUsers_003FNick_0020Wang_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fca0d4592dc494bbaa872fd9db942335922638_003Ff9_003Fb0105fc3_003FDependencyResolverMixins_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExecutionContext_002Ecs_002Fl_003AC_0021_003FUsers_003FNick_0020Wang_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F9eda537f15ea23cdfae523c19e87eb303a3ded88937ae7e55919387a43f70_003FExecutionContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileDialogFilter_002Ecs_002Fl_003AC_0021_003FUsers_003FNick_0020Wang_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8c5be7826d6a434f911dfe811b698519eca00_003F96_003F3ad872d1_003FFileDialogFilter_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFilePickerFileType_002Ecs_002Fl_003AC_0021_003FUsers_003FNick_0020Wang_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fba3ea9c1caf09c71e5e1a6f29cc110e55f6baaeffa8a3c2a8743035da53a0ce_003FFilePickerFileType_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFilePickerOpenOptions_002Ecs_002Fl_003AC_0021_003FUsers_003FNick_0020Wang_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F64c077c15772bb4c699bdf49a561c536eb480867eabb4544519519e287c16_003FFilePickerOpenOptions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonSerializerInternalReader_002Ecs_002Fl_003AC_0021_003FUsers_003FNick_0020Wang_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F29ea32a76b2a6b8eb246f247df6a6a86d887384b4c31db2a35effccdd86c24_003FJsonSerializerInternalReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonStringEnumConverter_002Ecs_002Fl_003AC_0021_003FUsers_003Fxiongwei_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe8fd44bb4fe5af449849853612f32962e78c0e82a7b6a4307a7bcae61a547a_003FJsonStringEnumConverter_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMethodBaseInvoker_002Ecs_002Fl_003AC_0021_003FUsers_003FNick_0020Wang_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fd882146b4f265f10bcbec2663fce248db9ffec5fa1aeaf76e32a11ba5eafcd6_003FMethodBaseInvoker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
Loading…
Reference in New Issue
Block a user