Skip to content

Commit

Permalink
Story so far
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander van Delft committed Oct 25, 2024
1 parent e49aa88 commit 05836dc
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CDP4Orm/CDP4Orm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<EmbeddedResource Include="MigrationScript\SiteDirectory_20210108_6_3_0_0_Model_Updates.sql" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CDP4JsonSerializer-CE" Version="27.3.5" />
<PackageReference Include="CDP4DalJsonSerializer-CE" Version="28.0.0-rc11" />
<PackageReference Include="Npgsql" Version="8.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
</ItemGroup>
Expand Down
7 changes: 1 addition & 6 deletions CDP4Orm/Dao/BaseDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public abstract class BaseDao
/// </summary>
private NpgsqlTransaction currentTransactionDataTimeTransaction;

/// <summary>
/// Gets or sets the injected <see cref="ICdp4JsonSerializer" />
/// </summary>
public ICdp4JsonSerializer JsonSerializer { get; set; }

/// <summary>
/// Execute additional logic before each update function call.
/// </summary>
Expand Down Expand Up @@ -324,7 +319,7 @@ private DateTime GetTransactionDateTime(NpgsqlTransaction transaction)
/// <returns>A <see cref="Thing"/></returns>
protected Thing MapJsonbToDto(NpgsqlDataReader reader)
{
var jsonObject = System.Text.Json.JsonSerializer.Deserialize<JsonElement>(reader.GetValue(0).ToString());
var jsonObject = JsonSerializer.Deserialize<JsonElement>(reader.GetValue(0).ToString());
Thing thing;

try
Expand Down
11 changes: 10 additions & 1 deletion CDP4Orm/Dao/Cache/CacheDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,16 @@ public void BulkWrite(NpgsqlTransaction transaction, string partition, IReadOnly
{
var iidParam = new NpgsqlParameter($"iid_{index}", NpgsqlDbType.Uuid) { Value = thing.Iid };
var revisionParam = new NpgsqlParameter($"revision_{index}", NpgsqlDbType.Integer) { Value = thing.RevisionNumber };
var jsonbParam = new NpgsqlParameter($"jsonb_{index}", NpgsqlDbType.Jsonb) { Value = this.JsonSerializer.SerializeToString(thing) };
var jsonbParam = new NpgsqlParameter($"jsonb_{index}", NpgsqlDbType.Jsonb);

var serializedJson = this.JsonSerializer.SerializeToString(thing);

if (string.IsNullOrWhiteSpace(serializedJson))
{
serializedJson = "{}";
}

jsonbParam.Value = serializedJson;

parameters.Add(iidParam);
parameters.Add(revisionParam);
Expand Down
11 changes: 3 additions & 8 deletions CDP4Orm/Dao/Revision/RevisionDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ public class RevisionDao : IRevisionDao
/// </summary>
public IResolveDao ResolveDao { get; set; }

/// <summary>
/// Gets or sets the injected <see cref="ICdp4JsonSerializer" />
/// </summary>
public ICdp4JsonSerializer JsonSerializer { get; set; }

/// <summary>
/// Retrieves data from the RevisionRegistry table in the specific partition.
/// </summary>
Expand Down Expand Up @@ -195,7 +190,7 @@ public void WriteRevision(NpgsqlTransaction transaction, string partition, Thing
command.Parameters.Add("iid", NpgsqlDbType.Uuid).Value = thing.Iid;
command.Parameters.Add("revisionnumber", NpgsqlDbType.Integer).Value = thing.RevisionNumber;
command.Parameters.Add("actor", NpgsqlDbType.Uuid).Value = actor;
command.Parameters.Add("jsonb", NpgsqlDbType.Jsonb).Value = this.JsonSerializer.SerializeToString(thing);
command.Parameters.Add("jsonb", NpgsqlDbType.Jsonb).Value = JsonSerializer.Serialize(thing);

command.ExecuteNonQuery();
}
Expand Down Expand Up @@ -229,7 +224,7 @@ public void BulkWriteRevision(NpgsqlTransaction transaction, string partition, I
var iidParam = new NpgsqlParameter($"iid_{index}", NpgsqlDbType.Uuid) { Value = thing.Iid };
var revisionParam = new NpgsqlParameter($"revisionnumber_{index}", NpgsqlDbType.Integer) { Value = thing.RevisionNumber };
var actorParam = new NpgsqlParameter($"actor_{index}", NpgsqlDbType.Uuid) { Value = actor };
var jsonbParam = new NpgsqlParameter($"jsonb_{index}", NpgsqlDbType.Jsonb) { Value = this.JsonSerializer.SerializeToString(thing) };
var jsonbParam = new NpgsqlParameter($"jsonb_{index}", NpgsqlDbType.Jsonb) { Value = JsonSerializer.Serialize(thing) };

parameters.Add(iidParam);
parameters.Add(revisionParam);
Expand Down Expand Up @@ -666,7 +661,7 @@ private static string GetThingRevisionTableName(ClassKind classKind)
/// <returns>A <see cref="Thing"/></returns>
private Thing MapToDto(NpgsqlDataReader reader)
{
var jsonObject = this.JsonSerializer.Deserialize<JsonElement>(reader.GetValue(0).ToString());
var jsonObject = JsonSerializer.Deserialize<JsonElement>(reader.GetValue(0).ToString());

Thing thing;

Expand Down
6 changes: 3 additions & 3 deletions CometServer/CometServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Carter" Version="8.2.1" />
<PackageReference Include="CDP4MessagePackSerializer-CE" Version="27.3.5" />
<PackageReference Include="CDP4DalJsonSerializer-CE" Version="27.3.5" />
<PackageReference Include="CDP4ServicesMessaging-CE" Version="27.3.5" />
<PackageReference Include="CDP4MessagePackSerializer-CE" Version="28.0.0-rc11" />
<PackageReference Include="CDP4DalJsonSerializer-CE" Version="28.0.0-rc11" />
<PackageReference Include="CDP4ServicesMessaging-CE" Version="28.0.0-rc11" />
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
Expand Down
1 change: 1 addition & 0 deletions CometServer/Modules/10-25/EngineeringModelApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public override void AddRoutes(IEndpointRouteBuilder app)

res.StatusCode = (int)HttpStatusCode.InternalServerError;
await res.AsJson($"exception:{ex.Message}");
return;
}

if (postRequestData.IsMultiPart && requestUtils.QueryParameters.WaitTime > 0)
Expand Down
1 change: 1 addition & 0 deletions CometServer/Modules/10-25/SiteDirectoryApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public override void AddRoutes(IEndpointRouteBuilder app)

res.StatusCode = (int)HttpStatusCode.InternalServerError;
await res.AsJson($"exception:{ex.Message}");
return;
}

if (postRequestData.IsMultiPart )
Expand Down
2 changes: 1 addition & 1 deletion CometServer/Modules/Tasks/CometTasksModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace CometServer.Modules.Tasks
using Carter;
using Carter.Response;

using CDP4DalCommon.Tasks;
using CDP4DalCommon.Protocol.Tasks;

using CometServer.Authorization;
using CometServer.Configuration;
Expand Down
3 changes: 2 additions & 1 deletion CometServer/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ public void ConfigureContainer(ContainerBuilder builder)
builder.RegisterType<DefaultPermissionProvider>().As<IDefaultPermissionProvider>().SingleInstance();
builder.RegisterAssemblyTypes(typeof(IMetaInfo).Assembly).Where(x => typeof(IMetaInfo).IsAssignableFrom(x)).AsImplementedInterfaces().PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies).InstancePerLifetimeScope();
builder.RegisterType<MetaInfoProvider>().As<IMetaDataProvider>().As<IMetaInfoProvider>().PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies).InstancePerLifetimeScope();
builder.Register(_ => new Cdp4DalJsonSerializer(false)).As<ICdp4JsonSerializer>().InstancePerLifetimeScope();
builder.Register(_ =>
new Cdp4DalJsonSerializer(false)).As<ICdp4JsonSerializer>().InstancePerLifetimeScope();
builder.RegisterType<MessagePackSerializer>().As<IMessagePackSerializer>().InstancePerLifetimeScope();

// authentication services
Expand Down

0 comments on commit 05836dc

Please sign in to comment.