forked from ddrilling/AsbCloudServer
Fix TimezoneId mapping, rename TimeZoneId to TimezoneId
This commit is contained in:
parent
4db67113b4
commit
e99ac84c46
@ -4,7 +4,7 @@ namespace AsbCloudDb.Model
|
||||
public class SimpleTimezone
|
||||
{
|
||||
public double Hours { get; set; }
|
||||
public string TimeZoneId { get; set; }
|
||||
public string TimezoneId { get; set; }
|
||||
public bool IsOverride { get; set; }
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,23 @@ namespace AsbCloudInfrastructure
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<TimeOnly, TimeDto>()
|
||||
.MapWith((source) => new(source));
|
||||
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<WellDto, Well>()
|
||||
.Ignore(dst => dst.Cluster,
|
||||
dst => dst.RelationCompaniesWells,
|
||||
dst => dst.Telemetry,
|
||||
dst => dst.WellComposites,
|
||||
dst => dst.WellCompositeSrcs,
|
||||
dst => dst.WellOperations,
|
||||
dst => dst.WellType);
|
||||
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<ClusterDto, Cluster>()
|
||||
.Ignore(dst => dst.Deposit,
|
||||
dst=>dst.Wells);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
||||
|
@ -58,7 +58,7 @@ namespace AsbCloudInfrastructure
|
||||
Well = well.Caption,
|
||||
Customer = well.RelationCompaniesWells.FirstOrDefault(c => c.Company.IdCompanyType == 1)?.Company.Caption,
|
||||
DrillingStartDate = well.Telemetry?.Info?.DrillingStartDate.ToRemoteDateTime(timezoneOffset) ?? default,
|
||||
TimeZoneId = well.Telemetry?.Info?.TimeZoneId ?? well.Timezone?.TimeZoneId ?? default,
|
||||
TimeZoneId = well.Telemetry?.Info?.TimeZoneId ?? well.Timezone?.TimezoneId ?? default,
|
||||
TimeZoneOffsetTotalHours = timezoneOffset,
|
||||
};
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
telemetry.TimeZone = new SimpleTimezone()
|
||||
{
|
||||
Hours = info.TimeZoneOffsetTotalHours,
|
||||
TimeZoneId = info.TimeZoneId
|
||||
TimezoneId = info.TimeZoneId
|
||||
};
|
||||
|
||||
await cacheTelemetry.UpsertAsync(telemetry, token)
|
||||
@ -135,7 +135,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
{
|
||||
Hours = telemetry.Info.TimeZoneOffsetTotalHours,
|
||||
IsOverride = false,
|
||||
TimeZoneId = telemetry.Info.TimeZoneId,
|
||||
TimezoneId = telemetry.Info.TimeZoneId,
|
||||
};
|
||||
cacheTelemetry.Upsert(telemetry);
|
||||
return telemetry.TimeZone.Adapt<SimpleTimezoneDto>();
|
||||
@ -186,7 +186,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
||||
{
|
||||
Hours = 5,
|
||||
IsOverride = false,
|
||||
TimeZoneId = "default",
|
||||
TimezoneId = "default",
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -16,17 +16,6 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
public class WellService : CrudCacheServiceBase<WellDto, Well>, IWellService
|
||||
{
|
||||
private static readonly TypeAdapterConfig typeAdapterConfig = TypeAdapterConfig<WellDto, Well>
|
||||
.NewConfig()
|
||||
.Ignore(dst => dst.Cluster,
|
||||
dst => dst.RelationCompaniesWells,
|
||||
dst => dst.Telemetry,
|
||||
dst => dst.WellComposites,
|
||||
dst => dst.WellCompositeSrcs,
|
||||
dst => dst.WellOperations,
|
||||
dst => dst.WellType)
|
||||
.Config;
|
||||
|
||||
private const string relationCompaniesWellsCacheTag = "RelationCompaniesWells";
|
||||
private static readonly TimeSpan relationCompaniesWellsCacheObsolence = TimeSpan.FromMinutes(15);
|
||||
|
||||
@ -216,7 +205,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
|
||||
protected override Well Convert(WellDto dto)
|
||||
{
|
||||
var entity = dto.Adapt<Well>(typeAdapterConfig);
|
||||
var entity = dto.Adapt<Well>();
|
||||
|
||||
entity.IdTelemetry = entity.IdTelemetry ?? dto.IdTelemetry ?? dto.Telemetry?.Id;
|
||||
|
||||
@ -267,7 +256,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
{
|
||||
Hours = 5,
|
||||
IsOverride = false,
|
||||
TimeZoneId = "Assumed",
|
||||
TimezoneId = "Assumed",
|
||||
};
|
||||
|
||||
await dbSet.Where(w => w.Timezone == null)
|
||||
|
@ -22,7 +22,9 @@ namespace AsbCloudWebApi
|
||||
services.AddControllers()
|
||||
.AddJsonOptions(new System.Action<Microsoft.AspNetCore.Mvc.JsonOptions>(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals | System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString; }))
|
||||
options.JsonSerializerOptions.NumberHandling =
|
||||
System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals |
|
||||
System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString;}))
|
||||
.AddProtoBufNet();
|
||||
|
||||
ProtobufModel.EnshureRegistered();
|
||||
@ -41,7 +43,6 @@ namespace AsbCloudWebApi
|
||||
{
|
||||
policy.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
//.SetIsOriginAllowed(h => true)
|
||||
.WithOrigins(
|
||||
"http://0.0.0.0",
|
||||
"http://*",
|
||||
|
Loading…
Reference in New Issue
Block a user