release:6.0.4.60

refactor: 支持全局按钮权限
refactor: 修改服务类插件启动错误后的等待间隔时间
This commit is contained in:
Diego
2024-08-08 10:56:23 +08:00
parent 8e820c0e47
commit 4bfd7acd96
19 changed files with 56 additions and 33 deletions

View File

@@ -127,7 +127,7 @@ public class SysUserService : BaseService<SysUser>, ISysUserService
Dictionary<string, List<string>> buttonCodeList = new();
foreach (var item in button)
{
var href = allResources.FirstOrDefault(b => b.Id == item.ParentId)?.Href;
var href = allResources.FirstOrDefault(b => b.Id == item.ParentId)?.Href ?? string.Empty;
if (buttonCodeList.TryGetValue(href, out var buttonCode))
{
buttonCode.Add(item.Title);

View File

@@ -143,7 +143,16 @@ public class BlazorAppContext : IAsyncDisposable
{
if (UserManager.SuperAdmin)
return true;
var data = CurrentUser?.ButtonCodeList?.TryGetValue(url.StartsWith("/") ? url : $"/{url}", out var titles) == true && titles.Contains(code);
return data;
url ??= string.Empty;
if (!url.IsNullOrWhiteSpace())
{
var data = CurrentUser?.ButtonCodeList?.TryGetValue(url.StartsWith("/") ? url : $"/{url}", out var titles) == true && titles.Contains(code);
return data;
}
else
{
var data = CurrentUser?.ButtonCodeList?.TryGetValue(url, out var titles) == true && titles.Contains(code);
return data;
}
}
}

View File

@@ -427,7 +427,7 @@ public interface IProtocol : IDisposable
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
Task Close(string msg = null);
Task CloseAsync(string msg = null);
/// <summary>
/// 配置IPluginManager

View File

@@ -214,7 +214,7 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
}
/// <inheritdoc/>
public Task Close(string msg = default)
public Task CloseAsync(string msg = default)
{
return Channel.CloseAsync(msg);
}

View File

@@ -1,5 +1,14 @@
{
"RECORDS": [
{
"Id": "61000010000001",
"ParentId": 0,
"Module": "6",
"Title": "快捷按钮",
"Code": "System",
"Category": "2",
"IsDelete": "0"
},
{
"Id": "61000012001001",
"ParentId": "61000012001",

View File

@@ -73,11 +73,14 @@
</Main>
<NotAuthorized>
<Redirect Url="/Account/Login"/>
<Redirect Url="/Account/Login" />
</NotAuthorized>
</Layout>
<QuickActions></QuickActions>
@if (AppContext.IsHasButtonWithRole(string.Empty, "快捷按钮"))
{
<QuickActions></QuickActions>
}
</div>
</CascadingValue>

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>6.0.4.59</Version>
<Version>6.0.4.60</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -8,8 +8,6 @@
// QQ群605534569
//------------------------------------------------------------------------------
using System.Text;
using TouchSocket.Core;
namespace ThingsGateway.Foundation.SiemensS7;

View File

@@ -8,9 +8,6 @@
// QQ群605534569
//------------------------------------------------------------------------------
using System.Data;
using System.Net;
using ThingsGateway.Foundation.Extension.String;
using TouchSocket.Core;
@@ -117,7 +114,7 @@ public partial class SiemensS7Master : ProtocolBase
{
try
{
this.Channel.Connect();
Channel.Connect();
}
catch
{
@@ -144,7 +141,7 @@ public partial class SiemensS7Master : ProtocolBase
int len = Math.Min(addressLen - num, PduLength);
sAddress.Length = len;
var result = await this.SendThenReturnAsync(
var result = await SendThenReturnAsync(
new S7Send([sAddress], true), cancellationToken: cancellationToken).ConfigureAwait(false);
if (!result.IsSuccess) return result;
@@ -207,7 +204,7 @@ public partial class SiemensS7Master : ProtocolBase
return dictOperResult;
}
var result = await this.SendThenReturnAsync(
var result = await SendThenReturnAsync(
new S7Send([sAddress], true), cancellationToken: cancellationToken).ConfigureAwait(false);
if (!result.IsSuccess)
@@ -222,7 +219,7 @@ public partial class SiemensS7Master : ProtocolBase
result.Content[i / 8] = result.Content[i / 8].SetBit((i % 8), value[i - sAddress.BitCode]);
}
sAddress.Data = result.Content;
var wresult = await this.SendThenReturnAsync(
var wresult = await SendThenReturnAsync(
new S7Send([sAddress], false), cancellationToken: cancellationToken).ConfigureAwait(false);
dictOperResult.TryAdd(sAddress, wresult);
return dictOperResult;
@@ -281,7 +278,7 @@ new S7Send([sAddress], false), cancellationToken: cancellationToken).ConfigureAw
try
{
var result = await this.SendThenReturnAsync(
var result = await SendThenReturnAsync(
new S7Send(item.ToArray(), false), cancellationToken: cancellationToken).ConfigureAwait(false);
foreach (var i1 in item)
{
@@ -424,14 +421,14 @@ new S7Send([sAddress], false), cancellationToken: cancellationToken).ConfigureAw
if (!result2.IsSuccess)
{
Logger?.LogWarning(SiemensS7Resource.Localizer["HandshakeError1", channel.ToString(), result2.ErrorMessage]);
channel.Close();
await channel.CloseAsync();
return;
}
}
catch (Exception ex)
{
Logger?.LogWarning(SiemensS7Resource.Localizer["HandshakeError1", channel.ToString(), ex.Message]);
channel.Close();
await channel.CloseAsync();
return;
}
try
@@ -440,7 +437,7 @@ new S7Send([sAddress], false), cancellationToken: cancellationToken).ConfigureAw
if (!result2.IsSuccess)
{
Logger?.LogWarning(SiemensS7Resource.Localizer["HandshakeError2", channel.ToString(), result2.ErrorMessage]);
channel.Close();
await channel.CloseAsync();
return;
}
PduLength = ThingsGatewayBitConverter.ToUInt16(result2.Content, 0) - 28;
@@ -450,13 +447,13 @@ new S7Send([sAddress], false), cancellationToken: cancellationToken).ConfigureAw
catch (Exception ex)
{
Logger?.LogWarning(SiemensS7Resource.Localizer["HandshakeError2", channel.ToString(), ex.Message]);
channel.Close();
await channel.CloseAsync();
return;
}
}
catch (Exception ex)
{
channel.Close();
await channel.CloseAsync();
Logger.Exception(ex);
}
finally
@@ -475,7 +472,7 @@ new S7Send([sAddress], false), cancellationToken: cancellationToken).ConfigureAw
/// <returns></returns>
public async ValueTask<OperResult<System.DateTime>> ReadDateAsync(string address, CancellationToken cancellationToken)
{
return (await this.ReadAsync(address, 2, cancellationToken).ConfigureAwait(false)).
return (await ReadAsync(address, 2, cancellationToken).ConfigureAwait(false)).
Then(m => OperResult.CreateSuccessResult(S7DateTime.SpecMinimumDateTime.AddDays(
ThingsGatewayBitConverter.ToUInt16(m, 0)))
);

View File

@@ -63,7 +63,8 @@ public partial class Dlt645_2007Master : ComponentBase, IDisposable
private async Task OnDisConnectClick()
{
_plc?.Close();
if (_plc != null)
await _plc?.CloseAsync();
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -127,7 +127,7 @@ public class ModbusSlave : BusinessBase
CurrentDevice.SetDeviceStatus(TimerX.Now, 999);
try
{
Protocol.Channel.Close();
await Protocol.Channel.CloseAsync().ConfigureAwait(false);
await Protocol.Channel.ConnectAsync(3000, cancellationToken).ConfigureAwait(false);
success = true;
}
@@ -136,6 +136,7 @@ public class ModbusSlave : BusinessBase
if (success)
LogMessage.LogWarning(ex, Localizer["CanStartService"]);
success = false;
await Task.Delay(10000, cancellationToken).ConfigureAwait(false);
}
}
var list = _modbusVariableDict.ToListWithDequeue();

View File

@@ -63,7 +63,8 @@ public partial class ModbusMaster : ComponentBase, IDisposable
private async Task OnDisConnectClick()
{
_plc?.Close();
if (_plc != null)
await _plc?.CloseAsync();
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -60,7 +60,8 @@ public partial class ModbusSlave : ComponentBase, IDisposable
private async Task OnDisConnectClick()
{
_plc?.Close();
if (_plc != null)
await _plc?.CloseAsync();
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -105,7 +105,7 @@ public partial class MqttClient : BusinessBaseWithCacheIntervalScript<VariableDa
LogMessage.LogWarning(clientResult.Exception, clientResult.ErrorMessage);
success = clientResult.IsSuccess;
}
await Delay(cancellationToken).ConfigureAwait(false);
await Task.Delay(10000, cancellationToken).ConfigureAwait(false);
//return;
}

View File

@@ -133,7 +133,7 @@ public class OpcUaMaster : CollectBase
connectFirstFailLoged = true;
CurrentDevice.SetDeviceStatus(TimerX.Now, 999, ex.Message);
await Task.Delay(3000);
await Task.Delay(10000, cancellationToken).ConfigureAwait(false);
}
}
else

View File

@@ -129,6 +129,7 @@ public partial class OpcUaServer : BusinessBase
if (success)
LogMessage.LogWarning(ex, Localizer["CanStartService"]);
success = false;
await Task.Delay(10000, cancellationToken).ConfigureAwait(false);
}
}

View File

@@ -88,6 +88,7 @@ public partial class RabbitMQProducer : BusinessBaseWithCacheIntervalScript<Vari
LogMessage?.LogWarning(ex);
success = false;
}
await Task.Delay(10000, cancellationToken).ConfigureAwait(false);
}
}
else

View File

@@ -61,7 +61,8 @@ public partial class SiemensS7Master : IDisposable
private async Task OnDisConnectClick()
{
_plc?.Close();
if (_plc != null)
await _plc?.CloseAsync();
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -96,11 +96,11 @@ public partial class ChannelDataDebugComponent : ComponentBase
private async Task DisconnectClick()
{
if (Model != null)
if (Model?.Channel != null)
{
try
{
Model.Channel.Close(DefaultResource.Localizer["ProactivelyDisconnect", nameof(DisconnectClick)]);
await Model.Channel.CloseAsync(DefaultResource.Localizer["ProactivelyDisconnect", nameof(DisconnectClick)]);
if (OnDisConnectClick.HasDelegate)
await OnDisConnectClick.InvokeAsync();
}