137 lines
4.5 KiB
Plaintext
137 lines
4.5 KiB
Plaintext
@page "/init"
|
|
@using MasaBlazorApp3.Pojo.Config;
|
|
@using MasaBlazorApp3.Pojo.Vo;
|
|
@using MasaBlazorApp3.Util;
|
|
@using Microsoft.Extensions.Options;
|
|
@using Newtonsoft.Json;
|
|
@using log4net;
|
|
|
|
<RadzenStack AlignItems="AlignItems.Center" Gap="2rem" class="rz-p-12">
|
|
<RadzenImage Path="images/community.svg" Style="width: 200px;" AlternateText="community" />
|
|
<RadzenText TextStyle="TextStyle.H6">@myText.Loading</RadzenText>
|
|
<RadzenText TextStyle="TextStyle.H6">@msg</RadzenText>
|
|
<RadzenText TextStyle="TextStyle.H6">@errMsg</RadzenText>
|
|
</RadzenStack>
|
|
|
|
@code {
|
|
@inject Radzen.DialogService dialogService;
|
|
@inject IOptions<DrawerConfig> setting;
|
|
@inject NotificationService _message;
|
|
@inject PortUtil PortUtil;
|
|
@inject FingerprintUtil FingerprintUtil;
|
|
@inject GlobalStateService globalStateService;
|
|
@inject IOptions<PortConfig> portSetting;
|
|
|
|
@inject Toolbelt.Blazor.I18nText.I18nText I18nText;
|
|
private I18nText.local myText = new I18nText.local();
|
|
|
|
string msg;
|
|
string errMsg;
|
|
|
|
private readonly ILog logger = LogManager.GetLogger(typeof(InitPage));
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
myText = await I18nText.GetTextTableAsync<I18nText.local>(this);
|
|
base.OnInitializedAsync();
|
|
}
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
base.OnAfterRender(firstRender);
|
|
|
|
if (firstRender)
|
|
{
|
|
await Task.Delay(15);
|
|
msg = myText.ConnectFinger;
|
|
InvokeAsync(StateHasChanged);
|
|
try
|
|
{
|
|
bool flag=await FingerprintUtil.ConnectionMain();
|
|
if (flag)
|
|
{
|
|
msg = myText.FingerConnected;
|
|
}
|
|
else
|
|
{
|
|
msg = myText.FingerFailed;
|
|
}
|
|
InvokeAsync(StateHasChanged);
|
|
} catch (Exception e)
|
|
{
|
|
msg = myText.FingerFailed;
|
|
errMsg += "【" + myText .FingerFailed+ "】";
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(500);
|
|
msg = myText.ConnectDrawer;
|
|
InvokeAsync(StateHasChanged);
|
|
try
|
|
{
|
|
PortUtil.drawerSerial.Open();
|
|
logger.Info($"抽屉串口打开结果【{PortUtil.drawerSerial.IsOpen}】");
|
|
msg = myText.DrawerConnected;
|
|
InvokeAsync(StateHasChanged);
|
|
} catch (Exception e)
|
|
{
|
|
msg = myText.DrawerFailed;
|
|
errMsg += "【"+myText.DrawerFailed+"】";
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(500);
|
|
msg = myText.ConnectCan;
|
|
InvokeAsync(StateHasChanged);
|
|
try
|
|
{
|
|
PortUtil.canBusSerial.Open();
|
|
logger.Info($"CanBus模块打开结果【{PortUtil.canBusSerial.IsOpen}】");
|
|
msg = myText.CanConnected;
|
|
InvokeAsync(StateHasChanged);
|
|
} catch (Exception e)
|
|
{
|
|
msg = myText.CanFailed;
|
|
errMsg += "【"+myText.CanFailed+"】";
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
await Task.Delay(500);
|
|
msg = myText.ConnectScanCode;
|
|
InvokeAsync(StateHasChanged);
|
|
try
|
|
{
|
|
PortUtil.scanCodeSerial.Open();
|
|
logger.Info($"条码扫描模块打开结果【{PortUtil.scanCodeSerial.IsOpen}】");
|
|
msg = myText.ScanCodeConnected;
|
|
InvokeAsync(StateHasChanged);
|
|
} catch (Exception e)
|
|
{
|
|
msg = myText.ScanCodeFailed;
|
|
errMsg += "【" + myText.ScanCodeFailed + "】";
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
if (portSetting.Value.fridgePortExist)
|
|
{
|
|
try
|
|
{
|
|
PortUtil.fridgeSerial.Open();
|
|
logger.Info($"冰箱串口打开结果【{PortUtil.fridgeSerial.IsOpen}】");
|
|
msg = myText.FridgeConnected;
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
msg = myText.FridgeFailed;
|
|
errMsg += "【"+ myText.FridgeFailed+"】";
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|
|
globalStateService.isInit = true;
|
|
dialogService.Close();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|