From 25cb18c645265b178f85faa17d5f4b65659d21a2 Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Mon, 13 Nov 2023 09:59:24 +0100 Subject: [PATCH 1/4] Property renaming --- Src/Witsml/Data/MudLog/WitsmlMudLog.cs | 4 +- Src/Witsml/Data/Rig/WitsmlRig.cs | 4 +- Src/Witsml/Data/Tubular/WitsmlTubular.cs | 4 +- Src/Witsml/Data/WitsmlBhaRun.cs | 4 +- Src/Witsml/Data/WitsmlChangeLog.cs | 2 +- Src/Witsml/Data/WitsmlFluidsReport.cs | 4 +- Src/Witsml/Data/WitsmlFormationMarker.cs | 4 +- Src/Witsml/Data/WitsmlLog.cs | 4 +- Src/Witsml/Data/WitsmlMessage.cs | 4 +- Src/Witsml/Data/WitsmlObjectOnWellbore.cs | 2 +- Src/Witsml/Data/WitsmlRisk.cs | 4 +- Src/Witsml/Data/WitsmlTrajectory.cs | 4 +- Src/Witsml/Data/WitsmlWbGeometry.cs | 4 +- Src/Witsml/Extensions/ListExtensions.cs | 2 +- .../Configuration/ServerCredentials.cs | 2 +- .../Extensions/WebApplicationExtensions.cs | 55 +++++-------------- Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs | 4 +- .../Query/FluidsReportQueries.cs | 2 +- Src/WitsmlExplorer.Api/Query/LogQueries.cs | 10 ++-- .../Query/MessageQueries.cs | 6 +- Src/WitsmlExplorer.Api/Query/MudLogQueries.cs | 10 ++-- Src/WitsmlExplorer.Api/Query/ObjectQueries.cs | 2 +- Src/WitsmlExplorer.Api/Query/RigQueries.cs | 6 +- Src/WitsmlExplorer.Api/Query/RiskQueries.cs | 10 ++-- .../Query/TrajectoryQueries.cs | 12 ++-- .../Query/TubularQueries.cs | 8 +-- .../Query/WbGeometryQueries.cs | 18 +++--- Src/WitsmlExplorer.Api/Query/WellQueries.cs | 10 ++-- .../Query/WellboreQueries.cs | 12 ++-- .../Services/LogObjectService.cs | 4 +- .../Services/ObjectService.cs | 2 +- Src/WitsmlExplorer.Api/Services/RigService.cs | 2 +- .../Services/StringHelpers.cs | 45 +++------------ .../Services/WbGeometryService.cs | 2 +- .../Services/WellboreService.cs | 4 +- .../Workers/Copy/CopyComponentsWorker.cs | 2 +- .../Workers/Copy/CopyLogWorker.cs | 2 +- .../Workers/Copy/CopyUtils.cs | 2 +- .../Workers/Create/CreateLogWorker.cs | 4 +- .../Workers/Create/CreateWbGeometryWorker.cs | 2 +- .../Workers/Delete/DeleteComponentsWorker.cs | 2 +- .../Workers/Delete/DeleteObjectsWorker.cs | 2 +- .../Workers/ImportLogDataWorker.cs | 2 +- .../Workers/MissingDataWorker.cs | 2 +- .../Workers/Modify/ModifyLogObjectWorker.cs | 2 +- .../Workers/Modify/ModifyTubularWorker.cs | 2 +- .../Workers/SpliceLogsWorker.cs | 2 +- Src/WitsmlExplorer.Api/Workers/WorkerTools.cs | 2 +- .../ListCommands/ListBhaRunsCommand.cs | 2 +- .../ListCommands/ListLogsCommand.cs | 2 +- .../ListCommands/ListRisksCommand.cs | 2 +- .../ListCommands/ListTubularsCommand.cs | 2 +- .../ListCommands/ListWellboresCommand.cs | 2 +- .../ShowCommands/ShowTubularCommand.cs | 2 +- .../Services/MessageObjectServiceTests.cs | 2 +- .../Services/ObjectServiceTests.cs | 8 +-- .../Services/StringHelpersTests.cs | 6 +- .../Workers/AnalyzeGapWorkerTests.cs | 2 +- .../Workers/CheckLogHeaderWorkerTests.cs | 8 +-- .../Workers/CompareLogDataWorker.Tests.cs | 6 +- .../Workers/CopyComponentsWorkerTests.cs | 2 +- .../Workers/CopyWellWorkerTests.cs | 6 +- .../Workers/CopyWellboreWorkerTests.cs | 6 +- .../Workers/CountLogDataRowWorkerTest.cs | 2 +- .../Workers/LogUtils.cs | 8 +-- .../Workers/SpliceLogsWorkerTests.cs | 2 +- .../Witsml/AddToStore/LogObjectTests.cs | 4 +- .../Witsml/AddToStore/TrajectoryTests.cs | 2 +- .../Witsml/GetFromStore/FluidsReportTests.cs | 2 +- .../Witsml/GetFromStore/LogObjectTests.cs | 2 +- witsml-explorer.sln.DotSettings | 1 + 71 files changed, 165 insertions(+), 220 deletions(-) diff --git a/Src/Witsml/Data/MudLog/WitsmlMudLog.cs b/Src/Witsml/Data/MudLog/WitsmlMudLog.cs index 77e2fb4ad..63f1b1ecc 100644 --- a/Src/Witsml/Data/MudLog/WitsmlMudLog.cs +++ b/Src/Witsml/Data/MudLog/WitsmlMudLog.cs @@ -8,11 +8,11 @@ namespace Witsml.Data.MudLog { public class WitsmlMudLog : WitsmlObjectOnWellbore { - public override WitsmlMudLogs AsSingletonWitsmlList() + public override WitsmlMudLogs AsItemInWitsmlList() { return new WitsmlMudLogs() { - MudLogs = this.AsSingletonList() + MudLogs = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/Rig/WitsmlRig.cs b/Src/Witsml/Data/Rig/WitsmlRig.cs index 82dd28dce..c91a1841f 100644 --- a/Src/Witsml/Data/Rig/WitsmlRig.cs +++ b/Src/Witsml/Data/Rig/WitsmlRig.cs @@ -9,11 +9,11 @@ namespace Witsml.Data.Rig { public class WitsmlRig : WitsmlObjectOnWellbore { - public override WitsmlRigs AsSingletonWitsmlList() + public override WitsmlRigs AsItemInWitsmlList() { return new WitsmlRigs() { - Rigs = this.AsSingletonList() + Rigs = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/Tubular/WitsmlTubular.cs b/Src/Witsml/Data/Tubular/WitsmlTubular.cs index 15d3299a1..4d82a80ca 100644 --- a/Src/Witsml/Data/Tubular/WitsmlTubular.cs +++ b/Src/Witsml/Data/Tubular/WitsmlTubular.cs @@ -9,11 +9,11 @@ namespace Witsml.Data.Tubular { public class WitsmlTubular : WitsmlObjectOnWellbore { - public override WitsmlTubulars AsSingletonWitsmlList() + public override WitsmlTubulars AsItemInWitsmlList() { return new WitsmlTubulars() { - Tubulars = this.AsSingletonList() + Tubulars = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/WitsmlBhaRun.cs b/Src/Witsml/Data/WitsmlBhaRun.cs index 734fe5770..6ea8126d4 100644 --- a/Src/Witsml/Data/WitsmlBhaRun.cs +++ b/Src/Witsml/Data/WitsmlBhaRun.cs @@ -8,11 +8,11 @@ namespace Witsml.Data { public class WitsmlBhaRun : WitsmlObjectOnWellbore { - public override WitsmlBhaRuns AsSingletonWitsmlList() + public override WitsmlBhaRuns AsItemInWitsmlList() { return new WitsmlBhaRuns() { - BhaRuns = this.AsSingletonList() + BhaRuns = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/WitsmlChangeLog.cs b/Src/Witsml/Data/WitsmlChangeLog.cs index 927fdedf4..eaf02cb01 100644 --- a/Src/Witsml/Data/WitsmlChangeLog.cs +++ b/Src/Witsml/Data/WitsmlChangeLog.cs @@ -11,7 +11,7 @@ public WitsmlChangeLogs AsSingletonWitsmlList() { return new WitsmlChangeLogs() { - ChangeLogs = this.AsSingletonList() + ChangeLogs = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/WitsmlFluidsReport.cs b/Src/Witsml/Data/WitsmlFluidsReport.cs index d9f52582a..0411ec61e 100644 --- a/Src/Witsml/Data/WitsmlFluidsReport.cs +++ b/Src/Witsml/Data/WitsmlFluidsReport.cs @@ -8,11 +8,11 @@ namespace Witsml.Data { public class WitsmlFluidsReport : WitsmlObjectOnWellbore { - public override WitsmlFluidsReports AsSingletonWitsmlList() + public override WitsmlFluidsReports AsItemInWitsmlList() { return new WitsmlFluidsReports() { - FluidsReports = this.AsSingletonList() + FluidsReports = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/WitsmlFormationMarker.cs b/Src/Witsml/Data/WitsmlFormationMarker.cs index 9fa040dfe..e8a149ae0 100644 --- a/Src/Witsml/Data/WitsmlFormationMarker.cs +++ b/Src/Witsml/Data/WitsmlFormationMarker.cs @@ -7,11 +7,11 @@ namespace Witsml.Data { public class WitsmlFormationMarker : WitsmlObjectOnWellbore { - public override WitsmlFormationMarkers AsSingletonWitsmlList() + public override WitsmlFormationMarkers AsItemInWitsmlList() { return new WitsmlFormationMarkers() { - FormationMarkers = this.AsSingletonList() + FormationMarkers = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/WitsmlLog.cs b/Src/Witsml/Data/WitsmlLog.cs index 06d9395db..a69be0a37 100644 --- a/Src/Witsml/Data/WitsmlLog.cs +++ b/Src/Witsml/Data/WitsmlLog.cs @@ -7,11 +7,11 @@ namespace Witsml.Data { public class WitsmlLog : WitsmlObjectOnWellbore { - public override WitsmlLogs AsSingletonWitsmlList() + public override WitsmlLogs AsItemInWitsmlList() { return new WitsmlLogs() { - Logs = this.AsSingletonList() + Logs = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/WitsmlMessage.cs b/Src/Witsml/Data/WitsmlMessage.cs index e24f8124d..10217a80e 100644 --- a/Src/Witsml/Data/WitsmlMessage.cs +++ b/Src/Witsml/Data/WitsmlMessage.cs @@ -9,11 +9,11 @@ namespace Witsml.Data [XmlRoot] public class WitsmlMessage : WitsmlObjectOnWellbore { - public override WitsmlMessages AsSingletonWitsmlList() + public override WitsmlMessages AsItemInWitsmlList() { return new WitsmlMessages() { - Messages = this.AsSingletonList() + Messages = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/WitsmlObjectOnWellbore.cs b/Src/Witsml/Data/WitsmlObjectOnWellbore.cs index 535d94415..0c9cb4063 100644 --- a/Src/Witsml/Data/WitsmlObjectOnWellbore.cs +++ b/Src/Witsml/Data/WitsmlObjectOnWellbore.cs @@ -5,7 +5,7 @@ namespace Witsml.Data { public abstract class WitsmlObjectOnWellbore { - public abstract IWitsmlQueryType AsSingletonWitsmlList(); + public abstract IWitsmlQueryType AsItemInWitsmlList(); [XmlAttribute("uidWell")] public string UidWell { get; set; } diff --git a/Src/Witsml/Data/WitsmlRisk.cs b/Src/Witsml/Data/WitsmlRisk.cs index 08300a227..3a12ddeea 100644 --- a/Src/Witsml/Data/WitsmlRisk.cs +++ b/Src/Witsml/Data/WitsmlRisk.cs @@ -8,11 +8,11 @@ namespace Witsml.Data { public class WitsmlRisk : WitsmlObjectOnWellbore { - public override WitsmlRisks AsSingletonWitsmlList() + public override WitsmlRisks AsItemInWitsmlList() { return new WitsmlRisks() { - Risks = this.AsSingletonList() + Risks = this.AsItemInList() }; } [XmlElement("objectReference")] diff --git a/Src/Witsml/Data/WitsmlTrajectory.cs b/Src/Witsml/Data/WitsmlTrajectory.cs index 6540bb50f..c0dbf79d4 100644 --- a/Src/Witsml/Data/WitsmlTrajectory.cs +++ b/Src/Witsml/Data/WitsmlTrajectory.cs @@ -9,11 +9,11 @@ namespace Witsml.Data { public class WitsmlTrajectory : WitsmlObjectOnWellbore { - public override WitsmlTrajectories AsSingletonWitsmlList() + public override WitsmlTrajectories AsItemInWitsmlList() { return new WitsmlTrajectories() { - Trajectories = this.AsSingletonList() + Trajectories = this.AsItemInList() }; } diff --git a/Src/Witsml/Data/WitsmlWbGeometry.cs b/Src/Witsml/Data/WitsmlWbGeometry.cs index 3542457c9..7c4227d61 100644 --- a/Src/Witsml/Data/WitsmlWbGeometry.cs +++ b/Src/Witsml/Data/WitsmlWbGeometry.cs @@ -9,11 +9,11 @@ namespace Witsml.Data { public class WitsmlWbGeometry : WitsmlObjectOnWellbore { - public override WitsmlWbGeometrys AsSingletonWitsmlList() + public override WitsmlWbGeometrys AsItemInWitsmlList() { return new WitsmlWbGeometrys() { - WbGeometrys = this.AsSingletonList() + WbGeometrys = this.AsItemInList() }; } diff --git a/Src/Witsml/Extensions/ListExtensions.cs b/Src/Witsml/Extensions/ListExtensions.cs index 8f05af771..a914c8b96 100644 --- a/Src/Witsml/Extensions/ListExtensions.cs +++ b/Src/Witsml/Extensions/ListExtensions.cs @@ -4,7 +4,7 @@ namespace Witsml.Extensions { public static class ListExtensions { - public static List AsSingletonList(this T item) + public static List AsItemInList(this T item) { return new List { item }; } diff --git a/Src/WitsmlExplorer.Api/Configuration/ServerCredentials.cs b/Src/WitsmlExplorer.Api/Configuration/ServerCredentials.cs index d0c1bc0c2..e0f813ea1 100644 --- a/Src/WitsmlExplorer.Api/Configuration/ServerCredentials.cs +++ b/Src/WitsmlExplorer.Api/Configuration/ServerCredentials.cs @@ -29,7 +29,7 @@ public bool IsCredsNullOrEmpty() } public bool Equals(ServerCredentials other) { - return (Host.EqualsIgnoreCase(other.Host)) && + return (other != null && Host.EqualsIgnoreCase(other.Host)) && (UserId == other.UserId) && (Password == other.Password); } diff --git a/Src/WitsmlExplorer.Api/Extensions/WebApplicationExtensions.cs b/Src/WitsmlExplorer.Api/Extensions/WebApplicationExtensions.cs index c82fec261..a3935ce71 100644 --- a/Src/WitsmlExplorer.Api/Extensions/WebApplicationExtensions.cs +++ b/Src/WitsmlExplorer.Api/Extensions/WebApplicationExtensions.cs @@ -6,88 +6,59 @@ namespace WitsmlExplorer.Api.Extensions { - public static class WebApplicationExtensions { private static readonly string ApiPath = "/api"; public static void MapGet(this IEndpointRouteBuilder endpoints, string pattern, Delegate handler, bool useOAuth2) { + var routeHandlerBuilder = endpoints.MapGet(ApiPath + pattern, handler); if (useOAuth2) { - endpoints.MapGet(ApiPath + pattern, handler).RequireAuthorization(); - } - else - { - endpoints.MapGet(ApiPath + pattern, handler); + routeHandlerBuilder.RequireAuthorization(); } } public static void MapGet(this IEndpointRouteBuilder endpoints, string pattern, Delegate handler, bool useOAuth2, params string[] policyNames) { + var routeHandlerBuilder = endpoints.MapGet(ApiPath + pattern, handler); if (useOAuth2) { - endpoints.MapGet(ApiPath + pattern, handler).RequireAuthorization(policyNames); - } - else - { - endpoints.MapGet(ApiPath + pattern, handler); - } - } - public static void MapPost(this IEndpointRouteBuilder endpoints, string pattern, Delegate handler, bool useOAuth2) - { - if (useOAuth2) - { - endpoints.MapPost(ApiPath + pattern, handler).RequireAuthorization(); - } - else - { - endpoints.MapPost(ApiPath + pattern, handler); + routeHandlerBuilder.RequireAuthorization(policyNames); } } + public static void MapPost(this IEndpointRouteBuilder endpoints, string pattern, Delegate handler, bool useOAuth2, params string[] policyNames) { + var routeHandlerBuilder = endpoints.MapPost(ApiPath + pattern, handler); if (useOAuth2) { - endpoints.MapPost(ApiPath + pattern, handler).RequireAuthorization(policyNames); - } - else - { - endpoints.MapPost(ApiPath + pattern, handler); + routeHandlerBuilder.RequireAuthorization(policyNames); } } public static void MapDelete(this IEndpointRouteBuilder endpoints, string pattern, Delegate handler, bool useOAuth2, params string[] policyNames) { + var routeHandlerBuilder = endpoints.MapDelete(ApiPath + pattern, handler); if (useOAuth2) { - endpoints.MapDelete(ApiPath + pattern, handler).RequireAuthorization(policyNames); - } - else - { - endpoints.MapDelete(ApiPath + pattern, handler); + routeHandlerBuilder.RequireAuthorization(policyNames); } } public static void MapPatch(this IEndpointRouteBuilder endpoints, string pattern, Delegate handler, bool useOAuth2, params string[] policyNames) { + var routeHandlerBuilder = endpoints.MapPatch(ApiPath + pattern, handler); if (useOAuth2) { - endpoints.MapPatch(ApiPath + pattern, handler).RequireAuthorization(policyNames); - } - else - { - endpoints.MapPatch(ApiPath + pattern, handler); + routeHandlerBuilder.RequireAuthorization(policyNames); } } public static void MapHub(this IEndpointRouteBuilder endpoints, string pattern, bool useOAuth2, params string[] policyNames) where T : Hub { + var routeHandlerBuilder = endpoints.MapHub(pattern); if (useOAuth2) { - endpoints.MapHub(pattern).RequireAuthorization(policyNames); - } - else - { - endpoints.MapHub(pattern); + routeHandlerBuilder.RequireAuthorization(policyNames); } } } diff --git a/Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs b/Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs index 151d94afb..3313cd17c 100644 --- a/Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs @@ -51,7 +51,7 @@ public static WitsmlBhaRuns GetWitsmlBhaRun(string wellUid, string wellboreUid, Comments = "", DefaultDatum = "", } - }.AsSingletonList() + }.AsItemInList() }; } @@ -107,7 +107,7 @@ public static WitsmlBhaRuns CreateBhaRun(BhaRun bhaRun) Comments = bhaRun.CommonData.Comments, DefaultDatum = bhaRun.CommonData.DefaultDatum, } - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/FluidsReportQueries.cs b/Src/WitsmlExplorer.Api/Query/FluidsReportQueries.cs index faaae444d..a7089b51c 100644 --- a/Src/WitsmlExplorer.Api/Query/FluidsReportQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/FluidsReportQueries.cs @@ -27,7 +27,7 @@ public static WitsmlFluidsReports QueryByWellbore(string wellUid, string wellbor Comments = "", DefaultDatum = "" } - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Query/LogQueries.cs b/Src/WitsmlExplorer.Api/Query/LogQueries.cs index e9e20e49f..42aeef82c 100644 --- a/Src/WitsmlExplorer.Api/Query/LogQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/LogQueries.cs @@ -33,7 +33,7 @@ public static WitsmlLogs GetWitsmlLogsByWellbore(string wellUid, string wellbore DTimCreation = "", DTimLastChange = "" } - }.AsSingletonList() + }.AsItemInList() }; } @@ -46,7 +46,7 @@ public static WitsmlLogs GetWitsmlLogById(string wellUid, string wellboreUid, st Uid = logUid, UidWell = wellUid, UidWellbore = wellboreUid - }.AsSingletonList() + }.AsItemInList() }; } @@ -160,7 +160,7 @@ public static WitsmlLogs DeleteMnemonics(string wellUid, string wellboreUid, str { Mnemonic = mnemonic }).ToList() - }.AsSingletonList() + }.AsItemInList() }; } @@ -185,8 +185,8 @@ public static WitsmlLogs GetLogHeaderIndexes(string wellUid, string wellboreUid, MaxIndex = new WitsmlIndex(), MinDateTimeIndex = "", MaxDateTimeIndex = "" - }.AsSingletonList(), - }.AsSingletonList() + }.AsItemInList(), + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/MessageQueries.cs b/Src/WitsmlExplorer.Api/Query/MessageQueries.cs index 2281ea9e0..8ad616d5a 100644 --- a/Src/WitsmlExplorer.Api/Query/MessageQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/MessageQueries.cs @@ -16,7 +16,7 @@ public static WitsmlMessages GetMessageById(string wellUid, string wellboreUid, UidWellbore = wellboreUid, UidWell = wellUid, Uid = messageUid - }.AsSingletonList() + }.AsItemInList() }; } @@ -42,7 +42,7 @@ public static WitsmlMessages GetMessageByWellbore(string wellUid, string wellbor DTimLastChange = "", Comments = "" } - }.AsSingletonList() + }.AsItemInList() }; } @@ -59,7 +59,7 @@ public static WitsmlMessages CreateMessageObject(MessageObject messageObject) Uid = messageObject.Uid, Name = messageObject.Name, MessageText = messageObject.MessageText - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/MudLogQueries.cs b/Src/WitsmlExplorer.Api/Query/MudLogQueries.cs index 15f6b9308..580374463 100644 --- a/Src/WitsmlExplorer.Api/Query/MudLogQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/MudLogQueries.cs @@ -32,7 +32,7 @@ public static WitsmlMudLogs QueryByWellbore(string wellUid, string wellboreUid) DTimCreation = "", DTimLastChange = "" } - }.AsSingletonList() + }.AsItemInList() }; } @@ -81,7 +81,7 @@ public static WitsmlMudLogs SetupMudLogToUpdate(MudLog mudLog) Name = mudLog.Name, NameWellbore = mudLog.WellboreName, NameWell = mudLog.WellName, - ObjectGrowing = StringHelpers.OptionalBooleanToString(mudLog.ObjectGrowing), + ObjectGrowing = StringHelpers.NullableBooleanToString(mudLog.ObjectGrowing), MudLogCompany = mudLog.MudLogCompany, MudLogEngineers = mudLog.MudLogEngineers, StartMd = mudLog.StartMd?.ToWitsml(), @@ -92,7 +92,7 @@ public static WitsmlMudLogs SetupMudLogToUpdate(MudLog mudLog) ItemState = mudLog.CommonData.ItemState, SourceName = mudLog.CommonData.SourceName } - }.AsSingletonList() + }.AsItemInList() }; } @@ -123,7 +123,7 @@ public static WitsmlMudLogs DeleteGeologyIntervals(string wellUid, string wellbo { Uid = uid }).ToList() - }.AsSingletonList() + }.AsItemInList() }; } @@ -164,7 +164,7 @@ public static WitsmlMudLogs UpdateGeologyInterval(MudLogGeologyInterval geologyI }).ToList() } }, - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs b/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs index fd8c44541..d355a9cfa 100644 --- a/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/ObjectQueries.cs @@ -63,7 +63,7 @@ public static IWitsmlObjectList GetWitsmlObjectsWithParamByType(EntityType type, { o = QueryHelper.AddPropertyToObject(o, objectProperty, objectPropertyValue); }; - return (IWitsmlObjectList)o.AsSingletonWitsmlList(); + return (IWitsmlObjectList)o.AsItemInWitsmlList(); } public static IWitsmlObjectList GetWitsmlObjectsByIds(string wellUid, string wellboreUid, string[] objectUids, EntityType type) diff --git a/Src/WitsmlExplorer.Api/Query/RigQueries.cs b/Src/WitsmlExplorer.Api/Query/RigQueries.cs index 365f57df1..232ff30e7 100644 --- a/Src/WitsmlExplorer.Api/Query/RigQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/RigQueries.cs @@ -46,7 +46,7 @@ public static WitsmlRigs GetWitsmlRig(string wellUid, string wellboreUid, string DTimLastChange = "", ItemState = "" } - }.AsSingletonList() + }.AsItemInList() }; } @@ -84,7 +84,7 @@ public static WitsmlRigs CreateRig(Rig rig) DTimEndOp = StringHelpers.ToUniversalDateTimeString(rig.DTimEndOp), EmailAddress = rig.EmailAddress.NullIfEmpty(), FaxNumber = rig.FaxNumber.NullIfEmpty(), - IsOffshore = StringHelpers.OptionalBooleanToString(rig.IsOffshore), + IsOffshore = StringHelpers.NullableBooleanToString(rig.IsOffshore), Manufacturer = rig.Manufacturer.NullIfEmpty(), NameContact = rig.NameContact.NullIfEmpty(), RatingDrillDepth = rig.RatingDrillDepth != null ? new WitsmlLengthMeasure { Uom = rig.RatingDrillDepth.Uom, Value = rig.RatingDrillDepth.Value.ToString(CultureInfo.InvariantCulture) } : null, @@ -99,7 +99,7 @@ public static WitsmlRigs CreateRig(Rig rig) DTimLastChange = null, ItemState = rig.CommonData.ItemState, } - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/RiskQueries.cs b/Src/WitsmlExplorer.Api/Query/RiskQueries.cs index 452fb9f83..aea751440 100644 --- a/Src/WitsmlExplorer.Api/Query/RiskQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/RiskQueries.cs @@ -42,7 +42,7 @@ public static WitsmlRisks GetWitsmlRiskByWellbore(string wellUid, string wellbor DTimLastChange = "", DTimCreation = "", } - }.AsSingletonList() + }.AsItemInList() }; } @@ -55,7 +55,7 @@ public static WitsmlRisks QueryById(string wellUid, string wellboreUid, string r Uid = riskUid, UidWell = wellUid, UidWellbore = wellboreUid - }.AsSingletonList() + }.AsItemInList() }; } @@ -83,7 +83,7 @@ public static WitsmlRisks QueryByNameAndDepth(string wellUid, string wellboreUid Name = name, MdBitStart = mdBitStart != null ? new WitsmlMeasuredDepthCoord { Uom = mdBitStart.Uom, Value = mdBitStart.Value.ToString(CultureInfo.InvariantCulture) } : null, MdBitEnd = mdBitEnd != null ? new WitsmlMeasuredDepthCoord { Uom = mdBitEnd.Uom, Value = mdBitEnd.Value.ToString(CultureInfo.InvariantCulture) } : null - }.AsSingletonList() + }.AsItemInList() }; } @@ -100,7 +100,7 @@ public static WitsmlRisks QueryBySource(string wellUid, string wellboreUid, stri { SourceName = source, }, - }.AsSingletonList() + }.AsItemInList() }; } @@ -144,7 +144,7 @@ public static WitsmlRisks CreateRisk(Risk risk) DTimCreation = null, DTimLastChange = null } - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/TrajectoryQueries.cs b/Src/WitsmlExplorer.Api/Query/TrajectoryQueries.cs index 3c7f05e6e..8db13f2bb 100644 --- a/Src/WitsmlExplorer.Api/Query/TrajectoryQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/TrajectoryQueries.cs @@ -37,7 +37,7 @@ public static WitsmlTrajectories GetWitsmlTrajectoryByWellbore(string wellUid, s DTimCreation = "", DTimLastChange = "" } - }.AsSingletonList() + }.AsItemInList() }; } @@ -50,7 +50,7 @@ public static WitsmlTrajectories GetWitsmlTrajectoryById(string wellUid, string Uid = trajectoryUid, UidWell = wellUid, UidWellbore = wellboreUid - }.AsSingletonList() + }.AsItemInList() }; } @@ -87,7 +87,7 @@ public static WitsmlTrajectories DeleteTrajectoryStations(string wellUid, string { Uid = uid }).ToList() - }.AsSingletonList() + }.AsItemInList() }; } @@ -114,7 +114,7 @@ public static WitsmlTrajectories CreateTrajectory(Trajectory trajectory) ServiceCompany = trajectory.ServiceCompany.NullIfEmpty(), DTimTrajStart = StringHelpers.ToUniversalDateTimeString(trajectory.DTimTrajStart), DTimTrajEnd = StringHelpers.ToUniversalDateTimeString(trajectory.DTimTrajEnd), - }.AsSingletonList() + }.AsItemInList() }; } @@ -154,8 +154,8 @@ public static WitsmlTrajectories UpdateTrajectoryStation(TrajectoryStation traje UidWell = trajectoryReference.WellUid, UidWellbore = trajectoryReference.WellboreUid, Uid = trajectoryReference.Uid, - TrajectoryStations = ts.AsSingletonList() - }.AsSingletonList() + TrajectoryStations = ts.AsItemInList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/TubularQueries.cs b/Src/WitsmlExplorer.Api/Query/TubularQueries.cs index 621e0e685..f41d752cb 100644 --- a/Src/WitsmlExplorer.Api/Query/TubularQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/TubularQueries.cs @@ -32,7 +32,7 @@ public static WitsmlTubulars GetWitsmlTubular(string wellUid, string wellboreUid DTimCreation = "", DTimLastChange = "" } - }.AsSingletonList() + }.AsItemInList() }; } @@ -69,7 +69,7 @@ public static WitsmlTubulars DeleteTubularComponents(string wellUid, string well { Uid = uid }).ToList() - }.AsSingletonList() + }.AsItemInList() }; } @@ -104,8 +104,8 @@ public static WitsmlTubulars UpdateTubularComponent(TubularComponent tubularComp UidWell = tubularReference.WellUid, UidWellbore = tubularReference.WellboreUid, Uid = tubularReference.Uid, - TubularComponents = tc.AsSingletonList() - }.AsSingletonList() + TubularComponents = tc.AsItemInList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/WbGeometryQueries.cs b/Src/WitsmlExplorer.Api/Query/WbGeometryQueries.cs index f5bddaec4..7bba74d0d 100644 --- a/Src/WitsmlExplorer.Api/Query/WbGeometryQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/WbGeometryQueries.cs @@ -34,7 +34,7 @@ public static WitsmlWbGeometrys GetWitsmlWbGeometryIdOnly(string wellUid, string Uid = wbGeometryUid, UidWell = wellUid, UidWellbore = wellboreUid, - }.AsSingletonList() + }.AsItemInList() }; } @@ -62,7 +62,7 @@ private static WitsmlWbGeometrys RequiredElementsQuery(string wellUid, string we DTimCreation = "", DTimLastChange = "", } - }.AsSingletonList() + }.AsItemInList() }; } @@ -90,8 +90,8 @@ public static WitsmlWbGeometrys GetSectionsByWbGeometryId(string wellUid, string CurveConductor = "", DiaDrift = LengthMeasure.ToEmptyWitsml(), FactFric = "" - }.AsSingletonList() - }.AsSingletonList() + }.AsItemInList() + }.AsItemInList() }; } @@ -119,7 +119,7 @@ public static WitsmlWbGeometrys CreateWbGeometry(WbGeometry wbGeometry) DTimCreation = null, DTimLastChange = null } - }.AsSingletonList() + }.AsItemInList() }; } @@ -130,7 +130,7 @@ public static WitsmlWbGeometrys UpdateWbGeometrySection(WbGeometrySection wbGeom Uid = wbGeometrySection.Uid, Grade = wbGeometrySection.Grade, TypeHoleCasing = wbGeometrySection.TypeHoleCasing, - CurveConductor = StringHelpers.OptionalBooleanToString(wbGeometrySection.CurveConductor), + CurveConductor = StringHelpers.NullableBooleanToString(wbGeometrySection.CurveConductor), DiaDrift = wbGeometrySection.DiaDrift?.ToWitsml(), IdSection = wbGeometrySection.IdSection?.ToWitsml(), OdSection = wbGeometrySection.OdSection?.ToWitsml(), @@ -149,8 +149,8 @@ public static WitsmlWbGeometrys UpdateWbGeometrySection(WbGeometrySection wbGeom UidWell = wbGeometryReference.WellUid, UidWellbore = wbGeometryReference.WellboreUid, Uid = wbGeometryReference.Uid, - WbGeometrySections = wbgs.AsSingletonList() - }.AsSingletonList() + WbGeometrySections = wbgs.AsItemInList() + }.AsItemInList() }; } @@ -183,7 +183,7 @@ public static WitsmlWbGeometrys DeleteWbGeometrySections(string wellUid, string { Uid = uid }).ToList() - }.AsSingletonList() + }.AsItemInList() }; } diff --git a/Src/WitsmlExplorer.Api/Query/WellQueries.cs b/Src/WitsmlExplorer.Api/Query/WellQueries.cs index 574f365ad..2db88077e 100644 --- a/Src/WitsmlExplorer.Api/Query/WellQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/WellQueries.cs @@ -35,7 +35,7 @@ public static WitsmlWells CreateWitsmlWell(Well well) Operator = well.Operator.NullIfEmpty(), NumLicense = well.NumLicense.NullIfEmpty(), TimeZone = well.TimeZone - }.AsSingletonList() + }.AsItemInList() }; } @@ -47,7 +47,7 @@ public static WitsmlWells UpdateWitsmlWell(string wellUid, string name) { Uid = wellUid, Name = name - }.AsSingletonList() + }.AsItemInList() }; } @@ -64,13 +64,13 @@ public static WitsmlWells UpdateWitsmlWell(Well well) Country = well.Country, Operator = well.Operator, NumLicense = well.NumLicense - }.AsSingletonList() + }.AsItemInList() }; } public static WitsmlWells DeleteWitsmlWell(string wellUid) { - return new WitsmlWells { Wells = new WitsmlWell { Uid = wellUid }.AsSingletonList() }; + return new WitsmlWells { Wells = new WitsmlWell { Uid = wellUid }.AsItemInList() }; } private static WitsmlWells GetWitsmlWell(string wellUid = "") @@ -97,7 +97,7 @@ private static WitsmlWells GetWitsmlWell(string wellUid = "") DTimLastChange = "", ItemState = "" } - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Query/WellboreQueries.cs b/Src/WitsmlExplorer.Api/Query/WellboreQueries.cs index 76de9382d..96009a1c9 100644 --- a/Src/WitsmlExplorer.Api/Query/WellboreQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/WellboreQueries.cs @@ -28,7 +28,7 @@ public static WitsmlWellbores GetWitsmlWellboreByWell(string wellUid = "") DTimCreation = "", DTimLastChange = "" } - }.AsSingletonList() + }.AsItemInList() }; } @@ -42,7 +42,7 @@ public static WitsmlWellbores GetWitsmlWellboreByUid(string wellUid, string well UidWell = wellUid, Name = "", NameWell = "" - }.AsSingletonList() + }.AsItemInList() }; } @@ -137,7 +137,7 @@ public static WitsmlWellbores UpdateWitsmlWellbore(Wellbore wellbore) return new WitsmlWellbores { - Wellbores = witsmlWellbore.AsSingletonList() + Wellbores = witsmlWellbore.AsItemInList() }; } @@ -159,7 +159,7 @@ public static WitsmlWellbores CreateWitsmlWellbore(Wellbore wellbore) }, PurposeWellbore = wellbore.WellborePurpose - }.AsSingletonList() + }.AsItemInList() } : new WitsmlWellbores { @@ -170,7 +170,7 @@ public static WitsmlWellbores CreateWitsmlWellbore(Wellbore wellbore) UidWell = wellbore.WellUid, NameWell = wellbore.WellName, PurposeWellbore = wellbore.WellborePurpose - }.AsSingletonList() + }.AsItemInList() }; } @@ -182,7 +182,7 @@ public static WitsmlWellbores DeleteWitsmlWellbore(string wellUid, string wellbo { Uid = wellboreUid, UidWell = wellUid - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Services/LogObjectService.cs b/Src/WitsmlExplorer.Api/Services/LogObjectService.cs index 35ea9aa8e..6a8508901 100644 --- a/Src/WitsmlExplorer.Api/Services/LogObjectService.cs +++ b/Src/WitsmlExplorer.Api/Services/LogObjectService.cs @@ -45,7 +45,7 @@ public async Task> GetLogs(string wellUid, string wellbor WellName = log.NameWell, WellboreUid = log.UidWellbore, WellboreName = log.NameWellbore, - ObjectGrowing = StringHelpers.ToBooleanSafe(log.ObjectGrowing), + ObjectGrowing = StringHelpers.ToBoolean(log.ObjectGrowing), ServiceCompany = log.ServiceCompany, RunNumber = log.RunNumber, StartIndex = log.GetStartIndexAsString(), @@ -86,7 +86,7 @@ public async Task GetLog(string wellUid, string wellboreUid, string l WellboreUid = witsmlLog.UidWellbore, WellboreName = witsmlLog.NameWellbore, IndexCurve = witsmlLog.IndexCurve.Value, - ObjectGrowing = StringHelpers.ToBooleanSafe(witsmlLog.ObjectGrowing), + ObjectGrowing = StringHelpers.ToBoolean(witsmlLog.ObjectGrowing), ServiceCompany = witsmlLog.ServiceCompany, RunNumber = witsmlLog.RunNumber, CommonData = new() diff --git a/Src/WitsmlExplorer.Api/Services/ObjectService.cs b/Src/WitsmlExplorer.Api/Services/ObjectService.cs index 19e258a51..f8882f2af 100644 --- a/Src/WitsmlExplorer.Api/Services/ObjectService.cs +++ b/Src/WitsmlExplorer.Api/Services/ObjectService.cs @@ -76,7 +76,7 @@ public async Task> GetObjectsWithParamByType(Ent if (!objectPropertyValue.IsNullOrEmpty()) { // send a request to see if the server is capable of searching by the property. - IWitsmlObjectList capabilityQuery = (IWitsmlObjectList)EntityTypeHelper.ToObjectOnWellbore(objectType).AsSingletonWitsmlList(); + IWitsmlObjectList capabilityQuery = (IWitsmlObjectList)EntityTypeHelper.ToObjectOnWellbore(objectType).AsItemInWitsmlList(); IWitsmlObjectList capabilityResult = await _witsmlClient.GetFromStoreNullableAsync(capabilityQuery, new OptionsIn(RequestObjectSelectionCapability: true)); WitsmlObjectOnWellbore capabilities = capabilityResult?.Objects?.FirstOrDefault(); diff --git a/Src/WitsmlExplorer.Api/Services/RigService.cs b/Src/WitsmlExplorer.Api/Services/RigService.cs index fed112c88..10baee3e9 100644 --- a/Src/WitsmlExplorer.Api/Services/RigService.cs +++ b/Src/WitsmlExplorer.Api/Services/RigService.cs @@ -48,7 +48,7 @@ private static Rig WitsmlRigToRig(WitsmlRig witsmlRig) DTimEndOp = witsmlRig.DTimEndOp, EmailAddress = witsmlRig.EmailAddress, FaxNumber = witsmlRig.FaxNumber, - IsOffshore = witsmlRig.IsOffshore == null ? null : StringHelpers.ToBooleanSafe(witsmlRig.IsOffshore), + IsOffshore = witsmlRig.IsOffshore == null ? null : StringHelpers.ToBoolean(witsmlRig.IsOffshore), Owner = witsmlRig.Owner, Manufacturer = witsmlRig.Manufacturer, Name = witsmlRig.Name, diff --git a/Src/WitsmlExplorer.Api/Services/StringHelpers.cs b/Src/WitsmlExplorer.Api/Services/StringHelpers.cs index bc9b9c4e8..e6730a8b2 100644 --- a/Src/WitsmlExplorer.Api/Services/StringHelpers.cs +++ b/Src/WitsmlExplorer.Api/Services/StringHelpers.cs @@ -6,13 +6,13 @@ namespace WitsmlExplorer.Api.Services public static class StringHelpers { /// - /// Converts "1", "0" and string representation of logical value to boolean - /// All other strings converted to false + /// Converts "1", "0", NULL and string representation of logical value (true/false) to boolean + /// All other strings throws exception /// /// string value to convert /// boolean value for given input string /// - public static bool ToBooleanSafe(string input) + public static bool ToBoolean(string input) { if (string.IsNullOrEmpty(input) || input == "0") { @@ -24,35 +24,12 @@ public static bool ToBooleanSafe(string input) return true; } - bool isBoolean = bool.TryParse(input, out bool value); - - return isBoolean ? value : throw new ArgumentException($"Input is not compatible to be parsed to a bool value: {input}"); - } - - public static bool ToBoolean(string input) - { - return ToBooleanSafe(input); - } - - public static bool? ToNullableBoolean(string input) - { - if (string.IsNullOrEmpty(input)) + if (!bool.TryParse(input, out bool value)) { - return null; + throw new ArgumentException($"Input is not compatible to be parsed to a bool value: {input}"); } - if (input == "1") - { - return true; - } - if (input == "0") - { - return false; - } - - bool isBoolean = bool.TryParse(input, out bool value); - - return isBoolean ? value : throw new ArgumentException($"Input is not compatible to be parsed to a bool value: {input}"); + return value; } /// @@ -62,13 +39,9 @@ public static bool ToBoolean(string input) /// bool? value to convert /// string value for given input boolean, or null if input is null /// - public static string OptionalBooleanToString(bool? input) + public static string NullableBooleanToString(bool? input) { - if (input == null) - { - return null; - } - return (bool)input ? "true" : "false"; + return input?.ToString().ToLowerInvariant(); } public static DateTime? ToDateTime(string input) @@ -86,7 +59,7 @@ public static string OptionalBooleanToString(bool? input) public static string ToUniversalDateTimeString(string input) { DateTime? dateTime = ToDateTime(input); - return dateTime.HasValue ? dateTime.Value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") : null; + return dateTime?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); } public static decimal ToDecimal(string input) diff --git a/Src/WitsmlExplorer.Api/Services/WbGeometryService.cs b/Src/WitsmlExplorer.Api/Services/WbGeometryService.cs index d55f49010..ac80b9f42 100644 --- a/Src/WitsmlExplorer.Api/Services/WbGeometryService.cs +++ b/Src/WitsmlExplorer.Api/Services/WbGeometryService.cs @@ -81,7 +81,7 @@ public async Task> GetWbGeometrySections(string wellUid, OdSection = LengthMeasure.FromWitsml(section.OdSection), WtPerLen = LengthMeasure.FromWitsml(section.WtPerLen), Grade = section.Grade, - CurveConductor = StringHelpers.ToNullableBoolean(section.CurveConductor), + CurveConductor = StringHelpers.ToBoolean(section.CurveConductor), DiaDrift = LengthMeasure.FromWitsml(section.DiaDrift), FactFric = string.IsNullOrEmpty(section.FactFric) ? null : StringHelpers.ToDouble(section.FactFric) }).ToList(); diff --git a/Src/WitsmlExplorer.Api/Services/WellboreService.cs b/Src/WitsmlExplorer.Api/Services/WellboreService.cs index 9d4546502..51e677bdc 100644 --- a/Src/WitsmlExplorer.Api/Services/WellboreService.cs +++ b/Src/WitsmlExplorer.Api/Services/WellboreService.cs @@ -40,7 +40,7 @@ public async Task GetWellbore(string wellUid, string wellboreUid) SuffixAPI = witsmlWellbore.SuffixAPI, NumGovt = witsmlWellbore.NumGovt, WellStatus = witsmlWellbore.StatusWellbore, - IsActive = StringHelpers.ToBooleanSafe(witsmlWellbore.IsActive), + IsActive = StringHelpers.ToBoolean(witsmlWellbore.IsActive), WellborePurpose = witsmlWellbore.PurposeWellbore, WellboreParentUid = witsmlWellbore.ParentWellbore?.UidRef, WellboreParentName = witsmlWellbore.ParentWellbore?.Value, @@ -79,7 +79,7 @@ public async Task> GetWellbores(string wellUid = "") WellName = witsmlWellbore.NameWell, WellStatus = witsmlWellbore.StatusWellbore, WellType = witsmlWellbore.TypeWellbore, - IsActive = StringHelpers.ToBooleanSafe(witsmlWellbore.IsActive), + IsActive = StringHelpers.ToBoolean(witsmlWellbore.IsActive), DateTimeLastChange = witsmlWellbore.CommonData.DTimLastChange, DateTimeCreation = witsmlWellbore.CommonData.DTimCreation }) diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyComponentsWorker.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyComponentsWorker.cs index 5a72aec73..08d3d6b13 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyComponentsWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyComponentsWorker.cs @@ -79,7 +79,7 @@ public CopyComponentsWorker(ILogger logger, IWitsmlClientProv } WitsmlObjectOnWellbore updateTargetQuery = ObjectQueries.CopyComponents(source.Objects?.FirstOrDefault(), _componentType, job.Target, toCopyUids); - QueryResult copyResult = await targetClient.UpdateInStoreAsync(updateTargetQuery.AsSingletonWitsmlList()); + QueryResult copyResult = await targetClient.UpdateInStoreAsync(updateTargetQuery.AsItemInWitsmlList()); if (!copyResult.IsSuccessful) { return LogErrorAndReturnResult(copyResult.Reason); diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogWorker.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogWorker.cs index ff163a7e0..4b960c25e 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogWorker.cs @@ -38,7 +38,7 @@ public CopyLogWorker(ILogger logger, IWitsmlClientProvider witsm { (WitsmlLog[] sourceLogs, WitsmlWellbore targetWellbore) = await FetchSourceLogsAndTargetWellbore(job); IEnumerable copyLogsQuery = ObjectQueries.CopyObjectsQuery(sourceLogs, targetWellbore); - List> copyLogTasks = copyLogsQuery.Select(logToCopy => GetTargetWitsmlClientOrThrow().AddToStoreAsync(logToCopy.AsSingletonWitsmlList())).ToList(); + List> copyLogTasks = copyLogsQuery.Select(logToCopy => GetTargetWitsmlClientOrThrow().AddToStoreAsync(logToCopy.AsItemInWitsmlList())).ToList(); Task copyLogTasksResult = Task.WhenAll(copyLogTasks); IEnumerable results = await copyLogTasksResult; diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs index efcc45f8b..53e097916 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyUtils.cs @@ -37,7 +37,7 @@ public CopyUtils(ILogger logger) { try { - QueryResult result = await witsmlClient.AddToStoreAsync(query.AsSingletonWitsmlList()); + QueryResult result = await witsmlClient.AddToStoreAsync(query.AsItemInWitsmlList()); if (result.IsSuccessful) { _logger.LogInformation( diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs index a97aad85e..464284d12 100644 --- a/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs @@ -69,8 +69,8 @@ private static WitsmlLogs CreateLogQuery(CreateLogJob job, WitsmlWellbore target Mnemonic = indexType.ToString(), Unit = unit, TypeLogData = indexType == IndexType.Depth ? WitsmlLogCurveInfo.LogDataTypeDouble : WitsmlLogCurveInfo.LogDataTypeDatetime - }.AsSingletonList() - }.AsSingletonList() + }.AsItemInList() + }.AsItemInList() }; } diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateWbGeometryWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateWbGeometryWorker.cs index cf433172b..6540c7f59 100644 --- a/Src/WitsmlExplorer.Api/Workers/Create/CreateWbGeometryWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Create/CreateWbGeometryWorker.cs @@ -87,7 +87,7 @@ private static WitsmlWbGeometrys SetupWbGeometryToCreate(WbGeometry wbGeometry) SourceName = wbGeometry.CommonData.SourceName, Comments = wbGeometry.CommonData.Comments, }, - }.AsSingletonList() + }.AsItemInList() }; } diff --git a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteComponentsWorker.cs b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteComponentsWorker.cs index 6ba010340..1f8376f47 100644 --- a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteComponentsWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteComponentsWorker.cs @@ -39,7 +39,7 @@ public DeleteComponentsWorker(ILogger logger, IWitsmlClient WitsmlObjectOnWellbore query = ObjectQueries.IdsToObjects(wellUid, wellboreUid, new string[] { parentUid }, parentType).First(); ObjectQueries.SetComponents(query, componentType, componentUids); - QueryResult result = await GetTargetWitsmlClientOrThrow().DeleteFromStoreAsync(query.AsSingletonWitsmlList()); + QueryResult result = await GetTargetWitsmlClientOrThrow().DeleteFromStoreAsync(query.AsItemInWitsmlList()); if (result.IsSuccessful) { Logger.LogInformation("Deleted {ComponentType} for {ObjectType}. {Description}", componentsName, parentType, objectsDescription); diff --git a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs index 228512759..d9734bf05 100644 --- a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs @@ -49,7 +49,7 @@ await Task.WhenAll(queries.Select(async (query) => { try { - QueryResult result = await witsmlClient.DeleteFromStoreAsync(query.AsSingletonWitsmlList()); + QueryResult result = await witsmlClient.DeleteFromStoreAsync(query.AsItemInWitsmlList()); if (result.IsSuccessful) { Logger.LogInformation("Deleted {ObjectType} successfully, UidWell: {WellUid}, UidWellbore: {WellboreUid}, ObjectUid: {Uid}.", diff --git a/Src/WitsmlExplorer.Api/Workers/ImportLogDataWorker.cs b/Src/WitsmlExplorer.Api/Workers/ImportLogDataWorker.cs index d5ce28357..5ffba644e 100644 --- a/Src/WitsmlExplorer.Api/Workers/ImportLogDataWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/ImportLogDataWorker.cs @@ -140,7 +140,7 @@ private static WitsmlLogs CreateAddMnemonicsQuery(ImportLogDataJob job, WitsmlLo Uid = job.Mnemonics.ElementAt(i), TypeLogData = WitsmlLogCurveInfo.LogDataTypeDouble }).ToList(), - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Src/WitsmlExplorer.Api/Workers/MissingDataWorker.cs b/Src/WitsmlExplorer.Api/Workers/MissingDataWorker.cs index 2bfb5ea35..b60188481 100644 --- a/Src/WitsmlExplorer.Api/Workers/MissingDataWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/MissingDataWorker.cs @@ -94,7 +94,7 @@ private async Task> CheckWell(MissingDataChec { WellName = wellboreReferences.First().WellName, WellUid = wellboreReferences.First().WellUid - }.AsSingletonList(); + }.AsItemInList(); } var query = new WitsmlWells diff --git a/Src/WitsmlExplorer.Api/Workers/Modify/ModifyLogObjectWorker.cs b/Src/WitsmlExplorer.Api/Workers/Modify/ModifyLogObjectWorker.cs index 7db9bd6d5..a9fd0b4fa 100644 --- a/Src/WitsmlExplorer.Api/Workers/Modify/ModifyLogObjectWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Modify/ModifyLogObjectWorker.cs @@ -79,7 +79,7 @@ private static WitsmlLogs CreateRequest(string wellUid, string wellboreUid, stri Name = logObject.Name, RunNumber = logObject.RunNumber, ServiceCompany = logObject.ServiceCompany - }.AsSingletonList() + }.AsItemInList() }; } diff --git a/Src/WitsmlExplorer.Api/Workers/Modify/ModifyTubularWorker.cs b/Src/WitsmlExplorer.Api/Workers/Modify/ModifyTubularWorker.cs index 34af04b86..6106f0672 100644 --- a/Src/WitsmlExplorer.Api/Workers/Modify/ModifyTubularWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Modify/ModifyTubularWorker.cs @@ -77,7 +77,7 @@ private static WitsmlTubulars CreateRequest(string wellUid, string wellboreUid, Uid = tubularUid, Name = tubular.Name, TypeTubularAssy = tubular.TypeTubularAssy - }.AsSingletonList() + }.AsItemInList() }; } diff --git a/Src/WitsmlExplorer.Api/Workers/SpliceLogsWorker.cs b/Src/WitsmlExplorer.Api/Workers/SpliceLogsWorker.cs index c6926c5cf..816a54ed8 100644 --- a/Src/WitsmlExplorer.Api/Workers/SpliceLogsWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/SpliceLogsWorker.cs @@ -138,7 +138,7 @@ private async Task CreateNewLog(WitsmlLog newLogHeader) { WitsmlLogs query = new() { - Logs = newLogHeader.AsSingletonList() + Logs = newLogHeader.AsItemInList() }; QueryResult result = await GetTargetWitsmlClientOrThrow().AddToStoreAsync(query); if (!result.IsSuccessful) throw new ArgumentException($"Could not create log. {result.Reason}"); diff --git a/Src/WitsmlExplorer.Api/Workers/WorkerTools.cs b/Src/WitsmlExplorer.Api/Workers/WorkerTools.cs index 3d9e21c68..53e3cbcb4 100644 --- a/Src/WitsmlExplorer.Api/Workers/WorkerTools.cs +++ b/Src/WitsmlExplorer.Api/Workers/WorkerTools.cs @@ -47,7 +47,7 @@ public static async Task GetLog(IWitsmlClient client, IObjectReferenc public static async Task GetLogDataForCurve(IWitsmlClient witsmlClient, WitsmlLog log, string mnemonic, ILogger logger) { - await using LogDataReader logDataReader = new(witsmlClient, log, mnemonic.AsSingletonList(), logger); + await using LogDataReader logDataReader = new(witsmlClient, log, mnemonic.AsItemInList(), logger); List data = new(); WitsmlLogData logData = await logDataReader.GetNextBatch(); var mnemonicList = logData?.MnemonicList; diff --git a/Src/WitsmlExplorer.Console/ListCommands/ListBhaRunsCommand.cs b/Src/WitsmlExplorer.Console/ListCommands/ListBhaRunsCommand.cs index 4a09beb0f..43e344f53 100644 --- a/Src/WitsmlExplorer.Console/ListCommands/ListBhaRunsCommand.cs +++ b/Src/WitsmlExplorer.Console/ListCommands/ListBhaRunsCommand.cs @@ -93,7 +93,7 @@ private async Task> GetBhaRuns(string wellUid, string { DTimLastChange = "" } - }.AsSingletonList() + }.AsItemInList() }; WitsmlBhaRuns result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested)); diff --git a/Src/WitsmlExplorer.Console/ListCommands/ListLogsCommand.cs b/Src/WitsmlExplorer.Console/ListCommands/ListLogsCommand.cs index 9dce4d20f..229e01260 100644 --- a/Src/WitsmlExplorer.Console/ListCommands/ListLogsCommand.cs +++ b/Src/WitsmlExplorer.Console/ListCommands/ListLogsCommand.cs @@ -106,7 +106,7 @@ private async Task> GetLogs(string wellUid, string wellboreUid) { UidWell = wellUid, UidWellbore = wellboreUid - }.AsSingletonList() + }.AsItemInList() }; WitsmlLogs result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.HeaderOnly)); diff --git a/Src/WitsmlExplorer.Console/ListCommands/ListRisksCommand.cs b/Src/WitsmlExplorer.Console/ListCommands/ListRisksCommand.cs index 99a39f671..ff361a1ec 100644 --- a/Src/WitsmlExplorer.Console/ListCommands/ListRisksCommand.cs +++ b/Src/WitsmlExplorer.Console/ListCommands/ListRisksCommand.cs @@ -93,7 +93,7 @@ private async Task> GetRisks(string wellUid, string wellboreUi SourceName = source, DTimLastChange = lastChanged } - }.AsSingletonList() + }.AsItemInList() }; try diff --git a/Src/WitsmlExplorer.Console/ListCommands/ListTubularsCommand.cs b/Src/WitsmlExplorer.Console/ListCommands/ListTubularsCommand.cs index ce5068acf..ca0521ac5 100644 --- a/Src/WitsmlExplorer.Console/ListCommands/ListTubularsCommand.cs +++ b/Src/WitsmlExplorer.Console/ListCommands/ListTubularsCommand.cs @@ -91,7 +91,7 @@ private async Task> GetTubulars(string wellUid, strin { DTimLastChange = "" } - }.AsSingletonList() + }.AsItemInList() }; WitsmlTubulars result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested)); diff --git a/Src/WitsmlExplorer.Console/ListCommands/ListWellboresCommand.cs b/Src/WitsmlExplorer.Console/ListCommands/ListWellboresCommand.cs index 4b4f876c7..22ce74f09 100644 --- a/Src/WitsmlExplorer.Console/ListCommands/ListWellboresCommand.cs +++ b/Src/WitsmlExplorer.Console/ListCommands/ListWellboresCommand.cs @@ -72,7 +72,7 @@ private async IAsyncEnumerable GetActiveWellbores() NameWell = "", NameWellbore = "", ObjectGrowing = "true" - }.AsSingletonList() + }.AsItemInList() }; WitsmlLogs result = await _witsmlClient.GetFromStoreAsync(liveLogsQuery, new OptionsIn(ReturnElements.Requested)); var groupedResults = result.Logs diff --git a/Src/WitsmlExplorer.Console/ShowCommands/ShowTubularCommand.cs b/Src/WitsmlExplorer.Console/ShowCommands/ShowTubularCommand.cs index 578d3c734..bc200e65e 100644 --- a/Src/WitsmlExplorer.Console/ShowCommands/ShowTubularCommand.cs +++ b/Src/WitsmlExplorer.Console/ShowCommands/ShowTubularCommand.cs @@ -56,7 +56,7 @@ private async Task GetTubular(string wellUid, string wellboreUid, Uid = tubularUid, UidWell = wellUid, UidWellbore = wellboreUid - }.AsSingletonList() + }.AsItemInList() }; WitsmlTubulars result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All)); diff --git a/Tests/WitsmlExplorer.Api.Tests/Services/MessageObjectServiceTests.cs b/Tests/WitsmlExplorer.Api.Tests/Services/MessageObjectServiceTests.cs index edfaae43d..67e53893b 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Services/MessageObjectServiceTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Services/MessageObjectServiceTests.cs @@ -65,7 +65,7 @@ public async Task GetMessageObjects_AllRequiredElements_AllAccountedFor() DTimLastChange = dTimLastChange, Comments = comments } - }.AsSingletonList() + }.AsItemInList() }; _witsmlClient.Setup(client => client.GetFromStoreAsync(It.IsAny(), It.Is((ops) => ops.ReturnElements == ReturnElements.Requested))) diff --git a/Tests/WitsmlExplorer.Api.Tests/Services/ObjectServiceTests.cs b/Tests/WitsmlExplorer.Api.Tests/Services/ObjectServiceTests.cs index 93c95093b..71f1792ce 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Services/ObjectServiceTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Services/ObjectServiceTests.cs @@ -190,7 +190,7 @@ public async Task GetObjectsByType_ReturnsObjects() o.UidWellbore = ""; o.Uid = ""; o.Name = ""; - IWitsmlObjectList objectList = (IWitsmlObjectList)o.AsSingletonWitsmlList(); + IWitsmlObjectList objectList = (IWitsmlObjectList)o.AsItemInWitsmlList(); _witsmlClient.Setup(client => client.GetFromStoreNullableAsync( @@ -226,7 +226,7 @@ public async Task GetObjectsWithParamByType_ReturnsObjects() Name = "", ServiceCompany = "myCompany" }; - IWitsmlObjectList objectList = log.AsSingletonWitsmlList(); + IWitsmlObjectList objectList = log.AsItemInWitsmlList(); _witsmlClient.SetupSequence(client => client.GetFromStoreNullableAsync( @@ -250,7 +250,7 @@ public async Task GetObjectsWithParamByType_NullResult_ReturnZero() Name = "", ServiceCompany = "myCompany" }; - IWitsmlObjectList objectList = log.AsSingletonWitsmlList(); + IWitsmlObjectList objectList = log.AsItemInWitsmlList(); _witsmlClient.SetupSequence(client => client.GetFromStoreNullableAsync( @@ -271,7 +271,7 @@ public async Task GetObjectsWithParamByType_Uncapable_ThrowsError() o.UidWellbore = ""; o.Uid = ""; o.Name = ""; - IWitsmlObjectList objectList = (IWitsmlObjectList)o.AsSingletonWitsmlList(); + IWitsmlObjectList objectList = (IWitsmlObjectList)o.AsItemInWitsmlList(); _witsmlClient.SetupSequence(client => client.GetFromStoreNullableAsync( diff --git a/Tests/WitsmlExplorer.Api.Tests/Services/StringHelpersTests.cs b/Tests/WitsmlExplorer.Api.Tests/Services/StringHelpersTests.cs index 777ecb558..1f3f87fdc 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Services/StringHelpersTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Services/StringHelpersTests.cs @@ -69,19 +69,19 @@ public void Parse_DateTime() [Fact] public void OptionalBooleanToString_False_CorrectResult() { - Assert.Equal("false", StringHelpers.OptionalBooleanToString(false)); + Assert.Equal("false", StringHelpers.NullableBooleanToString(false)); } [Fact] public void OptionalBooleanToString_True_CorrectResult() { - Assert.Equal("true", StringHelpers.OptionalBooleanToString(true)); + Assert.Equal("true", StringHelpers.NullableBooleanToString(true)); } [Fact] public void OptionalBooleanToString_Null_CorrectResult() { - Assert.Null(StringHelpers.OptionalBooleanToString(null)); + Assert.Null(StringHelpers.NullableBooleanToString(null)); } } } diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/AnalyzeGapWorkerTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/AnalyzeGapWorkerTests.cs index 0fc4f0925..435225eeb 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/AnalyzeGapWorkerTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/AnalyzeGapWorkerTests.cs @@ -244,7 +244,7 @@ private static WitsmlLogs GetTestWitsmlLogs(WitsmlLogData logData, bool isDepthL MaxDateTimeIndex = maxDateTimeIndex }, }, - }.AsSingletonList() + }.AsItemInList() }; } diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/CheckLogHeaderWorkerTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/CheckLogHeaderWorkerTests.cs index d6727efc9..018dd79dc 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/CheckLogHeaderWorkerTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/CheckLogHeaderWorkerTests.cs @@ -302,7 +302,7 @@ public static WitsmlLogs GetTestLogHeader(bool shouldBeConsistent) MaxDateTimeIndex = "2023-04-19T00:00:01Z" }, }, - }.AsSingletonList() + }.AsItemInList() }; } @@ -325,7 +325,7 @@ public static WitsmlLogs GetTestLogDataLatestValues(string indexType) new WitsmlData(){Data = isDepthLog ? DepthDataRow3 : TimeDataRow3} } } - }.AsSingletonList() + }.AsItemInList() }; } @@ -347,7 +347,7 @@ public static WitsmlLogs GetTestLogDataFirstRow(string indexType) new WitsmlData(){Data = isDepthLog ? DepthDataRow1 : TimeDataRow1}, } } - }.AsSingletonList() + }.AsItemInList() }; } @@ -372,7 +372,7 @@ public static WitsmlLogs GetTestLogDataFirstRowForMnemonic(string indexType) }, } } - }.AsSingletonList() + }.AsItemInList() }; } } diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/CompareLogDataWorker.Tests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/CompareLogDataWorker.Tests.cs index 161fa32d2..efcc2c410 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/CompareLogDataWorker.Tests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/CompareLogDataWorker.Tests.cs @@ -702,7 +702,7 @@ private void SetupClient(Mock witsmlClient, WitsmlLogs logHeaders UnitList = logs.Logs.First().LogData.UnitList, Data = dataForCurve.Select(d => new WitsmlData() { Data = d }).ToList() } - }.AsSingletonList() + }.AsItemInList() }; return Task.FromResult(newLogData); } @@ -755,7 +755,7 @@ private WitsmlLogs CreateSampleLogData(string wellUid, string wellboreUid, strin UnitList = unitList, Data = GetLogData(log.Data), } - }.AsSingletonList() + }.AsItemInList() }; } @@ -782,7 +782,7 @@ private WitsmlLogs CreateSampleLogHeaders(string wellUid, string wellboreUid, st EndDateTimeIndex = isDepthLog ? null : log.EndIndex, IndexCurve = new WitsmlIndexCurve() { Value = "IndexCurve" }, LogCurveInfo = GetLogCurveInfo(log.IndexType, log.StartIndex, log.EndIndex, log.LogCurveInfo) - }.AsSingletonList(), + }.AsItemInList(), }; } diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyComponentsWorkerTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyComponentsWorkerTests.cs index 59bb9471f..1fca6c614 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyComponentsWorkerTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyComponentsWorkerTests.cs @@ -165,7 +165,7 @@ private static IWitsmlObjectList GetWitsmlObject(string[] componentUids, string source.UidWellbore = WellboreUid; source.Uid = uid; ObjectQueries.SetComponents(source, componentType, componentUids); - return (IWitsmlObjectList)source.AsSingletonWitsmlList(); + return (IWitsmlObjectList)source.AsItemInWitsmlList(); } } } diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyWellWorkerTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyWellWorkerTests.cs index 4063c6b35..f9e75d0f8 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyWellWorkerTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyWellWorkerTests.cs @@ -47,7 +47,7 @@ public async Task Execute_TargetWellExists_NoCopy() WitsmlWell existing = CreateWell(wellUid); - WitsmlWells existingWells = new() { Wells = existing.AsSingletonList() }; + WitsmlWells existingWells = new() { Wells = existing.AsItemInList() }; WitsmlWells query = WellQueries.GetWitsmlWellByUid(wellUid); string queryText = XmlHelper.Serialize(WellQueries.GetWitsmlWellByUid(wellUid)); @@ -71,7 +71,7 @@ public async Task Execute_TargetWellNotFound_Copied() WitsmlWell well = CreateWell(wellUid); - WitsmlWells sourceWells = new() { Wells = well.AsSingletonList() }; + WitsmlWells sourceWells = new() { Wells = well.AsItemInList() }; WitsmlWells query = WellQueries.GetWitsmlWellByUid(wellUid); @@ -100,7 +100,7 @@ public async Task Execute_AddFailed_ErrorInResult() WitsmlWell well = CreateWell(wellUid); - WitsmlWells sourceWells = new() { Wells = well.AsSingletonList() }; + WitsmlWells sourceWells = new() { Wells = well.AsItemInList() }; WitsmlWells query = WellQueries.GetWitsmlWellByUid(wellUid); diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyWellboreWorkerTests.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyWellboreWorkerTests.cs index b6982916b..ccb83974d 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/CopyWellboreWorkerTests.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/CopyWellboreWorkerTests.cs @@ -49,7 +49,7 @@ public async Task Execute_TargetWellboreExists_NoCopy() WitsmlWellbore existing = CreateWellbore(wellboreUid); - WitsmlWellbores existingWells = new() { Wellbores = existing.AsSingletonList() }; + WitsmlWellbores existingWells = new() { Wellbores = existing.AsItemInList() }; WitsmlWellbores query = WellboreQueries.GetWitsmlWellboreByUid(WellUid, wellboreUid); string queryText = XmlHelper.Serialize(WellQueries.GetWitsmlWellByUid(wellboreUid)); @@ -73,7 +73,7 @@ public async Task Execute_TargetWellboreNotFound_Copied() WitsmlWellbore wellbore = CreateWellbore(wellboreUid); - WitsmlWellbores sourceWells = new() { Wellbores = wellbore.AsSingletonList() }; + WitsmlWellbores sourceWells = new() { Wellbores = wellbore.AsItemInList() }; WitsmlWellbores query = WellboreQueries.GetWitsmlWellboreByUid(WellUid, wellboreUid); @@ -102,7 +102,7 @@ public async Task Execute_AddFailed_ErrorInResult() WitsmlWellbore wellbore = CreateWellbore(wellboreUid); - WitsmlWellbores sourceWells = new() { Wellbores = wellbore.AsSingletonList() }; + WitsmlWellbores sourceWells = new() { Wellbores = wellbore.AsItemInList() }; WitsmlWellbores query = WellboreQueries.GetWitsmlWellboreByUid(WellUid, wellboreUid); diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/CountLogDataRowWorkerTest.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/CountLogDataRowWorkerTest.cs index 7d6bcbdf9..6d80e3b5f 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/CountLogDataRowWorkerTest.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/CountLogDataRowWorkerTest.cs @@ -182,7 +182,7 @@ private static WitsmlLogs GetTestWitsmlLogs(WitsmlLogData logData, bool isDepthL LogData = logData, IndexType = isDepthLog ? WitsmlLog.WITSML_INDEX_TYPE_MD : WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME, LogCurveInfo = logCurveInfo, - }.AsSingletonList() + }.AsItemInList() }; } diff --git a/Tests/WitsmlExplorer.Api.Tests/Workers/LogUtils.cs b/Tests/WitsmlExplorer.Api.Tests/Workers/LogUtils.cs index a1cf653e5..4ed119f47 100644 --- a/Tests/WitsmlExplorer.Api.Tests/Workers/LogUtils.cs +++ b/Tests/WitsmlExplorer.Api.Tests/Workers/LogUtils.cs @@ -312,7 +312,7 @@ public static WitsmlLogs GetSourceLogData(string startIndexValue, string endInde UnitList = "datetime,m,m", Data = data } - }.AsSingletonList() + }.AsItemInList() }; } @@ -349,7 +349,7 @@ public static WitsmlLogs GetSourceLogData(double startIndexValue, double endInde UnitList = "m,m,m", Data = data } - }.AsSingletonList() + }.AsItemInList() }; } @@ -387,7 +387,7 @@ public static WitsmlLogs GetSourceLogDataDecreasing(double startIndexValue, doub UnitList = "m,m,m", Data = data } - }.AsSingletonList() + }.AsItemInList() }; } @@ -410,7 +410,7 @@ public static void SetupGetDepthIndexed(Mock witsmlClient, Func witsmlClient, WitsmlLogs logHeaders UnitList = logs.Logs.First().LogData.UnitList, Data = dataForCurve.Select(d => new WitsmlData() { Data = d }).ToList() } - }.AsSingletonList() + }.AsItemInList() }; return Task.FromResult(newLogData); } diff --git a/Tests/WitsmlExplorer.IntegrationTests/Witsml/AddToStore/LogObjectTests.cs b/Tests/WitsmlExplorer.IntegrationTests/Witsml/AddToStore/LogObjectTests.cs index b9159d045..d8c98a7a3 100644 --- a/Tests/WitsmlExplorer.IntegrationTests/Witsml/AddToStore/LogObjectTests.cs +++ b/Tests/WitsmlExplorer.IntegrationTests/Witsml/AddToStore/LogObjectTests.cs @@ -89,8 +89,8 @@ private static WitsmlLogs CreateLogQuery(string wellUid, string wellName, string MaxIndex = null, MinDateTimeIndex = null, MaxDateTimeIndex = null - }.AsSingletonList() - }.AsSingletonList() + }.AsItemInList() + }.AsItemInList() }; } diff --git a/Tests/WitsmlExplorer.IntegrationTests/Witsml/AddToStore/TrajectoryTests.cs b/Tests/WitsmlExplorer.IntegrationTests/Witsml/AddToStore/TrajectoryTests.cs index 162e9c2ca..96893c309 100644 --- a/Tests/WitsmlExplorer.IntegrationTests/Witsml/AddToStore/TrajectoryTests.cs +++ b/Tests/WitsmlExplorer.IntegrationTests/Witsml/AddToStore/TrajectoryTests.cs @@ -102,7 +102,7 @@ private static WitsmlTrajectories CreateTrajectoryQuery(string wellUid, string w AziRef = aziRef, TrajectoryStations = tStations, CommonData = commonData - }.AsSingletonList() + }.AsItemInList() }; return trajectories; diff --git a/Tests/WitsmlExplorer.IntegrationTests/Witsml/GetFromStore/FluidsReportTests.cs b/Tests/WitsmlExplorer.IntegrationTests/Witsml/GetFromStore/FluidsReportTests.cs index 30f3140df..11234c0fb 100644 --- a/Tests/WitsmlExplorer.IntegrationTests/Witsml/GetFromStore/FluidsReportTests.cs +++ b/Tests/WitsmlExplorer.IntegrationTests/Witsml/GetFromStore/FluidsReportTests.cs @@ -36,7 +36,7 @@ public async Task GetFluidsReportSerializesCorrectly() UidWell = wellUid, UidWellbore = wellboreUid, Uid = fluidsReportUid - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); WitsmlFluidsReports serverFluidsReport = await _client.GetFromStoreAsync(queryExisting, new OptionsIn(ReturnElements.All)); string responseXml = XmlHelper.Serialize(serverFluidsReport); string serverFluidsReportXml = TestUtils.CleanResponse(responseXml); diff --git a/Tests/WitsmlExplorer.IntegrationTests/Witsml/GetFromStore/LogObjectTests.cs b/Tests/WitsmlExplorer.IntegrationTests/Witsml/GetFromStore/LogObjectTests.cs index b6950c61d..6ec99ff89 100644 --- a/Tests/WitsmlExplorer.IntegrationTests/Witsml/GetFromStore/LogObjectTests.cs +++ b/Tests/WitsmlExplorer.IntegrationTests/Witsml/GetFromStore/LogObjectTests.cs @@ -97,7 +97,7 @@ public async Task GetDepthDataObjectFromStoreAsync_ParseInvariant() UidWell = UidWellDepth, UidWellbore = UidWellboreDepth - }.AsSingletonList() + }.AsItemInList() }; var result = await _client.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All)); diff --git a/witsml-explorer.sln.DotSettings b/witsml-explorer.sln.DotSettings index 70e9f9f1f..4b0863395 100644 --- a/witsml-explorer.sln.DotSettings +++ b/witsml-explorer.sln.DotSettings @@ -3,6 +3,7 @@ True True True + True True True True \ No newline at end of file From f0008b3dfe240bda6904adfdb593e171eddb84fa Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Tue, 28 Nov 2023 09:53:43 +0100 Subject: [PATCH 2/4] duplicities fixes --- .../Jobs/DeleteEmptyMnemonicsJob.cs | 10 +-- .../WitsmlUnsupportedCapabilityException.cs | 3 +- .../Services/BhaRunService.cs | 7 +- Src/WitsmlExplorer.Api/Swagger/SwaggerGen.cs | 4 +- .../Workers/Copy/CopyLogDataWorker.cs | 8 +- .../Delete/DeleteEmptyMnemonicsWorker.cs | 77 +++++++------------ .../Workers/Delete/DeleteObjectsWorker.cs | 5 +- 7 files changed, 44 insertions(+), 70 deletions(-) diff --git a/Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs b/Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs index e7d04f8db..f53b86057 100644 --- a/Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs +++ b/Src/WitsmlExplorer.Api/Jobs/DeleteEmptyMnemonicsJob.cs @@ -14,17 +14,11 @@ namespace WitsmlExplorer.Api.Jobs public record DeleteEmptyMnemonicsJob : Job { - public ICollection Wells { get; init; } - public ICollection Wellbores { get; init; } + public ICollection Wells { get; init; } = new List(); + public ICollection Wellbores { get; init; } = new List(); public double NullDepthValue { get; init; } public DateTime NullTimeValue { get; init; } - public DeleteEmptyMnemonicsJob() - { - Wells = new List(); - Wellbores = new List(); - } - public override string Description() { return "DeleteEmptyMnemonicsJob" diff --git a/Src/WitsmlExplorer.Api/Middleware/WitsmlUnsupportedCapabilityException.cs b/Src/WitsmlExplorer.Api/Middleware/WitsmlUnsupportedCapabilityException.cs index 85f53995a..92fc71ad9 100644 --- a/Src/WitsmlExplorer.Api/Middleware/WitsmlUnsupportedCapabilityException.cs +++ b/Src/WitsmlExplorer.Api/Middleware/WitsmlUnsupportedCapabilityException.cs @@ -1,4 +1,5 @@ using System; +using System.Net; namespace WitsmlExplorer.Api.Middleware { @@ -8,7 +9,7 @@ public class WitsmlUnsupportedCapabilityException : Exception public WitsmlUnsupportedCapabilityException(string message) : base(message) { - StatusCode = 500; + StatusCode = (int)HttpStatusCode.InternalServerError; } } } diff --git a/Src/WitsmlExplorer.Api/Services/BhaRunService.cs b/Src/WitsmlExplorer.Api/Services/BhaRunService.cs index 85660ac8a..1a32f7e75 100644 --- a/Src/WitsmlExplorer.Api/Services/BhaRunService.cs +++ b/Src/WitsmlExplorer.Api/Services/BhaRunService.cs @@ -25,19 +25,18 @@ public async Task GetBhaRun(string wellUid, string wellboreUid, string b { WitsmlBhaRuns query = BhaRunQueries.GetWitsmlBhaRun(wellUid, wellboreUid, bhaRunUid); WitsmlBhaRuns result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All)); - return result.BhaRuns.Any() ? WitsmlToBhaRun(result.BhaRuns.First()) : null; + return WitsmlToBhaRun(result.BhaRuns.FirstOrDefault()); } public async Task> GetBhaRuns(string wellUid, string wellboreUid) { WitsmlBhaRuns witsmlBhaRun = BhaRunQueries.GetWitsmlBhaRun(wellUid, wellboreUid); WitsmlBhaRuns result = await _witsmlClient.GetFromStoreAsync(witsmlBhaRun, new OptionsIn(ReturnElements.Requested)); - return result.BhaRuns.Select(WitsmlToBhaRun - ).OrderBy(bhaRun => bhaRun.Name).ToList(); + return result.BhaRuns.Select(WitsmlToBhaRun).OrderBy(bhaRun => bhaRun.Name).ToList(); } private static BhaRun WitsmlToBhaRun(WitsmlBhaRun bhaRun) { - return new BhaRun + return bhaRun == null ? null : new BhaRun { Uid = bhaRun.Uid, Name = bhaRun.Name, diff --git a/Src/WitsmlExplorer.Api/Swagger/SwaggerGen.cs b/Src/WitsmlExplorer.Api/Swagger/SwaggerGen.cs index 0df8f727f..1e4aec14e 100644 --- a/Src/WitsmlExplorer.Api/Swagger/SwaggerGen.cs +++ b/Src/WitsmlExplorer.Api/Swagger/SwaggerGen.cs @@ -17,7 +17,7 @@ public static void ConfigureSwaggerGen(this IServiceCollection services, IConfig options.OperationFilter(); if (configuration["OAuth2Enabled"] == "True") { - OpenApiSecurityScheme oAuth2scheme = new() + OpenApiSecurityScheme oAuth2Scheme = new() { In = ParameterLocation.Header, Name = "Authorization", @@ -31,7 +31,7 @@ public static void ConfigureSwaggerGen(this IServiceCollection services, IConfig }, Type = SecuritySchemeType.OAuth2 }; - options.AddSecurityDefinition("OAuth2", oAuth2scheme); + options.AddSecurityDefinition("OAuth2", oAuth2Scheme); options.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme diff --git a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs index edc52c014..c99f42395 100644 --- a/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Copy/CopyLogDataWorker.cs @@ -382,10 +382,10 @@ private static void VerifyIndexCurveIsIncludedInMnemonics(WitsmlLog log, IList 0) + switch (mnemonicsCheckedCount) { - switch (mnemonicsCheckedCount) - { - case 0: - summary = summary.AppendFormat("No mnemonics were"); - break; - case 1: - summary = summary.AppendFormat("One mnemonic was"); - break; - default: - summary = summary.AppendFormat("{0} mnemonics were", mnemonicsCheckedCount.ToString()); - break; - } + case 0: + summary = summary.AppendFormat("No mnemonics were"); + break; + case 1: + summary = summary.AppendFormat("One mnemonic was"); + break; + default: + summary = summary.AppendFormat("{0} mnemonics were", mnemonicsCheckedCount.ToString()); + break; + } - summary = summary.AppendFormat(" checked for NullDepthValue: \"{0}\" and NullTimeValue: \"{1}\". ", - job.NullDepthValue.ToString(), - job.NullTimeValue.ToISODateTimeString()); + summary = summary.AppendFormat(" checked for NullDepthValue: \"{0}\" and NullTimeValue: \"{1}\". ", + job.NullDepthValue.ToString(), + job.NullTimeValue.ToISODateTimeString()); - switch (mnemonicsDeletedCount) - { - case 0: - summary = summary.AppendFormat("No empty mnemonics were found and deleted."); - break; - case 1: - summary = summary.AppendFormat("One empty mnemonic was found and deleted."); - break; - default: - summary = summary.AppendFormat("{0} empty mnemonics were found and deleted.", mnemonicsDeletedCount.ToString()); - break; - } - } - else + switch (mnemonicsDeletedCount) { - summary = summary.AppendFormat("No mnemonics were checked for NullDepthValue: \"{0}\" and NullTimeValue: \"{1}\".", - job.NullDepthValue.ToString(), - job.NullTimeValue.ToISODateTimeString()); + case 0: + summary = summary.AppendFormat("No empty mnemonics were found and deleted."); + break; + case 1: + summary = summary.AppendFormat("One empty mnemonic was found and deleted."); + break; + default: + summary = summary.AppendFormat("{0} empty mnemonics were found and deleted.", mnemonicsDeletedCount.ToString()); + break; } return summary.ToString(); @@ -178,23 +169,11 @@ private ICollection FindNullMnemonics(double nullDepthValue, DateT { if (logToCheck.IndexType == WitsmlLog.WITSML_INDEX_TYPE_MD) { - foreach (var logCurve in logCurves) - { - if (logCurve.MinDepthIndex == nullDepthValueString && logCurve.MaxDepthIndex == nullDepthValueString) - { - nullMnemonics.Add(logCurve); - } - } + nullMnemonics.AddRange(logCurves.Where(logCurve => logCurve.MinDepthIndex == nullDepthValueString && logCurve.MaxDepthIndex == nullDepthValueString)); } else if (logToCheck.IndexType == WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME) { - foreach (var logCurve in logCurves) - { - if (logCurve.MinDateTimeIndex == nullTimeValueString && logCurve.MaxDateTimeIndex == nullTimeValueString) - { - nullMnemonics.Add(logCurve); - } - } + nullMnemonics.AddRange(logCurves.Where(logCurve => logCurve.MinDateTimeIndex == nullTimeValueString && logCurve.MaxDateTimeIndex == nullTimeValueString)); } } @@ -211,7 +190,7 @@ private async Task> ExtractLogs(WellboreReference wellbor return (await _logObjectService.GetLogs(wellboreRef.WellUid, wellboreRef.WellboreUid)).ToList(); } - private async Task> ExtractWellboreRefs(IEnumerable wellRefs) + private async Task> ExtractWellboreRefs(ICollection wellRefs) { var wellboreRefs = new List(); diff --git a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs index 64d3e2e89..c496945ed 100644 --- a/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs +++ b/Src/WitsmlExplorer.Api/Workers/Delete/DeleteObjectsWorker.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -35,7 +36,7 @@ public DeleteObjectsWorker(ILogger logger, IWitsmlClientProvid return await DeleteObjectsOnWellbore(queries, refreshAction); } - private async Task<(WorkerResult, RefreshAction)> DeleteObjectsOnWellbore(IEnumerable queries, RefreshAction refreshAction) + private async Task<(WorkerResult, RefreshAction)> DeleteObjectsOnWellbore(ICollection queries, RefreshAction refreshAction) { IWitsmlClient witsmlClient = GetTargetWitsmlClientOrThrow(); var witsmlObjectOnWellbore = queries.FirstOrDefault(); @@ -44,7 +45,7 @@ public DeleteObjectsWorker(ILogger logger, IWitsmlClientProvid string uidWellbore = witsmlObjectOnWellbore?.UidWellbore; bool error = false; - List successUids = new(); + ConcurrentBag successUids = new(); string errorReason = null; await Task.WhenAll(queries.Select(async (query) => From 26a35a5f04d9fdb97f375cd295f7d8794c3bcd50 Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Mon, 4 Dec 2023 08:47:07 +0100 Subject: [PATCH 3/4] Missing DB config message added --- Src/WitsmlExplorer.Api/Configuration/Dependencies.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Src/WitsmlExplorer.Api/Configuration/Dependencies.cs b/Src/WitsmlExplorer.Api/Configuration/Dependencies.cs index 0abb9f34a..d04ace1f0 100644 --- a/Src/WitsmlExplorer.Api/Configuration/Dependencies.cs +++ b/Src/WitsmlExplorer.Api/Configuration/Dependencies.cs @@ -19,6 +19,8 @@ namespace WitsmlExplorer.Api.Configuration { public static class Dependencies { + private const string MissingDatabaseConfigMessage = "Did not detect any configuration for database"; + public static void ConfigureDependencies(this IServiceCollection services, IConfiguration configuration) { services.RegisterAssemblyPublicNonGenericClasses(Assembly.GetAssembly(typeof(Program))) @@ -55,8 +57,8 @@ private static void AddRepository(IServiceCollection services, ICo } else { - Log.Error("Did not detect any configuration for database"); - return; + Log.Error(MissingDatabaseConfigMessage); + throw new ApplicationException(MissingDatabaseConfigMessage); } } From 7b901d700fa1592750c1d6bd69cfcb4497c343b2 Mon Sep 17 00:00:00 2001 From: Petr Licman Date: Mon, 4 Dec 2023 08:55:31 +0100 Subject: [PATCH 4/4] After merge fixes --- Src/WitsmlExplorer.Api/Models/BhaRun.cs | 2 +- Src/WitsmlExplorer.Api/Models/FluidsReport.cs | 2 +- Src/WitsmlExplorer.Api/Models/FormationMarker.cs | 2 +- Src/WitsmlExplorer.Api/Models/LogObject.cs | 4 ++-- Src/WitsmlExplorer.Api/Models/MessageObject.cs | 2 +- Src/WitsmlExplorer.Api/Models/MudLog.cs | 4 ++-- Src/WitsmlExplorer.Api/Models/Rig.cs | 4 ++-- Src/WitsmlExplorer.Api/Models/Risk.cs | 4 ++-- Src/WitsmlExplorer.Api/Models/Trajectory.cs | 2 +- Src/WitsmlExplorer.Api/Models/Tubular.cs | 2 +- Src/WitsmlExplorer.Api/Models/WbGeometry.cs | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Src/WitsmlExplorer.Api/Models/BhaRun.cs b/Src/WitsmlExplorer.Api/Models/BhaRun.cs index 87b7fef4e..ff7fe9be1 100644 --- a/Src/WitsmlExplorer.Api/Models/BhaRun.cs +++ b/Src/WitsmlExplorer.Api/Models/BhaRun.cs @@ -47,7 +47,7 @@ public override WitsmlBhaRuns ToWitsml() DTimStartDrilling = StringHelpers.ToUniversalDateTimeString(DTimStartDrilling), DTimStopDrilling = StringHelpers.ToUniversalDateTimeString(DTimStopDrilling), CommonData = CommonData?.ToWitsml() - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/FluidsReport.cs b/Src/WitsmlExplorer.Api/Models/FluidsReport.cs index 2df38e9c0..96161e3be 100644 --- a/Src/WitsmlExplorer.Api/Models/FluidsReport.cs +++ b/Src/WitsmlExplorer.Api/Models/FluidsReport.cs @@ -34,7 +34,7 @@ public override WitsmlFluidsReports ToWitsml() NumReport = NumReport, Fluids = Fluids?.Select(fluid => fluid?.ToWitsml())?.ToList(), CommonData = CommonData?.ToWitsml() - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/FormationMarker.cs b/Src/WitsmlExplorer.Api/Models/FormationMarker.cs index 0b6abf2bd..2001001f6 100644 --- a/Src/WitsmlExplorer.Api/Models/FormationMarker.cs +++ b/Src/WitsmlExplorer.Api/Models/FormationMarker.cs @@ -48,7 +48,7 @@ public override WitsmlFormationMarkers ToWitsml() Chronostratigraphic = Chronostratigraphic?.ToWitsmlChronostratigraphyStruct(), Description = Description, CommonData = CommonData?.ToWitsml() - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/LogObject.cs b/Src/WitsmlExplorer.Api/Models/LogObject.cs index 263b8efa1..346fa14f6 100644 --- a/Src/WitsmlExplorer.Api/Models/LogObject.cs +++ b/Src/WitsmlExplorer.Api/Models/LogObject.cs @@ -33,7 +33,7 @@ public override WitsmlLogs ToWitsml() UidWellbore = WellboreUid, NameWellbore = WellboreName, IndexType = IndexType, - ObjectGrowing = StringHelpers.OptionalBooleanToString(ObjectGrowing), + ObjectGrowing = StringHelpers.NullableBooleanToString(ObjectGrowing), ServiceCompany = ServiceCompany, RunNumber = RunNumber, IndexCurve = IndexCurve != null ? new WitsmlIndexCurve { Value = IndexCurve } : null, @@ -52,7 +52,7 @@ public override WitsmlLogs ToWitsml() log.EndDateTimeIndex = EndIndex; } - return log.AsSingletonWitsmlList(); + return log.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/MessageObject.cs b/Src/WitsmlExplorer.Api/Models/MessageObject.cs index 2a135f3d8..9a3eec9cc 100644 --- a/Src/WitsmlExplorer.Api/Models/MessageObject.cs +++ b/Src/WitsmlExplorer.Api/Models/MessageObject.cs @@ -25,7 +25,7 @@ public override WitsmlMessages ToWitsml() MessageText = MessageText, TypeMessage = TypeMessage, CommonData = CommonData?.ToWitsml() - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/MudLog.cs b/Src/WitsmlExplorer.Api/Models/MudLog.cs index 74f94de91..184eaa4df 100644 --- a/Src/WitsmlExplorer.Api/Models/MudLog.cs +++ b/Src/WitsmlExplorer.Api/Models/MudLog.cs @@ -29,14 +29,14 @@ public override WitsmlMudLogs ToWitsml() NameWellbore = WellboreName, Uid = Uid, Name = Name, - ObjectGrowing = StringHelpers.OptionalBooleanToString(ObjectGrowing), + ObjectGrowing = StringHelpers.NullableBooleanToString(ObjectGrowing), MudLogCompany = MudLogCompany, MudLogEngineers = MudLogEngineers, StartMd = StartMd?.ToWitsml(), EndMd = EndMd?.ToWitsml(), GeologyInterval = GeologyInterval?.Select(geologyInterval => geologyInterval?.ToWitsml())?.ToList(), CommonData = CommonData?.ToWitsml() - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/Rig.cs b/Src/WitsmlExplorer.Api/Models/Rig.cs index 893c71a85..532d43122 100644 --- a/Src/WitsmlExplorer.Api/Models/Rig.cs +++ b/Src/WitsmlExplorer.Api/Models/Rig.cs @@ -45,7 +45,7 @@ public override WitsmlRigs ToWitsml() DTimEndOp = StringHelpers.ToUniversalDateTimeString(DTimEndOp), EmailAddress = EmailAddress, FaxNumber = FaxNumber, - IsOffshore = StringHelpers.OptionalBooleanToString(IsOffshore), + IsOffshore = StringHelpers.NullableBooleanToString(IsOffshore), Manufacturer = Manufacturer, NameContact = NameContact, Owner = Owner, @@ -56,7 +56,7 @@ public override WitsmlRigs ToWitsml() TypeRig = TypeRig, YearEntService = YearEntService, CommonData = CommonData?.ToWitsml() - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/Risk.cs b/Src/WitsmlExplorer.Api/Models/Risk.cs index 2078bb619..5cdda6c39 100644 --- a/Src/WitsmlExplorer.Api/Models/Risk.cs +++ b/Src/WitsmlExplorer.Api/Models/Risk.cs @@ -45,7 +45,7 @@ public override WitsmlRisks ToWitsml() Category = Category, SubCategory = SubCategory, ExtendCategory = ExtendCategory, - AffectedPersonnel = (AffectedPersonnel != null && AffectedPersonnel.Length != 0) ? AffectedPersonnel?.Split(", ") : null, + AffectedPersonnel = !string.IsNullOrEmpty(AffectedPersonnel) ? AffectedPersonnel.Split(", ") : null, DTimStart = StringHelpers.ToUniversalDateTimeString(DTimStart), DTimEnd = StringHelpers.ToUniversalDateTimeString(DTimStart), MdHoleStart = MdHoleStart?.ToWitsml(), @@ -63,7 +63,7 @@ public override WitsmlRisks ToWitsml() Contingency = Contingency, Mitigation = Mitigation, CommonData = CommonData?.ToWitsml() - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/Trajectory.cs b/Src/WitsmlExplorer.Api/Models/Trajectory.cs index 04d059913..aa5335543 100644 --- a/Src/WitsmlExplorer.Api/Models/Trajectory.cs +++ b/Src/WitsmlExplorer.Api/Models/Trajectory.cs @@ -40,7 +40,7 @@ public override WitsmlTrajectories ToWitsml() TrajectoryStations = TrajectoryStations?.Select((trajectoryStation) => trajectoryStation?.ToWitsml()).ToList(), ServiceCompany = ServiceCompany, CommonData = CommonData?.ToWitsml(), - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/Tubular.cs b/Src/WitsmlExplorer.Api/Models/Tubular.cs index 6c1f2cfbe..4e66f5db8 100644 --- a/Src/WitsmlExplorer.Api/Models/Tubular.cs +++ b/Src/WitsmlExplorer.Api/Models/Tubular.cs @@ -19,7 +19,7 @@ public override WitsmlTubulars ToWitsml() Name = Name, TypeTubularAssy = TypeTubularAssy, CommonData = CommonData?.ToWitsml(), - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } } diff --git a/Src/WitsmlExplorer.Api/Models/WbGeometry.cs b/Src/WitsmlExplorer.Api/Models/WbGeometry.cs index 509a8b69f..b9856d921 100644 --- a/Src/WitsmlExplorer.Api/Models/WbGeometry.cs +++ b/Src/WitsmlExplorer.Api/Models/WbGeometry.cs @@ -29,7 +29,7 @@ public override WitsmlWbGeometrys ToWitsml() GapAir = GapAir?.ToWitsml(), DepthWaterMean = DepthWaterMean?.ToWitsml(), CommonData = CommonData?.ToWitsml(), - }.AsSingletonWitsmlList(); + }.AsItemInWitsmlList(); } } }