Skip to content

Commit

Permalink
🎨 format and fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnkwlp committed Feb 8, 2024
1 parent d7da3a0 commit b753188
Show file tree
Hide file tree
Showing 31 changed files with 122 additions and 121 deletions.
34 changes: 18 additions & 16 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -268,54 +268,56 @@ dotnet_naming_rule.private_or_internal_field_should_be_begins_with__.style = beg

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.property.applicable_kinds = property
dotnet_naming_symbols.property.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.property.required_modifiers =
dotnet_naming_symbols.property.required_modifiers =

dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected
dotnet_naming_symbols.private_or_internal_field.required_modifiers =
dotnet_naming_symbols.private_or_internal_field.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.begins_with__.required_prefix = _
dotnet_naming_style.begins_with__.required_suffix =
dotnet_naming_style.begins_with__.word_separator =
dotnet_naming_style.begins_with__.required_suffix =
dotnet_naming_style.begins_with__.word_separator =
dotnet_naming_style.begins_with__.capitalization = camel_case


dotnet_analyzer_diagnostic.category-roslynator.severity = warning
roslynator_analyzers.enabled_by_default = true
roslynator_refactorings.enabled = true
roslynator_compiler_diagnostic_fixes.enabled = true

# roslynator_refactoring.<REFACTORING_NAME>.enabled = true
# roslynator_compiler_diagnostic_fix.<COMPILER_DIAGNOSTIC_ID>.enabled = true|false
# roslynator_compiler_diagnostic_fix.<COMPILER_DIAGNOSTIC_ID>.enabled = true|false
# dotnet_diagnostic.<ANALYZER_ID>.severity = default|none|silent|suggestion|warning|error

dotnet_diagnostic.Ca2016.severity = warning
dotnet_diagnostic.RCS1251.severity = none
dotnet_diagnostic.CA1848.severity = silent
dotnet_diagnostic.CA1305.severity = silent
dotnet_diagnostic.CA1305.severity = silent
dotnet_diagnostic.ide0011.severity = warning
dotnet_diagnostic.RCS1251.severity = silent
dotnet_diagnostic.RCS1251.severity = silent
dotnet_diagnostic.ide0011.severity = silent
dotnet_diagnostic.ca2254.severity = silent
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,38 @@ public class ApiKeyAuthenticationHandler : AuthenticationHandler<ApiKeyOptions>
private readonly AbpSignInManager _signInManager;
private readonly IUnitOfWorkManager _unitOfWorkManager;

public ApiKeyAuthenticationHandler(IOptionsMonitor<ApiKeyOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, ApiKeyDomainService domainService, AbpSignInManager signInManager, IUnitOfWorkManager unitOfWorkManager, IIdentityUserRepository userRepository) : base(options, logger, encoder, clock)
[Obsolete]
public ApiKeyAuthenticationHandler(
IOptionsMonitor<ApiKeyOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock,
ApiKeyDomainService domainService,
AbpSignInManager signInManager,
IUnitOfWorkManager unitOfWorkManager,
IIdentityUserRepository userRepository) : base(options, logger, encoder, clock)
{
_domainService = domainService;
_signInManager = signInManager;
_unitOfWorkManager = unitOfWorkManager;
_userRepository = userRepository;
}

public ApiKeyAuthenticationHandler(
IOptionsMonitor<ApiKeyOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ApiKeyDomainService domainService,
IIdentityUserRepository userRepository,
AbpSignInManager signInManager,
IUnitOfWorkManager unitOfWorkManager) : base(options, logger, encoder)
{
_domainService = domainService;
_userRepository = userRepository;
_signInManager = signInManager;
_unitOfWorkManager = unitOfWorkManager;
}

protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
{
if (Context.GetEndpoint()?.Metadata?.GetMetadata<Microsoft.AspNetCore.Authorization.IAllowAnonymous>() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public UserAndRoleLookupService(IIdentityUserRepository identityUserRepository,

public async Task<UserLookupResultItem> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default)
{
var item = await _identityUserRepository.FindByNormalizedUserNameAsync(userName);
var item = await _identityUserRepository.FindByNormalizedUserNameAsync(userName, cancellationToken: cancellationToken);

if (item == null)
return null;
Expand All @@ -34,7 +34,7 @@ public async Task<UserLookupResultItem> FindByUserNameAsync(string userName, Can

public async Task<List<UserLookupResultItem>> GetListAsync(string filter = null, CancellationToken cancellationToken = default)
{
var list = await _identityUserRepository.GetListAsync();
var list = await _identityUserRepository.GetListAsync(cancellationToken: cancellationToken);
return list.ConvertAll(x => new UserLookupResultItem
{
UserName = x.UserName,
Expand All @@ -45,7 +45,7 @@ public async Task<List<UserLookupResultItem>> GetListAsync(string filter = null,

public async Task<List<UserLookupResultItem>> GetListByRoleNameAsync(string roleName, CancellationToken cancellationToken = default)
{
var users = await _identityUserRepository.GetListByNormalizedRoleNameAsync(roleName);
var users = await _identityUserRepository.GetListByNormalizedRoleNameAsync(roleName, cancellationToken: cancellationToken);

return users.ConvertAll(x => new UserLookupResultItem
{
Expand All @@ -57,7 +57,7 @@ public async Task<List<UserLookupResultItem>> GetListByRoleNameAsync(string role

async Task<List<RoleLookupResultItem>> IRoleLookupService.GetListAsync(string filter, CancellationToken cancellationToken)
{
var list = await _identityRoleRepository.GetListAsync();
var list = await _identityRoleRepository.GetListAsync(cancellationToken: cancellationToken);
return list.ConvertAll(x => new RoleLookupResultItem
{
Id = x.Id.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public async Task<IRemoteStreamContent> ExportAsync(WorkflowDefinitionExportRequ
public async Task<WorkflowDefinitionImportResultDto> ImportAsync(WorkflowDefinitionImportRequestDto input)
{
if (input.File?.ContentLength == 0)
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(input.File));

var randomName = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
var zipFilePath = Path.Combine(Path.GetTempPath(), "workflow", "import", $"{randomName}.zip");
Expand All @@ -620,7 +620,7 @@ public async Task<WorkflowDefinitionImportResultDto> ImportAsync(WorkflowDefinit
// extract zip file
try
{
using MemoryStream ms = new MemoryStream();
await using MemoryStream ms = new MemoryStream();

await input.File.GetStream().CopyToAsync(ms);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ public async Task<WorkflowInstanceDateCountStatisticsResultDto> GetStatusDateCou
dto.Items.Add(new WorkflowInstanceDateCountStatisticDto
{
Date = date,
FailedCount = faulted.ContainsKey(date.Date) ? faulted[date.Date] : 0,
FinishedCount = finished.ContainsKey(date.Date) ? finished[date.Date] : 0,
FailedCount = faulted.TryGetValue(date.Date, out var value) ? value : 0,
FinishedCount = finished.TryGetValue(date.Date, out var value2) ? value2 : 0,
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public async Task<WorkflowDefinition> ImportAsync(string jsonContent, bool overw
var name = jsonNode["Name"].GetValue<string>();
var version = jsonNode["PublishedVersion"].GetValue<int>();

var workflow = await _workflowDefinitionRepository.FindAsync(x => x.Name == name);
var workflow = await _workflowDefinitionRepository.FindAsync(x => x.Name == name, cancellationToken: cancellationToken);

// check exists workflow
if (workflow != null)
{
// check permssion
if (!await _workflowPermissionService.IsGrantedAsync(workflow.Id, ElsaModulePermissions.Definitions.Import))
if (!await _workflowPermissionService.IsGrantedAsync(workflow.Id, ElsaModulePermissions.Definitions.Import, cancellationToken))
{
throw new Exception($"Workflow '{name}' unauthorized access.");
}
Expand Down Expand Up @@ -94,7 +94,7 @@ public async Task<WorkflowDefinition> ImportAsync(string jsonContent, bool overw
workflow.SetLatestVersion(version);
workflow.SetPublishedVersion(version);

workflow = await _workflowDefinitionRepository.InsertAsync(workflow);
workflow = await _workflowDefinitionRepository.InsertAsync(workflow, cancellationToken: cancellationToken);

// add permission
// auto added by event handler
Expand All @@ -118,11 +118,11 @@ await _workflowDefinitionManager.UpdateDefinitionAsync(
workflow.SetLatestVersion(version);
workflow.SetPublishedVersion(version);

workflow = await _workflowDefinitionRepository.UpdateAsync(workflow);
workflow = await _workflowDefinitionRepository.UpdateAsync(workflow, cancellationToken: cancellationToken);
}

// version
var publishedVersion = await _workflowDefinitionVersionRepository.FindByVersionAsync(workflow.Id, version, true);
var publishedVersion = await _workflowDefinitionVersionRepository.FindByVersionAsync(workflow.Id, version, true, cancellationToken);

if (publishedVersion == null)
{
Expand All @@ -137,7 +137,7 @@ await _workflowDefinitionManager.UpdateDefinitionAsync(
workflowVersion.SetIsLatest(true);
workflowVersion.SetIsPublished(true);

workflowVersion = await _workflowDefinitionVersionRepository.InsertAsync(workflowVersion);
workflowVersion = await _workflowDefinitionVersionRepository.InsertAsync(workflowVersion, cancellationToken: cancellationToken);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Linq;
using System.Data;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Services;
using Volo.Abp.Uow;
using Volo.Abp.Domain.Services;

namespace Passingwind.Abp.ElsaModule.GlobalCodes;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Linq;
using System.Data;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Services;
using Volo.Abp.Uow;
using Volo.Abp.Domain.Services;

namespace Passingwind.Abp.ElsaModule.GlobalCodes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ public virtual async System.Threading.Tasks.Task<string> GetValueFromCacheAsync(
{
Value = entity?.Value,
};
},
() => new DistributedCacheEntryOptions
}, () => new DistributedCacheEntryOptions
{
AbsoluteExpiration = DateTimeOffset.Now.AddDays(1)
});
}, token: cancellationToken);

return cacheItem?.Value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public WorkflowPermissionGrantResult AddProvider(Guid workflowId, string name, s
{
lock (WorkflowGrantProviders)
{
if (WorkflowGrantProviders.ContainsKey(workflowId))
if (WorkflowGrantProviders.TryGetValue(workflowId, out var grantProviders))
{
var providers = WorkflowGrantProviders[workflowId].ToList();
var providers = grantProviders.ToList();

providers.Add(new WorkflowPermissionGrantProvider(name, value));
WorkflowGrantProviders[workflowId] = providers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public virtual async Task<WorkflowPermissionGrantResult> GetGrantsAsync(ClaimsPr
}

// get user owners
var userGrantedList = await PermissionGrantRepository.GetListAsync(WorkflowUserOwnerPermissionValueProvider.ProviderName, userId.Value.ToString("d"));
var userGrantedList = await PermissionGrantRepository.GetListAsync(WorkflowUserOwnerPermissionValueProvider.ProviderName, userId.Value.ToString("d"), cancellationToken);

foreach (var permissionGrant in userGrantedList)
{
Expand All @@ -116,7 +116,7 @@ public virtual async Task<WorkflowPermissionGrantResult> GetGrantsAsync(ClaimsPr

public virtual async Task<WorkflowPermissionGrantResult> GetGrantsAsync(CancellationToken cancellationToken = default)
{
return await GetGrantsAsync(PrincipalAccessor.Principal);
return await GetGrantsAsync(PrincipalAccessor.Principal, cancellationToken);
}

public virtual async Task<bool> IsGrantedAsync(ClaimsPrincipal claimsPrincipal, Guid workflowId, string name, CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -145,7 +145,7 @@ public virtual async Task<bool> IsGrantedAsync(ClaimsPrincipal claimsPrincipal,

public virtual async Task<bool> IsGrantedAsync(Guid workflowId, string name, CancellationToken cancellationToken = default)
{
return await IsGrantedAsync(PrincipalAccessor.Principal, workflowId, name);
return await IsGrantedAsync(PrincipalAccessor.Principal, workflowId, name, cancellationToken);
}

public virtual async Task SetUserWorkflowPermissionGrantAsync(WorkflowDefinition workflowDefinition, IdentityUser user, bool isGranted, CancellationToken cancellationToken = default)
Expand All @@ -157,17 +157,17 @@ public virtual async Task SetUserWorkflowPermissionGrantAsync(WorkflowDefinition
public virtual async Task InitialWorkflowPermissionDefinitionsAsync(CancellationToken cancellationToken = default)
{
// group
var group = await PermissionGroupDefinitionRepository.FindAsync(x => x.Name == ElsaModulePermissions.GroupName);
var group = await PermissionGroupDefinitionRepository.FindAsync(x => x.Name == ElsaModulePermissions.GroupName, cancellationToken: cancellationToken);
if (group == null)
{
group = await PermissionGroupDefinitionRepository.InsertAsync(new PermissionGroupDefinitionRecord(
GuidGenerator.Create(),
ElsaModulePermissions.GroupName,
$"L:ElsaModule,Permission:${ElsaModulePermissions.GroupName}"));
$"L:ElsaModule,Permission:${ElsaModulePermissions.GroupName}"), cancellationToken: cancellationToken);
}

// parent
var parent = await PermissionDefinitionRepository.FindAsync(x => x.GroupName == ElsaModulePermissions.GroupName && x.Name == ElsaModulePermissions.Workflows.Default);
var parent = await PermissionDefinitionRepository.FindAsync(x => x.GroupName == ElsaModulePermissions.GroupName && x.Name == ElsaModulePermissions.Workflows.Default, cancellationToken: cancellationToken);

if (parent == null)
{
Expand All @@ -176,12 +176,12 @@ public virtual async Task InitialWorkflowPermissionDefinitionsAsync(Cancellation
ElsaModulePermissions.GroupName,
ElsaModulePermissions.Workflows.Default,
null,
"Workflows"));
"Workflows"), cancellationToken: cancellationToken);
}

var exists = await PermissionDefinitionRepository.GetListAsync(x => x.GroupName == ElsaModulePermissions.GroupName && x.ParentName == ElsaModulePermissions.Workflows.Default, cancellationToken: cancellationToken);

var workflows = await WorkflowDefinitionRepository.GetListAsync();
var workflows = await WorkflowDefinitionRepository.GetListAsync(cancellationToken: cancellationToken);

foreach (var workflow in workflows)
{
Expand Down Expand Up @@ -221,7 +221,7 @@ public async Task<IEnumerable<IdentityUser>> GetWorkflowOwnersAsync(WorkflowDefi
var name = WorkflowHelper.GenerateWorkflowPermissionKey(workflowDefinition.Id);

// TODO
var list = await PermissionGrantRepository.GetListAsync();
var list = await PermissionGrantRepository.GetListAsync(cancellationToken: cancellationToken);
var grants = list.Where(x => x.Name == name && x.ProviderName == WorkflowUserOwnerPermissionValueProvider.ProviderName);

var userIds = grants.Select(x => x.ProviderKey).Select(x => Guid.Parse(x));
Expand All @@ -248,7 +248,7 @@ public async Task RemoveWorkflowOwnerAsync(WorkflowDefinition workflowDefinition
[UnitOfWork]
public async Task RestoreWorkflowTeamPermissionGrantsAsync(CancellationToken cancellationToken = default)
{
var teams = await WorkflowTeamRepository.GetListAsync(true);
var teams = await WorkflowTeamRepository.GetListAsync(true, cancellationToken);

foreach (var team in teams)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected override Expression VisitMember(MemberExpression node)
// Re-perform any member-binding.
var expr = Visit(node.Expression);

if (expr.Type != node.Type && expr.Type.GetMember(node.Member.Name).Any())
if (expr.Type != node.Type && expr.Type.GetMember(node.Member.Name).Length != 0)
{
var newMember = expr.Type.GetMember(node.Member.Name).Single();
return Expression.MakeMemberAccess(expr, newMember);
Expand Down
Loading

0 comments on commit b753188

Please sign in to comment.