Files
KinginfoGateway/framework/UpgradeManger/ThingsGateway.UpgradeManger/Pages/UpgradeMangerPage.razor
2023-09-30 23:05:53 +08:00

263 lines
12 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@*
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
*@
@page "/UpgradeManger"
@namespace ThingsGateway.UpgradeManger
@using System.Linq.Expressions;
@using BlazorComponent;
@using Mapster;
@using Masa.Blazor.Presets;
@using System.IO;
@using Masa.Blazor;
@using Microsoft.AspNetCore.Authorization;
@inherits BaseComponentBase
@inject NavigationManager NavigationManager
@layout MainLayout
<MRow NoGutters>
<MCol Md=@(IsShowTreeView?2:0)>
<MSheet Show=IsShowTreeView Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight}px);border-radius:0px;")>
<MCardTitle Class="text-body-2">
当前已连接的客户端
</MCardTitle>
<MVirtualScroll Context="item" Class="my-2" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+100}px)") OverscanCount=2 ItemSize="60" Items="TcpDmtpSocketClients">
<ItemContent>
<MListItem OnClick=@(()=>ChoiceTcpDmtpSocketClient(item))>
<MListItemContent>
<MListItemTitle>
<div class="mt-1 d-flex align-center justify-space-between" title=@($"{item.GetIPPort()} - {item.Id}")>
<span>@($"{item.GetIPPort()} - {item.Id}")</span>
</div>
</MListItemTitle>
</MListItemContent>
</MListItem>
<MDivider></MDivider>
</ItemContent>
</MVirtualScroll>
</MSheet>
</MCol>
<MCol Md=@(IsShowTreeView?10:12)>
<MButton Class="mx-1" OnClick=@(() =>
{
IsShowTreeView=!IsShowTreeView;
}
) Color="primary" Icon>
<MIcon>mdi-menu</MIcon>
</MButton>
<MSheet Rounded="false" Class="pa-2" Style="width:100%">
<MRow Class="my-1" Justify="JustifyTypes.Start" Align="AlignTypes.Start" NoGutters>
<MCol Md="5">
@if (TcpDmtpSocketClient != null && GatewayInfo != null)
{
<MSheet Class="ml-4">
<MDescriptions Title="当前选择的网关" Bordered="true">
<ActionsContent>
<MButton Class="text-capitalize mr-1" Color="primary" OnClick="()=>ChoiceTcpDmtpSocketClient(TcpDmtpSocketClient)">
刷新
</MButton>
</ActionsContent>
<ChildContent>
<MDescriptionsItem Label=连接信息 Span=3>@($"{TcpDmtpSocketClient.GetIPPort()} - {TcpDmtpSocketClient.Id}")</MDescriptionsItem>
<MDescriptionsItem Label=连接状态 Span=3 Class=@(!TcpDmtpSocketClient.CanSend?"red--text":"green--text")>@TcpDmtpSocketClient.CanSend</MDescriptionsItem>
<MDescriptionsItem Label=更新时间 Span=3>@GatewayInfo.UpdateTime</MDescriptionsItem>
<MDescriptionsItem Label=软件版本 Span=3>@GatewayInfo.Version</MDescriptionsItem>
<MDescriptionsItem Label=采集设备数量 Span=3>@GatewayInfo.CollectDeviceCount</MDescriptionsItem>
<MDescriptionsItem Label=上传设备数量 Span=3>@GatewayInfo.UploadDeviceCount</MDescriptionsItem>
<MDescriptionsItem Label=变量数量 Span=3>@GatewayInfo.VariableCount</MDescriptionsItem>
</ChildContent>
</MDescriptions>
</MSheet>
<MTabs @bind-Value="tab" Class="ma-2">
<MTab Value=1> 配置更新 </MTab>
<MTab Value=2> 软件更新 </MTab>
</MTabs>
<MTabsItems Value="tab">
<MTabItem Value="1">
@if (tab == 1)
{
<MContainer>
<MRow Dense>
<MCol Cols="12" Md="12">
<div class="m-descriptions-header__title my-2">
导出配置信息
</div>
</MCol>
<MCol Cols="12" Md="12">
<MButton Color="primary" Loading=isUploadLoading Disabled=disabled Class="ma-2" OnClick=@(()=>ExcelUpload())>
导出网关配置信息
</MButton>
</MCol>
<MCol Cols="12" Md="12">
<MButton Color="primary" Loading=isUploadLoading Disabled=disabled Class="ma-2" OnClick=@(()=>DBUpload())>
导出网关配置数据库(SQLITE)
</MButton>
</MCol>
</MRow>
<MDivider></MDivider>
<MRow Dense>
<MCol Cols="12" Md="12">
<div class="m-descriptions-header__title my-2">
更新网关配置信息
</div>
</MCol>
<MCol Cols="12" Md="12">
<MFileInput Label="采集设备Excel" HideDetails=@("true") @bind-Value="_importCollectDevicesFile" Style="width:90%;" ShowSize></MFileInput>
</MCol>
<MCol Cols="12" Md="12">
<MSwitch Label=删除后更新 HideDetails=@("true") @bind-Value=@IsCollectDevicesFullUp />
</MCol>
<MCol Cols="12" Md="12">
<MFileInput Label="上传设备Excel" HideDetails=@("true") @bind-Value="_importUploadDevicesFile" Style="width:90%;" ShowSize></MFileInput>
</MCol>
<MCol Cols="12" Md="12">
<MSwitch Label=删除后更新 HideDetails=@("true") @bind-Value=@IsUploadDevicesFullUp />
</MCol>
<MCol Cols="12" Md="12">
<MFileInput Label="采集变量Excel" HideDetails=@("true") @bind-Value="_importDeviceVariablesFile" Style="width:90%;" ShowSize></MFileInput>
</MCol>
<MCol Cols="12" Md="12">
<MSwitch Label=删除后更新 HideDetails=@("true") @bind-Value=@IsDeviceVariablesFullUp />
</MCol>
<MCol Cols="12" Md="12">
<MFileInput Label="内存变量Excel" HideDetails=@("true") @bind-Value="_importMemoryVariablesFile" Style="width:90%;" ShowSize></MFileInput>
</MCol>
<MCol Cols="12" Md="12">
<MSwitch Label=删除后更新 HideDetails=@("true") @bind-Value=@IsMemoryVariablesFullUp />
</MCol>
<MCol Cols="12" Md="12">
<MButton Loading=isUploadLoading Disabled=disabled Class="ma-2" Color="primary"
OnClick=@(()=>ExcelDown())>
推送Excel文件
</MButton>
</MCol>
</MRow>
<MDivider></MDivider>
<MRow Dense>
<MCol Cols="12" Md="12">
<div class="m-descriptions-header__title my-2">
重启
</div>
</MCol>
<MCol Cols="12" Md="12">
<MButton Color="primary" Loading=isUploadLoading Disabled=disabled Class="ma-2" OnClick=@(()=>DBRestart())>
重启网关运行态
</MButton>
</MCol>
<MCol Cols="12" Md="12">
</MCol>
</MRow>
</MContainer>
}
</MTabItem>
<MTabItem Value="2">
@if (tab == 2)
{
<MCol Cols="12" Md="12">
<MButton Loading=isUploadLoading Disabled=disabled Class="ma-2" Color="primary"
OnClick=@(()=>FileDown())>
推送文件
</MButton>
</MCol>
<MCol Cols="12" Md="12">
<MButton Loading=isUploadLoading Disabled=disabled Class="ma-2" Color="primary"
OnClick=@(()=>FileRestart())>
重启更新
</MButton>
</MCol>
}
</MTabItem>
</MTabsItems>
}
</MCol>
<MCol Md="7">
<MCard Style="overflow-y:auto;width:100%" Elevation="0" Flat Class="ml-4">
<ConsoleTxt Messages="UpgradeManger.Messages" Height=600></ConsoleTxt>
</MCard>
</MCol>
</MRow>
</MSheet>
</MCol>
</MRow>
@code {
StringNumber tab;
bool IsShowTreeView = true;
}