diff --git a/Src/WitsmlExplorer.Api/Jobs/CreateLogJob.cs b/Src/WitsmlExplorer.Api/Jobs/CreateLogJob.cs
deleted file mode 100644
index b7a48f98a..000000000
--- a/Src/WitsmlExplorer.Api/Jobs/CreateLogJob.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using WitsmlExplorer.Api.Models;
-
-namespace WitsmlExplorer.Api.Jobs
-{
- public record CreateLogJob : Job
- {
- public LogObject LogObject { get; init; }
-
- public override string Description()
- {
- return $"Create Log - WellUid: {LogObject.WellUid}; WellboreUid: {LogObject.WellboreUid}; LogUid: {LogObject.Uid};";
- }
-
- public override string GetObjectName()
- {
- return LogObject.Name;
- }
-
- public override string GetWellboreName()
- {
- return LogObject.WellboreName;
- }
-
- public override string GetWellName()
- {
- return LogObject.WellName;
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Jobs/CreateMudLogJob.cs b/Src/WitsmlExplorer.Api/Jobs/CreateMudLogJob.cs
deleted file mode 100644
index 283bf0ede..000000000
--- a/Src/WitsmlExplorer.Api/Jobs/CreateMudLogJob.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using WitsmlExplorer.Api.Models;
-
-namespace WitsmlExplorer.Api.Jobs
-{
- public record CreateMudLogJob : Job
- {
- public MudLog MudLog { get; init; }
-
- public override string Description()
- {
- return $"Create MudLog - WellUid: {MudLog.WellUid}; WellboreUid: {MudLog.WellboreUid}; MudLogUid: {MudLog.Uid};";
- }
-
- public override string GetObjectName()
- {
- return MudLog.Name;
- }
-
- public override string GetWellboreName()
- {
- return MudLog.WellboreName;
- }
-
- public override string GetWellName()
- {
- return MudLog.WellName;
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Jobs/CreateObjectOnWellboreJob.cs b/Src/WitsmlExplorer.Api/Jobs/CreateObjectOnWellboreJob.cs
new file mode 100644
index 000000000..e01984d29
--- /dev/null
+++ b/Src/WitsmlExplorer.Api/Jobs/CreateObjectOnWellboreJob.cs
@@ -0,0 +1,33 @@
+using System.Text.Json.Serialization;
+
+using WitsmlExplorer.Api.Models;
+
+namespace WitsmlExplorer.Api.Jobs
+{
+ public record CreateObjectOnWellboreJob : Job
+ {
+ [JsonConverter(typeof(ObjectOnWellboreConverter))]
+ public ObjectOnWellbore Object { get; init; }
+ public EntityType ObjectType { get; init; }
+
+ public override string Description()
+ {
+ return $"To Create - Type: {ObjectType}, Uid: {Object.Uid}.";
+ }
+
+ public override string GetObjectName()
+ {
+ return Object.Name;
+ }
+
+ public override string GetWellboreName()
+ {
+ return Object.WellboreName;
+ }
+
+ public override string GetWellName()
+ {
+ return Object.WellName;
+ }
+ }
+}
diff --git a/Src/WitsmlExplorer.Api/Jobs/CreateRigJob.cs b/Src/WitsmlExplorer.Api/Jobs/CreateRigJob.cs
deleted file mode 100644
index 08dd4b103..000000000
--- a/Src/WitsmlExplorer.Api/Jobs/CreateRigJob.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using WitsmlExplorer.Api.Models;
-
-namespace WitsmlExplorer.Api.Jobs;
-
-///
-/// Job for create rig with jobInfo.
-///
-public record CreateRigJob : Job
-{
- ///
- /// Rig API model.
- ///
- public Rig Rig { get; init; }
-
- ///
- /// Getting description of created rig.
- ///
- /// String of job info which provide WellUid, WellboreUid and RigUid.
- public override string Description()
- {
- return $"Create Rig - Uid: {Rig.Uid}; Name: {Rig.Name}; WellUid: {Rig.WellUid}; WellboreUid: {Rig.WellboreUid};";
- }
-
- ///
- /// Getting name of rig.
- ///
- /// String of rig name.
- public override string GetObjectName()
- {
- return Rig.Name;
- }
-
- ///
- /// Getting name of wellbore.
- ///
- /// String of wellbore name.
- public override string GetWellboreName()
- {
- return Rig.WellboreName;
- }
-
- ///
- /// Getting name of well.
- ///
- /// String of well name.
- public override string GetWellName()
- {
- return Rig.WellName;
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Jobs/CreateRiskJob.cs b/Src/WitsmlExplorer.Api/Jobs/CreateRiskJob.cs
deleted file mode 100644
index 767d98ab3..000000000
--- a/Src/WitsmlExplorer.Api/Jobs/CreateRiskJob.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using WitsmlExplorer.Api.Models;
-
-namespace WitsmlExplorer.Api.Jobs
-{
- public record CreateRiskJob : Job
- {
- public Risk Risk { get; init; }
-
- public override string Description()
- {
- return $"Create Risk - WellUid: {Risk.WellUid}; WellboreUid: {Risk.WellboreUid}; RiskUid: {Risk.Uid};";
- }
-
- public override string GetObjectName()
- {
- return Risk.Name;
- }
-
- public override string GetWellboreName()
- {
- return Risk.WellboreName;
- }
-
- public override string GetWellName()
- {
- return Risk.WellName;
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Jobs/CreateTrajectoryJob.cs b/Src/WitsmlExplorer.Api/Jobs/CreateTrajectoryJob.cs
deleted file mode 100644
index 2ba40901a..000000000
--- a/Src/WitsmlExplorer.Api/Jobs/CreateTrajectoryJob.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using WitsmlExplorer.Api.Models;
-
-namespace WitsmlExplorer.Api.Jobs;
-
-///
-/// Job for create trajectory with jobInfo.
-///
-public record CreateTrajectoryJob : Job
-{
- ///
- /// Trajectory API model.
- ///
- public Trajectory Trajectory { get; init; }
-
- ///
- /// Getting description of created trajectory.
- ///
- /// String of job info which provide Trajectory Uid and Name, WellUid, WellboreUid.
- public override string Description()
- {
- return $"Create Trajectory - Uid: {Trajectory.Uid}; Name: {Trajectory.Name}; WellUid: {Trajectory.WellUid}; WellboreUid: {Trajectory.WellboreUid};";
- }
-
- ///
- /// Getting name of trajectory.
- ///
- /// String of trajectory name.
- public override string GetObjectName()
- {
- return Trajectory.Name;
- }
-
- ///
- /// Getting name of wellbore.
- ///
- /// String of wellbore name.
- public override string GetWellboreName()
- {
- return Trajectory.WellboreName;
- }
-
- ///
- /// Getting name of well.
- ///
- /// String of well name.
- public override string GetWellName()
- {
- return Trajectory.WellName;
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Jobs/CreateWbGeometryJob.cs b/Src/WitsmlExplorer.Api/Jobs/CreateWbGeometryJob.cs
deleted file mode 100644
index 7e8d12a35..000000000
--- a/Src/WitsmlExplorer.Api/Jobs/CreateWbGeometryJob.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using WitsmlExplorer.Api.Models;
-
-namespace WitsmlExplorer.Api.Jobs
-{
- public record CreateWbGeometryJob : Job
- {
- public WbGeometry WbGeometry { get; init; }
-
- public override string Description()
- {
- return $"Create WbGeometry - WellUid: {WbGeometry.WellUid}; WellboreUid: {WbGeometry.WellboreUid}; WbGeometryUid: {WbGeometry.Uid};";
- }
-
- public override string GetObjectName()
- {
- return WbGeometry.Name;
- }
-
- public override string GetWellboreName()
- {
- return WbGeometry.WellboreName;
- }
-
- public override string GetWellName()
- {
- return WbGeometry.WellName;
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Models/JobType.cs b/Src/WitsmlExplorer.Api/Models/JobType.cs
index 5abeabf67..43f956661 100644
--- a/Src/WitsmlExplorer.Api/Models/JobType.cs
+++ b/Src/WitsmlExplorer.Api/Models/JobType.cs
@@ -25,14 +25,9 @@ public enum JobType
ModifyWbGeometrySection,
ModifyWell,
ModifyWellbore,
- CreateLogObject,
CreateWell,
CreateWellbore,
- CreateRisk,
- CreateMudLog,
- CreateRig,
- CreateTrajectory,
- CreateWbGeometry,
+ CreateObjectOnWellbore,
BatchModifyWell,
ImportLogData,
ReplaceComponents,
diff --git a/Src/WitsmlExplorer.Api/Models/LogObject.cs b/Src/WitsmlExplorer.Api/Models/LogObject.cs
index 346fa14f6..5523f91dc 100644
--- a/Src/WitsmlExplorer.Api/Models/LogObject.cs
+++ b/Src/WitsmlExplorer.Api/Models/LogObject.cs
@@ -9,7 +9,7 @@ public class LogObject : ObjectOnWellbore
public string IndexType { get; set; }
public string StartIndex { get; set; }
public string EndIndex { get; set; }
- public bool ObjectGrowing { get; init; }
+ public bool? ObjectGrowing { get; init; }
public string ServiceCompany { get; init; }
public string RunNumber { get; init; }
public string IndexCurve { get; init; }
diff --git a/Src/WitsmlExplorer.Api/Models/Measure/DayMeasure.cs b/Src/WitsmlExplorer.Api/Models/Measure/DayMeasure.cs
index 82304a39e..d6cb6e693 100644
--- a/Src/WitsmlExplorer.Api/Models/Measure/DayMeasure.cs
+++ b/Src/WitsmlExplorer.Api/Models/Measure/DayMeasure.cs
@@ -1,7 +1,20 @@
+using System.Globalization;
+
+using Witsml.Data.Measures;
+
namespace WitsmlExplorer.Api.Models.Measure
{
public class DayMeasure : Measure
{
public int Value { get; init; }
+
+ public WitsmlDayMeasure ToWitsml()
+ {
+ return new()
+ {
+ Uom = Uom,
+ Value = Value.ToString(CultureInfo.InvariantCulture)
+ };
+ }
}
}
diff --git a/Src/WitsmlExplorer.Api/Models/Wellbore.cs b/Src/WitsmlExplorer.Api/Models/Wellbore.cs
index 335996463..3ea6aa2b2 100644
--- a/Src/WitsmlExplorer.Api/Models/Wellbore.cs
+++ b/Src/WitsmlExplorer.Api/Models/Wellbore.cs
@@ -11,8 +11,8 @@ public class Wellbore
public string WellborePurpose { get; set; }
public string WellboreParentUid { get; set; }
public string WellboreParentName { get; set; }
- public string WellStatus { get; set; }
- public string WellType { get; set; }
+ public string WellboreStatus { get; set; }
+ public string WellboreType { get; set; }
public bool? IsActive { get; set; }
public string DateTimeCreation { get; set; }
public string DateTimeLastChange { get; set; }
diff --git a/Src/WitsmlExplorer.Api/Query/FluidsReportQueries.cs b/Src/WitsmlExplorer.Api/Query/FluidsReportQueries.cs
index a7089b51c..193103186 100644
--- a/Src/WitsmlExplorer.Api/Query/FluidsReportQueries.cs
+++ b/Src/WitsmlExplorer.Api/Query/FluidsReportQueries.cs
@@ -25,7 +25,9 @@ public static WitsmlFluidsReports QueryByWellbore(string wellUid, string wellbor
DTimLastChange = "",
ItemState = "",
Comments = "",
- DefaultDatum = ""
+ DefaultDatum = "",
+ SourceName = "",
+ ServiceCategory = ""
}
}.AsItemInWitsmlList();
}
diff --git a/Src/WitsmlExplorer.Api/Query/RigQueries.cs b/Src/WitsmlExplorer.Api/Query/RigQueries.cs
index d7bba277d..0ad6182bd 100644
--- a/Src/WitsmlExplorer.Api/Query/RigQueries.cs
+++ b/Src/WitsmlExplorer.Api/Query/RigQueries.cs
@@ -23,6 +23,8 @@ public static WitsmlRigs GetWitsmlRig(string wellUid, string wellboreUid, string
IsOffshore = "",
Manufacturer = "",
Name = "",
+ NameWell = "",
+ NameWellbore = "",
NameContact = "",
Owner = "",
Registration = "",
diff --git a/Src/WitsmlExplorer.Api/Query/RiskQueries.cs b/Src/WitsmlExplorer.Api/Query/RiskQueries.cs
index 6dd37a4ef..805b3f922 100644
--- a/Src/WitsmlExplorer.Api/Query/RiskQueries.cs
+++ b/Src/WitsmlExplorer.Api/Query/RiskQueries.cs
@@ -16,6 +16,8 @@ public static WitsmlRisks GetWitsmlRiskByWellbore(string wellUid, string wellbor
UidWell = wellUid,
UidWellbore = wellboreUid,
Name = "",
+ NameWell = "",
+ NameWellbore = "",
Type = "",
Category = "",
SubCategory = "",
diff --git a/Src/WitsmlExplorer.Api/Query/WellboreQueries.cs b/Src/WitsmlExplorer.Api/Query/WellboreQueries.cs
index 96009a1c9..c76fe5ce1 100644
--- a/Src/WitsmlExplorer.Api/Query/WellboreQueries.cs
+++ b/Src/WitsmlExplorer.Api/Query/WellboreQueries.cs
@@ -143,35 +143,44 @@ public static WitsmlWellbores UpdateWitsmlWellbore(Wellbore wellbore)
public static WitsmlWellbores CreateWitsmlWellbore(Wellbore wellbore)
{
- return !string.IsNullOrEmpty(wellbore.WellboreParentUid)
- ? new WitsmlWellbores
+ WitsmlParentWellbore parentWellbore = (wellbore.WellboreParentUid == null && wellbore.WellboreParentName == null) ? null
+ : new WitsmlParentWellbore
{
- Wellbores = new WitsmlWellbore
- {
- Uid = wellbore.Uid,
- Name = wellbore.Name,
- UidWell = wellbore.WellUid,
- NameWell = wellbore.WellName,
- ParentWellbore = new WitsmlParentWellbore
- {
- UidRef = wellbore.WellboreParentUid,
- Value = wellbore.WellboreParentName
- },
- PurposeWellbore = wellbore.WellborePurpose
-
- }.AsItemInList()
- }
- : new WitsmlWellbores
+ UidRef = wellbore.WellboreParentUid,
+ Value = wellbore.WellboreParentName
+ };
+ return new WitsmlWellbores
+ {
+ Wellbores = new WitsmlWellbore
{
- Wellbores = new WitsmlWellbore
+ Uid = wellbore.Uid,
+ Name = wellbore.Name,
+ UidWell = wellbore.WellUid,
+ NameWell = wellbore.WellName,
+ ParentWellbore = parentWellbore,
+ StatusWellbore = wellbore.WellboreStatus,
+ TypeWellbore = wellbore.WellboreType,
+ Number = wellbore.Number,
+ SuffixAPI = wellbore.SuffixAPI,
+ NumGovt = wellbore.NumGovt,
+ Shape = wellbore.Shape,
+ DTimKickoff = wellbore.DTimeKickoff,
+ PurposeWellbore = wellbore.WellborePurpose,
+ Md = wellbore.Md?.ToWitsml(),
+ Tvd = wellbore.Tvd?.ToWitsml(),
+ MdKickoff = wellbore.MdKickoff?.ToWitsml(),
+ TvdKickoff = wellbore.TvdKickoff?.ToWitsml(),
+ MdPlanned = wellbore.MdPlanned?.ToWitsml(),
+ TvdPlanned = wellbore.TvdPlanned?.ToWitsml(),
+ MdSubSeaPlanned = wellbore.MdSubSeaPlanned?.ToWitsml(),
+ TvdSubSeaPlanned = wellbore.TvdSubSeaPlanned?.ToWitsml(),
+ DayTarget = wellbore.DayTarget?.ToWitsml(),
+ CommonData = wellbore.Comments == null ? null : new WitsmlCommonData
{
- Uid = wellbore.Uid,
- Name = wellbore.Name,
- UidWell = wellbore.WellUid,
- NameWell = wellbore.WellName,
- PurposeWellbore = wellbore.WellborePurpose
- }.AsItemInList()
- };
+ Comments = wellbore.Comments
+ }
+ }.AsItemInList()
+ };
}
public static WitsmlWellbores DeleteWitsmlWellbore(string wellUid, string wellboreUid)
diff --git a/Src/WitsmlExplorer.Api/Services/BhaRunService.cs b/Src/WitsmlExplorer.Api/Services/BhaRunService.cs
index 096dd4abc..9edd88db8 100644
--- a/Src/WitsmlExplorer.Api/Services/BhaRunService.cs
+++ b/Src/WitsmlExplorer.Api/Services/BhaRunService.cs
@@ -45,10 +45,10 @@ private static BhaRun WitsmlToBhaRun(WitsmlBhaRun bhaRun)
WellboreName = bhaRun.NameWellbore,
WellboreUid = bhaRun.UidWellbore,
NumStringRun = bhaRun.NumStringRun,
- Tubular = new RefNameString
+ Tubular = (bhaRun.Tubular == null) ? null : new RefNameString
{
- UidRef = bhaRun.Tubular?.UidRef,
- Value = bhaRun.Tubular?.Value
+ UidRef = bhaRun.Tubular.UidRef,
+ Value = bhaRun.Tubular.Value
},
StatusBha = bhaRun.StatusBha ?? null,
NumBitRun = bhaRun.NumBitRun,
diff --git a/Src/WitsmlExplorer.Api/Services/FluidsReportService.cs b/Src/WitsmlExplorer.Api/Services/FluidsReportService.cs
index ce602b79f..e491fccfa 100644
--- a/Src/WitsmlExplorer.Api/Services/FluidsReportService.cs
+++ b/Src/WitsmlExplorer.Api/Services/FluidsReportService.cs
@@ -141,6 +141,8 @@ private static FluidsReport WitsmlToFluidsReport(WitsmlFluidsReport fluidsReport
ItemState = fluidsReport.CommonData.ItemState,
Comments = fluidsReport.CommonData.Comments,
DefaultDatum = fluidsReport.CommonData.DefaultDatum,
+ SourceName = fluidsReport.CommonData.SourceName,
+ ServiceCategory = fluidsReport.CommonData.ServiceCategory
}
};
}
diff --git a/Src/WitsmlExplorer.Api/Services/MudLogService.cs b/Src/WitsmlExplorer.Api/Services/MudLogService.cs
index 5987352f4..3ce66117e 100644
--- a/Src/WitsmlExplorer.Api/Services/MudLogService.cs
+++ b/Src/WitsmlExplorer.Api/Services/MudLogService.cs
@@ -74,8 +74,8 @@ private static List GetGeologyIntervals(List GetWellbore(string wellUid, string wellboreUid)
WitsmlWellbore witsmlWellbore = result.Wellbores.FirstOrDefault();
return witsmlWellbore == null
? null
- : new Wellbore
- {
- Uid = witsmlWellbore.Uid,
- Name = witsmlWellbore.Name,
- WellUid = witsmlWellbore.UidWell,
- WellName = witsmlWellbore.NameWell,
- Number = witsmlWellbore.Number,
- SuffixAPI = witsmlWellbore.SuffixAPI,
- NumGovt = witsmlWellbore.NumGovt,
- WellStatus = witsmlWellbore.StatusWellbore,
- IsActive = StringHelpers.ToBoolean(witsmlWellbore.IsActive),
- WellborePurpose = witsmlWellbore.PurposeWellbore,
- WellboreParentUid = witsmlWellbore.ParentWellbore?.UidRef,
- WellboreParentName = witsmlWellbore.ParentWellbore?.Value,
- WellType = witsmlWellbore.TypeWellbore,
- Shape = witsmlWellbore.Shape,
- DTimeKickoff = witsmlWellbore.DTimKickoff,
- Md = (witsmlWellbore.Md == null) ? null : new LengthMeasure { Uom = witsmlWellbore.Md.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.Md.Value) },
- Tvd = (witsmlWellbore.Tvd == null) ? null : new LengthMeasure { Uom = witsmlWellbore.Tvd.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.Tvd.Value) },
- MdKickoff = (witsmlWellbore.MdKickoff == null) ? null : new LengthMeasure { Uom = witsmlWellbore.MdKickoff.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.MdKickoff.Value) },
- TvdKickoff = (witsmlWellbore.TvdKickoff == null) ? null : new LengthMeasure { Uom = witsmlWellbore.TvdKickoff.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.TvdKickoff.Value) },
- MdPlanned = (witsmlWellbore.MdPlanned == null) ? null : new LengthMeasure { Uom = witsmlWellbore.MdPlanned.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.MdPlanned.Value) },
- TvdPlanned = (witsmlWellbore.TvdPlanned == null) ? null : new LengthMeasure { Uom = witsmlWellbore.TvdPlanned.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.TvdPlanned.Value) },
- MdSubSeaPlanned = (witsmlWellbore.MdSubSeaPlanned == null) ? null : new LengthMeasure { Uom = witsmlWellbore.MdSubSeaPlanned.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.MdSubSeaPlanned.Value) },
- TvdSubSeaPlanned = (witsmlWellbore.TvdSubSeaPlanned == null) ? null : new LengthMeasure { Uom = witsmlWellbore.TvdSubSeaPlanned.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.TvdSubSeaPlanned.Value) },
- DayTarget = (witsmlWellbore.DayTarget == null) ? null : new DayMeasure { Uom = witsmlWellbore.DayTarget.Uom, Value = int.Parse(witsmlWellbore.DayTarget.Value) },
- DateTimeCreation = witsmlWellbore.CommonData.DTimCreation,
- DateTimeLastChange = witsmlWellbore.CommonData.DTimLastChange,
- ItemState = witsmlWellbore.CommonData.ItemState,
- Comments = witsmlWellbore.CommonData.Comments
- };
+ : FromWitsml(witsmlWellbore);
}
public async Task> GetWellbores(string wellUid = "")
@@ -68,25 +38,48 @@ public async Task> GetWellbores(string wellUid = "")
return await MeasurementHelper.MeasureExecutionTimeAsync(async (timeMeasurer) =>
{
WitsmlWellbores query = WellboreQueries.GetWitsmlWellboreByWell(wellUid);
- WitsmlWellbores result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested));
+ WitsmlWellbores result = await _witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All));
List wellbores = result.Wellbores
- .Select(witsmlWellbore =>
- new Wellbore
- {
- Uid = witsmlWellbore.Uid,
- Name = witsmlWellbore.Name,
- WellUid = witsmlWellbore.UidWell,
- WellName = witsmlWellbore.NameWell,
- WellStatus = witsmlWellbore.StatusWellbore,
- WellType = witsmlWellbore.TypeWellbore,
- IsActive = StringHelpers.ToBoolean(witsmlWellbore.IsActive),
- DateTimeLastChange = witsmlWellbore.CommonData.DTimLastChange,
- DateTimeCreation = witsmlWellbore.CommonData.DTimCreation
- })
+ .Select(FromWitsml)
.OrderBy(wellbore => wellbore.Name).ToList();
timeMeasurer.LogMessage = executionTime => $"Fetched {wellbores.Count} wellbores in {executionTime} ms.";
return wellbores;
});
}
+
+ private Wellbore FromWitsml(WitsmlWellbore witsmlWellbore)
+ {
+ return new Wellbore
+ {
+ Uid = witsmlWellbore.Uid,
+ Name = witsmlWellbore.Name,
+ WellUid = witsmlWellbore.UidWell,
+ WellName = witsmlWellbore.NameWell,
+ Number = witsmlWellbore.Number,
+ SuffixAPI = witsmlWellbore.SuffixAPI,
+ NumGovt = witsmlWellbore.NumGovt,
+ WellboreStatus = witsmlWellbore.StatusWellbore,
+ IsActive = StringHelpers.ToBoolean(witsmlWellbore.IsActive),
+ WellborePurpose = witsmlWellbore.PurposeWellbore,
+ WellboreParentUid = witsmlWellbore.ParentWellbore?.UidRef,
+ WellboreParentName = witsmlWellbore.ParentWellbore?.Value,
+ WellboreType = witsmlWellbore.TypeWellbore,
+ Shape = witsmlWellbore.Shape,
+ DTimeKickoff = witsmlWellbore.DTimKickoff,
+ Md = (witsmlWellbore.Md == null) ? null : new LengthMeasure { Uom = witsmlWellbore.Md.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.Md.Value) },
+ Tvd = (witsmlWellbore.Tvd == null) ? null : new LengthMeasure { Uom = witsmlWellbore.Tvd.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.Tvd.Value) },
+ MdKickoff = (witsmlWellbore.MdKickoff == null) ? null : new LengthMeasure { Uom = witsmlWellbore.MdKickoff.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.MdKickoff.Value) },
+ TvdKickoff = (witsmlWellbore.TvdKickoff == null) ? null : new LengthMeasure { Uom = witsmlWellbore.TvdKickoff.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.TvdKickoff.Value) },
+ MdPlanned = (witsmlWellbore.MdPlanned == null) ? null : new LengthMeasure { Uom = witsmlWellbore.MdPlanned.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.MdPlanned.Value) },
+ TvdPlanned = (witsmlWellbore.TvdPlanned == null) ? null : new LengthMeasure { Uom = witsmlWellbore.TvdPlanned.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.TvdPlanned.Value) },
+ MdSubSeaPlanned = (witsmlWellbore.MdSubSeaPlanned == null) ? null : new LengthMeasure { Uom = witsmlWellbore.MdSubSeaPlanned.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.MdSubSeaPlanned.Value) },
+ TvdSubSeaPlanned = (witsmlWellbore.TvdSubSeaPlanned == null) ? null : new LengthMeasure { Uom = witsmlWellbore.TvdSubSeaPlanned.Uom, Value = StringHelpers.ToDecimal(witsmlWellbore.TvdSubSeaPlanned.Value) },
+ DayTarget = (witsmlWellbore.DayTarget == null) ? null : new DayMeasure { Uom = witsmlWellbore.DayTarget.Uom, Value = int.Parse(witsmlWellbore.DayTarget.Value) },
+ DateTimeCreation = witsmlWellbore.CommonData.DTimCreation,
+ DateTimeLastChange = witsmlWellbore.CommonData.DTimLastChange,
+ ItemState = witsmlWellbore.CommonData.ItemState,
+ Comments = witsmlWellbore.CommonData.Comments
+ };
+ }
}
}
diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs
deleted file mode 100644
index 7c2288fa0..000000000
--- a/Src/WitsmlExplorer.Api/Workers/Create/CreateLogWorker.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-
-using Microsoft.Extensions.Logging;
-
-using Witsml;
-using Witsml.Data;
-using Witsml.Data.Curves;
-using Witsml.Extensions;
-using Witsml.ServiceReference;
-
-using WitsmlExplorer.Api.Jobs;
-using WitsmlExplorer.Api.Models;
-using WitsmlExplorer.Api.Query;
-using WitsmlExplorer.Api.Services;
-
-namespace WitsmlExplorer.Api.Workers.Create
-{
- public class CreateLogWorker : BaseWorker, IWorker
- {
- public JobType JobType => JobType.CreateLogObject;
-
- public CreateLogWorker(ILogger logger, IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider, logger) { }
-
- public override async Task<(WorkerResult, RefreshAction)> Execute(CreateLogJob job, CancellationToken? cancellationToken = null)
- {
- WitsmlWellbore targetWellbore = await GetWellbore(GetTargetWitsmlClientOrThrow(), job.LogObject);
- WitsmlLogs copyLogQuery = CreateLogQuery(job, targetWellbore);
- QueryResult createLogResult = await GetTargetWitsmlClientOrThrow().AddToStoreAsync(copyLogQuery);
- if (!createLogResult.IsSuccessful)
- {
- string errorMessage = "Failed to create log.";
- Logger.LogError("{ErrorMessage}. {jobDescription}", errorMessage, job.Description());
- return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, errorMessage, createLogResult.Reason), null);
- }
-
- Logger.LogInformation("Log object created. {jobDescription}", job.Description());
- RefreshObjects refreshAction = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), job.LogObject.WellUid, job.LogObject.WellboreUid, EntityType.Log);
- WorkerResult workerResult = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), true, $"Log object {job.LogObject.Name} created for {targetWellbore.Name}");
-
- return (workerResult, refreshAction);
- }
-
- private static WitsmlLogs CreateLogQuery(CreateLogJob job, WitsmlWellbore targetWellbore)
- {
- IndexType indexType = job.LogObject.IndexCurve == IndexType.Depth.ToString() ? IndexType.Depth : IndexType.Time;
- string unit = indexType == IndexType.Depth ? DepthUnit.Meter.ToString() : Unit.TimeUnit.ToString();
- return new WitsmlLogs
- {
- Logs = new WitsmlLog
- {
- UidWell = targetWellbore.UidWell,
- NameWell = targetWellbore.NameWell,
- UidWellbore = targetWellbore.Uid,
- NameWellbore = targetWellbore.Name,
- Uid = job.LogObject.Uid,
- Name = job.LogObject.Name,
- RunNumber = job.LogObject.RunNumber,
- ServiceCompany = job.LogObject.ServiceCompany,
- IndexType = indexType == IndexType.Depth ? WitsmlLog.WITSML_INDEX_TYPE_MD : WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME,
- IndexCurve = new WitsmlIndexCurve()
- {
- Value = indexType.ToString()
- },
- LogCurveInfo = new WitsmlLogCurveInfo
- {
- Uid = Guid.NewGuid().ToString(),
- Mnemonic = indexType.ToString(),
- Unit = unit,
- TypeLogData = indexType == IndexType.Depth ? WitsmlLogCurveInfo.LogDataTypeDouble : WitsmlLogCurveInfo.LogDataTypeDatetime
- }.AsItemInList()
- }.AsItemInList()
- };
- }
-
- private enum IndexType
- {
- Depth,
- Time
- }
-
- private static async Task GetWellbore(IWitsmlClient client, LogObject logObject)
- {
- WitsmlWellbores query = WellboreQueries.GetWitsmlWellboreByUid(logObject.WellUid, logObject.WellboreUid);
- WitsmlWellbores wellbores = await client.GetFromStoreAsync(query, new OptionsIn(ReturnElements.Requested));
- return wellbores.Wellbores.FirstOrDefault();
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateMudLogWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateMudLogWorker.cs
deleted file mode 100644
index ceee3a87b..000000000
--- a/Src/WitsmlExplorer.Api/Workers/Create/CreateMudLogWorker.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-
-using Microsoft.Extensions.Logging;
-
-using Witsml;
-using Witsml.Data.MudLog;
-using Witsml.ServiceReference;
-
-using WitsmlExplorer.Api.Jobs;
-using WitsmlExplorer.Api.Models;
-using WitsmlExplorer.Api.Query;
-using WitsmlExplorer.Api.Services;
-
-namespace WitsmlExplorer.Api.Workers.Create
-{
- public class CreateMudLogWorker : BaseWorker, IWorker
- {
- public JobType JobType => JobType.CreateMudLog;
-
- public CreateMudLogWorker(ILogger logger, IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider, logger) { }
-
- public override async Task<(WorkerResult, RefreshAction)> Execute(CreateMudLogJob job, CancellationToken? cancellationToken = null)
- {
- MudLog mudLog = job.MudLog;
- Verify(mudLog);
-
- WitsmlMudLogs mudLogToCreate = mudLog.ToWitsml();
-
- QueryResult result = await GetTargetWitsmlClientOrThrow().AddToStoreAsync(mudLogToCreate);
- if (result.IsSuccessful)
- {
- await WaitUntilMudLogHasBeenCreated(mudLog);
- Logger.LogInformation("MudLog created. {jobDescription}", job.Description());
- WorkerResult workerResult = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), true, $"MudLog created ({mudLog.Name} [{mudLog.Uid}])");
- RefreshObjects refreshAction = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), mudLog.WellUid, mudLog.WellboreUid, EntityType.MudLog);
- return (workerResult, refreshAction);
- }
-
- EntityDescription description = new() { WellboreName = mudLog.WellboreName };
- string errorMessage = "Failed to create mudLog.";
- Logger.LogError("{ErrorMessage}. {jobDescription}", errorMessage, job.Description());
- return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, errorMessage, result.Reason, description), null);
- }
-
- private async Task WaitUntilMudLogHasBeenCreated(MudLog mudLog)
- {
- bool isMudLogCreated = false;
- WitsmlMudLogs query = MudLogQueries.QueryById(mudLog.WellUid, mudLog.WellboreUid, new string[] { mudLog.Uid });
- int maxRetries = 30;
- while (!isMudLogCreated)
- {
- if (--maxRetries == 0)
- {
- throw new InvalidOperationException($"Not able to read newly created MudLog with name {mudLog.Name} (id={mudLog.Uid})");
- }
- Thread.Sleep(1000);
- WitsmlMudLogs mudLogResult = await GetTargetWitsmlClientOrThrow().GetFromStoreAsync(query, new OptionsIn(ReturnElements.IdOnly));
- isMudLogCreated = mudLogResult.MudLogs.Any();
- }
- }
-
- private static void Verify(MudLog mudLog)
- {
- if (string.IsNullOrEmpty(mudLog.Uid))
- {
- throw new InvalidOperationException($"{nameof(mudLog.Uid)} cannot be empty");
- }
-
- if (string.IsNullOrEmpty(mudLog.Name))
- {
- throw new InvalidOperationException($"{nameof(mudLog.Name)} cannot be empty");
- }
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateObjectOnWellboreWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateObjectOnWellboreWorker.cs
new file mode 100644
index 000000000..3c0bc06c7
--- /dev/null
+++ b/Src/WitsmlExplorer.Api/Workers/Create/CreateObjectOnWellboreWorker.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+using Microsoft.Extensions.Logging;
+
+using Witsml;
+using Witsml.Data;
+using Witsml.Data.Curves;
+using Witsml.Extensions;
+
+using WitsmlExplorer.Api.Jobs;
+using WitsmlExplorer.Api.Models;
+using WitsmlExplorer.Api.Services;
+using WitsmlExplorer.Api.Workers.Modify;
+
+namespace WitsmlExplorer.Api.Workers.Create
+{
+ public class CreateObjectOnWellboreWorker : BaseWorker, IWorker
+ {
+ public JobType JobType => JobType.CreateObjectOnWellbore;
+
+ public CreateObjectOnWellboreWorker(ILogger logger, IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider, logger) { }
+
+ public override async Task<(WorkerResult, RefreshAction)> Execute(CreateObjectOnWellboreJob job, CancellationToken? cancellationToken = null)
+ {
+ ObjectOnWellbore obj = job.Object;
+ EntityType objectType = job.ObjectType;
+
+ Logger.LogInformation("Started {JobType}. {jobDescription}", JobType, job.Description());
+
+ try
+ {
+ ModifyUtils.VerifyCreationValues(obj);
+ }
+ catch (Exception e)
+ {
+ Logger.LogError("{JobType} - Job validation failed", JobType);
+ return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, e.Message, ""), null);
+ }
+
+ IWitsmlQueryType query = obj.ToWitsml();
+
+ if (job.ObjectType == EntityType.Log)
+ {
+ LogObject log = (LogObject)job.Object;
+ ((WitsmlLogs)query).Logs.First().LogCurveInfo = new WitsmlLogCurveInfo
+ {
+ Uid = Guid.NewGuid().ToString(),
+ Mnemonic = log.IndexCurve,
+ Unit = log.IndexType == WitsmlLog.WITSML_INDEX_TYPE_MD ? DepthUnit.Meter.ToString() : Unit.TimeUnit.ToString(),
+ TypeLogData = log.IndexType == WitsmlLog.WITSML_INDEX_TYPE_MD ? WitsmlLogCurveInfo.LogDataTypeDouble : WitsmlLogCurveInfo.LogDataTypeDatetime
+ }.AsItemInList();
+ }
+
+ QueryResult createResult = await GetTargetWitsmlClientOrThrow().AddToStoreAsync(query);
+
+ if (!createResult.IsSuccessful)
+ {
+ string errorMessage = $"Failed to create {objectType}";
+ Logger.LogError("{ErrorMessage}. {jobDescription}", errorMessage, job.Description());
+ return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, errorMessage, createResult.Reason), null);
+ }
+
+ Logger.LogInformation("{objectType} created. {jobDescription}", objectType, job.Description());
+ RefreshObjects refreshAction = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), obj.WellUid, obj.WellboreUid, objectType);
+ WorkerResult workerResult = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), true, $"{objectType} {obj.Name} updated for {obj.WellboreName}");
+
+ return (workerResult, refreshAction);
+ }
+ }
+}
diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateRigWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateRigWorker.cs
deleted file mode 100644
index eeb7d2758..000000000
--- a/Src/WitsmlExplorer.Api/Workers/Create/CreateRigWorker.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
-using Microsoft.Extensions.Logging;
-
-using Witsml;
-using Witsml.Data.Rig;
-
-using WitsmlExplorer.Api.Jobs;
-using WitsmlExplorer.Api.Models;
-using WitsmlExplorer.Api.Services;
-
-namespace WitsmlExplorer.Api.Workers.Create;
-
-///
-/// Worker for creating new rig by specific well and wellbore.
-///
-public class CreateRigWorker : BaseWorker, IWorker
-{
- public CreateRigWorker(ILogger logger, IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider, logger) { }
- public JobType JobType => JobType.CreateRig;
-
- ///
- /// Create new rig on wellbore for witsml client.
- ///
- /// Job info of created rig.
- /// Task of workerResult with refresh objects.
- public override async Task<(WorkerResult, RefreshAction)> Execute(CreateRigJob job, CancellationToken? cancellationToken = null)
- {
- Verify(job.Rig);
-
- WitsmlRigs rigToCreate = job.Rig.ToWitsml();
-
- QueryResult addToStoreResult = await GetTargetWitsmlClientOrThrow().AddToStoreAsync(rigToCreate);
-
- if (!addToStoreResult.IsSuccessful)
- {
- string errorMessage = "Failed to create rig.";
- Logger.LogError("{ErrorMessage}. {jobDescription}", errorMessage, job.Description());
- return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, errorMessage, addToStoreResult.Reason), null);
- }
-
- Logger.LogInformation("Rig created. {jobDescription}", job.Description());
- RefreshObjects refreshAction = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), job.Rig.WellUid, job.Rig.WellboreUid, EntityType.Rig);
- WorkerResult workerResult = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), true, $"Rig {job.Rig.Name} add for {job.Rig.WellboreName}");
-
- return (workerResult, refreshAction);
- }
-
- private static void Verify(Rig rig)
- {
- if (string.IsNullOrEmpty(rig.Uid))
- {
- throw new InvalidOperationException($"{nameof(rig.Uid)} cannot be empty");
- }
-
- if (string.IsNullOrEmpty(rig.Name))
- {
- throw new InvalidOperationException($"{nameof(rig.Name)} cannot be empty");
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateRiskWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateRiskWorker.cs
deleted file mode 100644
index 26553e6b5..000000000
--- a/Src/WitsmlExplorer.Api/Workers/Create/CreateRiskWorker.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-
-using Microsoft.Extensions.Logging;
-
-using Witsml;
-using Witsml.Data;
-using Witsml.ServiceReference;
-
-using WitsmlExplorer.Api.Jobs;
-using WitsmlExplorer.Api.Models;
-using WitsmlExplorer.Api.Query;
-using WitsmlExplorer.Api.Services;
-
-namespace WitsmlExplorer.Api.Workers.Create
-{
-
- public class CreateRiskWorker : BaseWorker, IWorker
- {
- public JobType JobType => JobType.CreateRisk;
-
- public CreateRiskWorker(ILogger logger, IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider, logger) { }
-
- public override async Task<(WorkerResult, RefreshAction)> Execute(CreateRiskJob job, CancellationToken? cancellationToken = null)
- {
- Risk risk = job.Risk;
- Verify(risk);
-
- WitsmlRisks riskToCreate = risk.ToWitsml();
-
- QueryResult result = await GetTargetWitsmlClientOrThrow().AddToStoreAsync(riskToCreate);
- if (result.IsSuccessful)
- {
- await WaitUntilRiskHasBeenCreated(risk);
- Logger.LogInformation("Risk created. {jobDescription}", job.Description());
- WorkerResult workerResult = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), true, $"Risk created ({risk.Name} [{risk.Uid}])");
- RefreshObjects refreshAction = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), risk.WellUid, risk.WellboreUid, EntityType.Risk);
- return (workerResult, refreshAction);
- }
-
- EntityDescription description = new() { WellboreName = risk.WellboreName };
- string errorMessage = "Failed to create Risk.";
- Logger.LogError("{ErrorMessage}. {jobDescription}", errorMessage, job.Description());
- return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, errorMessage, result.Reason, description), null);
- }
- private async Task WaitUntilRiskHasBeenCreated(Risk risk)
- {
- bool isCreated = false;
- WitsmlRisks query = RiskQueries.QueryById(risk.WellUid, risk.WellboreUid, risk.Uid);
- int maxRetries = 30;
- while (!isCreated)
- {
- if (--maxRetries == 0)
- {
- throw new InvalidOperationException($"Not able to read newly created Risk with name {risk.Name} (id={risk.Uid})");
- }
- Thread.Sleep(1000);
- WitsmlRisks riskResult = await GetTargetWitsmlClientOrThrow().GetFromStoreAsync(query, new OptionsIn(ReturnElements.IdOnly));
- isCreated = riskResult.Risks.Any();
- }
- }
-
- private static void Verify(Risk risk)
- {
- if (string.IsNullOrEmpty(risk.Uid))
- {
- throw new InvalidOperationException($"{nameof(risk.Uid)} cannot be empty");
- }
-
- if (string.IsNullOrEmpty(risk.Name))
- {
- throw new InvalidOperationException($"{nameof(risk.Name)} cannot be empty");
- }
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateTrajectoryWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateTrajectoryWorker.cs
deleted file mode 100644
index 302d295f5..000000000
--- a/Src/WitsmlExplorer.Api/Workers/Create/CreateTrajectoryWorker.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
-using Microsoft.Extensions.Logging;
-
-using Witsml;
-using Witsml.Data;
-
-using WitsmlExplorer.Api.Jobs;
-using WitsmlExplorer.Api.Models;
-using WitsmlExplorer.Api.Services;
-
-namespace WitsmlExplorer.Api.Workers.Create;
-
-///
-/// Worker for creating new trajectory by specific well and wellbore.
-///
-public class CreateTrajectoryWorker : BaseWorker, IWorker
-{
- public CreateTrajectoryWorker(ILogger logger, IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider, logger) { }
- public JobType JobType => JobType.CreateTrajectory;
-
- ///
- /// Create new trajectory on wellbore for witsml client.
- ///
- /// Job info of created trajectory.
- /// Task of workerResult with refresh objects.
- public override async Task<(WorkerResult, RefreshAction)> Execute(CreateTrajectoryJob job, CancellationToken? cancellationToken = null)
- {
- Verify(job.Trajectory);
-
- WitsmlTrajectories trajectoryToCreate = job.Trajectory.ToWitsml();
-
- QueryResult addToStoreResult = await GetTargetWitsmlClientOrThrow().AddToStoreAsync(trajectoryToCreate);
-
- if (!addToStoreResult.IsSuccessful)
- {
- string errorMessage = "Failed to create trajectory.";
- Logger.LogError("{ErrorMessage}. {jobDescription}", errorMessage, job.Description());
- return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, errorMessage, addToStoreResult.Reason), null);
- }
-
- Logger.LogInformation("Trajectory created. {jobDescription}", job.Description());
- RefreshObjects refreshAction = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), job.Trajectory.WellUid, job.Trajectory.WellboreUid, EntityType.Trajectory);
- WorkerResult workerResult = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), true, $"Trajectory {job.Trajectory.Name} add for {job.Trajectory.WellboreName}");
-
- return (workerResult, refreshAction);
- }
-
- private static void Verify(Trajectory trajectory)
- {
- if (string.IsNullOrEmpty(trajectory.Uid))
- {
- throw new InvalidOperationException($"{nameof(trajectory.Uid)} cannot be empty");
- }
-
- if (string.IsNullOrEmpty(trajectory.Name))
- {
- throw new InvalidOperationException($"{nameof(trajectory.Name)} cannot be empty");
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Workers/Create/CreateWbGeometryWorker.cs b/Src/WitsmlExplorer.Api/Workers/Create/CreateWbGeometryWorker.cs
deleted file mode 100644
index 5f23fd23e..000000000
--- a/Src/WitsmlExplorer.Api/Workers/Create/CreateWbGeometryWorker.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using System.Globalization;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-
-using Microsoft.Extensions.Logging;
-
-using Witsml;
-using Witsml.Data;
-using Witsml.Data.Measures;
-using Witsml.Extensions;
-using Witsml.ServiceReference;
-
-using WitsmlExplorer.Api.Jobs;
-using WitsmlExplorer.Api.Models;
-using WitsmlExplorer.Api.Query;
-using WitsmlExplorer.Api.Services;
-
-namespace WitsmlExplorer.Api.Workers.Create
-{
- public class CreateWbGeometryWorker : BaseWorker, IWorker
- {
- public JobType JobType => JobType.CreateWbGeometry;
-
- public CreateWbGeometryWorker(ILogger logger, IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider, logger) { }
-
- public override async Task<(WorkerResult, RefreshAction)> Execute(CreateWbGeometryJob job, CancellationToken? cancellationToken = null)
- {
- WbGeometry wbGeometry = job.WbGeometry;
- Verify(wbGeometry);
-
- WitsmlWbGeometrys wbGeometryToCreate = SetupWbGeometryToCreate(wbGeometry);
-
- QueryResult result = await GetTargetWitsmlClientOrThrow().AddToStoreAsync(wbGeometryToCreate);
- if (result.IsSuccessful)
- {
- await WaitUntilWbGeometryHasBeenCreated(wbGeometry);
- Logger.LogInformation("WbGeometry created. {jobDescription}", job.Description());
- WorkerResult workerResult = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), true, $"WbGeometry created ({wbGeometry.Name} [{wbGeometry.Uid}])");
- RefreshObjects refreshAction = new(GetTargetWitsmlClientOrThrow().GetServerHostname(), wbGeometry.WellUid, wbGeometry.WellboreUid, EntityType.WbGeometry);
- return (workerResult, refreshAction);
- }
-
- EntityDescription description = new() { WellboreName = wbGeometry.WellboreName };
- string errorMessage = "Failed to create WbGeometry.";
- Logger.LogError("{ErrorMessage}. {jobDescription}", errorMessage, job.Description());
- return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, errorMessage, result.Reason, description), null);
-
- }
- private async Task WaitUntilWbGeometryHasBeenCreated(WbGeometry wbGeometry)
- {
- bool isCreated = false;
- WitsmlWbGeometrys query = WbGeometryQueries.GetWitsmlWbGeometryIdOnly(wbGeometry.WellUid, wbGeometry.WellboreUid, wbGeometry.Uid);
- int maxRetries = 30;
- while (!isCreated)
- {
- if (--maxRetries == 0)
- {
- throw new InvalidOperationException($"Not able to read newly created WbGeometry with name {wbGeometry.Name} (id={wbGeometry.Uid})");
- }
- Thread.Sleep(1000);
- WitsmlWbGeometrys wbGeometryResult = await GetTargetWitsmlClientOrThrow().GetFromStoreAsync(query, new OptionsIn(ReturnElements.IdOnly));
- isCreated = wbGeometryResult.WbGeometrys.Any(); //Or WbGeometry
- }
- }
-
- private static WitsmlWbGeometrys SetupWbGeometryToCreate(WbGeometry wbGeometry)
- {
- return new WitsmlWbGeometrys
- {
- WbGeometrys = new WitsmlWbGeometry
- {
- UidWell = wbGeometry.WellUid,
- UidWellbore = wbGeometry.WellboreUid,
- Uid = wbGeometry.Name,
- Name = wbGeometry.Name,
- NameWell = wbGeometry.WellName,
- NameWellbore = wbGeometry.WellboreName,
- DTimReport = wbGeometry.DTimReport,
- MdBottom = wbGeometry.MdBottom != null ? new WitsmlMeasuredDepthCoord { Uom = wbGeometry.MdBottom.Uom, Value = wbGeometry.MdBottom.Value.ToString(CultureInfo.InvariantCulture) } : null,
- GapAir = wbGeometry.GapAir != null ? new WitsmlLengthMeasure { Uom = wbGeometry.GapAir.Uom, Value = wbGeometry.GapAir.Value.ToString(CultureInfo.InvariantCulture) } : null,
- DepthWaterMean = wbGeometry.DepthWaterMean != null ? new WitsmlLengthMeasure { Uom = wbGeometry.DepthWaterMean.Uom, Value = wbGeometry.DepthWaterMean.Value.ToString(CultureInfo.InvariantCulture) } : null,
- CommonData = new WitsmlCommonData
- {
- ItemState = wbGeometry.CommonData.ItemState,
- SourceName = wbGeometry.CommonData.SourceName,
- Comments = wbGeometry.CommonData.Comments,
- },
- }.AsItemInList()
- };
- }
-
- private static void Verify(WbGeometry wbGeometry)
- {
- if (string.IsNullOrEmpty(wbGeometry.Uid))
- {
- throw new InvalidOperationException($"{nameof(wbGeometry.Uid)} cannot be empty");
- }
-
- if (string.IsNullOrEmpty(wbGeometry.Name))
- {
- throw new InvalidOperationException($"{nameof(wbGeometry.Name)} cannot be empty");
- }
- }
- }
-}
diff --git a/Src/WitsmlExplorer.Api/Workers/Modify/BatchModifyObjectsOnWellboreWorker.cs b/Src/WitsmlExplorer.Api/Workers/Modify/BatchModifyObjectsOnWellboreWorker.cs
index 2e850a26a..3f2d659fa 100644
--- a/Src/WitsmlExplorer.Api/Workers/Modify/BatchModifyObjectsOnWellboreWorker.cs
+++ b/Src/WitsmlExplorer.Api/Workers/Modify/BatchModifyObjectsOnWellboreWorker.cs
@@ -29,11 +29,10 @@ public BatchModifyObjectsOnWellboreWorker(ILogger ModifyUtils.PrepareModification(obj, objectType, Logger)).ToList();
-
try
{
- objects.ForEach(ModifyUtils.VerifyModification);
+ objects.ForEach(obj => ModifyUtils.VerifyModificationProperties(obj, objectType, Logger));
+ objects.ForEach(ModifyUtils.VerifyModificationValues);
}
catch (Exception e)
{
diff --git a/Src/WitsmlExplorer.Api/Workers/Modify/ModifyObjectOnWellboreWorker.cs b/Src/WitsmlExplorer.Api/Workers/Modify/ModifyObjectOnWellboreWorker.cs
index b34c7f684..c5db362a4 100644
--- a/Src/WitsmlExplorer.Api/Workers/Modify/ModifyObjectOnWellboreWorker.cs
+++ b/Src/WitsmlExplorer.Api/Workers/Modify/ModifyObjectOnWellboreWorker.cs
@@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
+using Microsoft.IdentityModel.Tokens;
using Witsml;
using Witsml.Data;
@@ -26,11 +27,10 @@ public ModifyObjectOnWellboreWorker(ILogger logger, I
Logger.LogInformation("Started {JobType}. {jobDescription}", JobType, job.Description());
- obj = ModifyUtils.PrepareModification(obj, objectType, Logger);
-
try
{
- ModifyUtils.VerifyModification(obj);
+ ModifyUtils.VerifyModificationProperties(obj, objectType, Logger);
+ ModifyUtils.VerifyModificationValues(obj);
}
catch (Exception e)
{
@@ -38,6 +38,8 @@ public ModifyObjectOnWellboreWorker(ILogger logger, I
return (new WorkerResult(GetTargetWitsmlClientOrThrow().GetServerHostname(), false, e.Message, ""), null);
}
+ await PreModifyModifications(job);
+
IWitsmlQueryType query = obj.ToWitsml();
QueryResult modifyResult = await GetTargetWitsmlClientOrThrow().UpdateInStoreAsync(query);
@@ -54,5 +56,25 @@ public ModifyObjectOnWellboreWorker(ILogger logger, I
return (workerResult, refreshAction);
}
+
+ private async Task PreModifyModifications(ModifyObjectOnWellboreJob job)
+ {
+ if (job.ObjectType == EntityType.Risk)
+ {
+ Risk risk = (Risk)job.Object;
+ if (!risk.AffectedPersonnel.IsNullOrEmpty())
+ {
+ // AffectedPersonnel can't be modified. So we delete it first, and then run the modification as usual.
+ WitsmlRisks test = new WitsmlRisk
+ {
+ Uid = risk.Uid,
+ UidWell = risk.WellUid,
+ UidWellbore = risk.WellboreUid,
+ AffectedPersonnel = [""] // Warning: The empty string must be included to ensure that AffectedPersonnel is serialized correctly and added to the query. Otherwise we risk deleting the entire risk object!
+ }.AsItemInWitsmlList();
+ await GetTargetWitsmlClientOrThrow().DeleteFromStoreAsync(test);
+ }
+ }
+ }
}
}
diff --git a/Src/WitsmlExplorer.Api/Workers/Modify/ModifyUtils.cs b/Src/WitsmlExplorer.Api/Workers/Modify/ModifyUtils.cs
index 1d3122c24..cfdff8622 100644
--- a/Src/WitsmlExplorer.Api/Workers/Modify/ModifyUtils.cs
+++ b/Src/WitsmlExplorer.Api/Workers/Modify/ModifyUtils.cs
@@ -11,6 +11,14 @@ namespace WitsmlExplorer.Api.Workers.Modify
{
public static class ModifyUtils
{
+ public static void VerifyNotNull(object value, string name)
+ {
+ if (value == null)
+ {
+ throw new InvalidOperationException($"{name} cannot be null");
+ }
+ }
+
public static void VerifyMeasure(Measure measure, string name)
{
if (measure == null)
@@ -47,6 +55,13 @@ public static void VerifyAllowedValues(string value, List allowedValues,
}
}
+ private static readonly List ObjectReferenceProperties = new List
+ {
+ nameof(ObjectOnWellbore.Uid),
+ nameof(ObjectOnWellbore.WellUid),
+ nameof(ObjectOnWellbore.WellboreUid)
+ };
+
// Properties not used when converting to WITSML can safely be added here.
private static readonly Dictionary> AllowedPropertiesToChange = new Dictionary>
{
@@ -74,6 +89,10 @@ public static void VerifyAllowedValues(string value, List allowedValues,
EntityType.FluidsReport, new HashSet
{
nameof(FluidsReport.Name),
+ nameof(FluidsReport.DTim),
+ nameof(FluidsReport.Md),
+ nameof(FluidsReport.Tvd),
+ nameof(FluidsReport.NumReport),
nameof(FormationMarker.CommonData)
}
},
@@ -161,6 +180,7 @@ public static void VerifyAllowedValues(string value, List allowedValues,
nameof(Risk.DTimEnd),
nameof(Risk.MdBitStart),
nameof(Risk.MdBitEnd),
+ nameof(Risk.SeverityLevel),
nameof(Risk.ProbabilityLevel),
nameof(Risk.Summary),
nameof(Risk.Details),
@@ -196,53 +216,43 @@ public static void VerifyAllowedValues(string value, List allowedValues,
},
};
- public static ObjectOnWellbore PrepareModification(ObjectOnWellbore obj, EntityType objectType, ILogger logger)
+ public static void VerifyModificationProperties(ObjectOnWellbore obj, EntityType objectType, ILogger logger)
{
if (!AllowedPropertiesToChange.TryGetValue(objectType, out var allowedProperties))
{
throw new NotSupportedException($"ObjectType '{objectType}' is not supported");
}
- return SetNotAllowedPropertiesToNull(obj, allowedProperties, logger);
- }
-
- private static ObjectOnWellbore SetNotAllowedPropertiesToNull(ObjectOnWellbore obj, HashSet allowedPropertiesToChange, ILogger logger)
- {
- // The uids should not be changed, but are needed to identify the object
- allowedPropertiesToChange.Add(nameof(obj.WellUid));
- allowedPropertiesToChange.Add(nameof(obj.WellboreUid));
- allowedPropertiesToChange.Add(nameof(obj.Uid));
-
foreach (var property in obj.GetType().GetProperties())
{
- if (!allowedPropertiesToChange.Contains(property.Name) && property.GetValue(obj) != null)
+ if (!allowedProperties.Contains(property.Name) && !ObjectReferenceProperties.Contains(property.Name) && property.GetValue(obj) != null)
{
- logger.LogWarning("Property '{propertyName}' should not be changed and will be set to null. If the change is intended, please update the AllowedPropertiesToChange list in ModifyUtils.cs", property.Name);
- property.SetValue(obj, null);
+ throw new ArgumentException($"Modifying {property.Name} for a {objectType} is prohibited");
}
}
-
- return obj;
}
- public static void VerifyModification(ObjectOnWellbore obj)
+ public static void VerifyCreationValues(ObjectOnWellbore obj)
{
- if (obj == null)
- {
- throw new InvalidOperationException("Object cannot be null");
- }
- if (string.IsNullOrEmpty(obj.WellUid))
- {
- throw new InvalidOperationException("WellUid cannot be empty");
- }
- if (string.IsNullOrEmpty(obj.WellboreUid))
- {
- throw new InvalidOperationException("WellboreUid cannot be empty");
- }
- if (string.IsNullOrEmpty(obj.Uid))
+ VerifyModificationValues(obj);
+ VerifyNotNull(obj.Name, nameof(obj.Name));
+ switch (obj)
{
- throw new InvalidOperationException("Uid cannot be empty");
+ case LogObject log:
+ VerifyLogCreation(log);
+ break;
}
+ }
+
+ public static void VerifyModificationValues(ObjectOnWellbore obj)
+ {
+ VerifyNotNull(obj, obj.GetType().Name);
+ VerifyNotNull(obj.WellUid, nameof(obj.WellUid));
+ VerifyNotNull(obj.WellboreUid, nameof(obj.WellboreUid));
+ VerifyNotNull(obj.Uid, nameof(obj.Uid));
+ VerifyString(obj.WellUid, nameof(obj.WellUid));
+ VerifyString(obj.WellboreUid, nameof(obj.WellboreUid));
+ VerifyString(obj.Uid, nameof(obj.Uid));
VerifyString(obj.Name, nameof(obj.Name));
switch (obj)
@@ -326,11 +336,19 @@ private static void VerifyFormationMarker(FormationMarker formationMarker)
private static void VerifyLog(LogObject log)
{
+ VerifyString(log.IndexType, nameof(log.IndexType));
+ VerifyString(log.IndexCurve, nameof(log.IndexCurve));
VerifyString(log.ServiceCompany, nameof(log.ServiceCompany));
VerifyString(log.RunNumber, nameof(log.RunNumber), 16);
VerifyAllowedValues(log.CommonData?.ItemState, _allowedItemStates, "CommonData.ItemState");
}
+ private static void VerifyLogCreation(LogObject log)
+ {
+ VerifyNotNull(log.IndexType, nameof(log.IndexType));
+ VerifyNotNull(log.IndexCurve, nameof(log.IndexCurve));
+ }
+
private static void VerifyMessage(MessageObject message)
{
VerifyAllowedValues(message.CommonData?.ItemState, _allowedItemStates, "CommonData.ItemState");
diff --git a/Src/WitsmlExplorer.Frontend/components/Constants.tsx b/Src/WitsmlExplorer.Frontend/components/Constants.tsx
index 102ca5f4c..3954dcd87 100644
--- a/Src/WitsmlExplorer.Frontend/components/Constants.tsx
+++ b/Src/WitsmlExplorer.Frontend/components/Constants.tsx
@@ -1,5 +1,8 @@
export const WITSML_INDEX_TYPE_MD = "measured depth";
export const WITSML_INDEX_TYPE_DATE_TIME = "date time";
+export type WITSML_INDEX_TYPE =
+ | typeof WITSML_INDEX_TYPE_MD
+ | typeof WITSML_INDEX_TYPE_DATE_TIME;
export const WITSML_LOG_ORDERTYPE_DECREASING = "decreasing";
export const DateFormat = {
diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/WellboresListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/WellboresListView.tsx
index 34f63e763..633ae83c5 100644
--- a/Src/WitsmlExplorer.Frontend/components/ContentViews/WellboresListView.tsx
+++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/WellboresListView.tsx
@@ -50,9 +50,13 @@ export default function WellboresListView() {
const columns: ContentTableColumn[] = [
{ property: "name", label: "name", type: ContentType.String },
- { property: "wellType", label: "typeWellbore", type: ContentType.String },
{
- property: "wellStatus",
+ property: "wellboreType",
+ label: "typeWellbore",
+ type: ContentType.String
+ },
+ {
+ property: "wellboreStatus",
label: "statusWellbore",
type: ContentType.String
},
diff --git a/Src/WitsmlExplorer.Frontend/components/ContextMenus/BatchModifyMenuItem.tsx b/Src/WitsmlExplorer.Frontend/components/ContextMenus/BatchModifyMenuItem.tsx
index 961c38129..4915c35d5 100644
--- a/Src/WitsmlExplorer.Frontend/components/ContextMenus/BatchModifyMenuItem.tsx
+++ b/Src/WitsmlExplorer.Frontend/components/ContextMenus/BatchModifyMenuItem.tsx
@@ -1,18 +1,14 @@
import { Typography } from "@equinor/eds-core-react";
import { MenuItem } from "@mui/material";
+import { getBatchModifyObjectOnWellboreProperties } from "components/Modals/PropertiesModal/Properties/BatchModifyObjectOnWellboreProperties";
+import { PropertiesModal } from "components/Modals/PropertiesModal/PropertiesModal";
import { useOperationState } from "hooks/useOperationState";
import { ReactElement, forwardRef } from "react";
import OperationType from "../../contexts/operationType";
import ObjectOnWellbore from "../../models/objectOnWellbore";
-import { ObjectType } from "../../models/objectType";
-import { rigType } from "../../models/rigType";
+import { ObjectType, ObjectTypeToModel } from "../../models/objectType";
import JobService, { JobType } from "../../services/jobService";
import { colors } from "../../styles/Colors";
-import {
- BatchModifyPropertiesModal,
- BatchModifyProperty
-} from "../Modals/BatchModifyPropertiesModal";
-import { validText } from "../Modals/ModalParts";
import { ReportModal } from "../Modals/ReportModal";
import { StyledIcon, menuItemText } from "./ContextMenuUtils";
@@ -25,11 +21,13 @@ export const BatchModifyMenuItem = forwardRef(
(props: BatchModifyMenuItemProps, ref: React.Ref): ReactElement => {
const { checkedObjects, objectType } = props;
const { dispatchOperation } = useOperationState();
- const batchModifyProperties = objectBatchModifyProperties[objectType];
+ const batchModifyProperties =
+ getBatchModifyObjectOnWellboreProperties(objectType);
const onSubmitBatchModify = async (batchUpdates: {
[key: string]: string;
}) => {
+ dispatchOperation({ type: OperationType.HideModal });
const objectsToModify = checkedObjects.map((object) => ({
uid: object.uid,
wellboreUid: object.wellboreUid,
@@ -59,12 +57,13 @@ export const BatchModifyMenuItem = forwardRef(
dispatchOperation({ type: OperationType.HideContextMenu });
const batchModifyModalProps = {
title: menuItemText("Batch update", objectType, checkedObjects),
+ object: {} as ObjectTypeToModel[typeof objectType],
properties: batchModifyProperties,
onSubmit: onSubmitBatchModify
};
dispatchOperation({
type: OperationType.DisplayModal,
- payload:
+ payload:
});
};
@@ -85,65 +84,3 @@ export const BatchModifyMenuItem = forwardRef(
);
BatchModifyMenuItem.displayName = "BatchModifyMenuItem";
-
-// Note: Only add properties that can be updated directly (without having to create a new object and delete the old one)
-export const objectBatchModifyProperties: {
- [key in ObjectType]?: BatchModifyProperty[];
-} = {
- [ObjectType.BhaRun]: [],
- [ObjectType.ChangeLog]: [],
- [ObjectType.FluidsReport]: [],
- [ObjectType.FormationMarker]: [],
- [ObjectType.Log]: [
- {
- property: "name",
- validator: (value: string) => validText(value, 0, 64),
- helperText: "Name must be less than 64 characters"
- },
- {
- property: "runNumber",
- validator: (value: string) => validText(value, 0, 16),
- helperText: "Run number must be less than 16 characters"
- },
- {
- property: "commonData.comments"
- }
- ],
- [ObjectType.Message]: [],
- [ObjectType.MudLog]: [],
- [ObjectType.Rig]: [
- {
- property: "owner",
- validator: (value: string) => validText(value, 0, 32),
- helperText: "Owner must be less than 32 characters"
- },
- {
- property: "typeRig",
- options: rigType
- },
- {
- property: "manufacturer",
- validator: (value: string) => validText(value, 0, 64),
- helperText: "Owner must be less than 64 characters"
- },
- {
- property: "classRig",
- validator: (value: string) => validText(value, 0, 32),
- helperText: "Owner must be less than 32 characters"
- },
- {
- property: "approvals",
- validator: (value: string) => validText(value, 0, 64),
- helperText: "Owner must be less than 64 characters"
- },
- {
- property: "registration",
- validator: (value: string) => validText(value, 0, 32),
- helperText: "Owner must be less than 32 characters"
- }
- ],
- [ObjectType.Risk]: [],
- [ObjectType.Trajectory]: [],
- [ObjectType.Tubular]: [],
- [ObjectType.WbGeometry]: []
-};
diff --git a/Src/WitsmlExplorer.Frontend/components/ContextMenus/BhaRunContextMenu.tsx b/Src/WitsmlExplorer.Frontend/components/ContextMenus/BhaRunContextMenu.tsx
index c77c4d863..a1b76305f 100644
--- a/Src/WitsmlExplorer.Frontend/components/ContextMenus/BhaRunContextMenu.tsx
+++ b/Src/WitsmlExplorer.Frontend/components/ContextMenus/BhaRunContextMenu.tsx
@@ -7,12 +7,8 @@ import {
ObjectContextMenuProps,
ObjectMenuItems
} from "components/ContextMenus/ObjectMenuItems";
-import BhaRunPropertiesModal, {
- BhaRunPropertiesModalProps
-} from "components/Modals/BhaRunPropertiesModal";
-import { PropertiesModalMode } from "components/Modals/ModalParts";
+import { openObjectOnWellboreProperties } from "components/Modals/PropertiesModal/openPropertiesHelpers";
import { useConnectedServer } from "contexts/connectedServerContext";
-import OperationType from "contexts/operationType";
import { useGetServers } from "hooks/query/useGetServers";
import { useOpenInQueryView } from "hooks/useOpenInQueryView";
import { useOperationState } from "hooks/useOperationState";
@@ -31,20 +27,6 @@ const BhaRunContextMenu = (
const { connectedServer } = useConnectedServer();
const queryClient = useQueryClient();
- const onClickModify = async () => {
- dispatchOperation({ type: OperationType.HideContextMenu });
- const mode = PropertiesModalMode.Edit;
- const modifyBhaRunProps: BhaRunPropertiesModalProps = {
- mode,
- bhaRun: checkedObjects[0] as BhaRun,
- dispatchOperation
- };
- dispatchOperation({
- type: OperationType.DisplayModal,
- payload:
- });
- };
-
return (
,