mirror of
				https://gitee.com/ThingsGateway/ThingsGateway.git
				synced 2025-11-04 09:33:58 +08:00 
			
		
		
		
	Compare commits
	
		
			19 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					d922296b70 | ||
| 
						 | 
					aec91da28b | ||
| 
						 | 
					013ff394be | ||
| 
						 | 
					081e07473d | ||
| 
						 | 
					d33d900592 | ||
| 
						 | 
					29365c4ef9 | ||
| 
						 | 
					17a6189089 | ||
| 
						 | 
					003b8a3763 | ||
| 
						 | 
					1c7f8b5cab | ||
| 
						 | 
					b7ff9ffca2 | ||
| 
						 | 
					9bba9bda76 | ||
| 
						 | 
					ec2fcc75d3 | ||
| 
						 | 
					57a4038577 | ||
| 
						 | 
					b78a76e60f | ||
| 
						 | 
					28bd751d44 | ||
| 
						 | 
					dcba7b9810 | ||
| 
						 | 
					7f1a741ce6 | ||
| 
						 | 
					ca2b17d433 | ||
| 
						 | 
					af589eac10 | 
@@ -0,0 +1,6 @@
 | 
			
		||||
## Release 1.0
 | 
			
		||||
 | 
			
		||||
### New Rules
 | 
			
		||||
Rule ID | Category | Severity | Notes
 | 
			
		||||
--------|----------|----------|--------------------
 | 
			
		||||
TG0001 | Conflict | Error | SetParametersAsyncGenerator
 | 
			
		||||
@@ -0,0 +1,32 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
	<Import Project="$(SolutionDir)PackNuget.props" />
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFrameworks>netstandard2.0;</TargetFrameworks>
 | 
			
		||||
		<Version>$(SourceGeneratorVersion)</Version>
 | 
			
		||||
		<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
 | 
			
		||||
		<NoPackageAnalysis>true</NoPackageAnalysis>
 | 
			
		||||
		<SignAssembly>false</SignAssembly>
 | 
			
		||||
 | 
			
		||||
		<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
 | 
			
		||||
		<IncludeBuildOutput>false</IncludeBuildOutput>
 | 
			
		||||
		<!-- 避免 DLL 被打包到 lib/ -->
 | 
			
		||||
		<EnableSourceGenerator>true</EnableSourceGenerator>
 | 
			
		||||
		<!-- 可选 -->
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<None Include="$(OutputPath)\$(TargetFileName)" Pack="true"
 | 
			
		||||
			  PackagePath="analyzers/dotnet/cs" Visible="false" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.9.0" PrivateAssets="all" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
</Project>
 | 
			
		||||
@@ -7,12 +7,3 @@
 | 
			
		||||
//  使用文档:https://thingsgateway.cn/
 | 
			
		||||
//  QQ群:605534569
 | 
			
		||||
//------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
global using BootstrapBlazor.Components;
 | 
			
		||||
 | 
			
		||||
global using Microsoft.AspNetCore.Components;
 | 
			
		||||
global using Microsoft.Extensions.Localization;
 | 
			
		||||
 | 
			
		||||
global using System.Diagnostics.CodeAnalysis;
 | 
			
		||||
 | 
			
		||||
global using ThingsGateway.Razor;
 | 
			
		||||
@@ -0,0 +1,534 @@
 | 
			
		||||
using Microsoft.CodeAnalysis;
 | 
			
		||||
using Microsoft.CodeAnalysis.CSharp;
 | 
			
		||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
 | 
			
		||||
 | 
			
		||||
namespace BlazorSetParametersAsyncGenerator;
 | 
			
		||||
 | 
			
		||||
[Generator]
 | 
			
		||||
public partial class SetParametersAsyncGenerator : ISourceGenerator
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    private string m_DoNotGenerateSetParametersAsyncAttribute = """
 | 
			
		||||
        
 | 
			
		||||
        using System;
 | 
			
		||||
        namespace BlazorSetParametersAsyncGenerator
 | 
			
		||||
        {
 | 
			
		||||
            [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
 | 
			
		||||
            internal sealed class DoNotGenerateSetParametersAsyncAttribute : Attribute
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        ;
 | 
			
		||||
    private string m_GenerateSetParametersAsyncAttribute = """
 | 
			
		||||
        
 | 
			
		||||
        using System;
 | 
			
		||||
        namespace BlazorSetParametersAsyncGenerator
 | 
			
		||||
        {
 | 
			
		||||
            [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
 | 
			
		||||
            internal sealed class GenerateSetParametersAsyncAttribute : Attribute
 | 
			
		||||
            {
 | 
			
		||||
                public bool RequireExactMatch { get; set; }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        ;
 | 
			
		||||
    private string m_GlobalGenerateSetParametersAsyncAttribute = """
 | 
			
		||||
        
 | 
			
		||||
        using System;
 | 
			
		||||
        namespace BlazorSetParametersAsyncGenerator
 | 
			
		||||
        {
 | 
			
		||||
            [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
 | 
			
		||||
            internal sealed class GlobalGenerateSetParametersAsyncAttribute : Attribute
 | 
			
		||||
            {
 | 
			
		||||
                public bool Enable { get; }
 | 
			
		||||
 | 
			
		||||
                public GlobalGenerateSetParametersAsyncAttribute(bool enable = true)
 | 
			
		||||
                {
 | 
			
		||||
                    Enable = enable;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
    private static readonly DiagnosticDescriptor ParameterNameConflict = new DiagnosticDescriptor(
 | 
			
		||||
        id: "TG0001",
 | 
			
		||||
        title: "Parameter name conflict",
 | 
			
		||||
        messageFormat: "Parameter names are case insensitive. {0} conflicts with {1}.",
 | 
			
		||||
        category: "Conflict",
 | 
			
		||||
        defaultSeverity: DiagnosticSeverity.Error,
 | 
			
		||||
        isEnabledByDefault: true,
 | 
			
		||||
        description: "Parameter names must be case insensitive to be usable in routes. Rename the parameter to not be in conflict with other parameters.");
 | 
			
		||||
 | 
			
		||||
    public void Initialize(GeneratorInitializationContext context)
 | 
			
		||||
    {
 | 
			
		||||
        context.RegisterForPostInitialization(a =>
 | 
			
		||||
        {
 | 
			
		||||
            a.AddSource(nameof(m_DoNotGenerateSetParametersAsyncAttribute), m_DoNotGenerateSetParametersAsyncAttribute);
 | 
			
		||||
            a.AddSource(nameof(m_GenerateSetParametersAsyncAttribute), m_GenerateSetParametersAsyncAttribute);
 | 
			
		||||
            a.AddSource(nameof(m_GlobalGenerateSetParametersAsyncAttribute), m_GlobalGenerateSetParametersAsyncAttribute);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        // Register a syntax receiver that will be created for each generation pass
 | 
			
		||||
        context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void Execute(GeneratorExecutionContext context)
 | 
			
		||||
    {
 | 
			
		||||
        // https://github.com/dotnet/AspNetCore.Docs/blob/1e199f340780f407a685695e6c4d953f173fa891/aspnetcore/blazor/webassembly-performance-best-practices.md#implement-setparametersasync-manually
 | 
			
		||||
        if (context.SyntaxReceiver is not SyntaxReceiver receiver)
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var candidate_classes = GetCandidateClasses(receiver, context);
 | 
			
		||||
 | 
			
		||||
        foreach (var class_symbol in candidate_classes.Distinct(SymbolEqualityComparer.Default).Cast<INamedTypeSymbol>())
 | 
			
		||||
        {
 | 
			
		||||
            GenerateSetParametersAsyncMethod(context, class_symbol);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void GenerateSetParametersAsyncMethod(GeneratorExecutionContext context, INamedTypeSymbol class_symbol)
 | 
			
		||||
    {
 | 
			
		||||
        var force_exact_match = class_symbol.GetAttributes().Any(a => a.NamedArguments.Any(na => na.Key == "RequireExactMatch" && na.Value.Value is bool v && v));
 | 
			
		||||
        var namespaceName = class_symbol.ContainingNamespace.ToDisplayString();
 | 
			
		||||
        var type_kind = class_symbol.TypeKind switch { TypeKind.Class => "class", TypeKind.Interface => "interface", _ => "struct" };
 | 
			
		||||
        var type_parameters = string.Join(", ", class_symbol.TypeArguments.Select(t => t.Name));
 | 
			
		||||
        type_parameters = string.IsNullOrEmpty(type_parameters) ? type_parameters : "<" + type_parameters + ">";
 | 
			
		||||
        context.AddCode(class_symbol.ToDisplayString() + "_override.cs", $@"
 | 
			
		||||
using Microsoft.AspNetCore.Components;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
#pragma warning disable CA2007
 | 
			
		||||
#pragma warning disable CS0162
 | 
			
		||||
#pragma warning disable CS8632
 | 
			
		||||
namespace {namespaceName}
 | 
			
		||||
{{
 | 
			
		||||
    public partial class {class_symbol.Name}{type_parameters}
 | 
			
		||||
    {{
 | 
			
		||||
        private bool _initialized;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// <inheritdoc/>
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override Task SetParametersAsync(ParameterView parameters)
 | 
			
		||||
        {{
 | 
			
		||||
            Dictionary<string,object?> parameterValues = new();
 | 
			
		||||
            foreach (var parameter in parameters)
 | 
			
		||||
            {{
 | 
			
		||||
              if(BlazorImplementation__WriteSingleParameter(parameter.Name, parameter.Value)==false)
 | 
			
		||||
              {{
 | 
			
		||||
                  // 如果没有处理参数,则添加到参数列表中
 | 
			
		||||
                  parameterValues.Add(parameter.Name, parameter.Value);
 | 
			
		||||
              }}
 | 
			
		||||
            }}
 | 
			
		||||
            
 | 
			
		||||
            if(parameterValues.Count > 0)
 | 
			
		||||
            {{
 | 
			
		||||
                parameters.SetParameterProperties(this);
 | 
			
		||||
            }}
 | 
			
		||||
            if (!_initialized)
 | 
			
		||||
            {{
 | 
			
		||||
                _initialized = true;
 | 
			
		||||
 | 
			
		||||
                return RunInitAndSetParametersAsync();
 | 
			
		||||
            }}
 | 
			
		||||
            else
 | 
			
		||||
            {{
 | 
			
		||||
                return CallOnParametersSetAsync();
 | 
			
		||||
            }}
 | 
			
		||||
        }}
 | 
			
		||||
 | 
			
		||||
        // We do not want the debugger to consider NavigationExceptions caught by this method as user-unhandled.
 | 
			
		||||
    #if NET9_0_OR_GREATER
 | 
			
		||||
        [System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
 | 
			
		||||
    #endif
 | 
			
		||||
        private async Task RunInitAndSetParametersAsync()
 | 
			
		||||
        {{
 | 
			
		||||
            Task task;
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {{
 | 
			
		||||
                OnInitialized();
 | 
			
		||||
                task = OnInitializedAsync();
 | 
			
		||||
            }}
 | 
			
		||||
            catch (Exception ex) when (ex is not NavigationException)
 | 
			
		||||
            {{
 | 
			
		||||
                throw;
 | 
			
		||||
            }}
 | 
			
		||||
 | 
			
		||||
            if (task.Status != TaskStatus.RanToCompletion && task.Status != TaskStatus.Canceled)
 | 
			
		||||
            {{
 | 
			
		||||
                // Call state has changed here so that we render after the sync part of OnInitAsync has run
 | 
			
		||||
                // and wait for it to finish before we continue. If no async work has been done yet, we want
 | 
			
		||||
                // to defer calling StateHasChanged up until the first bit of async code happens or until
 | 
			
		||||
                // the end. Additionally, we want to avoid calling StateHasChanged if no
 | 
			
		||||
                // async work is to be performed.
 | 
			
		||||
                StateHasChanged();
 | 
			
		||||
 | 
			
		||||
                try
 | 
			
		||||
                {{
 | 
			
		||||
                    await task;
 | 
			
		||||
                }}
 | 
			
		||||
                catch // avoiding exception filters for AOT runtime support
 | 
			
		||||
                {{
 | 
			
		||||
                    // Ignore exceptions from task cancellations.
 | 
			
		||||
                    // Awaiting a canceled task may produce either an OperationCanceledException (if produced as a consequence of
 | 
			
		||||
                    // CancellationToken.ThrowIfCancellationRequested()) or a TaskCanceledException (produced as a consequence of awaiting Task.FromCanceled).
 | 
			
		||||
                    // It's much easier to check the state of the Task (i.e. Task.IsCanceled) rather than catch two distinct exceptions.
 | 
			
		||||
                    if (!task.IsCanceled)
 | 
			
		||||
                    {{
 | 
			
		||||
                        throw;
 | 
			
		||||
                    }}
 | 
			
		||||
                }}
 | 
			
		||||
 | 
			
		||||
                // Don't call StateHasChanged here. CallOnParametersSetAsync should handle that for us.
 | 
			
		||||
            }}
 | 
			
		||||
 | 
			
		||||
            await CallOnParametersSetAsync();
 | 
			
		||||
        }}
 | 
			
		||||
 | 
			
		||||
        // We do not want the debugger to consider NavigationExceptions caught by this method as user-unhandled.
 | 
			
		||||
    #if NET9_0_OR_GREATER
 | 
			
		||||
        [System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
 | 
			
		||||
    #endif
 | 
			
		||||
        private Task CallOnParametersSetAsync()
 | 
			
		||||
        {{
 | 
			
		||||
            Task task;
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {{
 | 
			
		||||
                OnParametersSet();
 | 
			
		||||
                task = OnParametersSetAsync();
 | 
			
		||||
            }}
 | 
			
		||||
            catch (Exception ex) when (ex is not NavigationException)
 | 
			
		||||
            {{
 | 
			
		||||
    #if NET9_0_OR_GREATER
 | 
			
		||||
                System.Diagnostics.Debugger.BreakForUserUnhandledException(ex);
 | 
			
		||||
    #endif
 | 
			
		||||
                throw;
 | 
			
		||||
            }}
 | 
			
		||||
 | 
			
		||||
            // If no async work is to be performed, i.e. the task has already ran to completion
 | 
			
		||||
            // or was canceled by the time we got to inspect it, avoid going async and re-invoking
 | 
			
		||||
            // StateHasChanged at the culmination of the async work.
 | 
			
		||||
            var shouldAwaitTask = task.Status != TaskStatus.RanToCompletion &&
 | 
			
		||||
                task.Status != TaskStatus.Canceled;
 | 
			
		||||
 | 
			
		||||
            // We always call StateHasChanged here as we want to trigger a rerender after OnParametersSet and
 | 
			
		||||
            // the synchronous part of OnParametersSetAsync has run.
 | 
			
		||||
            StateHasChanged();
 | 
			
		||||
 | 
			
		||||
            return shouldAwaitTask ?
 | 
			
		||||
                CallStateHasChangedOnAsyncCompletion(task) :
 | 
			
		||||
                Task.CompletedTask;
 | 
			
		||||
        }}
 | 
			
		||||
 | 
			
		||||
        // We do not want the debugger to stop more than once per user-unhandled exception.
 | 
			
		||||
    #if NET9_0_OR_GREATER
 | 
			
		||||
        [System.Diagnostics.DebuggerDisableUserUnhandledExceptions]
 | 
			
		||||
    #endif
 | 
			
		||||
        private async Task CallStateHasChangedOnAsyncCompletion(Task task)
 | 
			
		||||
        {{
 | 
			
		||||
            try
 | 
			
		||||
            {{
 | 
			
		||||
                await task;
 | 
			
		||||
            }}
 | 
			
		||||
            catch // avoiding exception filters for AOT runtime support
 | 
			
		||||
            {{
 | 
			
		||||
                // Ignore exceptions from task cancellations, but don't bother issuing a state change.
 | 
			
		||||
                if (task.IsCanceled)
 | 
			
		||||
                {{
 | 
			
		||||
                    return;
 | 
			
		||||
                }}
 | 
			
		||||
 | 
			
		||||
                throw;
 | 
			
		||||
            }}
 | 
			
		||||
 | 
			
		||||
            StateHasChanged();
 | 
			
		||||
        }}
 | 
			
		||||
 | 
			
		||||
    }}
 | 
			
		||||
}}
 | 
			
		||||
#pragma warning restore CS8632
 | 
			
		||||
#pragma warning restore CS0162
 | 
			
		||||
#pragma warning restore CA2007
 | 
			
		||||
");
 | 
			
		||||
        var bases = class_symbol.GetTypeHierarchy().Where(t => !SymbolEqualityComparer.Default.Equals(t, class_symbol));
 | 
			
		||||
        var members = class_symbol.GetMembers() // members of the type itself
 | 
			
		||||
            .Concat(bases.SelectMany(t => t.GetMembers().Where(m => m.DeclaredAccessibility != Accessibility.Private))) // plus accessible members of any base
 | 
			
		||||
            .Distinct(SymbolEqualityComparer.Default);
 | 
			
		||||
        var property_symbols = members.OfType<IPropertySymbol>();
 | 
			
		||||
        var writable_property_symbols = property_symbols.Where(ps =>
 | 
			
		||||
            !ps.IsReadOnly || ps.GetAttributes().Any(a =>
 | 
			
		||||
                a.AttributeClass?.Name is "CascadingParameter" or "CascadingParameterAttribute")
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        var parameter_symbols = writable_property_symbols
 | 
			
		||||
            .Where(ps => ps.GetAttributes().Any(a => false
 | 
			
		||||
            || a.AttributeClass.Name == "Parameter"
 | 
			
		||||
            || a.AttributeClass.Name == "ParameterAttribute"
 | 
			
		||||
            || a.AttributeClass.Name == "CascadingParameter"
 | 
			
		||||
            || a.AttributeClass.Name == "CascadingParameterAttribute"
 | 
			
		||||
 | 
			
		||||
        ));
 | 
			
		||||
        var name_conflicts = parameter_symbols.GroupBy(ps => ps.Name.ToLowerInvariant()).Where(g => g.Count() > 1);
 | 
			
		||||
        foreach (var conflict in name_conflicts)
 | 
			
		||||
        {
 | 
			
		||||
            var key = conflict.Key;
 | 
			
		||||
            var conflicting_parameters = conflict.ToList();
 | 
			
		||||
            foreach (var parameter in conflicting_parameters)
 | 
			
		||||
            {
 | 
			
		||||
                var this_name = parameter.Name;
 | 
			
		||||
                var conflicting_name = conflicting_parameters.Select(p => p.Name).FirstOrDefault(n => n != this_name);
 | 
			
		||||
                foreach (var location in parameter.Locations)
 | 
			
		||||
                {
 | 
			
		||||
                    context.ReportDiagnostic(Diagnostic.Create(ParameterNameConflict, location, this_name, conflicting_name));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        var all = parameter_symbols.ToList();
 | 
			
		||||
        var catch_all_parameter = parameter_symbols.FirstOrDefault(p =>
 | 
			
		||||
        {
 | 
			
		||||
            var parameter_attr = p.GetAttributes().FirstOrDefault(a => a.AttributeClass!.Name.StartsWith("Parameter"));
 | 
			
		||||
            return parameter_attr?.NamedArguments.Any(n => n.Key == "CaptureUnmatchedValues" && n.Value.Value is bool v && v) == true;
 | 
			
		||||
        });
 | 
			
		||||
        var lower_case_match_cases = parameter_symbols.Except(new[] { catch_all_parameter }).Select(p => $"case \"{p.Name.ToLowerInvariant()}\": this.{p.Name} = ({p.Type.ToDisplayString()}) value; break;");
 | 
			
		||||
        var lower_case_match_default = catch_all_parameter == null ? @"default: {return false;}" : $@"
 | 
			
		||||
default:
 | 
			
		||||
{{
 | 
			
		||||
    this.{catch_all_parameter.Name} ??= new System.Collections.Generic.Dictionary<string, object>();
 | 
			
		||||
    var writable_dict = this.{catch_all_parameter.Name};
 | 
			
		||||
    if (!writable_dict.TryAdd(name, value))
 | 
			
		||||
    {{
 | 
			
		||||
        writable_dict[name] = value;
 | 
			
		||||
    }}
 | 
			
		||||
    break;
 | 
			
		||||
}}";
 | 
			
		||||
 | 
			
		||||
        var exact_match_cases = parameter_symbols.Except(new[] { catch_all_parameter }).Select(p => $"case \"{p!.Name}\": this.{p.Name} = ({p.Type.ToDisplayString()}) value; break;");
 | 
			
		||||
        string exact_match_default;
 | 
			
		||||
        if (force_exact_match)
 | 
			
		||||
        {
 | 
			
		||||
            if (catch_all_parameter == null) // exact matches are forced, and we do not have a catch-all parameter, therefore we need to throw on unmatched parameter
 | 
			
		||||
            {
 | 
			
		||||
                exact_match_default = @"default: { return false;";
 | 
			
		||||
            }
 | 
			
		||||
            else // exact matches are forced, and we DO have a catch-all parameter, therefore we simply add that unmatched parameter to the dictionary
 | 
			
		||||
            {
 | 
			
		||||
                exact_match_default = $@"
 | 
			
		||||
default:
 | 
			
		||||
{{
 | 
			
		||||
    this.{catch_all_parameter.Name} ??= new System.Collections.Generic.Dictionary<string, object>();
 | 
			
		||||
    var writable_dict = this.{catch_all_parameter.Name};
 | 
			
		||||
    if (!writable_dict.TryAdd(name, value))
 | 
			
		||||
    {{
 | 
			
		||||
        writable_dict[name] = value;
 | 
			
		||||
    }}
 | 
			
		||||
    break;
 | 
			
		||||
}}";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            // exact matches are not forced, so if there is no exact match, we fall back to compare it in lower case
 | 
			
		||||
            exact_match_default = $@"
 | 
			
		||||
default:
 | 
			
		||||
{{
 | 
			
		||||
    switch (name.ToLowerInvariant())
 | 
			
		||||
    {{
 | 
			
		||||
        {string.Join("\n", lower_case_match_cases)}
 | 
			
		||||
        {lower_case_match_default}
 | 
			
		||||
    }}
 | 
			
		||||
    break;
 | 
			
		||||
}}
 | 
			
		||||
";
 | 
			
		||||
        }
 | 
			
		||||
        context.AddCode(class_symbol.ToDisplayString() + "_implementation.cs", $@"
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
#pragma warning disable CS0162
 | 
			
		||||
#pragma warning disable CS0618
 | 
			
		||||
#pragma warning disable CS8632
 | 
			
		||||
namespace {namespaceName}
 | 
			
		||||
{{
 | 
			
		||||
    public partial class {class_symbol.Name}{type_parameters}
 | 
			
		||||
    {{
 | 
			
		||||
 | 
			
		||||
        private bool BlazorImplementation__WriteSingleParameter(string name, object value)
 | 
			
		||||
        {{
 | 
			
		||||
            if(name != ""Body"")
 | 
			
		||||
            {{
 | 
			
		||||
 | 
			
		||||
                switch (name)
 | 
			
		||||
                {{
 | 
			
		||||
                    {string.Join("\n", exact_match_cases)}
 | 
			
		||||
                    {exact_match_default}
 | 
			
		||||
                }}
 | 
			
		||||
                return true;
 | 
			
		||||
            }}
 | 
			
		||||
           return false;
 | 
			
		||||
         }}
 | 
			
		||||
    }}
 | 
			
		||||
}}
 | 
			
		||||
#pragma warning restore CS8632
 | 
			
		||||
#pragma warning restore CS0618
 | 
			
		||||
#pragma warning restore CS0162");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static bool HasUserDefinedSetParametersAsync(INamedTypeSymbol classSymbol)
 | 
			
		||||
    {
 | 
			
		||||
        return classSymbol
 | 
			
		||||
            .GetMembers("SetParametersAsync")
 | 
			
		||||
            .OfType<IMethodSymbol>()
 | 
			
		||||
            .Any(m =>
 | 
			
		||||
                m.Parameters.Length == 1 &&
 | 
			
		||||
                m.Parameters[0].Type.ToDisplayString() == "Microsoft.AspNetCore.Components.ParameterView" &&
 | 
			
		||||
                m.DeclaredAccessibility == Accessibility.Public &&
 | 
			
		||||
                !m.IsStatic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private static bool IsPartial(INamedTypeSymbol symbol)
 | 
			
		||||
    {
 | 
			
		||||
        return symbol.DeclaringSyntaxReferences
 | 
			
		||||
            .Select(r => r.GetSyntax())
 | 
			
		||||
            .OfType<ClassDeclarationSyntax>()
 | 
			
		||||
            .Any(c => c.Modifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword)));
 | 
			
		||||
    }
 | 
			
		||||
    private static bool IsComponent(ClassDeclarationSyntax classDeclarationSyntax, INamedTypeSymbol symbol, Compilation compilation)
 | 
			
		||||
    {
 | 
			
		||||
        if (HasUserDefinedSetParametersAsync(symbol))
 | 
			
		||||
        {
 | 
			
		||||
            // 用户自己写了方法,不生成
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!IsPartial(symbol))
 | 
			
		||||
        {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (classDeclarationSyntax.SyntaxTree.FilePath.EndsWith(".razor") || classDeclarationSyntax.SyntaxTree.FilePath.EndsWith(".razor.cs"))
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        var iComponent = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Components.IComponent");
 | 
			
		||||
        var componentBase = compilation.GetTypeByMetadataName("Microsoft.AspNetCore.Components.ComponentBase");
 | 
			
		||||
        if (iComponent == null || componentBase == null)
 | 
			
		||||
            return false;
 | 
			
		||||
 | 
			
		||||
        if (SymbolEqualityComparer.Default.Equals(symbol, iComponent))
 | 
			
		||||
            return true;
 | 
			
		||||
        if (SymbolEqualityComparer.Default.Equals(symbol, componentBase))
 | 
			
		||||
            return true;
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Enumerate methods with at least one Group attribute
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    private static IEnumerable<INamedTypeSymbol> GetCandidateClasses(SyntaxReceiver receiver, GeneratorExecutionContext context)
 | 
			
		||||
    {
 | 
			
		||||
        var compilation = context.Compilation;
 | 
			
		||||
        var positiveAttributeSymbol = compilation.GetTypeByMetadataName("BlazorSetParametersAsyncGenerator.GenerateSetParametersAsyncAttribute");
 | 
			
		||||
        var negativeAttributeSymbol = compilation.GetTypeByMetadataName("BlazorSetParametersAsyncGenerator.DoNotGenerateSetParametersAsyncAttribute");
 | 
			
		||||
 | 
			
		||||
        // loop over the candidate methods, and keep the ones that are actually annotated
 | 
			
		||||
 | 
			
		||||
        // 找特性
 | 
			
		||||
        var assemblyAttributes = compilation.Assembly.GetAttributes();
 | 
			
		||||
 | 
			
		||||
        var enableAttr = assemblyAttributes.FirstOrDefault(attr =>
 | 
			
		||||
            attr.AttributeClass?.ToDisplayString() == "BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsyncAttribute");
 | 
			
		||||
 | 
			
		||||
        var globalEnable = false;
 | 
			
		||||
        if (enableAttr != null)
 | 
			
		||||
        {
 | 
			
		||||
            var arg = enableAttr.ConstructorArguments.FirstOrDefault();
 | 
			
		||||
            if (arg.Value is bool b)
 | 
			
		||||
                globalEnable = b;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach (ClassDeclarationSyntax class_declaration in receiver.CandidateClasses)
 | 
			
		||||
        {
 | 
			
		||||
            var model = compilation.GetSemanticModel(class_declaration.SyntaxTree);
 | 
			
		||||
            var class_symbol = model.GetDeclaredSymbol(class_declaration);
 | 
			
		||||
            if (class_symbol is null)
 | 
			
		||||
            {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            if (class_symbol.Name == "_Imports")
 | 
			
		||||
            {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // 是否拒绝生成
 | 
			
		||||
            var hasNegative = class_symbol.GetAttributes().Any(ad =>
 | 
			
		||||
                ad.AttributeClass?.Equals(negativeAttributeSymbol, SymbolEqualityComparer.Default) == true);
 | 
			
		||||
 | 
			
		||||
            if (hasNegative)
 | 
			
		||||
                continue;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if (IsComponent(class_declaration, class_symbol, compilation))
 | 
			
		||||
            {
 | 
			
		||||
                if (globalEnable)
 | 
			
		||||
                {
 | 
			
		||||
                    yield return class_symbol;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    // 必须显式标注 Positive Attribute
 | 
			
		||||
                    var hasPositive = class_symbol.GetAttributes().Any(ad =>
 | 
			
		||||
                        ad.AttributeClass?.Equals(positiveAttributeSymbol, SymbolEqualityComparer.Default) == true);
 | 
			
		||||
 | 
			
		||||
                    if (hasPositive)
 | 
			
		||||
                        yield return class_symbol;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Created on demand before each generation pass
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    internal class SyntaxReceiver : ISyntaxReceiver
 | 
			
		||||
    {
 | 
			
		||||
        public List<ClassDeclarationSyntax> CandidateClasses { get; } = new List<ClassDeclarationSyntax>();
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Called for every syntax node in the compilation, we can inspect the nodes and save any information useful for generation
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void OnVisitSyntaxNode(SyntaxNode syntax_node)
 | 
			
		||||
        {
 | 
			
		||||
            // any class with at least one attribute is a candidate for property generation
 | 
			
		||||
            if (syntax_node is ClassDeclarationSyntax classDeclarationSyntax)
 | 
			
		||||
            {
 | 
			
		||||
                CandidateClasses.Add(classDeclarationSyntax);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,15 @@
 | 
			
		||||
using Microsoft.CodeAnalysis;
 | 
			
		||||
using Microsoft.CodeAnalysis.Text;
 | 
			
		||||
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace BlazorSetParametersAsyncGenerator
 | 
			
		||||
{
 | 
			
		||||
    internal static class SourceGeneratorContextExtension
 | 
			
		||||
    {
 | 
			
		||||
        public static void AddCode(this GeneratorExecutionContext context, string hint_name, string code)
 | 
			
		||||
        {
 | 
			
		||||
            context.AddSource(hint_name.Replace("<", "_").Replace(">", "_"), SourceText.From(code, Encoding.UTF8));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,13 @@
 | 
			
		||||
using Microsoft.CodeAnalysis;
 | 
			
		||||
using Microsoft.CodeAnalysis.CSharp;
 | 
			
		||||
 | 
			
		||||
namespace BlazorSetParametersAsyncGenerator
 | 
			
		||||
{
 | 
			
		||||
    internal static class StringExtension
 | 
			
		||||
    {
 | 
			
		||||
        public static string NormalizeWhitespace(this string code)
 | 
			
		||||
        {
 | 
			
		||||
            return CSharpSyntaxTree.ParseText(code).GetRoot().NormalizeWhitespace().ToFullString();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
using Microsoft.CodeAnalysis;
 | 
			
		||||
 | 
			
		||||
namespace BlazorSetParametersAsyncGenerator
 | 
			
		||||
{
 | 
			
		||||
    public static class TypeSymbolExtension
 | 
			
		||||
    {
 | 
			
		||||
        public static IEnumerable<INamedTypeSymbol> GetTypeHierarchy(this INamedTypeSymbol symbol)
 | 
			
		||||
        {
 | 
			
		||||
            yield return symbol;
 | 
			
		||||
            if (symbol.BaseType != null)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (var type in GetTypeHierarchy(symbol.BaseType))
 | 
			
		||||
                {
 | 
			
		||||
                    yield return type;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,49 @@
 | 
			
		||||
param($installPath, $toolsPath, $package, $project)
 | 
			
		||||
 | 
			
		||||
$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve
 | 
			
		||||
 | 
			
		||||
foreach($analyzersPath in $analyzersPaths)
 | 
			
		||||
{
 | 
			
		||||
    # Install the language agnostic analyzers.
 | 
			
		||||
    if (Test-Path $analyzersPath)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll)
 | 
			
		||||
        {
 | 
			
		||||
            if($project.Object.AnalyzerReferences)
 | 
			
		||||
            {
 | 
			
		||||
                $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# $project.Type gives the language name like (C# or VB.NET)
 | 
			
		||||
$languageFolder = ""
 | 
			
		||||
if($project.Type -eq "C#")
 | 
			
		||||
{
 | 
			
		||||
    $languageFolder = "cs"
 | 
			
		||||
}
 | 
			
		||||
if($project.Type -eq "VB.NET")
 | 
			
		||||
{
 | 
			
		||||
    $languageFolder = "vb"
 | 
			
		||||
}
 | 
			
		||||
if($languageFolder -eq "")
 | 
			
		||||
{
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
foreach($analyzersPath in $analyzersPaths)
 | 
			
		||||
{
 | 
			
		||||
    # Install language specific analyzers.
 | 
			
		||||
    $languageAnalyzersPath = join-path $analyzersPath $languageFolder
 | 
			
		||||
    if (Test-Path $languageAnalyzersPath)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll)
 | 
			
		||||
        {
 | 
			
		||||
            if($project.Object.AnalyzerReferences)
 | 
			
		||||
            {
 | 
			
		||||
                $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,56 @@
 | 
			
		||||
param($installPath, $toolsPath, $package, $project)
 | 
			
		||||
 | 
			
		||||
$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve
 | 
			
		||||
 | 
			
		||||
foreach($analyzersPath in $analyzersPaths)
 | 
			
		||||
{
 | 
			
		||||
    # Uninstall the language agnostic analyzers.
 | 
			
		||||
    if (Test-Path $analyzersPath)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll)
 | 
			
		||||
        {
 | 
			
		||||
            if($project.Object.AnalyzerReferences)
 | 
			
		||||
            {
 | 
			
		||||
                $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# $project.Type gives the language name like (C# or VB.NET)
 | 
			
		||||
$languageFolder = ""
 | 
			
		||||
if($project.Type -eq "C#")
 | 
			
		||||
{
 | 
			
		||||
    $languageFolder = "cs"
 | 
			
		||||
}
 | 
			
		||||
if($project.Type -eq "VB.NET")
 | 
			
		||||
{
 | 
			
		||||
    $languageFolder = "vb"
 | 
			
		||||
}
 | 
			
		||||
if($languageFolder -eq "")
 | 
			
		||||
{
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
foreach($analyzersPath in $analyzersPaths)
 | 
			
		||||
{
 | 
			
		||||
    # Uninstall language specific analyzers.
 | 
			
		||||
    $languageAnalyzersPath = join-path $analyzersPath $languageFolder
 | 
			
		||||
    if (Test-Path $languageAnalyzersPath)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll)
 | 
			
		||||
        {
 | 
			
		||||
            if($project.Object.AnalyzerReferences)
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
 | 
			
		||||
                }
 | 
			
		||||
                catch
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -20,6 +20,7 @@ using System.Collections.Concurrent;
 | 
			
		||||
using ThingsGateway.Extension;
 | 
			
		||||
using ThingsGateway.FriendlyException;
 | 
			
		||||
using ThingsGateway.NewLife.Json.Extension;
 | 
			
		||||
using ThingsGateway.SqlSugar;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
@@ -90,13 +91,12 @@ public sealed class OperDescAttribute : MoAttribute
 | 
			
		||||
            OperDescAttribute.WriteToQueue(log);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static SqlSugarClient _db = DbContext.GetDB<SysOperateLog>();
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 将日志消息写入数据库中
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    private static async Task ProcessQueue()
 | 
			
		||||
    {
 | 
			
		||||
        var db = DbContext.Db.GetConnectionScopeWithAttr<SysOperateLog>().CopyNew();
 | 
			
		||||
        var appLifetime = App.RootServices!.GetService<IHostApplicationLifetime>()!;
 | 
			
		||||
        while (!appLifetime.ApplicationStopping.IsCancellationRequested)
 | 
			
		||||
        {
 | 
			
		||||
@@ -105,7 +105,7 @@ public sealed class OperDescAttribute : MoAttribute
 | 
			
		||||
                var data = _logMessageQueue.ToListWithDequeue(); // 从日志队列中获取数据
 | 
			
		||||
                if (data.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    await db.InsertableWithAttr(data).ExecuteCommandAsync(appLifetime.ApplicationStopping).ConfigureAwait(false);//入库
 | 
			
		||||
                    await _db.InsertableWithAttr(data).ExecuteCommandAsync(appLifetime.ApplicationStopping).ConfigureAwait(false);//入库
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
 
 | 
			
		||||
@@ -267,7 +267,7 @@ public class RequestAuditFilter : IAsyncActionFilter, IOrderedFilter
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            logger.Log(LogLevel.Warning, $"{logData.Method}:{logData.Path}-{logData.Operation}{Environment.NewLine}{logData.Exception.ToSystemTextJsonString()}");
 | 
			
		||||
            logger.Log(LogLevel.Warning, $"{logData.Method}:{logData.Path}-{logData.Operation}{Environment.NewLine}{logData.Exception?.ToSystemTextJsonString()}{Environment.NewLine}{logData.Validation?.ToSystemTextJsonString()}");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
using Microsoft.AspNetCore.Authentication.OAuth;
 | 
			
		||||
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
/// <summary>OAuthOptions 配置类</summary>
 | 
			
		||||
public abstract class AdminOAuthOptions : OAuthOptions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>默认构造函数</summary>
 | 
			
		||||
    protected AdminOAuthOptions()
 | 
			
		||||
    {
 | 
			
		||||
        ConfigureClaims();
 | 
			
		||||
        this.Events.OnRemoteFailure = context =>
 | 
			
		||||
        {
 | 
			
		||||
            var redirectUri = string.IsNullOrEmpty(HomePath) ? "/" : HomePath;
 | 
			
		||||
            context.Response.Redirect(redirectUri);
 | 
			
		||||
            context.HandleResponse();
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>配置 Claims 映射</summary>
 | 
			
		||||
    protected virtual void ConfigureClaims()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public virtual string GetName(JsonElement element)
 | 
			
		||||
    {
 | 
			
		||||
        JsonElement.ObjectEnumerator target = element.EnumerateObject();
 | 
			
		||||
        return target.TryGetValue("name");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>获得/设置 登陆后首页</summary>
 | 
			
		||||
    public string HomePath { get; set; } = "/";
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
public class GiteeOAuthUser
 | 
			
		||||
{
 | 
			
		||||
    public string Id { get; set; }
 | 
			
		||||
 | 
			
		||||
    public string Login { get; set; }
 | 
			
		||||
 | 
			
		||||
    public string Name { get; set; }
 | 
			
		||||
 | 
			
		||||
    public string Avatar_Url { get; set; }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,22 +0,0 @@
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
public static class OAuthUserExtensions
 | 
			
		||||
{
 | 
			
		||||
    public static GiteeOAuthUser ToAuthUser(this JsonElement element)
 | 
			
		||||
    {
 | 
			
		||||
        GiteeOAuthUser authUser = new GiteeOAuthUser();
 | 
			
		||||
        JsonElement.ObjectEnumerator target = element.EnumerateObject();
 | 
			
		||||
        authUser.Id = target.TryGetValue("id");
 | 
			
		||||
        authUser.Login = target.TryGetValue("login");
 | 
			
		||||
        authUser.Name = target.TryGetValue("name");
 | 
			
		||||
        authUser.Avatar_Url = target.TryGetValue("avatar_url");
 | 
			
		||||
        return authUser;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static string TryGetValue(this JsonElement.ObjectEnumerator target, string propertyName)
 | 
			
		||||
    {
 | 
			
		||||
        return target.FirstOrDefault<JsonProperty>((Func<JsonProperty, bool>)(t => t.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase))).Value.ToString() ?? string.Empty;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -8,5 +8,4 @@
 | 
			
		||||
//  QQ群:605534569
 | 
			
		||||
//------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
global using ThingsGateway;
 | 
			
		||||
global using ThingsGateway.NewLife.Extension;
 | 
			
		||||
@@ -20,6 +20,7 @@ using ThingsGateway.NewLife;
 | 
			
		||||
using ThingsGateway.NewLife.Caching;
 | 
			
		||||
using ThingsGateway.NewLife.Threading;
 | 
			
		||||
using ThingsGateway.Schedule;
 | 
			
		||||
using ThingsGateway.SqlSugar;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
@@ -60,7 +61,7 @@ public class HardwareJob : IJob, IHardwareJob
 | 
			
		||||
        var historyHardwareInfos = MemoryCache.Get<List<HistoryHardwareInfo>>(CacheKey);
 | 
			
		||||
        if (historyHardwareInfos == null)
 | 
			
		||||
        {
 | 
			
		||||
            using var db = DbContext.Db.GetConnectionScopeWithAttr<HistoryHardwareInfo>().CopyNew();
 | 
			
		||||
            using var db = DbContext.GetDB<HistoryHardwareInfo>(); ;
 | 
			
		||||
            historyHardwareInfos = await db.Queryable<HistoryHardwareInfo>().Where(a => a.Date > DateTime.Now.AddDays(-3)).ToListAsync().ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
            MemoryCache.Set(CacheKey, historyHardwareInfos);
 | 
			
		||||
@@ -70,6 +71,7 @@ public class HardwareJob : IJob, IHardwareJob
 | 
			
		||||
 | 
			
		||||
    private bool error = false;
 | 
			
		||||
    private DateTime hisInsertTime = default;
 | 
			
		||||
    private SqlSugarClient _db = DbContext.GetDB<HistoryHardwareInfo>();
 | 
			
		||||
 | 
			
		||||
    public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
 | 
			
		||||
    {
 | 
			
		||||
@@ -79,7 +81,7 @@ public class HardwareJob : IJob, IHardwareJob
 | 
			
		||||
            {
 | 
			
		||||
                if (HardwareInfo.MachineInfo == null)
 | 
			
		||||
                {
 | 
			
		||||
                    await MachineInfo.RegisterAsync().ConfigureAwait(false);
 | 
			
		||||
                    MachineInfo.Register();
 | 
			
		||||
                    HardwareInfo.MachineInfo = MachineInfo.Current;
 | 
			
		||||
 | 
			
		||||
                    string currentPath = Directory.GetCurrentDirectory();
 | 
			
		||||
@@ -121,7 +123,6 @@ public class HardwareJob : IJob, IHardwareJob
 | 
			
		||||
                    if (DateTime.Now > hisInsertTime.Add(TimeSpan.FromMilliseconds(HardwareInfoOptions.HistoryInterval)))
 | 
			
		||||
                    {
 | 
			
		||||
                        hisInsertTime = DateTime.Now;
 | 
			
		||||
                        using var db = DbContext.Db.GetConnectionScopeWithAttr<HistoryHardwareInfo>().CopyNew();
 | 
			
		||||
                        {
 | 
			
		||||
                            var his = new HistoryHardwareInfo()
 | 
			
		||||
                            {
 | 
			
		||||
@@ -132,12 +133,12 @@ public class HardwareJob : IJob, IHardwareJob
 | 
			
		||||
                                CpuUsage = (HardwareInfo.MachineInfo.CpuRate * 100).ToInt(),
 | 
			
		||||
                                Temperature = (HardwareInfo.MachineInfo.Temperature).ToInt(),
 | 
			
		||||
                            };
 | 
			
		||||
                            await db.Insertable(his).ExecuteCommandAsync(stoppingToken).ConfigureAwait(false);
 | 
			
		||||
                            await _db.Insertable(his).ExecuteCommandAsync(stoppingToken).ConfigureAwait(false);
 | 
			
		||||
                            MemoryCache.Remove(CacheKey);
 | 
			
		||||
                        }
 | 
			
		||||
                        var sevenDaysAgo = TimerX.Now.AddDays(-HardwareInfoOptions.DaysAgo);
 | 
			
		||||
                        //删除特定信息
 | 
			
		||||
                        var result = await db.Deleteable<HistoryHardwareInfo>(a => a.Date <= sevenDaysAgo).ExecuteCommandAsync(stoppingToken).ConfigureAwait(false);
 | 
			
		||||
                        var result = await _db.Deleteable<HistoryHardwareInfo>(a => a.Date <= sevenDaysAgo).ExecuteCommandAsync(stoppingToken).ConfigureAwait(false);
 | 
			
		||||
                        if (result > 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            MemoryCache.Remove(CacheKey);
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ public class LogJob : IJob
 | 
			
		||||
 | 
			
		||||
    private static async Task DeleteSysOperateLog(int daysAgo, CancellationToken stoppingToken)
 | 
			
		||||
    {
 | 
			
		||||
        using var db = DbContext.Db.GetConnectionScopeWithAttr<SysOperateLog>().CopyNew();
 | 
			
		||||
        using var db = DbContext.GetDB<SysOperateLog>();
 | 
			
		||||
        var time = DateTime.Now.AddDays(-daysAgo);
 | 
			
		||||
        await db.DeleteableWithAttr<SysOperateLog>().Where(u => u.OpTime < time).ExecuteCommandAsync(stoppingToken).ConfigureAwait(false); // 删除操作日志
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -143,7 +143,7 @@ public class DatabaseLoggingWriter : IDatabaseLoggingWriter
 | 
			
		||||
 | 
			
		||||
        if (flush)
 | 
			
		||||
        {
 | 
			
		||||
            SqlSugarClient ??= DbContext.Db.GetConnectionScopeWithAttr<SysOperateLog>().CopyNew();
 | 
			
		||||
            SqlSugarClient ??= DbContext.GetDB<SysOperateLog>();
 | 
			
		||||
            await SqlSugarClient.InsertableWithAttr(_operateLogMessageQueue.ToListWithDequeue()).ExecuteCommandAsync().ConfigureAwait(false);//入库
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
@@ -202,7 +202,7 @@ public class DatabaseLoggingWriter : IDatabaseLoggingWriter
 | 
			
		||||
 | 
			
		||||
        if (flush)
 | 
			
		||||
        {
 | 
			
		||||
            SqlSugarClient ??= DbContext.Db.GetConnectionScopeWithAttr<SysOperateLog>().CopyNew();
 | 
			
		||||
            SqlSugarClient ??= DbContext.GetDB<SysOperateLog>();
 | 
			
		||||
            await SqlSugarClient.InsertableWithAttr(_operateLogMessageQueue.ToListWithDequeue()).ExecuteCommandAsync().ConfigureAwait(false);//入库
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,14 @@
 | 
			
		||||
using Microsoft.AspNetCore.Authentication;
 | 
			
		||||
using Microsoft.AspNetCore.Authentication.OAuth;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.WebUtilities;
 | 
			
		||||
using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
using Microsoft.Extensions.Hosting;
 | 
			
		||||
using Microsoft.Extensions.Logging;
 | 
			
		||||
using Microsoft.Extensions.Options;
 | 
			
		||||
 | 
			
		||||
using System.Collections.Concurrent;
 | 
			
		||||
using System.Net.Http.Headers;
 | 
			
		||||
using System.Security.Claims;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Text.Encodings.Web;
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
 | 
			
		||||
using ThingsGateway.Extension;
 | 
			
		||||
 | 
			
		||||
@@ -50,7 +46,7 @@ public class AdminOAuthHandler<TOptions>(
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    private static async Task Insertable()
 | 
			
		||||
    {
 | 
			
		||||
        var db = DbContext.Db.GetConnectionScopeWithAttr<SysOperateLog>().CopyNew();
 | 
			
		||||
        var db = DbContext.GetDB<SysOperateLog>();
 | 
			
		||||
        var appLifetime = App.RootServices!.GetService<IHostApplicationLifetime>()!;
 | 
			
		||||
        while (!appLifetime.ApplicationStopping.IsCancellationRequested)
 | 
			
		||||
        {
 | 
			
		||||
@@ -80,6 +76,7 @@ public class AdminOAuthHandler<TOptions>(
 | 
			
		||||
        AuthenticationProperties properties,
 | 
			
		||||
        OAuthTokenResponse tokens)
 | 
			
		||||
    {
 | 
			
		||||
        Backchannel.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokens.AccessToken);
 | 
			
		||||
        properties.RedirectUri = Options.HomePath;
 | 
			
		||||
        properties.IsPersistent = true;
 | 
			
		||||
        var appConfig = await configService.GetAppConfigAsync().ConfigureAwait(false);
 | 
			
		||||
@@ -90,7 +87,7 @@ public class AdminOAuthHandler<TOptions>(
 | 
			
		||||
            properties.ExpiresUtc = TimeProvider.System.GetUtcNow().AddSeconds(result);
 | 
			
		||||
            expire = (int)(result / 60.0);
 | 
			
		||||
        }
 | 
			
		||||
        var user = await HandleUserInfoAsync(tokens).ConfigureAwait(false);
 | 
			
		||||
        var user = await Options.HandleUserInfoAsync(Context, tokens).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
        var loginEvent = await GetLogin(expire).ConfigureAwait(false);
 | 
			
		||||
        await UpdateUser(loginEvent).ConfigureAwait(false);
 | 
			
		||||
@@ -148,43 +145,8 @@ public class AdminOAuthHandler<TOptions>(
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>处理用户信息方法</summary>
 | 
			
		||||
    protected virtual async Task<JsonElement> HandleUserInfoAsync(OAuthTokenResponse tokens)
 | 
			
		||||
    {
 | 
			
		||||
        var request = new HttpRequestMessage(HttpMethod.Get, BuildUserInfoUrl(tokens));
 | 
			
		||||
        request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 | 
			
		||||
 | 
			
		||||
        var response = await Backchannel.SendAsync(request, Context.RequestAborted).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
        var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
        if (response.IsSuccessStatusCode)
 | 
			
		||||
        {
 | 
			
		||||
            return JsonDocument.Parse(content).RootElement;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new OAuthTokenException($"OAuth user info endpoint failure: {await Display(response).ConfigureAwait(false)}");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>生成用户信息请求地址方法</summary>
 | 
			
		||||
    protected virtual string BuildUserInfoUrl(OAuthTokenResponse tokens)
 | 
			
		||||
    {
 | 
			
		||||
        return QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary<string, string>
 | 
			
		||||
        {
 | 
			
		||||
            { "access_token", tokens.AccessToken }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>生成错误信息方法</summary>
 | 
			
		||||
    protected static async Task<string> Display(HttpResponseMessage response)
 | 
			
		||||
    {
 | 
			
		||||
        var output = new StringBuilder();
 | 
			
		||||
        output.Append($"Status: {response.StatusCode}; ");
 | 
			
		||||
        output.Append($"Headers: {response.Headers}; ");
 | 
			
		||||
        output.Append($"Body: {await response.Content.ReadAsStringAsync().ConfigureAwait(false)};");
 | 
			
		||||
 | 
			
		||||
        return output.ToString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private async Task<LoginEvent> GetLogin(int expire)
 | 
			
		||||
    {
 | 
			
		||||
@@ -247,7 +209,7 @@ public class AdminOAuthHandler<TOptions>(
 | 
			
		||||
 | 
			
		||||
        #endregion 重新赋值属性,设置本次登录信息为最新的信息
 | 
			
		||||
 | 
			
		||||
        using var db = DbContext.Db.GetConnectionScopeWithAttr<SysUser>().CopyNew();
 | 
			
		||||
        using var db = DbContext.GetDB<SysUser>();
 | 
			
		||||
        //更新用户登录信息
 | 
			
		||||
        if (await db.Updateable(sysUser).UpdateColumns(it => new
 | 
			
		||||
        {
 | 
			
		||||
@@ -0,0 +1,87 @@
 | 
			
		||||
using Microsoft.AspNetCore.Authentication.OAuth;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.AspNetCore.WebUtilities;
 | 
			
		||||
 | 
			
		||||
using System.Net.Http.Headers;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
/// <summary>OAuthOptions 配置类</summary>
 | 
			
		||||
public abstract class AdminOAuthOptions : OAuthOptions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>默认构造函数</summary>
 | 
			
		||||
    protected AdminOAuthOptions()
 | 
			
		||||
    {
 | 
			
		||||
        ConfigureClaims();
 | 
			
		||||
        this.Events.OnRemoteFailure = context =>
 | 
			
		||||
        {
 | 
			
		||||
            var redirectUri = string.IsNullOrEmpty(HomePath) ? "/" : HomePath;
 | 
			
		||||
            context.Response.Redirect(redirectUri);
 | 
			
		||||
            context.HandleResponse();
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        Backchannel = new HttpClient(new HttpClientHandler
 | 
			
		||||
        {
 | 
			
		||||
            ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
 | 
			
		||||
        });
 | 
			
		||||
        Backchannel.DefaultRequestHeaders.UserAgent.Add(
 | 
			
		||||
            new ProductInfoHeaderValue("ThingsGateway", "1.0"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>配置 Claims 映射</summary>
 | 
			
		||||
    protected virtual void ConfigureClaims()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public virtual string GetName(JsonElement element)
 | 
			
		||||
    {
 | 
			
		||||
        JsonElement.ObjectEnumerator target = element.EnumerateObject();
 | 
			
		||||
        return target.TryGetValue("name");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>获得/设置 登陆后首页</summary>
 | 
			
		||||
    public string HomePath { get; set; } = "/";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>处理用户信息方法</summary>
 | 
			
		||||
    public virtual async Task<JsonElement> HandleUserInfoAsync(HttpContext context, OAuthTokenResponse tokens)
 | 
			
		||||
    {
 | 
			
		||||
        var request = new HttpRequestMessage(HttpMethod.Get, BuildUserInfoUrl(tokens));
 | 
			
		||||
        request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 | 
			
		||||
 | 
			
		||||
        var response = await Backchannel.SendAsync(request, context.RequestAborted).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
        var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
        if (response.IsSuccessStatusCode)
 | 
			
		||||
        {
 | 
			
		||||
            return JsonDocument.Parse(content).RootElement;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new OAuthTokenException($"OAuth user info endpoint failure: {await Display(response).ConfigureAwait(false)}");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>生成用户信息请求地址方法</summary>
 | 
			
		||||
    protected virtual string BuildUserInfoUrl(OAuthTokenResponse tokens)
 | 
			
		||||
    {
 | 
			
		||||
        return QueryHelpers.AddQueryString(UserInformationEndpoint, new Dictionary<string, string>
 | 
			
		||||
        {
 | 
			
		||||
            { "access_token", tokens.AccessToken }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /// <summary>生成错误信息方法</summary>
 | 
			
		||||
    protected async Task<string> Display(HttpResponseMessage response)
 | 
			
		||||
    {
 | 
			
		||||
        var output = new StringBuilder();
 | 
			
		||||
        output.Append($"Status: {response.StatusCode}; ");
 | 
			
		||||
        output.Append($"Headers: {response.Headers}; ");
 | 
			
		||||
        output.Append($"Body: {await response.Content.ReadAsStringAsync().ConfigureAwait(false)};");
 | 
			
		||||
 | 
			
		||||
        return output.ToString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -3,16 +3,20 @@ using Microsoft.AspNetCore.Authentication.OAuth;
 | 
			
		||||
using Microsoft.AspNetCore.WebUtilities;
 | 
			
		||||
 | 
			
		||||
using System.Net.Http.Headers;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
 | 
			
		||||
using ThingsGateway.NewLife.Log;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
public class GiteeOAuthOptions : AdminOAuthOptions
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    INoticeService _noticeService;
 | 
			
		||||
    IVerificatInfoService _verificatInfoService;
 | 
			
		||||
    public GiteeOAuthOptions() : base()
 | 
			
		||||
    {
 | 
			
		||||
        _noticeService = App.GetService<INoticeService>();
 | 
			
		||||
        _verificatInfoService = App.GetService<IVerificatInfoService>();
 | 
			
		||||
        this.SignInScheme = ClaimConst.Scheme;
 | 
			
		||||
        this.AuthorizationEndpoint = "https://gitee.com/oauth/authorize";
 | 
			
		||||
        this.TokenEndpoint = "https://gitee.com/oauth/token";
 | 
			
		||||
@@ -29,11 +33,14 @@ public class GiteeOAuthOptions : AdminOAuthOptions
 | 
			
		||||
 | 
			
		||||
        Events.OnRedirectToAuthorizationEndpoint = context =>
 | 
			
		||||
        {
 | 
			
		||||
            //context.RedirectUri = context.RedirectUri.Replace("http%3A%2F%2F", "https%3A%2F%2F"); // 强制替换
 | 
			
		||||
            context.Response.Redirect(context.RedirectUri);
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        Events.OnRemoteFailure = context =>
 | 
			
		||||
        {
 | 
			
		||||
            XTrace.WriteException(context.Failure);
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>刷新 Token 方法</summary>
 | 
			
		||||
@@ -60,16 +67,7 @@ public class GiteeOAuthOptions : AdminOAuthOptions
 | 
			
		||||
        return OAuthTokenResponse.Failed(new OAuthTokenException($"OAuth token endpoint failure: {await Display(response).ConfigureAwait(false)}"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>生成错误信息方法</summary>
 | 
			
		||||
    protected static async Task<string> Display(HttpResponseMessage response)
 | 
			
		||||
    {
 | 
			
		||||
        var output = new StringBuilder();
 | 
			
		||||
        output.Append($"Status: {response.StatusCode}; ");
 | 
			
		||||
        output.Append($"Headers: {response.Headers}; ");
 | 
			
		||||
        output.Append($"Body: {await response.Content.ReadAsStringAsync().ConfigureAwait(false)};");
 | 
			
		||||
 | 
			
		||||
        return output.ToString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public override string GetName(JsonElement element)
 | 
			
		||||
    {
 | 
			
		||||
@@ -77,7 +75,7 @@ public class GiteeOAuthOptions : AdminOAuthOptions
 | 
			
		||||
        return target.TryGetValue("name");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static async Task HandlerGiteeStarredUrl(OAuthCreatingTicketContext context, string repoFullName = "ThingsGateway/ThingsGateway")
 | 
			
		||||
    private async Task HandlerGiteeStarredUrl(OAuthCreatingTicketContext context, string repoFullName = "ThingsGateway/ThingsGateway")
 | 
			
		||||
    {
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(context.AccessToken))
 | 
			
		||||
            throw new InvalidOperationException("Access token is missing.");
 | 
			
		||||
@@ -89,7 +87,7 @@ public class GiteeOAuthOptions : AdminOAuthOptions
 | 
			
		||||
            { "access_token", context.AccessToken }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        var request = new HttpRequestMessage(HttpMethod.Put, QueryHelpers.AddQueryString(uri, queryString))
 | 
			
		||||
        var request = new HttpRequestMessage(HttpMethod.Get, QueryHelpers.AddQueryString(uri, queryString))
 | 
			
		||||
        {
 | 
			
		||||
            Headers = { Accept = { new MediaTypeWithQualityHeaderValue("application/json") } }
 | 
			
		||||
        };
 | 
			
		||||
@@ -99,7 +97,17 @@ public class GiteeOAuthOptions : AdminOAuthOptions
 | 
			
		||||
        if (!response.IsSuccessStatusCode)
 | 
			
		||||
        {
 | 
			
		||||
            var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
 | 
			
		||||
            throw new Exception($"Failed to star repository: {response.StatusCode}, {content}");
 | 
			
		||||
 | 
			
		||||
            var id = context.Identity.Claims.FirstOrDefault(a => a.Type == ClaimConst.VerificatId).Value;
 | 
			
		||||
 | 
			
		||||
            var verificatInfoIds = _verificatInfoService.GetOne(id.ToLong());
 | 
			
		||||
 | 
			
		||||
            _ = Task.Run(async () =>
 | 
			
		||||
             {
 | 
			
		||||
                 await Task.Delay(5000).ConfigureAwait(false);
 | 
			
		||||
                 await _noticeService.NavigationMesage(verificatInfoIds.ClientIds, "https://gitee.com/ThingsGateway/ThingsGateway", "创作不易,如有帮助请star仓库").ConfigureAwait(false);
 | 
			
		||||
             });
 | 
			
		||||
            //throw new Exception($"Failed to star repository: {response.StatusCode}, {content}");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,122 @@
 | 
			
		||||
using Microsoft.AspNetCore.Authentication;
 | 
			
		||||
using Microsoft.AspNetCore.Authentication.OAuth;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
 | 
			
		||||
using System.Net.Http.Headers;
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
 | 
			
		||||
using ThingsGateway.NewLife.Log;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
public class GitHubOAuthOptions : AdminOAuthOptions
 | 
			
		||||
{
 | 
			
		||||
    INoticeService _noticeService;
 | 
			
		||||
    IVerificatInfoService _verificatInfoService;
 | 
			
		||||
    public GitHubOAuthOptions() : base()
 | 
			
		||||
    {
 | 
			
		||||
        _noticeService = App.GetService<INoticeService>();
 | 
			
		||||
        _verificatInfoService = App.GetService<IVerificatInfoService>();
 | 
			
		||||
        SignInScheme = ClaimConst.Scheme;
 | 
			
		||||
        AuthorizationEndpoint = "https://github.com/login/oauth/authorize";
 | 
			
		||||
        TokenEndpoint = "https://github.com/login/oauth/access_token";
 | 
			
		||||
        UserInformationEndpoint = "https://api.github.com/user";
 | 
			
		||||
        HomePath = "/";
 | 
			
		||||
        CallbackPath = "/signin-github";
 | 
			
		||||
 | 
			
		||||
        Scope.Add("read:user");
 | 
			
		||||
        Scope.Add("public_repo"); // 需要用于 Star 仓库
 | 
			
		||||
 | 
			
		||||
        Events.OnCreatingTicket = async context =>
 | 
			
		||||
        {
 | 
			
		||||
            await HandleGitHubStarAsync(context).ConfigureAwait(false);
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        Events.OnRedirectToAuthorizationEndpoint = context =>
 | 
			
		||||
        {
 | 
			
		||||
            context.Response.Redirect(context.RedirectUri);
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        };
 | 
			
		||||
        Events.OnRemoteFailure = context =>
 | 
			
		||||
        {
 | 
			
		||||
            XTrace.WriteException(context.Failure);
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected override void ConfigureClaims()
 | 
			
		||||
    {
 | 
			
		||||
        ClaimActions.MapJsonKey(ClaimConst.AvatarUrl, "avatar_url");
 | 
			
		||||
        ClaimActions.MapJsonKey(ClaimConst.Account, "login");
 | 
			
		||||
 | 
			
		||||
        base.ConfigureClaims();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public override string GetName(JsonElement element)
 | 
			
		||||
    {
 | 
			
		||||
        if (element.TryGetProperty("login", out var loginProp))
 | 
			
		||||
        {
 | 
			
		||||
            return loginProp.GetString() ?? string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
        return string.Empty;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private async Task HandleGitHubStarAsync(OAuthCreatingTicketContext context, string repoFullName = "ThingsGateway/ThingsGateway")
 | 
			
		||||
    {
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(context.AccessToken))
 | 
			
		||||
            throw new InvalidOperationException("Access token is missing.");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        var request = new HttpRequestMessage(HttpMethod.Put, $"https://api.github.com/user/starred/{repoFullName}")
 | 
			
		||||
        {
 | 
			
		||||
            Headers =
 | 
			
		||||
            {
 | 
			
		||||
                Accept = { new MediaTypeWithQualityHeaderValue("application/vnd.github+json") },
 | 
			
		||||
                Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken),
 | 
			
		||||
            },
 | 
			
		||||
            Content = new StringContent(string.Empty) // GitHub Star 接口需要空内容
 | 
			
		||||
        };
 | 
			
		||||
        request.Headers.UserAgent.Add(new ProductInfoHeaderValue("ThingsGateway", "1.0")); // GitHub API 要求 User-Agent
 | 
			
		||||
 | 
			
		||||
        var response = await context.Backchannel.SendAsync(request, context.HttpContext.RequestAborted).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
        if (!response.IsSuccessStatusCode)
 | 
			
		||||
        {
 | 
			
		||||
            var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
            var id = context.Identity.Claims.FirstOrDefault(a => a.Type == ClaimConst.VerificatId).Value;
 | 
			
		||||
 | 
			
		||||
            var verificatInfoIds = _verificatInfoService.GetOne(id.ToLong());
 | 
			
		||||
            _ = Task.Run(async () =>
 | 
			
		||||
            {
 | 
			
		||||
                await Task.Delay(5000).ConfigureAwait(false);
 | 
			
		||||
                await _noticeService.NavigationMesage(verificatInfoIds.ClientIds, "https://github.com/ThingsGateway/ThingsGateway", "创作不易,如有帮助请star仓库").ConfigureAwait(false);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>处理用户信息方法</summary>
 | 
			
		||||
    public override async Task<JsonElement> HandleUserInfoAsync(HttpContext context, OAuthTokenResponse tokens)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        var request = new HttpRequestMessage(HttpMethod.Get, UserInformationEndpoint);
 | 
			
		||||
        request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken);
 | 
			
		||||
        request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github+json"));
 | 
			
		||||
        request.Headers.UserAgent.Add(new ProductInfoHeaderValue("ThingsGateway", "1.0")); // GitHub API 要求 User-Agent
 | 
			
		||||
        var response = await Backchannel.SendAsync(request, context.RequestAborted).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
        var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
        if (response.IsSuccessStatusCode)
 | 
			
		||||
        {
 | 
			
		||||
            return JsonDocument.Parse(content).RootElement;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new OAuthTokenException($"OAuth user info endpoint failure: {await Display(response).ConfigureAwait(false)}");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,6 @@
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
public class GithubOAuthSettings : GiteeOAuthSettings
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,11 @@
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
public static class OAuthUserExtensions
 | 
			
		||||
{
 | 
			
		||||
    public static string TryGetValue(this JsonElement.ObjectEnumerator target, string propertyName)
 | 
			
		||||
    {
 | 
			
		||||
        return target.FirstOrDefault<JsonProperty>((Func<JsonProperty, bool>)(t => t.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase))).Value.ToString() ?? string.Empty;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -18,7 +18,7 @@ public class SysRelationSeedData : ISqlSugarEntitySeedData<SysRelation>
 | 
			
		||||
    /// <inheritdoc/>
 | 
			
		||||
    public IEnumerable<SysRelation> SeedData()
 | 
			
		||||
    {
 | 
			
		||||
        var db = DbContext.Db.GetConnectionScopeWithAttr<SysRelation>().CopyNew();
 | 
			
		||||
        using var db = DbContext.GetDB<SysRelation>();
 | 
			
		||||
        if (db.Queryable<SysRelation>().Any(a => a.ObjectId == RoleConst.SuperAdminId))
 | 
			
		||||
            return Enumerable.Empty<SysRelation>();
 | 
			
		||||
        var data = SeedDataUtil.GetSeedData<SysRelation>(PathExtensions.CombinePathWithOs("SeedData", "Admin", "seed_sys_relation.json"));
 | 
			
		||||
 
 | 
			
		||||
@@ -324,7 +324,7 @@ public class AuthService : IAuthService
 | 
			
		||||
 | 
			
		||||
        #endregion 重新赋值属性,设置本次登录信息为最新的信息
 | 
			
		||||
 | 
			
		||||
        using var db = DbContext.Db.GetConnectionScopeWithAttr<SysUser>().CopyNew();
 | 
			
		||||
        using var db = DbContext.GetDB<SysUser>();
 | 
			
		||||
        //更新用户登录信息
 | 
			
		||||
        if (await db.Updateable(sysUser).UpdateColumns(it => new
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,6 @@
 | 
			
		||||
 | 
			
		||||
using BootstrapBlazor.Components;
 | 
			
		||||
 | 
			
		||||
using Microsoft.AspNetCore.Builder;
 | 
			
		||||
using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
@@ -67,7 +66,7 @@ public class Startup : AppStartup
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void Use(IApplicationBuilder applicationBuilder)
 | 
			
		||||
    public void Use(IServiceProvider serviceProvider)
 | 
			
		||||
    {
 | 
			
		||||
        //检查ConfigId
 | 
			
		||||
        var configIdGroup = DbContext.DbConfigs.GroupBy(it => it.ConfigId);
 | 
			
		||||
@@ -79,7 +78,7 @@ public class Startup : AppStartup
 | 
			
		||||
        //遍历配置
 | 
			
		||||
        DbContext.DbConfigs?.ForEach(it =>
 | 
			
		||||
        {
 | 
			
		||||
            var connection = DbContext.Db.GetConnection(it.ConfigId);//获取数据库连接对象
 | 
			
		||||
            var connection = DbContext.GetDB().GetConnection(it.ConfigId);//获取数据库连接对象
 | 
			
		||||
            if (it.InitDatabase == true)
 | 
			
		||||
                connection.DbMaintenance.CreateDatabase();//创建数据库,如果存在则不创建
 | 
			
		||||
        });
 | 
			
		||||
 
 | 
			
		||||
@@ -27,9 +27,9 @@
 | 
			
		||||
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="System.Formats.Asn1" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="System.Threading.RateLimiting" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(NET9Version)" />
 | 
			
		||||
		<PackageReference Include="System.Formats.Asn1" Version="$(NET9Version)" />
 | 
			
		||||
		<PackageReference Include="System.Threading.RateLimiting" Version="$(NET9Version)" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<Content Remove="SeedData\Admin\*.json" />
 | 
			
		||||
@@ -46,7 +46,6 @@
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<ProjectReference Include="..\ThingsGateway.Razor\ThingsGateway.Razor.csproj" />
 | 
			
		||||
		<ProjectReference Include="..\ThingsGateway.DB\ThingsGateway.DB.csproj" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ public static class ClearTokenUtil
 | 
			
		||||
    public static async Task DeleteUserTokenByOrgIds(HashSet<long> orgIds)
 | 
			
		||||
    {
 | 
			
		||||
        // 获取用户ID列表
 | 
			
		||||
        var userIds = await DbContext.Db.CopyNew().QueryableWithAttr<SysUser>().Where(it => orgIds.Contains(it.OrgId)).Select(it => it.Id).ToListAsync().ConfigureAwait(false);
 | 
			
		||||
        var userIds = await DbContext.GetDB<SysUser>().Queryable<SysUser>().Where(it => orgIds.Contains(it.OrgId)).Select(it => it.Id).ToListAsync().ConfigureAwait(false);
 | 
			
		||||
        //从redis中删除所属机构的用户token
 | 
			
		||||
        App.CacheService.HashDel<VerificatInfo>(CacheConst.Cache_Token, userIds.Select(it => it.ToString()).ToArray());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,9 @@
 | 
			
		||||
    @<div>
 | 
			
		||||
        <span class="mx-3">@item.ConfirmMessage</span>
 | 
			
		||||
 | 
			
		||||
        <Button Text=@Localizers["Jump"] Color="Color.Link" OnClick="()=>NavigationManager.NavigateTo(item.Uri)"></Button>
 | 
			
		||||
        <a href=@item.Uri target="_blank">
 | 
			
		||||
            @item.Uri
 | 
			
		||||
        </a>
 | 
			
		||||
 | 
			
		||||
    </div>;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -156,7 +156,7 @@ public class BlazorAppContext
 | 
			
		||||
            CurrentUser = (await SysUserService.GetUserByIdAsync(UserManager.UserId))!;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    TimeTick timeTick = new("50000");
 | 
			
		||||
    TimeTick timeTick = new("60000");
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 是否拥有按钮授权
 | 
			
		||||
    /// </summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -19,3 +19,4 @@ global using System.Diagnostics.CodeAnalysis;
 | 
			
		||||
global using ThingsGateway.Razor;
 | 
			
		||||
 | 
			
		||||
[assembly: SuppressMessage("Reliability", "CA2007", Justification = "<挂起>", Scope = "module")]
 | 
			
		||||
[assembly: BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsync(true)]
 | 
			
		||||
@@ -33,7 +33,7 @@
 | 
			
		||||
            </PopConfirmButton>
 | 
			
		||||
            <PopConfirmButton Color=Color.Warning IsDisabled="SelectedRows.Count!=1||!AuthorizeButton(AdminOperConst.Edit)" Text=@OperDescLocalizer["ChangeParentResource"] Icon="fa fa-copy" OnConfirm="OnChangeParent">
 | 
			
		||||
                <BodyTemplate>
 | 
			
		||||
                    <div class="min-height-500 overflow-y-auto">
 | 
			
		||||
                    <div class="overflow-y-auto" style="height:500px">
 | 
			
		||||
                        <TreeView Items="MenuTreeItems" IsVirtualize="true" OnTreeItemClick="a=>{ChangeParentId=a.Value.Id;return Task.CompletedTask;}" />
 | 
			
		||||
                    </div>
 | 
			
		||||
                </BodyTemplate>
 | 
			
		||||
 
 | 
			
		||||
@@ -22,12 +22,11 @@ public partial class SessionPage
 | 
			
		||||
 | 
			
		||||
    #region 查询
 | 
			
		||||
 | 
			
		||||
    private async Task<QueryData<SessionOutput>> OnQueryAsync(QueryPageOptions options)
 | 
			
		||||
    private Task<QueryData<SessionOutput>> OnQueryAsync(QueryPageOptions options)
 | 
			
		||||
    {
 | 
			
		||||
        return await Task.Run(async () =>
 | 
			
		||||
        return Task.Run(() =>
 | 
			
		||||
         {
 | 
			
		||||
             var data = await SessionService.PageAsync(options);
 | 
			
		||||
             return data;
 | 
			
		||||
             return SessionService.PageAsync(options);
 | 
			
		||||
         });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +0,0 @@
 | 
			
		||||
@namespace ThingsGateway.Admin.Razor
 | 
			
		||||
@using ThingsGateway.Admin.Application
 | 
			
		||||
 | 
			
		||||
    <AvatarUpload @bind-Value="@Picture" DisplayText=@AdminLocalizer["Picture"] IsSingle Accept="image/*" OnChange="OnAvatarUpload" DefaultFileList=PreviewFileList></AvatarUpload>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,73 +0,0 @@
 | 
			
		||||
//------------------------------------------------------------------------------
 | 
			
		||||
//  此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
 | 
			
		||||
//  此代码版权(除特别声明外的代码)归作者本人Diego所有
 | 
			
		||||
//  源代码使用协议遵循本仓库的开源协议及附加协议
 | 
			
		||||
//  Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
 | 
			
		||||
//  Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
 | 
			
		||||
//  使用文档:https://thingsgateway.cn/
 | 
			
		||||
//  QQ群:605534569
 | 
			
		||||
//------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
using Microsoft.AspNetCore.Components.Forms;
 | 
			
		||||
 | 
			
		||||
using ThingsGateway.Admin.Application;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.Admin.Razor;
 | 
			
		||||
 | 
			
		||||
public partial class SysUserAvatarEdit : IDisposable
 | 
			
		||||
{
 | 
			
		||||
    private List<UploadFile> PreviewFileList;
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    [NotNull]
 | 
			
		||||
    public SysUser? Model { get; set; }
 | 
			
		||||
 | 
			
		||||
    [FileValidation(Extensions = [".png", ".jpg", ".jpeg"], FileSize = 200 * 1024)]
 | 
			
		||||
    public IBrowserFile? Picture { get; set; }
 | 
			
		||||
 | 
			
		||||
    [Inject]
 | 
			
		||||
    private IStringLocalizer<ThingsGateway.Admin.Razor._Imports> AdminLocalizer { get; set; }
 | 
			
		||||
 | 
			
		||||
    private CancellationTokenSource? ReadAvatarToken { get; set; }
 | 
			
		||||
 | 
			
		||||
    [Inject]
 | 
			
		||||
    [NotNull]
 | 
			
		||||
    private ToastService ToastService { get; set; }
 | 
			
		||||
 | 
			
		||||
    public void Dispose()
 | 
			
		||||
    {
 | 
			
		||||
        ReadAvatarToken?.Cancel();
 | 
			
		||||
        GC.SuppressFinalize(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected override Task OnParametersSetAsync()
 | 
			
		||||
    {
 | 
			
		||||
        PreviewFileList = new(new[] { new UploadFile { PrevUrl = Model.Avatar } });
 | 
			
		||||
        return base.OnParametersSetAsync();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private async Task OnAvatarUpload(UploadFile file)
 | 
			
		||||
    {
 | 
			
		||||
        if (file?.File != null)
 | 
			
		||||
        {
 | 
			
		||||
            var format = file.File.ContentType;
 | 
			
		||||
            ReadAvatarToken ??= new CancellationTokenSource();
 | 
			
		||||
            if (ReadAvatarToken.IsCancellationRequested)
 | 
			
		||||
            {
 | 
			
		||||
                ReadAvatarToken.Dispose();
 | 
			
		||||
                ReadAvatarToken = new CancellationTokenSource();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            await file.RequestBase64ImageFileAsync(format, 640, 480, 1024 * 200, ReadAvatarToken.Token);
 | 
			
		||||
 | 
			
		||||
            if (file.Code != 0)
 | 
			
		||||
            {
 | 
			
		||||
                await ToastService.Error($"{file.Error} ");
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Model.Avatar = file.PrevUrl;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
<div class="row g-2 mx-1 form-inline">
 | 
			
		||||
 | 
			
		||||
    <div class="col-12  col-md-12">
 | 
			
		||||
        <SysUserAvatarEdit Model="Model"></SysUserAvatarEdit>
 | 
			
		||||
        <AvatarUpload @bind-Value="@Picture" DisplayText=@AdminLocalizer["Picture"] IsMultiple=false Accept="image/*" OnChange="OnAvatarUpload" DefaultFileList=PreviewFileList></AvatarUpload>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="col-12  col-md-6">
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,8 @@
 | 
			
		||||
//  QQ群:605534569
 | 
			
		||||
//------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
using Microsoft.AspNetCore.Components.Forms;
 | 
			
		||||
 | 
			
		||||
using ThingsGateway.Admin.Application;
 | 
			
		||||
using ThingsGateway.NewLife.Extension;
 | 
			
		||||
 | 
			
		||||
@@ -45,4 +47,55 @@ public partial class SysUserEdit
 | 
			
		||||
        Model.OrgId = items.LastOrDefault()?.Parent?.Value?.ToLong() ?? 0;
 | 
			
		||||
        return Task.CompletedTask;
 | 
			
		||||
    }
 | 
			
		||||
    [Inject]
 | 
			
		||||
    ToastService ToastService { get; set; }
 | 
			
		||||
 | 
			
		||||
    #region 头像
 | 
			
		||||
 | 
			
		||||
    private List<UploadFile> PreviewFileList;
 | 
			
		||||
 | 
			
		||||
    [FileValidation(Extensions = [".png", ".jpg", ".jpeg"], FileSize = 200 * 1024)]
 | 
			
		||||
    public IBrowserFile? Picture { get; set; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private CancellationTokenSource? ReadAvatarToken { get; set; }
 | 
			
		||||
 | 
			
		||||
    public void Dispose()
 | 
			
		||||
    {
 | 
			
		||||
        ReadAvatarToken?.Cancel();
 | 
			
		||||
        GC.SuppressFinalize(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected override void OnInitialized()
 | 
			
		||||
    {
 | 
			
		||||
        PreviewFileList = new(new[] { new UploadFile { PrevUrl = Model.Avatar } });
 | 
			
		||||
        base.OnInitialized();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private async Task OnAvatarUpload(UploadFile file)
 | 
			
		||||
    {
 | 
			
		||||
        if (file?.File != null)
 | 
			
		||||
        {
 | 
			
		||||
            var format = file.File.ContentType;
 | 
			
		||||
            ReadAvatarToken ??= new CancellationTokenSource();
 | 
			
		||||
            if (ReadAvatarToken.IsCancellationRequested)
 | 
			
		||||
            {
 | 
			
		||||
                ReadAvatarToken.Dispose();
 | 
			
		||||
                ReadAvatarToken = new CancellationTokenSource();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            await file.RequestBase64ImageFileAsync(format, 640, 480, 1024 * 200, token: ReadAvatarToken.Token);
 | 
			
		||||
 | 
			
		||||
            if (file.Code != 0)
 | 
			
		||||
            {
 | 
			
		||||
                await ToastService.Error($"{file.Error} ");
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Model.Avatar = file.PrevUrl;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #endregion 头像
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
 | 
			
		||||
<ValidateForm class="p-4" Model="@Model" OnValidSubmit="OnSave">
 | 
			
		||||
 | 
			
		||||
    <AvatarUpload @bind-Value="@Picture" DisplayText=@AdminLocalizer["Picture"] IsSingle Accept="image/*" OnChange="OnAvatarUpload" DefaultFileList=PreviewFileList></AvatarUpload>
 | 
			
		||||
    <AvatarUpload @bind-Value="@Picture" DisplayText=@AdminLocalizer["Picture"] IsMultiple=false Accept="image/*" OnChange="OnAvatarUpload" DefaultFileList=PreviewFileList></AvatarUpload>
 | 
			
		||||
 | 
			
		||||
    <BootstrapInput @bind-Value=@Model.Phone></BootstrapInput>
 | 
			
		||||
    <BootstrapInput @bind-Value=@Model.Email></BootstrapInput>
 | 
			
		||||
 
 | 
			
		||||
@@ -40,10 +40,10 @@ public partial class UserInfoEditComponent
 | 
			
		||||
        GC.SuppressFinalize(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected override Task OnParametersSetAsync()
 | 
			
		||||
    protected override void OnInitialized()
 | 
			
		||||
    {
 | 
			
		||||
        PreviewFileList = new(new[] { new UploadFile { PrevUrl = Model.Avatar } });
 | 
			
		||||
        return base.OnParametersSetAsync();
 | 
			
		||||
        base.OnInitialized();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private async Task OnAvatarUpload(UploadFile file)
 | 
			
		||||
@@ -58,7 +58,7 @@ public partial class UserInfoEditComponent
 | 
			
		||||
                ReadAvatarToken = new CancellationTokenSource();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            await file.RequestBase64ImageFileAsync(format, 640, 480, 1024 * 200, ReadAvatarToken.Token);
 | 
			
		||||
            await file.RequestBase64ImageFileAsync(format, 640, 480, 1024 * 200, token: ReadAvatarToken.Token);
 | 
			
		||||
 | 
			
		||||
            if (file.Code != 0)
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
@@ -9,14 +9,15 @@
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.16" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="$(NET8Version)" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	<ItemGroup Condition="'$(TargetFramework)'=='net9.0'">
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="$(NET9Version)" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
 | 
			
		||||
		<!--<UseRazorSourceGenerator>false</UseRazorSourceGenerator>-->
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<Content Remove="Locales\*.json" />
 | 
			
		||||
@@ -32,6 +33,12 @@
 | 
			
		||||
		<None Remove="$(SolutionDir)..\README.md" Pack="false" PackagePath="\" />
 | 
			
		||||
		<None Remove="$(SolutionDir)..\README.zh-CN.md" Pack="false" PackagePath="\" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<ProjectReference Include="..\BlazorSetParametersAsyncGenerator\BlazorSetParametersAsyncGenerator.csproj" PrivateAssets="all" OutputItemType="Analyzer" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	
 | 
			
		||||
</Project>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@
 | 
			
		||||
      "ThingsGateway.SqlSugar",
 | 
			
		||||
      "ThingsGateway.Admin.Application",
 | 
			
		||||
      "ThingsGateway.Admin.Razor",
 | 
			
		||||
      "ThingsGateway.DB",
 | 
			
		||||
      "ThingsGateway.Razor"
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@
 | 
			
		||||
      "ThingsGateway.SqlSugar",
 | 
			
		||||
      "ThingsGateway.Admin.Application",
 | 
			
		||||
      "ThingsGateway.Admin.Razor",
 | 
			
		||||
      "ThingsGateway.DB",
 | 
			
		||||
      "ThingsGateway.Razor"
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,7 @@ public class SingleFilePublish : ISingleFilePublish
 | 
			
		||||
            "ThingsGateway.NewLife.X",
 | 
			
		||||
            "ThingsGateway.Razor",
 | 
			
		||||
            "ThingsGateway.Admin.Razor"   ,
 | 
			
		||||
             "ThingsGateway.DB",
 | 
			
		||||
            "ThingsGateway.Admin.Application",
 | 
			
		||||
            "ThingsGateway.SqlSugar",
 | 
			
		||||
        ];
 | 
			
		||||
 
 | 
			
		||||
@@ -48,11 +48,11 @@ public class Startup : AppStartup
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // 事件总线
 | 
			
		||||
        services.AddEventBus(options =>
 | 
			
		||||
        {
 | 
			
		||||
        //// 事件总线
 | 
			
		||||
        //services.AddEventBus(options =>
 | 
			
		||||
        //{
 | 
			
		||||
 | 
			
		||||
        });
 | 
			
		||||
        //});
 | 
			
		||||
 | 
			
		||||
        // 任务调度
 | 
			
		||||
        services.AddSchedule(options =>
 | 
			
		||||
@@ -151,8 +151,6 @@ public class Startup : AppStartup
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        services.AddHealthChecks();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        #region 控制台美化
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@
 | 
			
		||||
 | 
			
		||||
		<!--动态适用GC-->
 | 
			
		||||
		<GarbageCollectionAdaptationMode>1</GarbageCollectionAdaptationMode>
 | 
			
		||||
		<CETCompat>false</CETCompat>
 | 
			
		||||
		<!--使用自托管线程池-->
 | 
			
		||||
		<!--<UseWindowsThreadPool>false</UseWindowsThreadPool> -->
 | 
			
		||||
 | 
			
		||||
@@ -45,7 +46,7 @@
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Data.Sqlite" Version="$(NET9Version)" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	<!--安装服务守护-->
 | 
			
		||||
	<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
 | 
			
		||||
@@ -54,8 +55,8 @@
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.1" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="$(NET9Version)" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="$(NET9Version)" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
@@ -41,19 +41,19 @@ public abstract class PrimaryKeyEntity : PrimaryIdEntity
 | 
			
		||||
    [SugarColumn(ColumnDescription = "扩展信息", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    [AutoGenerateColumn(Ignore = true)]
 | 
			
		||||
    public virtual string? ExtJson { get; set; }
 | 
			
		||||
    public virtual string ExtJson { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public interface IBaseEntity
 | 
			
		||||
{
 | 
			
		||||
    DateTime? CreateTime { get; set; }
 | 
			
		||||
    string? CreateUser { get; set; }
 | 
			
		||||
    DateTime CreateTime { get; set; }
 | 
			
		||||
    string CreateUser { get; set; }
 | 
			
		||||
    long CreateUserId { get; set; }
 | 
			
		||||
    bool IsDelete { get; set; }
 | 
			
		||||
    int? SortCode { get; set; }
 | 
			
		||||
    DateTime? UpdateTime { get; set; }
 | 
			
		||||
    string? UpdateUser { get; set; }
 | 
			
		||||
    long? UpdateUserId { get; set; }
 | 
			
		||||
    int SortCode { get; set; }
 | 
			
		||||
    DateTime UpdateTime { get; set; }
 | 
			
		||||
    string UpdateUser { get; set; }
 | 
			
		||||
    long UpdateUserId { get; set; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
@@ -61,13 +61,22 @@ public interface IBaseEntity
 | 
			
		||||
/// </summary>
 | 
			
		||||
public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
 | 
			
		||||
{
 | 
			
		||||
    private long createUserId;
 | 
			
		||||
    private long updateUserId;
 | 
			
		||||
    private DateTime createTime;
 | 
			
		||||
    private DateTime updateTime;
 | 
			
		||||
    private int sortCode;
 | 
			
		||||
    private bool isDelete = false;
 | 
			
		||||
    private string createUser;
 | 
			
		||||
    private string updateUser;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 创建时间
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    [SugarColumn(ColumnDescription = "创建时间", IsOnlyIgnoreUpdate = true, IsNullable = true)]
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    [AutoGenerateColumn(Visible = false, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
 | 
			
		||||
    public virtual DateTime? CreateTime { get; set; }
 | 
			
		||||
    public virtual DateTime CreateTime { get => createTime; set => createTime = value; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 创建人
 | 
			
		||||
@@ -76,7 +85,7 @@ public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    [NotNull]
 | 
			
		||||
    [AutoGenerateColumn(Ignore = true)]
 | 
			
		||||
    public virtual string? CreateUser { get; set; }
 | 
			
		||||
    public virtual string CreateUser { get => createUser; set => createUser = value; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 创建者Id
 | 
			
		||||
@@ -84,7 +93,7 @@ public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
 | 
			
		||||
    [SugarColumn(ColumnDescription = "创建者Id", IsOnlyIgnoreUpdate = true, IsNullable = true)]
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    [AutoGenerateColumn(Ignore = true)]
 | 
			
		||||
    public virtual long CreateUserId { get; set; }
 | 
			
		||||
    public virtual long CreateUserId { get => createUserId; set => createUserId = value; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 软删除
 | 
			
		||||
@@ -92,8 +101,7 @@ public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
 | 
			
		||||
    [SugarColumn(ColumnDescription = "软删除", IsNullable = true)]
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    [AutoGenerateColumn(Ignore = true)]
 | 
			
		||||
    public virtual bool IsDelete { get; set; } = false;
 | 
			
		||||
 | 
			
		||||
    public virtual bool IsDelete { get => isDelete; set => isDelete = value; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 更新时间
 | 
			
		||||
@@ -101,7 +109,7 @@ public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
 | 
			
		||||
    [SugarColumn(ColumnDescription = "更新时间", IsOnlyIgnoreInsert = true, IsNullable = true)]
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    [AutoGenerateColumn(Visible = false, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
 | 
			
		||||
    public virtual DateTime? UpdateTime { get; set; }
 | 
			
		||||
    public virtual DateTime UpdateTime { get => updateTime; set => updateTime = value; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 更新人
 | 
			
		||||
@@ -109,7 +117,7 @@ public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
 | 
			
		||||
    [SugarColumn(ColumnDescription = "更新人", IsOnlyIgnoreInsert = true, IsNullable = true)]
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    [AutoGenerateColumn(Ignore = true)]
 | 
			
		||||
    public virtual string? UpdateUser { get; set; }
 | 
			
		||||
    public virtual string UpdateUser { get => updateUser; set => updateUser = value; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 修改者Id
 | 
			
		||||
@@ -117,7 +125,7 @@ public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
 | 
			
		||||
    [SugarColumn(ColumnDescription = "修改者Id", IsOnlyIgnoreInsert = true, IsNullable = true)]
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    [AutoGenerateColumn(Ignore = true)]
 | 
			
		||||
    public virtual long? UpdateUserId { get; set; }
 | 
			
		||||
    public virtual long UpdateUserId { get => updateUserId; set => updateUserId = value; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 排序码
 | 
			
		||||
@@ -125,7 +133,7 @@ public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
 | 
			
		||||
    [SugarColumn(ColumnDescription = "排序码", IsNullable = true)]
 | 
			
		||||
    [AutoGenerateColumn(Visible = false, DefaultSort = true, Sortable = true, DefaultSortOrder = SortOrder.Asc)]
 | 
			
		||||
    [IgnoreExcel]
 | 
			
		||||
    public virtual int? SortCode { get; set; }
 | 
			
		||||
    public virtual int SortCode { get => sortCode; set => sortCode = value; }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public interface IBaseDataEntity
 | 
			
		||||
 
 | 
			
		||||
@@ -124,16 +124,8 @@ public class SugarAopService : ISugarAopService
 | 
			
		||||
            //执行时间超过1秒
 | 
			
		||||
            if (db.Ado.SqlExecutionTime.TotalSeconds > 1)
 | 
			
		||||
            {
 | 
			
		||||
                //代码CS文件名
 | 
			
		||||
                var fileName = db.Ado.SqlStackTrace.FirstFileName;
 | 
			
		||||
                //代码行数
 | 
			
		||||
                var fileLine = db.Ado.SqlStackTrace.FirstLine;
 | 
			
		||||
                //方法名
 | 
			
		||||
                var FirstMethodName = db.Ado.SqlStackTrace.FirstMethodName;
 | 
			
		||||
 | 
			
		||||
                DbContext.WriteLog($"{fileName}-{FirstMethodName}-{fileLine} 执行时间超过1秒");
 | 
			
		||||
                DbContext.WriteLog($"SQL执行时间超过1秒");
 | 
			
		||||
                DbContext.WriteLogWithSql(UtilMethods.GetNativeSql(sql, pars));
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -161,7 +161,7 @@ public class BaseService<T> : IDataService<T>, IDisposable where T : class, new(
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    protected SqlSugarClient GetDB()
 | 
			
		||||
    {
 | 
			
		||||
        return DbContext.Db.GetConnectionScopeWithAttr<T>().CopyNew();
 | 
			
		||||
        return DbContext.GetDB<T>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,7 @@ public static class CodeFirstUtils
 | 
			
		||||
            var entityType = seedType.GetInterfaces().First().GetGenericArguments().First();//获取实体类型
 | 
			
		||||
            var tenantAtt = entityType.GetCustomAttribute<TenantAttribute>();//获取sqlSugar多库特性
 | 
			
		||||
            if (tenantAtt == null) continue;//如果没有多库特性就下一个
 | 
			
		||||
            using var db = DbContext.Db.GetConnectionScope(tenantAtt.configId.ToString()).CopyNew();//获取数据库对象
 | 
			
		||||
            using var db = DbContext.GetDB(tenantAtt.configId.ToString());//获取数据库对象
 | 
			
		||||
            var config = DbContext.DbConfigs.FirstOrDefault(u => u.ConfigId.ToString() == tenantAtt.configId.ToString());//获取数据库配置
 | 
			
		||||
            if (config?.InitSeedData != true) continue;
 | 
			
		||||
            var entityInfo = db.EntityMaintenance.GetEntityInfo(entityType);
 | 
			
		||||
@@ -66,7 +66,8 @@ public static class CodeFirstUtils
 | 
			
		||||
            {
 | 
			
		||||
                // 按主键进行批量增加和更新
 | 
			
		||||
                var storage = db.StorageableByObject(seedData.ToList()).ToStorage();
 | 
			
		||||
                if (ignoreAdd == null) storage.AsInsertable.ExecuteCommand();//执行插入
 | 
			
		||||
                if (ignoreAdd == null)
 | 
			
		||||
                    storage.AsInsertable.ExecuteCommand();//执行插入
 | 
			
		||||
                if (ignoreUpdate == null && config.IsUpdateSeedData) storage.AsUpdateable.ExecuteCommand();//只有没有忽略更新的特性才执行更新
 | 
			
		||||
            }
 | 
			
		||||
            else// 没有主键或者不是预定义的主键(有重复的可能)
 | 
			
		||||
@@ -98,7 +99,7 @@ public static class CodeFirstUtils
 | 
			
		||||
            var ignoreInit = entityType.GetCustomAttribute<IgnoreInitTableAttribute>();//获取忽略初始化特性
 | 
			
		||||
            if (ignoreInit != null) continue;//如果有忽略初始化特性
 | 
			
		||||
            if (tenantAtt == null) continue;//如果没有多库特性就下一个
 | 
			
		||||
            using var db = DbContext.Db.GetConnectionScope(tenantAtt.configId.ToString()).CopyNew();//获取数据库对象
 | 
			
		||||
            using var db = DbContext.GetDB(tenantAtt.configId.ToString());//获取数据库对象
 | 
			
		||||
            var splitTable = entityType.GetCustomAttribute<SplitTableAttribute>();//获取自动分表特性
 | 
			
		||||
            if (splitTable == null)//如果特性是空
 | 
			
		||||
                db.CodeFirst.InitTables(entityType);//普通创建
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ public static class DbContext
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// SqlSugar 数据库实例
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static readonly SqlSugarScope Db;
 | 
			
		||||
    private static readonly SqlSugarClient Db;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 读取配置文件中的 ConnectionStrings:Sqlsugar 配置节点
 | 
			
		||||
@@ -37,9 +37,28 @@ public static class DbContext
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static SqlSugarClient GetDB<T>()
 | 
			
		||||
    {
 | 
			
		||||
        return Db.GetConnectionScopeWithAttr<T>().CopyNew();
 | 
			
		||||
        return Db.GetConnectionWithAttr<T>().CopyNew();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取数据库连接
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static SqlSugarClient GetDB()
 | 
			
		||||
    {
 | 
			
		||||
        return Db;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取数据库连接
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static SqlSugarClient GetDB(string tenant)
 | 
			
		||||
    {
 | 
			
		||||
        return Db.GetConnection(tenant).CopyNew();//获取数据库对象
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private static ISugarAopService sugarAopService;
 | 
			
		||||
    private static ISugarAopService SugarAopService
 | 
			
		||||
    {
 | 
			
		||||
@@ -62,7 +81,7 @@ public static class DbContext
 | 
			
		||||
        {
 | 
			
		||||
            DbConfigs.ForEach(it =>
 | 
			
		||||
            {
 | 
			
		||||
                var sqlsugarScope = db.GetConnectionScope(it.ConfigId);//获取当前库
 | 
			
		||||
                var sqlsugarScope = db.GetConnection(it.ConfigId);//获取当前库
 | 
			
		||||
                MoreSetting(sqlsugarScope);//更多设置
 | 
			
		||||
                SugarAopService.AopSetting(sqlsugarScope, it.IsShowSql);//aop配置
 | 
			
		||||
            }
 | 
			
		||||
@@ -75,7 +94,7 @@ public static class DbContext
 | 
			
		||||
    /// 实体更多配置
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="db"></param>
 | 
			
		||||
    private static void MoreSetting(SqlSugarScopeProvider db)
 | 
			
		||||
    private static void MoreSetting(SqlSugarProvider db)
 | 
			
		||||
    {
 | 
			
		||||
        db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ namespace ThingsGateway.Admin.Application;
 | 
			
		||||
/// 种子数据工具类
 | 
			
		||||
/// </summary>
 | 
			
		||||
[ThingsGateway.DependencyInjection.SuppressSniffer]
 | 
			
		||||
public static class SeedDataUtil
 | 
			
		||||
public static partial class SeedDataUtil
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 获取List列表
 | 
			
		||||
@@ -53,9 +53,7 @@ public static class SeedDataUtil
 | 
			
		||||
        if (!string.IsNullOrEmpty(json))//如果有内容
 | 
			
		||||
        {
 | 
			
		||||
            //字段没有数据的替换成null
 | 
			
		||||
            json = Regex.Replace(json, "\\\"[^\"]+?\\\": \\\"\\\"", match => match.Value.Replace("\"\"", "null"));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            json = SeedDataRegex().Replace(json, match => match.Value.Replace("\"\"", "null"));
 | 
			
		||||
 | 
			
		||||
            var jtoken = JToken.Parse(json);
 | 
			
		||||
            jtoken = jtoken.SelectToken("Records") ?? jtoken.SelectToken("RECORDS");
 | 
			
		||||
@@ -96,6 +94,9 @@ public static class SeedDataUtil
 | 
			
		||||
 | 
			
		||||
        return seedData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [GeneratedRegex("\\\"[^\"]+?\\\": \\\"\\\"")]
 | 
			
		||||
    private static partial Regex SeedDataRegex();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,6 @@
 | 
			
		||||
 | 
			
		||||
using BootstrapBlazor.Components;
 | 
			
		||||
 | 
			
		||||
using Microsoft.AspNetCore.Builder;
 | 
			
		||||
using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
 | 
			
		||||
using ThingsGateway.SqlSugar;
 | 
			
		||||
@@ -32,11 +31,10 @@ public class Startup : AppStartup
 | 
			
		||||
 | 
			
		||||
        StaticConfig.EnableAllWhereIF = true;
 | 
			
		||||
 | 
			
		||||
        services.AddSingleton<ISugarAopService, SugarAopService>();
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void Use(IApplicationBuilder applicationBuilder)
 | 
			
		||||
    public void Use(IServiceProvider serviceProvider)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<!--<PackageReference Include="ThingsGateway.Razor" Version="$(SourceGeneratorVersion)" />-->
 | 
			
		||||
		<ProjectReference Include="..\ThingsGateway.Razor\ThingsGateway.Razor.csproj" />
 | 
			
		||||
		<ProjectReference Include="..\ThingsGateway.SqlSugar\ThingsGateway.SqlSugar.csproj" />
 | 
			
		||||
		<!--<PackageReference Include="SqlSugarCore" Version="5.1.4.195" />-->
 | 
			
		||||
 
 | 
			
		||||
@@ -67,13 +67,13 @@ internal static class Penetrates
 | 
			
		||||
            ["patch"] = "PATCH"
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        IsApiControllerCached = new ConcurrentDictionary<Type, bool>();
 | 
			
		||||
        //IsApiControllerCached = new ConcurrentDictionary<Type, bool>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// <see cref="IsApiController(Type)"/> 缓存集合
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    private static readonly ConcurrentDictionary<Type, bool> IsApiControllerCached;
 | 
			
		||||
    ///// <summary>
 | 
			
		||||
    ///// <see cref="IsApiController(Type)"/> 缓存集合
 | 
			
		||||
    ///// </summary>
 | 
			
		||||
    //private static readonly ConcurrentDictionary<Type, bool> IsApiControllerCached;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 是否是Api控制器
 | 
			
		||||
@@ -82,13 +82,13 @@ internal static class Penetrates
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    internal static bool IsApiController(Type type)
 | 
			
		||||
    {
 | 
			
		||||
        return IsApiControllerCached.GetOrAdd(type, Function);
 | 
			
		||||
 | 
			
		||||
        //return IsApiControllerCached.GetOrAdd(type, Function);
 | 
			
		||||
        return Function(type);
 | 
			
		||||
        // 本地静态方法
 | 
			
		||||
        static bool Function(Type type)
 | 
			
		||||
        {
 | 
			
		||||
            // 排除 OData 控制器
 | 
			
		||||
            if (type.Assembly.GetName().Name.StartsWith("Microsoft.AspNetCore.OData")) return false;
 | 
			
		||||
            //// 排除 OData 控制器
 | 
			
		||||
            //if (type.Assembly.GetName().Name.StartsWith("Microsoft.AspNetCore.OData")) return false;
 | 
			
		||||
 | 
			
		||||
            // 不能是非公开、基元类型、值类型、抽象类、接口、泛型类
 | 
			
		||||
            if (!type.IsPublic || type.IsPrimitive || type.IsValueType || type.IsAbstract || type.IsInterface || type.IsGenericType) return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -37,15 +37,15 @@ public sealed class Retry
 | 
			
		||||
    {
 | 
			
		||||
        if (action == null) throw new ArgumentNullException(nameof(action));
 | 
			
		||||
 | 
			
		||||
        InvokeAsync(async () =>
 | 
			
		||||
        InvokeAsync(() =>
 | 
			
		||||
        {
 | 
			
		||||
            action();
 | 
			
		||||
            await Task.CompletedTask.ConfigureAwait(false);
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        }, numRetries, retryTimeout, finalThrow, exceptionTypes, fallbackPolicy == null ? null
 | 
			
		||||
        : async (ex) =>
 | 
			
		||||
        : (ex) =>
 | 
			
		||||
        {
 | 
			
		||||
            fallbackPolicy?.Invoke(ex);
 | 
			
		||||
            await Task.CompletedTask.ConfigureAwait(false);
 | 
			
		||||
            return Task.CompletedTask;
 | 
			
		||||
        }, retryAction).GetAwaiter().GetResult();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -160,8 +160,8 @@ public sealed class DatabaseLoggerProvider : ILoggerProvider, ISupportExternalSc
 | 
			
		||||
        _databaseLoggingWriter = _serviceScope.ServiceProvider.GetRequiredService(databaseLoggingWriterType) as IDatabaseLoggingWriter;
 | 
			
		||||
 | 
			
		||||
        // 创建长时间运行的后台任务,并将日志消息队列中数据写入存储中
 | 
			
		||||
        _processQueueTask = Task.Factory.StartNew(async state => await ((DatabaseLoggerProvider)state).ProcessQueueAsync().ConfigureAwait(false)
 | 
			
		||||
            , this, TaskCreationOptions.LongRunning);
 | 
			
		||||
        _processQueueTask = Task.Factory.StartNew(ProcessQueueAsync
 | 
			
		||||
            , TaskCreationOptions.LongRunning);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -90,8 +90,7 @@ public sealed class FileLoggerProvider : ILoggerProvider, ISupportExternalScope
 | 
			
		||||
        _fileLoggingWriter = new FileLoggingWriter(this);
 | 
			
		||||
 | 
			
		||||
        // 创建长时间运行的后台任务,并将日志消息队列中数据写入文件中
 | 
			
		||||
        _processQueueTask = Task.Factory.StartNew(async state => await ((FileLoggerProvider)state).ProcessQueueAsync().ConfigureAwait(false)
 | 
			
		||||
            , this, TaskCreationOptions.LongRunning);
 | 
			
		||||
        _processQueueTask = Task.Factory.StartNew(ProcessQueueAsync, TaskCreationOptions.LongRunning);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -110,8 +110,7 @@ internal sealed partial class SchedulerFactory : ISchedulerFactory
 | 
			
		||||
        if (Persistence is not null)
 | 
			
		||||
        {
 | 
			
		||||
            // 创建长时间运行的后台任务,并将作业运行消息写入持久化中
 | 
			
		||||
            _processQueueTask = Task.Factory.StartNew(async state => await ((SchedulerFactory)state).ProcessQueueAsync().ConfigureAwait(false)
 | 
			
		||||
                , this, TaskCreationOptions.LongRunning);
 | 
			
		||||
            _processQueueTask = Task.Factory.StartNew(ProcessQueueAsync, TaskCreationOptions.LongRunning);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -39,22 +39,22 @@
 | 
			
		||||
		<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
 | 
			
		||||
		<PackageReference Include="Mapster" Version="7.4.0" />
 | 
			
		||||
		<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.5.4" />
 | 
			
		||||
		<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.4" />
 | 
			
		||||
		<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.16" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.16" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(NET8Version)" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(NET8Version)" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.2" />
 | 
			
		||||
		<PackageReference Include="System.Reflection.MetadataLoadContext" Version="8.0.1" />
 | 
			
		||||
		<PackageReference Include="System.Text.Json" Version="8.0.5" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="System.Reflection.MetadataLoadContext" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="System.Text.Json" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(NET9Version)" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(NET9Version)" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(NET9Version)" />
 | 
			
		||||
		<PackageReference Include="System.Reflection.MetadataLoadContext" Version="$(NET9Version)" />
 | 
			
		||||
		<PackageReference Include="System.Text.Json" Version="$(NET9Version)" />
 | 
			
		||||
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -127,16 +127,11 @@ public class MachineInfo
 | 
			
		||||
 | 
			
		||||
    //static MachineInfo() => RegisterAsync().Wait(100);
 | 
			
		||||
 | 
			
		||||
    private static Task<MachineInfo>? _task;
 | 
			
		||||
    /// <summary>异步注册一个初始化后的机器信息实例</summary>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static Task<MachineInfo> RegisterAsync()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        if (_task != null) return _task;
 | 
			
		||||
 | 
			
		||||
        return _task = Task.Factory.StartNew(() =>
 | 
			
		||||
    public static MachineInfo Register()
 | 
			
		||||
    {
 | 
			
		||||
        if (Current != null) return Current;
 | 
			
		||||
        // 文件缓存,加快机器信息获取。在Linux下,可能StarAgent以root权限写入缓存文件,其它应用以普通用户访问
 | 
			
		||||
        var file = Path.GetTempPath().CombinePath("machine_info.json");
 | 
			
		||||
        var json = "";
 | 
			
		||||
@@ -177,13 +172,12 @@ public class MachineInfo
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return mi;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>获取当前信息,如果未设置则等待异步注册结果</summary>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static MachineInfo GetCurrent() => Current ?? RegisterAsync().ConfigureAwait(false).GetAwaiter().GetResult();
 | 
			
		||||
    public static MachineInfo GetCurrent() => Current ?? Register();
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
@@ -1160,7 +1154,7 @@ public class MachineInfo
 | 
			
		||||
    public static String GetInfo(String path, String property, String? nameSpace = null)
 | 
			
		||||
    {
 | 
			
		||||
        // Linux Mono不支持WMI
 | 
			
		||||
        if (Runtime.Mono) return "";
 | 
			
		||||
        if (Runtime.Mono) return string.Empty;
 | 
			
		||||
 | 
			
		||||
        var bbs = new List<String>();
 | 
			
		||||
        try
 | 
			
		||||
@@ -1181,7 +1175,7 @@ public class MachineInfo
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
            if (XTrace.Log.Level <= LogLevel.Debug) XTrace.WriteLine("WMI.GetInfo({0})失败!{1}", path, ex.Message);
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        bbs.Sort();
 | 
			
		||||
 
 | 
			
		||||
@@ -854,13 +854,13 @@ public static class IOHelper
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static String ToHex(this Byte[]? data, Int32 offset = 0, Int32 count = -1)
 | 
			
		||||
    {
 | 
			
		||||
        if (data == null || data.Length <= 0) return "";
 | 
			
		||||
        if (data == null || data.Length <= 0) return string.Empty;
 | 
			
		||||
 | 
			
		||||
        if (count < 0)
 | 
			
		||||
            count = data.Length - offset;
 | 
			
		||||
        else if (offset + count > data.Length)
 | 
			
		||||
            count = data.Length - offset;
 | 
			
		||||
        if (count == 0) return "";
 | 
			
		||||
        if (count == 0) return string.Empty;
 | 
			
		||||
 | 
			
		||||
        //return BitConverter.ToString(data).Replace("-", null);
 | 
			
		||||
        // 上面的方法要替换-,效率太低
 | 
			
		||||
@@ -883,7 +883,7 @@ public static class IOHelper
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static String ToHex(this Byte[]? data, String? separate, Int32 groupSize = 0, Int32 maxLength = -1)
 | 
			
		||||
    {
 | 
			
		||||
        if (data == null || data.Length <= 0) return "";
 | 
			
		||||
        if (data == null || data.Length <= 0) return string.Empty;
 | 
			
		||||
 | 
			
		||||
        if (groupSize < 0) groupSize = 0;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -172,7 +172,6 @@ public class TimerScheduler : ILogFeature
 | 
			
		||||
                        else if (!timer.Async)
 | 
			
		||||
                            Execute(timer);
 | 
			
		||||
                        else
 | 
			
		||||
                            //Task.Factory.StartNew(() => ProcessItem(timer));
 | 
			
		||||
                            // 不需要上下文流动,捕获所有异常
 | 
			
		||||
                            ThreadPool.UnsafeQueueUserWorkItem(s =>
 | 
			
		||||
                            {
 | 
			
		||||
@@ -231,8 +230,6 @@ public class TimerScheduler : ILogFeature
 | 
			
		||||
    {
 | 
			
		||||
        if (state is not TimerX timer) return;
 | 
			
		||||
 | 
			
		||||
        TimerX.Current = timer;
 | 
			
		||||
 | 
			
		||||
        // 控制日志显示
 | 
			
		||||
        WriteLogEventArgs.CurrentThreadName = Name == "Default" ? "T" : Name;
 | 
			
		||||
 | 
			
		||||
@@ -274,7 +271,6 @@ public class TimerScheduler : ILogFeature
 | 
			
		||||
    {
 | 
			
		||||
        if (state is not TimerX timer) return;
 | 
			
		||||
 | 
			
		||||
        TimerX.Current = timer;
 | 
			
		||||
 | 
			
		||||
        // 控制日志显示
 | 
			
		||||
        WriteLogEventArgs.CurrentThreadName = Name == "Default" ? "T" : Name;
 | 
			
		||||
@@ -322,8 +318,6 @@ public class TimerScheduler : ILogFeature
 | 
			
		||||
 | 
			
		||||
        timer.Calling = false;
 | 
			
		||||
 | 
			
		||||
        TimerX.Current = null;
 | 
			
		||||
 | 
			
		||||
        // 控制日志显示
 | 
			
		||||
        WriteLogEventArgs.CurrentThreadName = null;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -84,15 +84,7 @@ public class TimerX : ITimer, IDisposable
 | 
			
		||||
    private readonly Cron[]? _crons;
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
    #region 静态
 | 
			
		||||
#if NET452
 | 
			
		||||
    private static readonly ThreadLocal<TimerX?> _Current = new();
 | 
			
		||||
#else
 | 
			
		||||
    private static readonly AsyncLocal<TimerX?> _Current = new();
 | 
			
		||||
#endif
 | 
			
		||||
    /// <summary>当前定时器</summary>
 | 
			
		||||
    public static TimerX? Current { get => _Current.Value; set => _Current.Value = value; }
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #region 构造
 | 
			
		||||
    private TimerX(Object? target, MethodInfo method, Object? state, String? scheduler = null)
 | 
			
		||||
@@ -382,19 +374,27 @@ public class TimerX : ITimer, IDisposable
 | 
			
		||||
    /// <param name="period">构造 Timer 时指定的回调方法调用之间的时间间隔。 指定 InfiniteTimeSpan 可以禁用定期终止。</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public Boolean Change(TimeSpan dueTime, TimeSpan period)
 | 
			
		||||
    {
 | 
			
		||||
        return Change((int)dueTime.TotalMilliseconds, (int)period.TotalMilliseconds);
 | 
			
		||||
    }
 | 
			
		||||
    /// <summary>更改计时器的启动时间和方法调用之间的时间间隔,使用 TimeSpan 值度量时间间隔。</summary>
 | 
			
		||||
    /// <param name="dueTime">一个 TimeSpan,表示在调用构造 ITimer 时指定的回调方法之前的延迟时间量。 指定 InfiniteTimeSpan 可防止重新启动计时器。 指定 Zero 可立即重新启动计时器。</param>
 | 
			
		||||
    /// <param name="period">构造 Timer 时指定的回调方法调用之间的时间间隔。 指定 InfiniteTimeSpan 可以禁用定期终止。</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public Boolean Change(int dueTime, int period)
 | 
			
		||||
    {
 | 
			
		||||
        if (Absolutely) return false;
 | 
			
		||||
        if (Crons?.Length > 0) return false;
 | 
			
		||||
 | 
			
		||||
        if (period.TotalMilliseconds <= 0)
 | 
			
		||||
        if (period <= 0)
 | 
			
		||||
        {
 | 
			
		||||
            Dispose();
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Period = (Int32)period.TotalMilliseconds;
 | 
			
		||||
        Period = period;
 | 
			
		||||
 | 
			
		||||
        if (dueTime.TotalMilliseconds >= 0) SetNext((Int32)dueTime.TotalMilliseconds);
 | 
			
		||||
        if (dueTime >= 0) SetNext(dueTime);
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -280,43 +280,6 @@ public static class ControlHelper
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void ProcessBell(ref String m)
 | 
			
		||||
    {
 | 
			
		||||
        var ch = (Char)7;
 | 
			
		||||
        var p = 0;
 | 
			
		||||
        while (true)
 | 
			
		||||
        {
 | 
			
		||||
            p = m.IndexOf(ch, p);
 | 
			
		||||
            if (p < 0) break;
 | 
			
		||||
 | 
			
		||||
            if (p > 0)
 | 
			
		||||
            {
 | 
			
		||||
                var str = m[..p];
 | 
			
		||||
                if (p + 1 < m.Length) str += m[(p + 1)..];
 | 
			
		||||
                m = str;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //Console.Beep();
 | 
			
		||||
            // 用定时器来控制Beep,避免被堵塞
 | 
			
		||||
            _timer ??= new TimerX(Bell, null, 100, 100);
 | 
			
		||||
            _Beep = true;
 | 
			
		||||
            //SystemSounds.Beep.Play();
 | 
			
		||||
            p++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static TimerX? _timer;
 | 
			
		||||
    private static Boolean _Beep;
 | 
			
		||||
 | 
			
		||||
    private static void Bell(Object? state)
 | 
			
		||||
    {
 | 
			
		||||
        if (_Beep)
 | 
			
		||||
        {
 | 
			
		||||
            _Beep = false;
 | 
			
		||||
            Console.Beep();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [DllImport("user32.dll")]
 | 
			
		||||
    private static extern Int32 SendMessage(IntPtr hwnd, Int32 wMsg, Int32 wParam, Int32 lParam);
 | 
			
		||||
    private const Int32 SB_TOP = 6;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,10 +13,10 @@
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.16" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="$(NET8Version)" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
	<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="$(NET9Version)" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
</Project>
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ namespace ThingsGateway.Razor;
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// 母版页基类
 | 
			
		||||
/// </summary>
 | 
			
		||||
[BlazorSetParametersAsyncGenerator.DoNotGenerateSetParametersAsync]
 | 
			
		||||
public partial class BaseLayout
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
namespace ThingsGateway.Razor;
 | 
			
		||||
 | 
			
		||||
/// <inheritdoc/>
 | 
			
		||||
public abstract class WebSiteModuleComponentBase : BootstrapModuleComponentBase
 | 
			
		||||
public abstract partial class WebSiteModuleComponentBase : BootstrapModuleComponentBase
 | 
			
		||||
{
 | 
			
		||||
    /// <inheritdoc/>
 | 
			
		||||
    protected override void OnLoadJSModule()
 | 
			
		||||
 
 | 
			
		||||
@@ -41,14 +41,16 @@
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            <PopConfirmButton IsAsync IsDisabled=@_importPreviews.Any(it => it.Value.HasError) Color=Color.Warning class="mt-2" OnConfirm=@(SaveDeviceImport)>@Localizer["Import"]</PopConfirmButton>
 | 
			
		||||
 | 
			
		||||
            <Button IsAsync class="mt-2" IsDisabled=@_importPreviews.Any(it => it.Value.HasError) OnClick="() => step.Next()">@Localizer["Next"]</Button>
 | 
			
		||||
@* 
 | 
			
		||||
            <Button IsAsync class="mt-2" IsDisabled=@_importPreviews.Any(it => it.Value.HasError) OnClick="() => step.Next()">@Localizer["Next"]</Button> *@
 | 
			
		||||
 | 
			
		||||
        </div>
 | 
			
		||||
    </StepItem>
 | 
			
		||||
    <StepItem Text=@Localizer["Third"] Title=@Localizer["Import"]>
 | 
			
		||||
@*     <StepItem Text=@Localizer["Third"] Title=@Localizer["Import"]>
 | 
			
		||||
        <PopConfirmButton IsAsync Color=Color.Warning class="mt-2" OnConfirm=@(SaveDeviceImport)>@Localizer["Import"]</PopConfirmButton>
 | 
			
		||||
    </StepItem>
 | 
			
		||||
    </StepItem> *@
 | 
			
		||||
</Step>
 | 
			
		||||
@code {
 | 
			
		||||
    [NotNull]
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,8 @@
 | 
			
		||||
//  QQ群:605534569
 | 
			
		||||
//------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
using System.Collections.Concurrent;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
@@ -22,7 +24,7 @@ public static class ParallelExtensions
 | 
			
		||||
    /// <typeparam name="T">集合元素类型</typeparam>
 | 
			
		||||
    /// <param name="source">要操作的集合</param>
 | 
			
		||||
    /// <param name="body">要执行的操作</param>
 | 
			
		||||
    public static void ParallelForEach<T>(this IEnumerable<T> source, Action<T> body)
 | 
			
		||||
    public static void ParallelForEach<T>(this IList<T> source, Action<T> body)
 | 
			
		||||
    {
 | 
			
		||||
        ParallelOptions options = new();
 | 
			
		||||
        options.MaxDegreeOfParallelism = Environment.ProcessorCount;
 | 
			
		||||
@@ -39,7 +41,7 @@ public static class ParallelExtensions
 | 
			
		||||
    /// <typeparam name="T">集合元素类型</typeparam>
 | 
			
		||||
    /// <param name="source">要操作的集合</param>
 | 
			
		||||
    /// <param name="body">要执行的操作</param>
 | 
			
		||||
    public static void ParallelForEach<T>(this IEnumerable<T> source, Action<T, ParallelLoopState, long> body)
 | 
			
		||||
    public static void ParallelForEach<T>(this IList<T> source, Action<T, ParallelLoopState, long> body)
 | 
			
		||||
    {
 | 
			
		||||
        ParallelOptions options = new();
 | 
			
		||||
        options.MaxDegreeOfParallelism = Environment.ProcessorCount;
 | 
			
		||||
@@ -57,7 +59,7 @@ public static class ParallelExtensions
 | 
			
		||||
    /// <param name="source">要操作的集合</param>
 | 
			
		||||
    /// <param name="body">要执行的操作</param>
 | 
			
		||||
    /// <param name="parallelCount">最大并行度</param>
 | 
			
		||||
    public static void ParallelForEach<T>(this IEnumerable<T> source, Action<T> body, int parallelCount)
 | 
			
		||||
    public static void ParallelForEach<T>(this IList<T> source, Action<T> body, int parallelCount)
 | 
			
		||||
    {
 | 
			
		||||
        // 创建并行操作的选项对象,设置最大并行度为指定的值
 | 
			
		||||
        var options = new ParallelOptions();
 | 
			
		||||
@@ -69,6 +71,47 @@ public static class ParallelExtensions
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 使用默认的并行设置执行指定的操作(Partitioner 分区)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static void ParallelForEachStreamed<T>(this IEnumerable<T> source, Action<T> body)
 | 
			
		||||
    {
 | 
			
		||||
        var partitioner = Partitioner.Create<T>(source, EnumerablePartitionerOptions.NoBuffering);
 | 
			
		||||
        Parallel.ForEach(partitioner, new ParallelOptions
 | 
			
		||||
        {
 | 
			
		||||
            MaxDegreeOfParallelism = Environment.ProcessorCount
 | 
			
		||||
        }, body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 使用默认的并行设置执行指定的操作(带索引和 LoopState,Partitioner 分区)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static void ParallelForEachStreamed<T>(this IEnumerable<T> source, Action<T, ParallelLoopState, long> body)
 | 
			
		||||
    {
 | 
			
		||||
        var partitioner = Partitioner.Create<T>(source, EnumerablePartitionerOptions.NoBuffering);
 | 
			
		||||
        Parallel.ForEach(partitioner, new ParallelOptions
 | 
			
		||||
        {
 | 
			
		||||
            MaxDegreeOfParallelism = Environment.ProcessorCount
 | 
			
		||||
        }, (item, state, index) => body(item, state, index));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 执行指定的操作,并指定最大并行度(Partitioner 分区)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static void ParallelForEachStreamed<T>(this IEnumerable<T> source, Action<T> body, int parallelCount)
 | 
			
		||||
    {
 | 
			
		||||
        var options = new ParallelOptions
 | 
			
		||||
        {
 | 
			
		||||
            MaxDegreeOfParallelism = parallelCount <= 0 ? 1 : parallelCount
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        var partitioner = Partitioner.Create<T>(source, EnumerablePartitionerOptions.NoBuffering);
 | 
			
		||||
        Parallel.ForEach(partitioner, options, body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 异步执行指定的操作,并指定最大并行度和取消标志
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -78,7 +121,7 @@ public static class ParallelExtensions
 | 
			
		||||
    /// <param name="parallelCount">最大并行度</param>
 | 
			
		||||
    /// <param name="cancellationToken">取消操作的标志</param>
 | 
			
		||||
    /// <returns>表示异步操作的任务</returns>
 | 
			
		||||
    public static Task ParallelForEachAsync<T>(this IEnumerable<T> source, Func<T, CancellationToken, ValueTask> body, int parallelCount, CancellationToken cancellationToken = default)
 | 
			
		||||
    public static Task ParallelForEachAsync<T>(this IList<T> source, Func<T, CancellationToken, ValueTask> body, int parallelCount, CancellationToken cancellationToken = default)
 | 
			
		||||
    {
 | 
			
		||||
        // 创建并行操作的选项对象,设置最大并行度和取消标志
 | 
			
		||||
        var options = new ParallelOptions();
 | 
			
		||||
@@ -95,8 +138,10 @@ public static class ParallelExtensions
 | 
			
		||||
    /// <param name="body">异步执行的操作</param>
 | 
			
		||||
    /// <param name="cancellationToken">取消操作的标志</param>
 | 
			
		||||
    /// <returns>表示异步操作的任务</returns>
 | 
			
		||||
    public static Task ParallelForEachAsync<T>(this IEnumerable<T> source, Func<T, CancellationToken, ValueTask> body, CancellationToken cancellationToken = default)
 | 
			
		||||
    public static Task ParallelForEachAsync<T>(this IList<T> source, Func<T, CancellationToken, ValueTask> body, CancellationToken cancellationToken = default)
 | 
			
		||||
    {
 | 
			
		||||
        return ParallelForEachAsync(source, body, Environment.ProcessorCount, cancellationToken);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,3 +21,4 @@ global using System.Globalization;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[assembly: SuppressMessage("Reliability", "CA2007", Justification = "<挂起>", Scope = "module")]
 | 
			
		||||
[assembly: BlazorSetParametersAsyncGenerator.GlobalGenerateSetParametersAsync(true)]
 | 
			
		||||
@@ -5,10 +5,11 @@
 | 
			
		||||
 | 
			
		||||
using Microsoft.Extensions.Logging;
 | 
			
		||||
 | 
			
		||||
using System.Collections.Concurrent;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.Resources;
 | 
			
		||||
 | 
			
		||||
using ThingsGateway.NewLife.Collections;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
@@ -107,14 +108,14 @@ internal class JsonStringLocalizer(Assembly assembly, string typeName, string ba
 | 
			
		||||
        return ret;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private readonly ConcurrentDictionary<string, object?> _missingManifestCache = [];
 | 
			
		||||
    private readonly ConcurrentHashSet<string> _missingManifestCache = [];
 | 
			
		||||
    private string? GetStringFromJson(string name)
 | 
			
		||||
    {
 | 
			
		||||
        // get string from json localization file
 | 
			
		||||
        var localizerStrings = MegerResolveLocalizers(CacheManager.GetAllStringsByTypeName(Assembly, typeName));
 | 
			
		||||
        var cacheKey = $"name={name}&culture={CultureInfo.CurrentUICulture.Name}";
 | 
			
		||||
        string? ret = null;
 | 
			
		||||
        if (!_missingManifestCache.ContainsKey(cacheKey))
 | 
			
		||||
        if (!_missingManifestCache.Contain(cacheKey))
 | 
			
		||||
        {
 | 
			
		||||
            var l = localizerStrings.Find(i => i.Name == name);
 | 
			
		||||
            if (l is { ResourceNotFound: false })
 | 
			
		||||
@@ -161,6 +162,7 @@ internal class JsonStringLocalizer(Assembly assembly, string typeName, string ba
 | 
			
		||||
    private List<LocalizedString> MegerResolveLocalizers(IEnumerable<LocalizedString>? localizerStrings)
 | 
			
		||||
    {
 | 
			
		||||
        var localizers = new List<LocalizedString>(CacheManager.GetTypeStringsFromResolve(typeName));
 | 
			
		||||
 | 
			
		||||
        if (localizerStrings != null)
 | 
			
		||||
        {
 | 
			
		||||
            localizers.AddRange(localizerStrings);
 | 
			
		||||
@@ -175,7 +177,7 @@ internal class JsonStringLocalizer(Assembly assembly, string typeName, string ba
 | 
			
		||||
        {
 | 
			
		||||
            Logger.LogInformation("{JsonStringLocalizerName} searched for '{Name}' in '{TypeName}' with culture '{CultureName}' not found.", nameof(JsonStringLocalizer), name, typeName, CultureInfo.CurrentUICulture.Name);
 | 
			
		||||
        }
 | 
			
		||||
        _missingManifestCache.TryAdd($"name={name}&culture={CultureInfo.CurrentUICulture.Name}", null);
 | 
			
		||||
        _missingManifestCache.TryAdd($"name={name}&culture={CultureInfo.CurrentUICulture.Name}");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private List<LocalizedString>? _allLocalizerdStrings;
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,6 @@
 | 
			
		||||
//  QQ群:605534569
 | 
			
		||||
//------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
using Microsoft.AspNetCore.Builder;
 | 
			
		||||
using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
 | 
			
		||||
using ThingsGateway.NewLife;
 | 
			
		||||
@@ -48,7 +47,7 @@ public class Startup : AppStartup
 | 
			
		||||
        // 缓存
 | 
			
		||||
        services.AddSingleton<ICache, MemoryCache>();
 | 
			
		||||
 | 
			
		||||
        MachineInfo.RegisterAsync();
 | 
			
		||||
        MachineInfo.Register();
 | 
			
		||||
 | 
			
		||||
        // 配置雪花Id算法机器码
 | 
			
		||||
        YitIdHelper.SetIdGenerator(new IdGeneratorOptions
 | 
			
		||||
@@ -59,7 +58,7 @@ public class Startup : AppStartup
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc/>
 | 
			
		||||
    public void Use(IApplicationBuilder applicationBuilder)
 | 
			
		||||
    public void Use(IServiceProvider serviceProvider)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,16 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
 | 
			
		||||
 | 
			
		||||
	<Import Project="$(SolutionDir)Version.props" />
 | 
			
		||||
	<Import Project="$(SolutionDir)PackNuget.props" />
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<TargetFrameworks>net8.0;</TargetFrameworks>
 | 
			
		||||
		<TargetFrameworks>net8.0</TargetFrameworks>
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="BootstrapBlazor.FontAwesome" Version="9.0.2" />
 | 
			
		||||
		<PackageReference Include="BootstrapBlazor" Version="9.7.0" />
 | 
			
		||||
		<PackageReference Include="BootstrapBlazor" Version="9.7.4-beta07" />
 | 
			
		||||
		<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<Content Remove="Locales\*.json" />
 | 
			
		||||
		<EmbeddedResource Include="Locales\*.json">
 | 
			
		||||
			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
 | 
			
		||||
		</EmbeddedResource>
 | 
			
		||||
@@ -30,6 +28,16 @@
 | 
			
		||||
		<ProjectReference Include="..\ThingsGateway.Furion\ThingsGateway.Furion.csproj" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	<!--<ItemGroup Condition="'$(Configuration)' != 'Debug' ">
 | 
			
		||||
		<None Include="..\BlazorSetParametersAsyncGenerator\tools\*.ps1" PackagePath="tools" Pack="true" Visible="false" />
 | 
			
		||||
		<None Include="..\BlazorSetParametersAsyncGenerator\bin\$(Configuration)\netstandard2.0\BlazorSetParametersAsyncGenerator.dll" PackagePath="analyzers\dotnet\cs" Pack="true" Visible="false" />
 | 
			
		||||
	</ItemGroup>-->
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<ProjectReference Include="..\BlazorSetParametersAsyncGenerator\BlazorSetParametersAsyncGenerator.csproj" PrivateAssets="all" OutputItemType="Analyzer" />
 | 
			
		||||
	</ItemGroup>
 | 
			
		||||
 | 
			
		||||
</Project>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,4 @@
 | 
			
		||||
 | 
			
		||||
@using System.Net.Http
 | 
			
		||||
@using System.Net.Http
 | 
			
		||||
@using System.Net.Http.Json
 | 
			
		||||
@using Microsoft.AspNetCore.Components.Forms
 | 
			
		||||
@using Microsoft.AspNetCore.Components.Routing
 | 
			
		||||
@@ -16,4 +15,5 @@
 | 
			
		||||
@using BootstrapBlazor.Components
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@using ThingsGateway.Razor;
 | 
			
		||||
@using ThingsGateway.Razor
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,10 @@
 | 
			
		||||
    height: var(--line-chart-table-height);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.wb-control .wb-full {
 | 
			
		||||
    display: none;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.dialog-table {
 | 
			
		||||
    height: calc(100vh - 200px);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -201,9 +201,9 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                if (this.Context.CurrentConnectionConfig?.MoreSettings?.IsNoReadXmlDescription == true)
 | 
			
		||||
                if (this.Context.CurrentConnectionConfig?.MoreSettings?.IsNoReadXmlDescription ?? true == true)
 | 
			
		||||
                {
 | 
			
		||||
                    return "";
 | 
			
		||||
                    return string.Empty;
 | 
			
		||||
                }
 | 
			
		||||
                if (entityType.Assembly.IsDynamic && entityType.Assembly.FullName.StartsWith("Dynamic"))
 | 
			
		||||
                {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,8 +7,8 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public partial class SqlSugarScope : ISqlSugarClient, ITenant
 | 
			
		||||
    {
 | 
			
		||||
        private List<ConnectionConfig> _configs;
 | 
			
		||||
        private Action<SqlSugarClient> _configAction;
 | 
			
		||||
        protected List<ConnectionConfig> _configs;
 | 
			
		||||
        protected Action<SqlSugarClient> _configAction;
 | 
			
		||||
 | 
			
		||||
        protected virtual SqlSugarClient GetContext()
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
        public int DefaultCacheDurationInSeconds { get; set; }
 | 
			
		||||
        public bool? TableEnumIsString { get; set; }
 | 
			
		||||
        public DateTime? DbMinDate { get; set; } = DateTime.MinValue.Date.AddYears(1900 - 1);
 | 
			
		||||
        public bool IsNoReadXmlDescription { get; set; }
 | 
			
		||||
        public bool IsNoReadXmlDescription { get; set; } = true;
 | 
			
		||||
        public bool SqlServerCodeFirstNvarchar { get; set; }
 | 
			
		||||
        public bool OracleCodeFirstNvarchar2 { get; set; }
 | 
			
		||||
        public bool SqliteCodeFirstEnableDefaultValue { get; set; }
 | 
			
		||||
 
 | 
			
		||||
@@ -501,7 +501,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
            {
 | 
			
		||||
                return GetFirstTypeNameFromExpression(methodCall.Arguments.FirstOrDefault());
 | 
			
		||||
            }
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string GetMethodName(Expression expression)
 | 
			
		||||
 
 | 
			
		||||
@@ -245,7 +245,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
 | 
			
		||||
        public string GetMemberName(MemberExpression memberExpression)
 | 
			
		||||
        {
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void ExtMapper(MapperExpressionInfo fillInfo, MapperExpressionInfo mappingFild1Info, MapperExpressionInfo mappingFild1Info2, MapperExpressionInfo selectInfo)
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
            var isWhere = Convert.ToBoolean(value);
 | 
			
		||||
            if (!Convert.ToBoolean(isWhere))
 | 
			
		||||
            {
 | 
			
		||||
                return "";
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
            var argExp = exp.Arguments[1];
 | 
			
		||||
            var copyContext = this.Context;
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                return "";
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -161,7 +161,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
            }
 | 
			
		||||
            else if (db is SqlSugarScope)
 | 
			
		||||
            {
 | 
			
		||||
                db = (db as SqlSugarScope).ScopedContext.Context;
 | 
			
		||||
                db = (db as SqlSugarScope).Context;
 | 
			
		||||
            }
 | 
			
		||||
            if (!(db is SqlSugarProvider))
 | 
			
		||||
            {
 | 
			
		||||
@@ -685,19 +685,22 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
 | 
			
		||||
        private static Type GetCustomDbType(string className, Type type)
 | 
			
		||||
        {
 | 
			
		||||
            if (className.Replace(".", "").Length + 1 == className.Length)
 | 
			
		||||
            //命名空间相关
 | 
			
		||||
            if (className.Replace(".", "").Length + 2 == className.Length)
 | 
			
		||||
            {
 | 
			
		||||
                var array = className.Split('.');
 | 
			
		||||
                if (array.Length >= 3)
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (var item in UtilMethods.EnumToDictionary<DbType>())
 | 
			
		||||
                    {
 | 
			
		||||
                        if (array.Last().StartsWith(item.Value.ToString()))
 | 
			
		||||
                        {
 | 
			
		||||
 | 
			
		||||
                        var newName = array.First() + "." + item.Value.ToString() + "." + array.Last();
 | 
			
		||||
                            var newName = $"{array[0]}.{array[1]}.{item.Value}.{array.Last()}";
 | 
			
		||||
                            type = GetCustomTypeByClass(newName);
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,6 @@
 | 
			
		||||
namespace ThingsGateway.SqlSugar
 | 
			
		||||
using ThingsGateway.NewLife.Caching;
 | 
			
		||||
 | 
			
		||||
namespace ThingsGateway.SqlSugar
 | 
			
		||||
{
 | 
			
		||||
    public class ReflectionInoCacheService : ICacheService
 | 
			
		||||
    {
 | 
			
		||||
@@ -6,6 +8,7 @@
 | 
			
		||||
        {
 | 
			
		||||
            ReflectionInoCore<V>.GetInstance().Add(key, value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Add<V>(string key, V value, int cacheDurationInSeconds)
 | 
			
		||||
        {
 | 
			
		||||
            ReflectionInoCore<V>.GetInstance().Add(key, value, cacheDurationInSeconds);
 | 
			
		||||
@@ -38,7 +41,7 @@
 | 
			
		||||
    }
 | 
			
		||||
    public class ReflectionInoCore<V>
 | 
			
		||||
    {
 | 
			
		||||
        readonly System.Collections.Concurrent.ConcurrentDictionary<string, V> InstanceCache = new System.Collections.Concurrent.ConcurrentDictionary<string, V>();
 | 
			
		||||
        readonly MemoryCache InstanceCache = new() { Expire = 1800 };
 | 
			
		||||
        private static ReflectionInoCore<V> _instance = null;
 | 
			
		||||
        private static readonly object _instanceLock = new object();
 | 
			
		||||
        private ReflectionInoCore() { }
 | 
			
		||||
@@ -58,10 +61,7 @@
 | 
			
		||||
 | 
			
		||||
        public V Get(string key)
 | 
			
		||||
        {
 | 
			
		||||
            if (this.ContainsKey(key))
 | 
			
		||||
                return this.InstanceCache[key];
 | 
			
		||||
            else
 | 
			
		||||
                return default(V);
 | 
			
		||||
            return this.InstanceCache.Get<V>(key);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static ReflectionInoCore<V> GetInstance()
 | 
			
		||||
@@ -89,8 +89,7 @@
 | 
			
		||||
 | 
			
		||||
        public void Remove(string key)
 | 
			
		||||
        {
 | 
			
		||||
            V val;
 | 
			
		||||
            this.InstanceCache.TryRemove(key, out val);
 | 
			
		||||
            this.InstanceCache.Remove(key);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void RemoveAllCache()
 | 
			
		||||
@@ -108,16 +107,10 @@
 | 
			
		||||
 | 
			
		||||
        public V GetOrCreate(string cacheKey, Func<V> create)
 | 
			
		||||
        {
 | 
			
		||||
            if (this.ContainsKey(cacheKey)) return Get(cacheKey);
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                var reval = create();
 | 
			
		||||
                this.Add(cacheKey, reval);
 | 
			
		||||
                return reval;
 | 
			
		||||
            return InstanceCache.GetOrAdd<V>(cacheKey, (a) => create());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    }
 | 
			
		||||
    internal static class ReflectionInoHelper
 | 
			
		||||
    public static class ReflectionInoHelper
 | 
			
		||||
    {
 | 
			
		||||
        private static List<Action> removeActions = new List<Action>();
 | 
			
		||||
        internal static void AddRemoveFunc(Action removeAction)
 | 
			
		||||
 
 | 
			
		||||
@@ -576,7 +576,7 @@ WHERE table_name = '" + tableName + "'");
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                return "";
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -144,7 +144,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
        public string DataTableToCsvString(DataTable table)
 | 
			
		||||
        {
 | 
			
		||||
            if (table.Rows.Count == 0)
 | 
			
		||||
                return "";
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            StringBuilder sb = new StringBuilder();
 | 
			
		||||
            DataColumn colum;
 | 
			
		||||
            foreach (DataRow row in table.Rows)
 | 
			
		||||
 
 | 
			
		||||
@@ -262,7 +262,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return "";
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return "";
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        protected override string AddColumnToTableSql
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,8 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
            _configs = configs;
 | 
			
		||||
            this._configAction = configAction;
 | 
			
		||||
        }
 | 
			
		||||
        public SqlSugarClient ScopedContext { get { return GetContext(); } }
 | 
			
		||||
        public ISqlSugarClient Context => ScopedContext.Context;
 | 
			
		||||
        protected SqlSugarClient ScopedContext { get { return GetContext(); } }
 | 
			
		||||
        public SugarActionType SugarActionType { get => ScopedContext.SugarActionType; set => ScopedContext.SugarActionType = value; }
 | 
			
		||||
        public MappingTableList MappingTables { get => ScopedContext.MappingTables; set => ScopedContext.MappingTables = value; }
 | 
			
		||||
        public MappingColumnList MappingColumns { get => ScopedContext.MappingColumns; set => ScopedContext.MappingColumns = value; }
 | 
			
		||||
 
 | 
			
		||||
@@ -92,12 +92,12 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
        public static string ObjToString(this object thisValue)
 | 
			
		||||
        {
 | 
			
		||||
            if (thisValue != null) return thisValue.ToString().Trim();
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
        public static string ObjToStringNoTrim(this object thisValue)
 | 
			
		||||
        {
 | 
			
		||||
            if (thisValue != null) return thisValue.ToString();
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
        public static string ObjToStringNew(this object thisValue)
 | 
			
		||||
        {
 | 
			
		||||
@@ -110,7 +110,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
                return Convert.ToDateTime(thisValue.ToString()).ToString("yyyy-MM-dd");
 | 
			
		||||
            }
 | 
			
		||||
            if (thisValue != null) return thisValue.ToString().Trim();
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string ObjToString(this object thisValue, string errorValue)
 | 
			
		||||
 
 | 
			
		||||
@@ -57,7 +57,7 @@
 | 
			
		||||
        public static string ObjToString(this object thisValue)
 | 
			
		||||
        {
 | 
			
		||||
            if (thisValue != null) return thisValue.ToString().Trim();
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string ObjToString(this object thisValue, string errorValue)
 | 
			
		||||
 
 | 
			
		||||
@@ -893,42 +893,25 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
                return Guid.NewGuid() + "";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        static Type IAsyncStateMachineType = typeof(IAsyncStateMachine);
 | 
			
		||||
 | 
			
		||||
        public static bool IsAsyncMethod(MethodBase method)
 | 
			
		||||
        {
 | 
			
		||||
            if (method == null)
 | 
			
		||||
            {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            if (method.DeclaringType != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (method.DeclaringType.GetInterfaces().Contains(typeof(IAsyncStateMachine)))
 | 
			
		||||
                {
 | 
			
		||||
            if (method == null) return false;
 | 
			
		||||
 | 
			
		||||
            if (method.GetCustomAttribute<AsyncStateMachineAttribute>() != null)
 | 
			
		||||
                return true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (method.DeclaringType?.GetInterfaces().Contains(IAsyncStateMachineType) == true)
 | 
			
		||||
                return true;
 | 
			
		||||
 | 
			
		||||
            // 补救方案:有些 async 方法是动态生成的,名字惯例判断
 | 
			
		||||
            var name = method.Name;
 | 
			
		||||
            if (name.Contains("OutputAsyncCausalityEvents"))
 | 
			
		||||
            {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            if (name.Contains("OutputWaitEtwEvents"))
 | 
			
		||||
            {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            if (name.Contains("ExecuteAsync"))
 | 
			
		||||
            {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            //if (method?.DeclaringType?.FullName?.Contains("Furion.InternalApp")==true)
 | 
			
		||||
            //{
 | 
			
		||||
            //    return false;
 | 
			
		||||
            //}
 | 
			
		||||
            Type attType = typeof(AsyncStateMachineAttribute);
 | 
			
		||||
            var attrib = (AsyncStateMachineAttribute)method.GetCustomAttribute(attType);
 | 
			
		||||
            return (attrib != null);
 | 
			
		||||
            return name.EndsWith("ExecuteAsync") || name.Contains("OutputAsyncCausalityEvents") || name.Contains("OutputWaitEtwEvents");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public static StackTraceInfo GetStackTrace()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
@@ -939,7 +922,7 @@ namespace ThingsGateway.SqlSugar
 | 
			
		||||
            for (int i = 0; i < st.FrameCount; i++)
 | 
			
		||||
            {
 | 
			
		||||
                var frame = st.GetFrame(i);
 | 
			
		||||
                if (!frame.GetMethod().Module.Name.Equals("sqlsugar.dll", StringComparison.CurrentCultureIgnoreCase) && frame.GetMethod().Name.First() != '<')
 | 
			
		||||
                if (!frame.GetMethod().Module.Name.Equals("thingsgateway.sqlsugar.dll", StringComparison.CurrentCultureIgnoreCase) && frame.GetMethod().Name.First() != '<')
 | 
			
		||||
                {
 | 
			
		||||
                    info.MyStackTraceList.Add(new StackTraceInfoItem()
 | 
			
		||||
                    {
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ namespace ThingsGateway.SqlSugar.TDengine
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return "";
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
        public static string ObjToStringNoTrim(this object thisValue)
 | 
			
		||||
        {
 | 
			
		||||
            if (thisValue != null) return thisValue.ToString();
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
        public static string ToLower(this string value, bool isLower)
 | 
			
		||||
        {
 | 
			
		||||
@@ -78,7 +78,7 @@
 | 
			
		||||
        public static string ObjToString(this object thisValue)
 | 
			
		||||
        {
 | 
			
		||||
            if (thisValue != null) return thisValue.ToString().Trim();
 | 
			
		||||
            return "";
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static string ObjToString(this object thisValue, string errorValue)
 | 
			
		||||
 
 | 
			
		||||
@@ -142,7 +142,7 @@ namespace ThingsGateway.SqlSugar.TDengine
 | 
			
		||||
            for (int i = 0; i < st.FrameCount; i++)
 | 
			
		||||
            {
 | 
			
		||||
                var frame = st.GetFrame(i);
 | 
			
		||||
                if (!string.Equals(frame.GetMethod().Module.Name, "sqlsugar.dll", StringComparison.OrdinalIgnoreCase) && frame.GetMethod().Name.First() != '<')
 | 
			
		||||
                if (!string.Equals(frame.GetMethod().Module.Name, "thingsgateway.sqlsugar.dll", StringComparison.OrdinalIgnoreCase) && frame.GetMethod().Name.First() != '<')
 | 
			
		||||
                {
 | 
			
		||||
                    info.MyStackTraceList.Add(new StackTraceInfoItem()
 | 
			
		||||
                    {
 | 
			
		||||
 
 | 
			
		||||
@@ -23,14 +23,14 @@
 | 
			
		||||
 | 
			
		||||
	<ItemGroup>
 | 
			
		||||
		<PackageReference Include="SqlSugarCore.Dm" Version="8.8.0" />
 | 
			
		||||
		<PackageReference Include="SqlSugarCore.Kdbndp" Version="9.3.7.605" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.5" />
 | 
			
		||||
		<PackageReference Include="SqlSugarCore.Kdbndp" Version="9.3.7.613" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Data.Sqlite" Version="$(NET9Version)" />
 | 
			
		||||
		<PackageReference Include="MySqlConnector" Version="2.4.0" />
 | 
			
		||||
		<PackageReference Include="Npgsql" Version="9.0.3" />
 | 
			
		||||
		<PackageReference Include="CsvHelper" Version="33.1.0" />
 | 
			
		||||
		<PackageReference Include="TDengine.Connector" Version="3.1.6" />
 | 
			
		||||
		<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.8.0" />
 | 
			
		||||
		<PackageReference Include="Oscar.Data.SqlClient" Version="4.2.18" />
 | 
			
		||||
		<PackageReference Include="Oscar.Data.SqlClient" Version="4.2.20" />
 | 
			
		||||
		<PackageReference Include="System.Data.Common" Version="4.3.0" />
 | 
			
		||||
		<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.2" />
 | 
			
		||||
		<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										92
									
								
								src/Base1.sln
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								src/Base1.sln
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
Microsoft Visual Studio Solution File, Format Version 12.00
 | 
			
		||||
# Visual Studio Version 17
 | 
			
		||||
VisualStudioVersion = 17.9.34622.214
 | 
			
		||||
MinimumVisualStudioVersion = 10.0.40219.1
 | 
			
		||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "other", "other", "{0B748352-5D27-4F14-8A20-364034C72867}"
 | 
			
		||||
	ProjectSection(SolutionItems) = preProject
 | 
			
		||||
		.editorconfig = .editorconfig
 | 
			
		||||
		Directory.Build.props = Directory.Build.props
 | 
			
		||||
		..\git_pull.bat = ..\git_pull.bat
 | 
			
		||||
		..\README.md = ..\README.md
 | 
			
		||||
		..\README.zh-CN.md = ..\README.zh-CN.md
 | 
			
		||||
		Version.props = Version.props
 | 
			
		||||
	EndProjectSection
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Foundation", "Foundation", "{2AC600BB-4325-4E0A-93A7-B1F53C8E2CA7}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.CSScript", "Foundation\ThingsGateway.CSScript\ThingsGateway.CSScript.csproj", "{506232CE-0FB6-4ACB-96DE-C8C8D075A642}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Foundation", "Foundation\ThingsGateway.Foundation\ThingsGateway.Foundation.csproj", "{9D49F8E2-A82C-4E36-8F54-4F45BF3E47C0}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Foundation.SourceGenerator", "Foundation\ThingsGateway.Foundation.SourceGenerator\ThingsGateway.Foundation.SourceGenerator.csproj", "{E325A64C-2B72-4DD0-8A6C-229B29FB95EB}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Foundation.Variable", "Foundation\ThingsGateway.Foundation.Variable\ThingsGateway.Foundation.Variable.csproj", "{8EE037EC-ED21-42A0-BE1F-219E9886E43A}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Admin", "Admin", "{72C65578-92A5-4E99-9779-27835B12B32F}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThingsGateway.Furion", "Admin\ThingsGateway.Furion\ThingsGateway.Furion.csproj", "{D56A6669-28C5-4A99-89CF-356C7964B8E1}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThingsGateway.NewLife.X", "Admin\ThingsGateway.NewLife.X\ThingsGateway.NewLife.X.csproj", "{8198BEEA-AC24-4D70-B3D7-2601A803610B}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThingsGateway.Razor", "Admin\ThingsGateway.Razor\ThingsGateway.Razor.csproj", "{93C0CC9A-500E-419A-B896-F36225377D43}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorSetParametersAsyncGenerator", "Admin\BlazorSetParametersAsyncGenerator\BlazorSetParametersAsyncGenerator.csproj", "{4C412EC1-8501-8211-5A57-3CEEE7EEA6B3}"
 | 
			
		||||
EndProject
 | 
			
		||||
Global
 | 
			
		||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
			
		||||
		Debug|Any CPU = Debug|Any CPU
 | 
			
		||||
		Release|Any CPU = Release|Any CPU
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
			
		||||
		{506232CE-0FB6-4ACB-96DE-C8C8D075A642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{506232CE-0FB6-4ACB-96DE-C8C8D075A642}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{506232CE-0FB6-4ACB-96DE-C8C8D075A642}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{506232CE-0FB6-4ACB-96DE-C8C8D075A642}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{9D49F8E2-A82C-4E36-8F54-4F45BF3E47C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{9D49F8E2-A82C-4E36-8F54-4F45BF3E47C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{9D49F8E2-A82C-4E36-8F54-4F45BF3E47C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{9D49F8E2-A82C-4E36-8F54-4F45BF3E47C0}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{E325A64C-2B72-4DD0-8A6C-229B29FB95EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{E325A64C-2B72-4DD0-8A6C-229B29FB95EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{E325A64C-2B72-4DD0-8A6C-229B29FB95EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{E325A64C-2B72-4DD0-8A6C-229B29FB95EB}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{8EE037EC-ED21-42A0-BE1F-219E9886E43A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{8EE037EC-ED21-42A0-BE1F-219E9886E43A}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{8EE037EC-ED21-42A0-BE1F-219E9886E43A}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{8EE037EC-ED21-42A0-BE1F-219E9886E43A}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{D56A6669-28C5-4A99-89CF-356C7964B8E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{D56A6669-28C5-4A99-89CF-356C7964B8E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{D56A6669-28C5-4A99-89CF-356C7964B8E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{D56A6669-28C5-4A99-89CF-356C7964B8E1}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{8198BEEA-AC24-4D70-B3D7-2601A803610B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{8198BEEA-AC24-4D70-B3D7-2601A803610B}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{8198BEEA-AC24-4D70-B3D7-2601A803610B}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{8198BEEA-AC24-4D70-B3D7-2601A803610B}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{93C0CC9A-500E-419A-B896-F36225377D43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{93C0CC9A-500E-419A-B896-F36225377D43}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{93C0CC9A-500E-419A-B896-F36225377D43}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{93C0CC9A-500E-419A-B896-F36225377D43}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{4C412EC1-8501-8211-5A57-3CEEE7EEA6B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{4C412EC1-8501-8211-5A57-3CEEE7EEA6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{4C412EC1-8501-8211-5A57-3CEEE7EEA6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{4C412EC1-8501-8211-5A57-3CEEE7EEA6B3}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(SolutionProperties) = preSolution
 | 
			
		||||
		HideSolutionNode = FALSE
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(NestedProjects) = preSolution
 | 
			
		||||
		{506232CE-0FB6-4ACB-96DE-C8C8D075A642} = {2AC600BB-4325-4E0A-93A7-B1F53C8E2CA7}
 | 
			
		||||
		{9D49F8E2-A82C-4E36-8F54-4F45BF3E47C0} = {2AC600BB-4325-4E0A-93A7-B1F53C8E2CA7}
 | 
			
		||||
		{E325A64C-2B72-4DD0-8A6C-229B29FB95EB} = {2AC600BB-4325-4E0A-93A7-B1F53C8E2CA7}
 | 
			
		||||
		{8EE037EC-ED21-42A0-BE1F-219E9886E43A} = {2AC600BB-4325-4E0A-93A7-B1F53C8E2CA7}
 | 
			
		||||
		{D56A6669-28C5-4A99-89CF-356C7964B8E1} = {72C65578-92A5-4E99-9779-27835B12B32F}
 | 
			
		||||
		{8198BEEA-AC24-4D70-B3D7-2601A803610B} = {72C65578-92A5-4E99-9779-27835B12B32F}
 | 
			
		||||
		{93C0CC9A-500E-419A-B896-F36225377D43} = {72C65578-92A5-4E99-9779-27835B12B32F}
 | 
			
		||||
		{4C412EC1-8501-8211-5A57-3CEEE7EEA6B3} = {72C65578-92A5-4E99-9779-27835B12B32F}
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(ExtensibilityGlobals) = postSolution
 | 
			
		||||
		RESX_NeutralResourcesLanguage = zh-Hans
 | 
			
		||||
		RESX_Rules = {"EnabledRules":[]}
 | 
			
		||||
		SolutionGuid = {199B1B96-4F56-4828-9531-813BA02DB282}
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
EndGlobal
 | 
			
		||||
@@ -1,9 +1,12 @@
 | 
			
		||||
<Project>
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<PluginVersion>10.7.45</PluginVersion>
 | 
			
		||||
		<ProPluginVersion>10.7.45</ProPluginVersion>
 | 
			
		||||
		<AuthenticationVersion>2.5.0</AuthenticationVersion>
 | 
			
		||||
		<PluginVersion>10.8.6</PluginVersion>
 | 
			
		||||
		<ProPluginVersion>10.8.6</ProPluginVersion>
 | 
			
		||||
		<AuthenticationVersion>2.8.0</AuthenticationVersion>
 | 
			
		||||
		<SourceGeneratorVersion>10.8.2</SourceGeneratorVersion>
 | 
			
		||||
		<NET8Version>8.0.17</NET8Version>
 | 
			
		||||
		<NET9Version>9.0.6</NET9Version>
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
@@ -22,7 +25,7 @@
 | 
			
		||||
		<AnalysisModeStyle>None</AnalysisModeStyle>
 | 
			
		||||
 | 
			
		||||
		<NoWarn>
 | 
			
		||||
			CS8603;CS8618;CS1591;CS8625;CS8602;CS8604;CS8600;CS8601;CS8714;CS8619;CS8629;CS8765;CS8634;CS8621;CS8767;CS8633;CS8620;CS8610;CS8631;CS8605;CS8622;CS8613;NU5100;NU5104;NU1903;NU1902;CA1813;CA1852;CA1822;CA2100;CA2008;CA1812;CA1508;CA1512;CA1513;CA1810;CA1814;CA1815;CA1835;CA1819;CA1823;CA2002;CA5350;CA5351;CA5358;CA5384;CA5392;CA1805;CA1851;CA1510;CA5401;CA2022;CA1848;CA2000;CA5394;CA3003;CA1515;CA1849;CA1863
 | 
			
		||||
			CS8603;CS8618;CS1591;CS8625;CS8602;CS8604;CS8600;CS8601;CS8714;CS8619;CS8629;CS8765;CS8634;CS8621;CS8767;CS8633;CS8620;CS8610;CS8631;CS8605;CS8622;CS8613;NU5100;NU5104;NU1903;NU1902;CA1813;CA1852;CA1822;CA2100;CA2008;CA1812;CA1508;CA1512;CA1513;CA1810;CA1814;CA1815;CA1835;CA1819;CA1823;CA2002;CA5350;CA5351;CA5358;CA5384;CA5392;CA1805;CA1851;CA1510;CA5401;CA2022;CA1848;CA2000;CA5394;CA3003;CA1515;CA1849;CA1863;CA5400
 | 
			
		||||
		</NoWarn>
 | 
			
		||||
		<TargetFrameworks>net8.0;</TargetFrameworks>
 | 
			
		||||
		<LangVersion>13.0</LangVersion>
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user