Skip to content

Commit

Permalink
Merge pull request #9 from aruss/some-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aruss authored Jun 2, 2023
2 parents bc8034c + bfef0de commit 9e64be9
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 63 deletions.
4 changes: 2 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ then
fi

# Set version
VERSION=6.0.0
VERSION=6.0.1

# Remove previous builds and artifacts
#find . -iname "bin" -o -iname "obj" -o -iname "artifacts" | xargs rm -rf
Expand All @@ -19,7 +19,7 @@ dotnet build ./ServiceBase.sln --no-restore --configuration Release /property:Ve

# Pack all the nugets
for PROJECT in "${PROJECTS[@]}"; do
updeps ./src/$PROJECT/$PROJECT.csproj ./src/$PROJECT/$PROJECT.nuspec
# updeps ./src/$PROJECT/$PROJECT.csproj ./src/$PROJECT/$PROJECT.nuspec
nuget pack ./src/$PROJECT/$PROJECT.nuspec -OutputDirectory ./artifacts/packages -Properties Configuration=Release -version $VERSION -IncludeReferencedProjects
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
<PackageReference Include="RabbitMQ.Client" Version="6.4.0" />
<PackageReference Include="RabbitMQ.Client" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 5 additions & 3 deletions src/ServiceBase.Mvc/Filters/ModelStateFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ public override void OnActionExecuting(ActionExecutingContext context)
{
if (!context.ModelState.IsValid)
{
context.Result =
context.Result =
new BadRequestObjectResult(context.ModelState);
}
}

public override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
public override Task OnActionExecutionAsync(
ActionExecutingContext context,
ActionExecutionDelegate next)
{
return base.OnActionExecutionAsync(context, next);
}
}
}
}
2 changes: 1 addition & 1 deletion src/ServiceBase.Mvc/ServiceBase.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<ItemGroup>
<!--<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.4" />-->
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceBase.PayPal/ServiceBase.PayPal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
19 changes: 0 additions & 19 deletions src/ServiceBase/Collections/SortDirection.cs

This file was deleted.

8 changes: 4 additions & 4 deletions src/ServiceBase/Collections/SortInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ namespace ServiceBase.Collections
public class SortInfo
{
public string Field { get; set; }
public SortDirection Direction { get; set; }
public bool IsAsc { get; set; }

public SortInfo()
{
}

public SortInfo(string field, SortDirection direction)
public SortInfo(string field, bool isAsc)
{
this.Field = field;
this.Direction = direction;
this.IsAsc = isAsc;
}
}
}
}
5 changes: 3 additions & 2 deletions src/ServiceBase/Events/DefaultEventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public DefaultEventService(

if (!this._eventSinks.Any())
{
throw new ApplicationException("Requres at least one event sink");
throw new ApplicationException(
"Requres at least one event sink");
}
}

Expand Down Expand Up @@ -176,4 +177,4 @@ protected virtual async Task PrepareEventAsync(Event evt)
await evt.PrepareAsync();
}
}
}
}
62 changes: 41 additions & 21 deletions src/ServiceBase/Resources/InMemoryResourceStore.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Russlan Akiev. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project
// root for license information.

namespace ServiceBase.Resources
{
Expand Down Expand Up @@ -27,17 +28,19 @@ public Task<Resource> GetAsync(
string group,
string key)
{
IEnumerable<Resource> query = this.GetAllAsync(culture, group).Result
.Where(c =>
key.Equals(c.Key,
StringComparison.InvariantCultureIgnoreCase));
IEnumerable<Resource> query =
this.GetAllAsync(culture, group).Result
.Where(c =>
key.Equals(c.Key,
StringComparison.InvariantCultureIgnoreCase));

Resource result = query
.OrderBy(c => c.CreatedAt)
.FirstOrDefault();

this._logger.LogDebug(
"Found resource in database {0}, {1} {2}", culture, key, result != null);
"Found resource in database {0}, {1} {2}",
culture, key, result != null);

return Task.FromResult(result);
}
Expand All @@ -52,11 +55,15 @@ public Task<IEnumerable<Resource>> GetAllAsync(
StringComparison.InvariantCultureIgnoreCase) &&
group.Equals(c.Group,
StringComparison.InvariantCultureIgnoreCase));

// TODO: Create message only if debug log level is active
this._logger.LogDebug("Found {0} number of resources in database",
result.Count());


this._logger.LogDebug(() =>
{
return String.Format(
"Found {0} resources in resource store",
result.Count()
);
});

return Task.FromResult(result);
}

Expand All @@ -70,12 +77,16 @@ public Task<IEnumerable<string>> GetAllCulturesAsync(string group)
)
)
.Select(s => s.Culture)
.Distinct();

// TODO: Create message only if debug log level is active
this._logger.LogDebug("Found {0} number of cultures in database",
result.Count());

.Distinct();

this._logger.LogDebug(() =>
{
return String.Format(
"Found {0} cultures in resource store",
result.Count()
);
});

return Task.FromResult(result);
}

Expand Down Expand Up @@ -116,14 +127,23 @@ public Task WriteAsync(

this._logger.LogDebug(() =>
{
return String.Format("Writing resource to database \n {0}",
return String.Format("Adding resource to resource store: {0}",
Newtonsoft.Json.JsonConvert.SerializeObject(
resource,
Newtonsoft.Json.Formatting.Indented)
Newtonsoft.Json.Formatting.None)
);
});

InMemoryResourceStore._resources.TryAdd(resource);

try
{
InMemoryResourceStore._resources.TryAdd(resource);
}
catch (InvalidOperationException ex)
{
// In case dupplicate key is added just log it instead of
// exiting the app
this._logger.LogError(ex.Message);
}

return Task.CompletedTask;
}
Expand Down
8 changes: 4 additions & 4 deletions src/ServiceBase/ServiceBase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions test/ServiceBase.UnitTests/ServiceBase.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="ReportGenerator" Version="5.1.10" />
<PackageReference Include="ReportGenerator" Version="5.1.21" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 9e64be9

Please sign in to comment.