diff --git a/Src/Witsml/Data/Measures/WitsmlLinearAccelerationMeasure.cs b/Src/Witsml/Data/Measures/WitsmlLinearAccelerationMeasure.cs new file mode 100644 index 000000000..7b0d145d8 --- /dev/null +++ b/Src/Witsml/Data/Measures/WitsmlLinearAccelerationMeasure.cs @@ -0,0 +1,6 @@ +namespace Witsml.Data.Measures +{ + public class WitsmlLinearAccelerationMeasure : Measure + { + } +} diff --git a/Src/Witsml/Data/Measures/WitsmlMagneticFluxDensityMeasure.cs b/Src/Witsml/Data/Measures/WitsmlMagneticFluxDensityMeasure.cs new file mode 100644 index 000000000..614294261 --- /dev/null +++ b/Src/Witsml/Data/Measures/WitsmlMagneticFluxDensityMeasure.cs @@ -0,0 +1,6 @@ +namespace Witsml.Data.Measures +{ + public class WitsmlMagneticFluxDensityMeasure : Measure + { + } +} diff --git a/Src/Witsml/Data/WitsmlTrajectoryStation.cs b/Src/Witsml/Data/WitsmlTrajectoryStation.cs index 29af56363..5f11474d5 100644 --- a/Src/Witsml/Data/WitsmlTrajectoryStation.cs +++ b/Src/Witsml/Data/WitsmlTrajectoryStation.cs @@ -124,6 +124,10 @@ public string MsaCorUsedText [XmlElement("magModelValid")] public string MagModelValid { get; set; } [XmlElement("geoModelUsed")] public string GeoModelUsed { get; set; } [XmlElement("statusTrajStation")] public string StatusTrajStation { get; set; } + [XmlElement("gravAxialRaw")] public WitsmlLinearAccelerationMeasure GravAxialRaw { get; set; } + [XmlElement("gravTran1Raw")] public WitsmlLinearAccelerationMeasure GravTran1Raw { get; set; } + [XmlElement("gravTran2Raw")] public WitsmlLinearAccelerationMeasure GravTran2Raw { get; set; } + [XmlElement("magAxialRaw")] public WitsmlMagneticFluxDensityMeasure MagAxialRaw { get; set; } [XmlElement("rawData")] public WitsmlTrajRawData RawData { get; set; } [XmlElement("corUsed")] public WitsmlStnTrajCorUsed CorUsed { get; set; } [XmlElement("valid")] public WitsmlStnTrajValid Valid { get; set; } diff --git a/Src/WitsmlExplorer.Api/Models/BaseObjectOnWellbore.cs b/Src/WitsmlExplorer.Api/Models/BaseObjectOnWellbore.cs new file mode 100644 index 000000000..efb165696 --- /dev/null +++ b/Src/WitsmlExplorer.Api/Models/BaseObjectOnWellbore.cs @@ -0,0 +1,12 @@ +using Witsml.Data; + +namespace WitsmlExplorer.Api.Models +{ + public class BaseObjectOnWellbore : ObjectOnWellbore + { + public override IWitsmlQueryType ToWitsml() + { + throw new System.NotImplementedException("BaseObjectOnWellbore is not supposed to be converted to a WITSML model"); + } + } +} diff --git a/Src/WitsmlExplorer.Api/Models/BhaRun.cs b/Src/WitsmlExplorer.Api/Models/BhaRun.cs index 62745fa26..87b7fef4e 100644 --- a/Src/WitsmlExplorer.Api/Models/BhaRun.cs +++ b/Src/WitsmlExplorer.Api/Models/BhaRun.cs @@ -1,12 +1,15 @@ +using Witsml.Data; +using Witsml.Data.Measures; + using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.Models { public class BhaRun : ObjectOnWellbore { public string NumStringRun { get; init; } - public string Tubular { get; init; } - public string TubularUidRef { get; init; } + public RefNameString Tubular { get; init; } public string DTimStart { get; init; } public string DTimStop { get; init; } public string DTimStartDrilling { get; init; } @@ -19,5 +22,32 @@ public class BhaRun : ObjectOnWellbore public string ReasonTrip { get; init; } public string ObjectiveBha { get; init; } public CommonData CommonData { get; init; } + + public override WitsmlBhaRuns ToWitsml() + { + return new WitsmlBhaRun + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + NumStringRun = NumStringRun, + Tubular = Tubular?.ToWitsml(), + StatusBha = StatusBha, + NumBitRun = NumBitRun, + ReasonTrip = ReasonTrip, + ObjectiveBha = ObjectiveBha, + PlanDogleg = PlanDogleg?.ToWitsml(), + ActDogleg = ActDogleg?.ToWitsml(), + ActDoglegMx = ActDoglegMx?.ToWitsml(), + DTimStart = StringHelpers.ToUniversalDateTimeString(DTimStart), + DTimStop = StringHelpers.ToUniversalDateTimeString(DTimStop), + DTimStartDrilling = StringHelpers.ToUniversalDateTimeString(DTimStartDrilling), + DTimStopDrilling = StringHelpers.ToUniversalDateTimeString(DTimStopDrilling), + CommonData = CommonData?.ToWitsml() + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/ChangeLog.cs b/Src/WitsmlExplorer.Api/Models/ChangeLog.cs index f14d2c702..0ffe7afeb 100644 --- a/Src/WitsmlExplorer.Api/Models/ChangeLog.cs +++ b/Src/WitsmlExplorer.Api/Models/ChangeLog.cs @@ -1,3 +1,5 @@ +using Witsml.Data; + namespace WitsmlExplorer.Api.Models { // ChangeLog extends ObjectOnWellbore despite not having uid and name fields in WITSML @@ -8,5 +10,20 @@ public class ChangeLog : ObjectOnWellbore public string NameObject { get; init; } public string LastChangeType { get; init; } public CommonData CommonData { get; init; } + + public override WitsmlChangeLogs ToWitsml() + { + return new WitsmlChangeLog + { + UidObject = UidObject ?? Uid, + UidWellbore = WellboreUid, + UidWell = WellUid, + NameObject = NameObject ?? Name, + NameWellbore = WellboreName, + NameWell = WellName, + LastChangeType = LastChangeType, + CommonData = CommonData?.ToWitsml() + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/CommonData.cs b/Src/WitsmlExplorer.Api/Models/CommonData.cs index e0ad061ef..243ff1f96 100644 --- a/Src/WitsmlExplorer.Api/Models/CommonData.cs +++ b/Src/WitsmlExplorer.Api/Models/CommonData.cs @@ -1,3 +1,7 @@ +using Witsml.Data; + +using WitsmlExplorer.Api.Services; + namespace WitsmlExplorer.Api.Models { public class CommonData @@ -11,4 +15,22 @@ public class CommonData public string AcquisitionTimeZone { get; init; } public string DefaultDatum { get; init; } } + + public static class CommonDataExtensions + { + public static WitsmlCommonData ToWitsml(this CommonData commonData) + { + return new WitsmlCommonData + { + SourceName = commonData.SourceName, + DTimCreation = StringHelpers.ToUniversalDateTimeString(commonData.DTimCreation), + DTimLastChange = StringHelpers.ToUniversalDateTimeString(commonData.DTimLastChange), + ItemState = commonData.ItemState, + ServiceCategory = commonData.ServiceCategory, + Comments = commonData.Comments, + AcquisitionTimeZone = commonData.AcquisitionTimeZone, + DefaultDatum = commonData.DefaultDatum + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/CommonTime.cs b/Src/WitsmlExplorer.Api/Models/CommonTime.cs index 7dd961ddb..9444656bc 100644 --- a/Src/WitsmlExplorer.Api/Models/CommonTime.cs +++ b/Src/WitsmlExplorer.Api/Models/CommonTime.cs @@ -1,3 +1,7 @@ +using Witsml.Data; + +using WitsmlExplorer.Api.Services; + namespace WitsmlExplorer.Api.Models { public class CommonTime @@ -5,4 +9,16 @@ public class CommonTime public string DTimCreation { get; init; } public string DTimLastChange { get; init; } } + + public static class CommonTimeExtensions + { + public static WitsmlCommonTime ToWitsml(this CommonTime commonTime) + { + return new WitsmlCommonTime + { + DTimCreation = StringHelpers.ToUniversalDateTimeString(commonTime.DTimCreation), + DTimLastChange = StringHelpers.ToUniversalDateTimeString(commonTime.DTimLastChange) + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/Fluid.cs b/Src/WitsmlExplorer.Api/Models/Fluid.cs index 0e9c983e2..74c460ca1 100644 --- a/Src/WitsmlExplorer.Api/Models/Fluid.cs +++ b/Src/WitsmlExplorer.Api/Models/Fluid.cs @@ -1,6 +1,11 @@ using System.Collections.Generic; +using System.Linq; + +using Witsml.Data; +using Witsml.Data.Measures; using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.Models { @@ -63,4 +68,70 @@ public class Fluid public LengthMeasure Sulfide { get; init; } public string Comments { get; init; } } + + public static class FluidExtensions + { + public static WitsmlFluid ToWitsml(this Fluid fluid) + { + return new WitsmlFluid + { + Uid = fluid.Uid, + Type = fluid.Type, + LocationSample = fluid.LocationSample, + DTim = StringHelpers.ToUniversalDateTimeString(fluid.DTim), + Md = fluid.Md?.ToWitsml(), + Tvd = fluid.Tvd?.ToWitsml(), + PresBopRating = fluid.PresBopRating?.ToWitsml(), + MudClass = fluid.MudClass, + Density = fluid.Density?.ToWitsml(), + VisFunnel = fluid.VisFunnel?.ToWitsml(), + TempVis = fluid.TempVis?.ToWitsml(), + Pv = fluid.Pv?.ToWitsml(), + Yp = fluid.Yp?.ToWitsml(), + Gel10Sec = fluid.Gel10Sec?.ToWitsml(), + Gel10Min = fluid.Gel10Min?.ToWitsml(), + Gel30Min = fluid.Gel30Min?.ToWitsml(), + FilterCakeLtlp = fluid.FilterCakeLtlp?.ToWitsml(), + FiltrateLtlp = fluid.FiltrateLtlp?.ToWitsml(), + TempHthp = fluid.TempHthp?.ToWitsml(), + PresHthp = fluid.PresHthp?.ToWitsml(), + FiltrateHthp = fluid.FiltrateHthp?.ToWitsml(), + FilterCakeHthp = fluid.FilterCakeHthp?.ToWitsml(), + SolidsPc = fluid.SolidsPc?.ToWitsml(), + WaterPc = fluid.WaterPc?.ToWitsml(), + OilPc = fluid.OilPc?.ToWitsml(), + SandPc = fluid.SandPc?.ToWitsml(), + SolidsLowGravPc = fluid.SolidsLowGravPc?.ToWitsml(), + SolidsCalcPc = fluid.SolidsCalcPc?.ToWitsml(), + BaritePc = fluid.BaritePc?.ToWitsml(), + Lcm = fluid.Lcm?.ToWitsml(), + Mbt = fluid.Mbt?.ToWitsml(), + Ph = fluid.Ph, + TempPh = fluid.TempPh?.ToWitsml(), + Pm = fluid.Pm?.ToWitsml(), + PmFiltrate = fluid.PmFiltrate?.ToWitsml(), + Mf = fluid.Mf?.ToWitsml(), + AlkalinityP1 = fluid.AlkalinityP1?.ToWitsml(), + AlkalinityP2 = fluid.AlkalinityP2?.ToWitsml(), + Chloride = fluid.Chloride?.ToWitsml(), + Calcium = fluid.Calcium?.ToWitsml(), + Magnesium = fluid.Magnesium?.ToWitsml(), + Potassium = fluid.Potassium?.ToWitsml(), + Rheometers = fluid.Rheometers?.Select(rheometer => rheometer?.ToWitsml()).ToList(), + BrinePc = fluid.BrinePc?.ToWitsml(), + Lime = fluid.Lime?.ToWitsml(), + ElectStab = fluid.ElectStab?.ToWitsml(), + CalciumChloride = fluid.CalciumChloride?.ToWitsml(), + Company = fluid.Company, + SolidsHiGravPc = fluid.SolidsHiGravPc?.ToWitsml(), + Polymer = fluid.Polymer?.ToWitsml(), + PolyType = fluid.PolyType, + SolCorPc = fluid.SolCorPc?.ToWitsml(), + OilCtg = fluid.OilCtg?.ToWitsml(), + HardnessCa = fluid.HardnessCa?.ToWitsml(), + Sulfide = fluid.Sulfide?.ToWitsml(), + Comments = fluid.Comments, + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/FluidsReport.cs b/Src/WitsmlExplorer.Api/Models/FluidsReport.cs index a559b2550..2df38e9c0 100644 --- a/Src/WitsmlExplorer.Api/Models/FluidsReport.cs +++ b/Src/WitsmlExplorer.Api/Models/FluidsReport.cs @@ -1,6 +1,11 @@ using System.Collections.Generic; +using System.Linq; + +using Witsml.Data; +using Witsml.Data.Measures; using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.Models { @@ -12,5 +17,24 @@ public class FluidsReport : ObjectOnWellbore public string NumReport { get; init; } public List Fluids { get; set; } public CommonData CommonData { get; init; } + + public override WitsmlFluidsReports ToWitsml() + { + return new WitsmlFluidsReport + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + DTim = StringHelpers.ToUniversalDateTimeString(DTim), + Md = Md?.ToWitsml(), + Tvd = Tvd?.ToWitsml(), + NumReport = NumReport, + Fluids = Fluids?.Select(fluid => fluid?.ToWitsml())?.ToList(), + CommonData = CommonData?.ToWitsml() + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/FormationMarker.cs b/Src/WitsmlExplorer.Api/Models/FormationMarker.cs index 365ffc067..0b6abf2bd 100644 --- a/Src/WitsmlExplorer.Api/Models/FormationMarker.cs +++ b/Src/WitsmlExplorer.Api/Models/FormationMarker.cs @@ -1,3 +1,6 @@ +using Witsml.Data; +using Witsml.Data.Measures; + using WitsmlExplorer.Api.Models.Measure; namespace WitsmlExplorer.Api.Models @@ -5,33 +8,47 @@ namespace WitsmlExplorer.Api.Models public class FormationMarker : ObjectOnWellbore { public MeasureWithDatum MdPrognosed { get; init; } - public MeasureWithDatum TvdPrognosed { get; init; } - public MeasureWithDatum MdTopSample { get; init; } - public MeasureWithDatum TvdTopSample { get; init; } - public LengthMeasure ThicknessBed { get; init; } - public LengthMeasure ThicknessApparent { get; init; } - public LengthMeasure ThicknessPerpen { get; init; } - public MeasureWithDatum MdLogSample { get; init; } - public MeasureWithDatum TvdLogSample { get; init; } - public LengthMeasure Dip { get; init; } - public LengthMeasure DipDirection { get; init; } - public StratigraphicStruct Lithostratigraphic { get; init; } - public StratigraphicStruct Chronostratigraphic { get; init; } - public string Description { get; init; } - public CommonData CommonData { get; init; } + + public override WitsmlFormationMarkers ToWitsml() + { + return new WitsmlFormationMarker + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + MdPrognosed = MdPrognosed?.ToWitsml(), + TvdPrognosed = TvdPrognosed?.ToWitsml(), + MdTopSample = MdTopSample?.ToWitsml(), + TvdTopSample = TvdTopSample?.ToWitsml(), + ThicknessBed = ThicknessBed?.ToWitsml(), + ThicknessApparent = ThicknessApparent?.ToWitsml(), + ThicknessPerpen = ThicknessPerpen?.ToWitsml(), + MdLogSample = MdLogSample?.ToWitsml(), + TvdLogSample = TvdLogSample?.ToWitsml(), + Dip = Dip?.ToWitsml(), + DipDirection = DipDirection?.ToWitsml(), + Lithostratigraphic = Lithostratigraphic?.ToWitsmlLithostratigraphyStruct(), + Chronostratigraphic = Chronostratigraphic?.ToWitsmlChronostratigraphyStruct(), + Description = Description, + CommonData = CommonData?.ToWitsml() + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/LogObject.cs b/Src/WitsmlExplorer.Api/Models/LogObject.cs index 49ca9ae90..263b8efa1 100644 --- a/Src/WitsmlExplorer.Api/Models/LogObject.cs +++ b/Src/WitsmlExplorer.Api/Models/LogObject.cs @@ -1,5 +1,7 @@ using Witsml.Data; +using WitsmlExplorer.Api.Services; + namespace WitsmlExplorer.Api.Models { public class LogObject : ObjectOnWellbore @@ -19,5 +21,38 @@ public static string ConvertDirection(WitsmlLog witsmlLog) { return witsmlLog?.Direction?.ToLowerInvariant() ?? WitsmlLog.WITSML_DIRECTION_INCREASING; } + + public override WitsmlLogs ToWitsml() + { + WitsmlLog log = new() + { + Uid = Uid, + Name = Name, + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + IndexType = IndexType, + ObjectGrowing = StringHelpers.OptionalBooleanToString(ObjectGrowing), + ServiceCompany = ServiceCompany, + RunNumber = RunNumber, + IndexCurve = IndexCurve != null ? new WitsmlIndexCurve { Value = IndexCurve } : null, + CommonData = CommonData?.ToWitsml(), + Direction = Direction + }; + + if (IndexType == WitsmlLog.WITSML_INDEX_TYPE_MD) + { + log.StartIndex = StartIndex != null ? new WitsmlIndex(StartIndex) : null; + log.EndIndex = EndIndex != null ? new WitsmlIndex(EndIndex) : null; + } + else if (IndexType == WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME) + { + log.StartDateTimeIndex = StartIndex; + log.EndDateTimeIndex = EndIndex; + } + + return log.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/MessageObject.cs b/Src/WitsmlExplorer.Api/Models/MessageObject.cs index f6d962d9d..2a135f3d8 100644 --- a/Src/WitsmlExplorer.Api/Models/MessageObject.cs +++ b/Src/WitsmlExplorer.Api/Models/MessageObject.cs @@ -1,3 +1,7 @@ +using Witsml.Data; + +using WitsmlExplorer.Api.Services; + namespace WitsmlExplorer.Api.Models { public class MessageObject : ObjectOnWellbore @@ -6,5 +10,22 @@ public class MessageObject : ObjectOnWellbore public string MessageText { get; init; } public string TypeMessage { get; init; } public CommonData CommonData { get; init; } + + public override WitsmlMessages ToWitsml() + { + return new WitsmlMessage + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + DTim = StringHelpers.ToUniversalDateTimeString(DTim), + MessageText = MessageText, + TypeMessage = TypeMessage, + CommonData = CommonData?.ToWitsml() + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/MudLog.cs b/Src/WitsmlExplorer.Api/Models/MudLog.cs index c13b26d61..74f94de91 100644 --- a/Src/WitsmlExplorer.Api/Models/MudLog.cs +++ b/Src/WitsmlExplorer.Api/Models/MudLog.cs @@ -1,6 +1,11 @@ using System.Collections.Generic; +using System.Linq; + +using Witsml.Data.Measures; +using Witsml.Data.MudLog; using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.Models { @@ -13,5 +18,26 @@ public class MudLog : ObjectOnWellbore public MeasureWithDatum EndMd { get; init; } public List GeologyInterval { get; set; } public CommonData CommonData { get; init; } + + public override WitsmlMudLogs ToWitsml() + { + return new WitsmlMudLog + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + ObjectGrowing = StringHelpers.OptionalBooleanToString(ObjectGrowing), + MudLogCompany = MudLogCompany, + MudLogEngineers = MudLogEngineers, + StartMd = StartMd?.ToWitsml(), + EndMd = EndMd?.ToWitsml(), + GeologyInterval = GeologyInterval?.Select(geologyInterval => geologyInterval?.ToWitsml())?.ToList(), + CommonData = CommonData?.ToWitsml() + }.AsSingletonWitsmlList(); + } } } + diff --git a/Src/WitsmlExplorer.Api/Models/MudLogGeologyInterval.cs b/Src/WitsmlExplorer.Api/Models/MudLogGeologyInterval.cs index b1db9709c..febb17aad 100644 --- a/Src/WitsmlExplorer.Api/Models/MudLogGeologyInterval.cs +++ b/Src/WitsmlExplorer.Api/Models/MudLogGeologyInterval.cs @@ -1,4 +1,8 @@ using System.Collections.Generic; +using System.Linq; + +using Witsml.Data.Measures; +using Witsml.Data.MudLog; using WitsmlExplorer.Api.Models.Measure; @@ -24,4 +28,31 @@ public class MudLogGeologyInterval public string Description { get; init; } public CommonTime CommonTime { get; init; } } + + public static class MudLogGeologyIntervalExtensions + { + public static WitsmlMudLogGeologyInterval ToWitsml(this MudLogGeologyInterval mudLogGeologyInterval) + { + return new WitsmlMudLogGeologyInterval + { + Uid = mudLogGeologyInterval.Uid, + TypeLithology = mudLogGeologyInterval.TypeLithology, + MdTop = mudLogGeologyInterval.MdTop?.ToWitsml(), + MdBottom = mudLogGeologyInterval.MdBottom?.ToWitsml(), + TvdTop = mudLogGeologyInterval.TvdTop?.ToWitsml(), + TvdBase = mudLogGeologyInterval.TvdBase?.ToWitsml(), + RopAv = mudLogGeologyInterval.RopAv?.ToWitsml(), + WobAv = mudLogGeologyInterval.WobAv?.ToWitsml(), + TqAv = mudLogGeologyInterval.TqAv?.ToWitsml(), + CurrentAv = mudLogGeologyInterval.CurrentAv?.ToWitsml(), + RpmAv = mudLogGeologyInterval.RpmAv?.ToWitsml(), + WtMudAv = mudLogGeologyInterval.WtMudAv?.ToWitsml(), + EcdTdAv = mudLogGeologyInterval.EcdTdAv?.ToWitsml(), + DxcAv = mudLogGeologyInterval.DxcAv, + Lithologies = mudLogGeologyInterval.Lithologies?.Select(lithology => lithology?.ToWitsml())?.ToList(), + Description = mudLogGeologyInterval.Description, + CommonTime = mudLogGeologyInterval.CommonTime?.ToWitsml() + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/MudLogLithology.cs b/Src/WitsmlExplorer.Api/Models/MudLogLithology.cs index f7acae501..80fdf9b0a 100644 --- a/Src/WitsmlExplorer.Api/Models/MudLogLithology.cs +++ b/Src/WitsmlExplorer.Api/Models/MudLogLithology.cs @@ -1,3 +1,5 @@ +using Witsml.Data.MudLog; + namespace WitsmlExplorer.Api.Models { public class MudLogLithology @@ -7,4 +9,18 @@ public class MudLogLithology public string CodeLith { get; init; } public string LithPc { get; init; } } + + public static class MudLogLithologyExtensions + { + public static WitsmlMudLogLithology ToWitsml(this MudLogLithology mudLogLithology) + { + return new WitsmlMudLogLithology + { + Uid = mudLogLithology.Uid, + Type = mudLogLithology.Type, + CodeLith = mudLogLithology.CodeLith, + LithPc = mudLogLithology.LithPc != null ? new Witsml.Data.WitsmlIndex(mudLogLithology.LithPc) : null + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/ObjectOnWellbore.cs b/Src/WitsmlExplorer.Api/Models/ObjectOnWellbore.cs index b100ed7d1..55191b0e3 100644 --- a/Src/WitsmlExplorer.Api/Models/ObjectOnWellbore.cs +++ b/Src/WitsmlExplorer.Api/Models/ObjectOnWellbore.cs @@ -1,8 +1,10 @@ +using Witsml.Data; + using WitsmlExplorer.Api.Jobs.Common.Interfaces; namespace WitsmlExplorer.Api.Models { - public class ObjectOnWellbore : IObjectReference + public abstract class ObjectOnWellbore : IObjectReference { public string Uid { get; init; } public string WellUid { get; init; } @@ -10,5 +12,6 @@ public class ObjectOnWellbore : IObjectReference public string Name { get; set; } public string WellName { get; init; } public string WellboreName { get; init; } + public abstract IWitsmlQueryType ToWitsml(); } } diff --git a/Src/WitsmlExplorer.Api/Models/ObjectSearchResult.cs b/Src/WitsmlExplorer.Api/Models/ObjectSearchResult.cs index 8efe213ad..d90ef24a4 100644 --- a/Src/WitsmlExplorer.Api/Models/ObjectSearchResult.cs +++ b/Src/WitsmlExplorer.Api/Models/ObjectSearchResult.cs @@ -1,3 +1,4 @@ +using Witsml.Data; namespace WitsmlExplorer.Api.Models { @@ -5,5 +6,10 @@ public class ObjectSearchResult : ObjectOnWellbore { public string SearchProperty { get; set; } public EntityType ObjectType { get; set; } + + public override IWitsmlQueryType ToWitsml() + { + throw new System.NotImplementedException("ObjectSearchResult is not supposed to be converted to a WITSML model"); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/RefNameString.cs b/Src/WitsmlExplorer.Api/Models/RefNameString.cs new file mode 100644 index 000000000..fb3edef6c --- /dev/null +++ b/Src/WitsmlExplorer.Api/Models/RefNameString.cs @@ -0,0 +1,19 @@ +using Witsml.Data; + +namespace WitsmlExplorer.Api.Models +{ + public class RefNameString + { + public string UidRef { get; set; } + public string Value { get; set; } + + public WitsmlRefNameString ToWitsml() + { + return new() + { + UidRef = UidRef, + Value = Value + }; + } + } +} diff --git a/Src/WitsmlExplorer.Api/Models/Rheometer.cs b/Src/WitsmlExplorer.Api/Models/Rheometer.cs index 2e43af3a0..a28dac6a8 100644 --- a/Src/WitsmlExplorer.Api/Models/Rheometer.cs +++ b/Src/WitsmlExplorer.Api/Models/Rheometer.cs @@ -1,3 +1,6 @@ +using Witsml.Data; +using Witsml.Data.Measures; + using WitsmlExplorer.Api.Models.Measure; namespace WitsmlExplorer.Api.Models @@ -14,4 +17,23 @@ public class Rheometer public string Vis300Rpm { get; set; } public string Vis600Rpm { get; set; } } + + public static class RheometerExtensions + { + public static WitsmlRheometer ToWitsml(this Rheometer rheometer) + { + return new WitsmlRheometer + { + Uid = rheometer.Uid, + TempRheom = rheometer.TempRheom?.ToWitsml(), + PresRheom = rheometer.PresRheom?.ToWitsml(), + Vis3Rpm = rheometer.Vis3Rpm, + Vis6Rpm = rheometer.Vis6Rpm, + Vis100Rpm = rheometer.Vis100Rpm, + Vis200Rpm = rheometer.Vis200Rpm, + Vis300Rpm = rheometer.Vis300Rpm, + Vis600Rpm = rheometer.Vis600Rpm + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/Rig.cs b/Src/WitsmlExplorer.Api/Models/Rig.cs index 293ab3d77..893c71a85 100644 --- a/Src/WitsmlExplorer.Api/Models/Rig.cs +++ b/Src/WitsmlExplorer.Api/Models/Rig.cs @@ -1,4 +1,9 @@ +using Witsml.Data; +using Witsml.Data.Measures; +using Witsml.Data.Rig; + using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.Models { @@ -22,5 +27,36 @@ public class Rig : ObjectOnWellbore public string TypeRig { get; init; } public string YearEntService { get; init; } public CommonData CommonData { get; init; } + + public override WitsmlRigs ToWitsml() + { + return new WitsmlRig + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + AirGap = AirGap?.ToWitsml(), + Approvals = Approvals, + ClassRig = ClassRig, + DTimStartOp = StringHelpers.ToUniversalDateTimeString(DTimStartOp), + DTimEndOp = StringHelpers.ToUniversalDateTimeString(DTimEndOp), + EmailAddress = EmailAddress, + FaxNumber = FaxNumber, + IsOffshore = StringHelpers.OptionalBooleanToString(IsOffshore), + Manufacturer = Manufacturer, + NameContact = NameContact, + Owner = Owner, + RatingDrillDepth = RatingDrillDepth?.ToWitsml(), + RatingWaterDepth = RatingWaterDepth?.ToWitsml(), + Registration = Registration, + TelNumber = TelNumber, + TypeRig = TypeRig, + YearEntService = YearEntService, + CommonData = CommonData?.ToWitsml() + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/Risk.cs b/Src/WitsmlExplorer.Api/Models/Risk.cs index 0c0b759ff..2078bb619 100644 --- a/Src/WitsmlExplorer.Api/Models/Risk.cs +++ b/Src/WitsmlExplorer.Api/Models/Risk.cs @@ -1,4 +1,8 @@ +using Witsml.Data; +using Witsml.Data.Measures; + using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.Models { @@ -23,8 +27,43 @@ public class Risk : ObjectOnWellbore public string Summary { get; init; } public string Details { get; init; } public string Identification { get; init; } - public string Contigency { get; init; } + public string Contingency { get; init; } public string Mitigation { get; init; } public CommonData CommonData { get; init; } + + public override WitsmlRisks ToWitsml() + { + return new WitsmlRisk + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + Type = Type, + Category = Category, + SubCategory = SubCategory, + ExtendCategory = ExtendCategory, + AffectedPersonnel = (AffectedPersonnel != null && AffectedPersonnel.Length != 0) ? AffectedPersonnel?.Split(", ") : null, + DTimStart = StringHelpers.ToUniversalDateTimeString(DTimStart), + DTimEnd = StringHelpers.ToUniversalDateTimeString(DTimStart), + MdHoleStart = MdHoleStart?.ToWitsml(), + MdHoleEnd = MdHoleEnd?.ToWitsml(), + TvdHoleStart = TvdHoleStart?.ToWitsml(), + TvdHoleEnd = TvdHoleEnd?.ToWitsml(), + MdBitStart = MdBitStart?.ToWitsml(), + MdBitEnd = MdBitEnd?.ToWitsml(), + DiaHole = DiaHole?.ToWitsml(), + SeverityLevel = SeverityLevel, + ProbabilityLevel = ProbabilityLevel, + Summary = Summary, + Details = Details, + Identification = Identification, + Contingency = Contingency, + Mitigation = Mitigation, + CommonData = CommonData?.ToWitsml() + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/StnTrajCorUsed.cs b/Src/WitsmlExplorer.Api/Models/StnTrajCorUsed.cs index 7c43a65a5..b3804070e 100644 --- a/Src/WitsmlExplorer.Api/Models/StnTrajCorUsed.cs +++ b/Src/WitsmlExplorer.Api/Models/StnTrajCorUsed.cs @@ -1,3 +1,5 @@ +using Witsml.Data; + using WitsmlExplorer.Api.Models.Measure; namespace WitsmlExplorer.Api.Models @@ -15,4 +17,24 @@ public class StnTrajCorUsed public LengthMeasure StnGridCorUsed { get; init; } public LengthMeasure DirSensorOffset { get; init; } } + + public static class StnTrajCorUsedExtensions + { + public static WitsmlStnTrajCorUsed ToWitsml(this StnTrajCorUsed stnTrajCorUsed) + { + return new WitsmlStnTrajCorUsed + { + GravAxialAccelCor = stnTrajCorUsed.GravAxialAccelCor?.ToWitsml(), + GravTran1AccelCor = stnTrajCorUsed.GravTran1AccelCor?.ToWitsml(), + GravTran2AccelCor = stnTrajCorUsed.GravTran2AccelCor?.ToWitsml(), + MagAxialDrlstrCor = stnTrajCorUsed.MagAxialDrlstrCor?.ToWitsml(), + MagTran1DrlstrCor = stnTrajCorUsed.MagTran1DrlstrCor?.ToWitsml(), + MagTran2DrlstrCor = stnTrajCorUsed.MagTran2DrlstrCor?.ToWitsml(), + SagIncCor = stnTrajCorUsed.SagIncCor?.ToWitsml(), + StnMagDeclUsed = stnTrajCorUsed.StnMagDeclUsed?.ToWitsml(), + StnGridCorUsed = stnTrajCorUsed.StnGridCorUsed?.ToWitsml(), + DirSensorOffset = stnTrajCorUsed.DirSensorOffset?.ToWitsml() + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/StnTrajValid.cs b/Src/WitsmlExplorer.Api/Models/StnTrajValid.cs index 7a87ddb66..0c17046b5 100644 --- a/Src/WitsmlExplorer.Api/Models/StnTrajValid.cs +++ b/Src/WitsmlExplorer.Api/Models/StnTrajValid.cs @@ -1,3 +1,5 @@ +using Witsml.Data; + using WitsmlExplorer.Api.Models.Measure; namespace WitsmlExplorer.Api.Models @@ -8,4 +10,17 @@ public class StnTrajValid public LengthMeasure MagDipAngleCalc { get; init; } public LengthMeasure GravTotalFieldCalc { get; init; } } + + public static class StnTrajValidExtensions + { + public static WitsmlStnTrajValid ToWitsml(this StnTrajValid stnTrajValid) + { + return new WitsmlStnTrajValid + { + MagTotalFieldCalc = stnTrajValid.MagTotalFieldCalc?.ToWitsml(), + MagDipAngleCalc = stnTrajValid.MagDipAngleCalc?.ToWitsml(), + GravTotalFieldCalc = stnTrajValid.GravTotalFieldCalc?.ToWitsml() + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/TrajRawData.cs b/Src/WitsmlExplorer.Api/Models/TrajRawData.cs index 1702f8f72..6fa86e7ed 100644 --- a/Src/WitsmlExplorer.Api/Models/TrajRawData.cs +++ b/Src/WitsmlExplorer.Api/Models/TrajRawData.cs @@ -1,3 +1,5 @@ +using Witsml.Data; + using WitsmlExplorer.Api.Models.Measure; namespace WitsmlExplorer.Api.Models @@ -7,4 +9,16 @@ public class TrajRawData public LengthMeasure MagTran1Raw { get; init; } public LengthMeasure MagTran2Raw { get; init; } } + + public static class TrajRawDataExtensions + { + public static WitsmlTrajRawData ToWitsml(this TrajRawData trajRawData) + { + return new WitsmlTrajRawData + { + MagTran1Raw = trajRawData.MagTran1Raw?.ToWitsml(), + MagTran2Raw = trajRawData.MagTran2Raw?.ToWitsml() + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/Trajectory.cs b/Src/WitsmlExplorer.Api/Models/Trajectory.cs index 555633016..04d059913 100644 --- a/Src/WitsmlExplorer.Api/Models/Trajectory.cs +++ b/Src/WitsmlExplorer.Api/Models/Trajectory.cs @@ -1,4 +1,11 @@ using System.Collections.Generic; +using System.Linq; + +using Witsml.Data; +using Witsml.Data.Measures; + +using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; // ReSharper disable UnusedAutoPropertyAccessor.Global @@ -6,13 +13,34 @@ namespace WitsmlExplorer.Api.Models { public class Trajectory : ObjectOnWellbore { - public decimal? MdMin { get; init; } - public decimal? MdMax { get; init; } + public MeasureWithDatum MdMin { get; init; } + public MeasureWithDatum MdMax { get; init; } public string AziRef { get; init; } public string DTimTrajStart { get; init; } public string DTimTrajEnd { get; init; } public List TrajectoryStations { get; init; } public string ServiceCompany { get; init; } public CommonData CommonData { get; init; } + + public override WitsmlTrajectories ToWitsml() + { + return new WitsmlTrajectory + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + MdMin = MdMin?.ToWitsml(), + MdMax = MdMax?.ToWitsml(), + AziRef = AziRef, + DTimTrajStart = StringHelpers.ToUniversalDateTimeString(DTimTrajStart), + DTimTrajEnd = StringHelpers.ToUniversalDateTimeString(DTimTrajEnd), + TrajectoryStations = TrajectoryStations?.Select((trajectoryStation) => trajectoryStation?.ToWitsml()).ToList(), + ServiceCompany = ServiceCompany, + CommonData = CommonData?.ToWitsml(), + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/TrajectoryStation.cs b/Src/WitsmlExplorer.Api/Models/TrajectoryStation.cs index 35c76522c..0d68cb598 100644 --- a/Src/WitsmlExplorer.Api/Models/TrajectoryStation.cs +++ b/Src/WitsmlExplorer.Api/Models/TrajectoryStation.cs @@ -1,4 +1,8 @@ +using Witsml.Data; +using Witsml.Data.Measures; + using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; // ReSharper disable UnusedAutoPropertyAccessor.Global @@ -29,7 +33,7 @@ public class TrajectoryStation public LengthMeasure GravTotalFieldReference { get; init; } public LengthMeasure MagTotalFieldReference { get; init; } public LengthMeasure MagDipAngleReference { get; init; } - public LengthMeasure StatusTrajStation { get; init; } + public string StatusTrajStation { get; init; } public LengthMeasure GravAxialRaw { get; init; } public LengthMeasure GravTran1Raw { get; init; } public LengthMeasure GravTran2Raw { get; init; } @@ -38,4 +42,45 @@ public class TrajectoryStation public StnTrajCorUsed CorUsed { get; init; } public StnTrajValid Valid { get; set; } } + + public static class TrajectoryStationExtensions + { + public static WitsmlTrajectoryStation ToWitsml(this TrajectoryStation trajectoryStation) + { + return new WitsmlTrajectoryStation + { + Uid = trajectoryStation.Uid, + DTimStn = StringHelpers.ToUniversalDateTimeString(trajectoryStation.DTimStn), + TypeTrajStation = trajectoryStation.TypeTrajStation, + Md = trajectoryStation.Md?.ToWitsml(), + Tvd = trajectoryStation.Tvd?.ToWitsml(), + Incl = trajectoryStation.Incl?.ToWitsml(), + Azi = trajectoryStation.Azi?.ToWitsml(), + Dls = trajectoryStation.Dls?.ToWitsml(), + Mtf = trajectoryStation.Mtf?.ToWitsml(), + Gtf = trajectoryStation.Gtf?.ToWitsml(), + DispNs = trajectoryStation.DispNs?.ToWitsml(), + DispEw = trajectoryStation.DispEw?.ToWitsml(), + VertSect = trajectoryStation.VertSect?.ToWitsml(), + RateTurn = trajectoryStation.RateTurn?.ToWitsml(), + RateBuild = trajectoryStation.RateBuild?.ToWitsml(), + GravTotalUncert = trajectoryStation.GravTotalUncert?.ToWitsml(), + DipAngleUncert = trajectoryStation.DipAngleUncert?.ToWitsml(), + MagTotalUncert = trajectoryStation.MagTotalUncert?.ToWitsml(), + SagCorUsed = trajectoryStation.SagCorUsed, + MagDrlstrCorUsed = trajectoryStation.MagDrlstrCorUsed, + GravTotalFieldReference = trajectoryStation.GravTotalFieldReference?.ToWitsml(), + MagTotalFieldReference = trajectoryStation.MagTotalFieldReference?.ToWitsml(), + MagDipAngleReference = trajectoryStation.MagDipAngleReference?.ToWitsml(), + StatusTrajStation = trajectoryStation.StatusTrajStation, + GravAxialRaw = trajectoryStation.GravAxialRaw?.ToWitsml(), + GravTran1Raw = trajectoryStation.GravTran1Raw?.ToWitsml(), + GravTran2Raw = trajectoryStation.GravTran2Raw?.ToWitsml(), + MagAxialRaw = trajectoryStation.MagAxialRaw?.ToWitsml(), + RawData = trajectoryStation.RawData?.ToWitsml(), + CorUsed = trajectoryStation.CorUsed?.ToWitsml(), + Valid = trajectoryStation.Valid?.ToWitsml() + }; + } + } } diff --git a/Src/WitsmlExplorer.Api/Models/Tubular.cs b/Src/WitsmlExplorer.Api/Models/Tubular.cs index 660e730cf..6c1f2cfbe 100644 --- a/Src/WitsmlExplorer.Api/Models/Tubular.cs +++ b/Src/WitsmlExplorer.Api/Models/Tubular.cs @@ -1,8 +1,25 @@ +using Witsml.Data.Tubular; + namespace WitsmlExplorer.Api.Models { public class Tubular : ObjectOnWellbore { public string TypeTubularAssy { get; init; } public CommonData CommonData { get; init; } + + public override WitsmlTubulars ToWitsml() + { + return new WitsmlTubular + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + TypeTubularAssy = TypeTubularAssy, + CommonData = CommonData?.ToWitsml(), + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Models/WbGeometry.cs b/Src/WitsmlExplorer.Api/Models/WbGeometry.cs index f1446436b..509a8b69f 100644 --- a/Src/WitsmlExplorer.Api/Models/WbGeometry.cs +++ b/Src/WitsmlExplorer.Api/Models/WbGeometry.cs @@ -1,4 +1,8 @@ +using Witsml.Data; +using Witsml.Data.Measures; + using WitsmlExplorer.Api.Models.Measure; +using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.Models { @@ -9,5 +13,23 @@ public class WbGeometry : ObjectOnWellbore public LengthMeasure GapAir { get; init; } public LengthMeasure DepthWaterMean { get; init; } public CommonData CommonData { get; init; } + + public override WitsmlWbGeometrys ToWitsml() + { + return new WitsmlWbGeometry + { + UidWell = WellUid, + NameWell = WellName, + UidWellbore = WellboreUid, + NameWellbore = WellboreName, + Uid = Uid, + Name = Name, + DTimReport = StringHelpers.ToUniversalDateTimeString(DTimReport), + MdBottom = MdBottom?.ToWitsml(), + GapAir = GapAir?.ToWitsml(), + DepthWaterMean = DepthWaterMean?.ToWitsml(), + CommonData = CommonData?.ToWitsml(), + }.AsSingletonWitsmlList(); + } } } diff --git a/Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs b/Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs index 151d94afb..57dfb3106 100644 --- a/Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/BhaRunQueries.cs @@ -83,8 +83,8 @@ public static WitsmlBhaRuns CreateBhaRun(BhaRun bhaRun) NumStringRun = bhaRun.NumStringRun, Tubular = new WitsmlRefNameString { - UidRef = bhaRun.TubularUidRef, - Value = bhaRun.Tubular + UidRef = bhaRun.Tubular.UidRef, + Value = bhaRun.Tubular.Value }, StatusBha = bhaRun.StatusBha ?? null, NumBitRun = bhaRun.NumBitRun, diff --git a/Src/WitsmlExplorer.Api/Query/RiskQueries.cs b/Src/WitsmlExplorer.Api/Query/RiskQueries.cs index 452fb9f83..333e1dd95 100644 --- a/Src/WitsmlExplorer.Api/Query/RiskQueries.cs +++ b/Src/WitsmlExplorer.Api/Query/RiskQueries.cs @@ -135,7 +135,7 @@ public static WitsmlRisks CreateRisk(Risk risk) Summary = risk.Summary, Details = risk.Details, Identification = risk.Identification, - Contingency = risk.Contigency, + Contingency = risk.Contingency, Mitigation = risk.Mitigation, CommonData = new WitsmlCommonData() { diff --git a/Src/WitsmlExplorer.Api/Services/BhaRunService.cs b/Src/WitsmlExplorer.Api/Services/BhaRunService.cs index 85660ac8a..09a986573 100644 --- a/Src/WitsmlExplorer.Api/Services/BhaRunService.cs +++ b/Src/WitsmlExplorer.Api/Services/BhaRunService.cs @@ -46,8 +46,11 @@ private static BhaRun WitsmlToBhaRun(WitsmlBhaRun bhaRun) WellboreName = bhaRun.NameWellbore, WellboreUid = bhaRun.UidWellbore, NumStringRun = bhaRun.NumStringRun, - Tubular = bhaRun.Tubular?.Value, - TubularUidRef = bhaRun.Tubular?.UidRef, + Tubular = new RefNameString + { + UidRef = bhaRun.Tubular?.UidRef, + Value = bhaRun.Tubular?.Value + }, StatusBha = bhaRun.StatusBha ?? null, NumBitRun = bhaRun.NumBitRun, ReasonTrip = bhaRun.ReasonTrip, diff --git a/Src/WitsmlExplorer.Api/Services/ObjectService.cs b/Src/WitsmlExplorer.Api/Services/ObjectService.cs index 87338e47b..6d7902cf6 100644 --- a/Src/WitsmlExplorer.Api/Services/ObjectService.cs +++ b/Src/WitsmlExplorer.Api/Services/ObjectService.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -137,7 +136,7 @@ public async Task> GetObjectIdOnly(string wellUid, } // return ObjectOnWellbore to avoid serializing null fields from concrete WITSML types return result.Objects.Select((obj) => - new ObjectOnWellbore() + new BaseObjectOnWellbore() { Uid = obj.Uid, WellboreUid = obj.UidWellbore, @@ -146,7 +145,7 @@ public async Task> GetObjectIdOnly(string wellUid, WellboreName = obj.NameWellbore, WellName = obj.NameWell } - ).ToList(); + ).ToArray(); } public async Task> GetExpandableObjectsCount(string wellUid, string wellboreUid) diff --git a/Src/WitsmlExplorer.Api/Services/TrajectoryService.cs b/Src/WitsmlExplorer.Api/Services/TrajectoryService.cs index cb85c9854..290dd132d 100644 --- a/Src/WitsmlExplorer.Api/Services/TrajectoryService.cs +++ b/Src/WitsmlExplorer.Api/Services/TrajectoryService.cs @@ -69,13 +69,13 @@ public async Task> GetTrajectoryStations(string wellUid, SagCorUsed = tStation.SagCorUsed, MagDrlstrCorUsed = tStation.MagDrlstrCorUsed, GravTotalFieldReference = LengthMeasure.FromWitsml(tStation.GravTotalFieldReference), - MagTotalFieldReference = LengthMeasure.FromWitsml(tStation.DipAngleUncert), - MagDipAngleReference = LengthMeasure.FromWitsml(tStation.DipAngleUncert), - StatusTrajStation = LengthMeasure.FromWitsml(tStation.DipAngleUncert), - GravAxialRaw = LengthMeasure.FromWitsml(tStation.DipAngleUncert), - GravTran1Raw = LengthMeasure.FromWitsml(tStation.DipAngleUncert), - GravTran2Raw = LengthMeasure.FromWitsml(tStation.DipAngleUncert), - MagAxialRaw = LengthMeasure.FromWitsml(tStation.DipAngleUncert), + MagTotalFieldReference = LengthMeasure.FromWitsml(tStation.MagTotalFieldReference), + MagDipAngleReference = LengthMeasure.FromWitsml(tStation.MagDipAngleReference), + StatusTrajStation = tStation.StatusTrajStation, + GravAxialRaw = LengthMeasure.FromWitsml(tStation.GravAxialRaw), + GravTran1Raw = LengthMeasure.FromWitsml(tStation.GravTran1Raw), + GravTran2Raw = LengthMeasure.FromWitsml(tStation.GravTran2Raw), + MagAxialRaw = LengthMeasure.FromWitsml(tStation.MagAxialRaw), RawData = new TrajRawData() { @@ -115,8 +115,8 @@ private static Trajectory WitsmlToTrajectory(WitsmlTrajectory trajectory) Name = trajectory.Name, WellName = trajectory.NameWell, WellboreName = trajectory.NameWellbore, - MdMin = (trajectory.MdMin == null) ? null : StringHelpers.ToDecimal(trajectory.MdMin.Value), - MdMax = (trajectory.MdMax == null) ? null : StringHelpers.ToDecimal(trajectory.MdMax.Value), + MdMin = MeasureWithDatum.FromWitsml(trajectory.MdMin), + MdMax = MeasureWithDatum.FromWitsml(trajectory.MdMax), AziRef = trajectory.AziRef, DTimTrajStart = trajectory.DTimTrajStart, DTimTrajEnd = trajectory.DTimTrajEnd, diff --git a/Src/WitsmlExplorer.Frontend/__testUtils__/testUtils.tsx b/Src/WitsmlExplorer.Frontend/__testUtils__/testUtils.tsx index e0776f8db..b98f02503 100644 --- a/Src/WitsmlExplorer.Frontend/__testUtils__/testUtils.tsx +++ b/Src/WitsmlExplorer.Frontend/__testUtils__/testUtils.tsx @@ -24,6 +24,7 @@ import MudLog from "../models/mudLog"; import ObjectOnWellbore from "../models/objectOnWellbore"; import ObjectSearchResult from "../models/objectSearchResult"; import { ObjectType, ObjectTypeToModel } from "../models/objectType"; +import RefNameString from "../models/refNameString"; import Rig from "../models/rig"; import RiskObject from "../models/riskObject"; import { Server } from "../models/server"; @@ -179,8 +180,7 @@ export function getBhaRun(overrides?: Partial): BhaRun { return { ...getObjectOnWellbore(), numStringRun: "", - tubular: "", - tubularUidRef: "", + tubular: getRefNameString(), dTimStart: "", dTimStop: "", dTimStartDrilling: "", @@ -312,8 +312,8 @@ export function getRisk(overrides?: Partial): RiskObject { export function getTrajectory(overrides?: Partial): Trajectory { return { ...getObjectOnWellbore(), - mdMin: 0, - mdMax: 0, + mdMin: getMeasureWithDatum(), + mdMax: getMeasureWithDatum(), aziRef: "", dTimTrajStart: "", dTimTrajEnd: "", @@ -436,6 +436,14 @@ export function getStratigraphicStruct(overrides?: Partial) }; } +export function getRefNameString(overrides?: Partial): RefNameString { + return { + uidRef: "", + value: "", + ...overrides + }; +} + export function getAxisDefinition(overrides?: Partial): AxisDefinition { return { uid: "axisDefinitionUid", diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/BhaRunsListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/BhaRunsListView.tsx index 072ca3bc4..4644bf107 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/BhaRunsListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/BhaRunsListView.tsx @@ -40,7 +40,8 @@ export const BhaRunsListView = (): React.ReactElement => { dTimStartDrilling: formatDateString(bhaRun.dTimStartDrilling, timeZone, dateTimeFormat), dTimStopDrilling: formatDateString(bhaRun.dTimStopDrilling, timeZone, dateTimeFormat), dTimCreation: formatDateString(bhaRun.commonData.dTimCreation, timeZone, dateTimeFormat), - dTimLastChange: formatDateString(bhaRun.commonData.dTimLastChange, timeZone, dateTimeFormat) + dTimLastChange: formatDateString(bhaRun.commonData.dTimLastChange, timeZone, dateTimeFormat), + tubular: bhaRun.tubular?.value }; }); }; diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/TrajectoriesListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/TrajectoriesListView.tsx index c3106c0b4..0ff226997 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/TrajectoriesListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/TrajectoriesListView.tsx @@ -3,6 +3,7 @@ import NavigationContext from "../../contexts/navigationContext"; import NavigationType from "../../contexts/navigationType"; import OperationContext from "../../contexts/operationContext"; import OperationType from "../../contexts/operationType"; +import { measureToString } from "../../models/measure"; import { ObjectType } from "../../models/objectType"; import Trajectory from "../../models/trajectory"; import { getContextMenuPosition } from "../ContextMenus/ContextMenu"; @@ -26,8 +27,9 @@ export const TrajectoriesListView = (): React.ReactElement => { } }, [selectedWellbore?.trajectories]); - const onContextMenu = (event: React.MouseEvent, {}, trajectories: Trajectory[]) => { - const contextProps: ObjectContextMenuProps = { checkedObjects: trajectories, wellbore: selectedWellbore }; + const onContextMenu = (event: React.MouseEvent, {}, selectedTrajectories: Trajectory[]) => { + const unchangedSelectedTrajectories = trajectories.filter((trajectory) => selectedTrajectories.some((selectedTrajectory) => selectedTrajectory.uid === trajectory.uid)); + const contextProps: ObjectContextMenuProps = { checkedObjects: unchangedSelectedTrajectories, wellbore: selectedWellbore }; const position = getContextMenuPosition(event); dispatchOperation({ type: OperationType.DisplayContextMenu, payload: { component: , position } }); }; @@ -61,6 +63,8 @@ export const TrajectoriesListView = (): React.ReactElement => { dTimTrajEnd: formatDateString(trajectory.dTimTrajEnd, timeZone, dateTimeFormat), dateTimeCreation: formatDateString(trajectory.commonData.dTimCreation, timeZone, dateTimeFormat), dateTimeLastChange: formatDateString(trajectory.commonData.dTimLastChange, timeZone, dateTimeFormat), + mdMin: measureToString(trajectory.mdMin), + mdMax: measureToString(trajectory.mdMax), id: trajectory.uid }; }); diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/BhaRunPropertiesModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/BhaRunPropertiesModal.tsx index d40f1e03f..679996402 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/BhaRunPropertiesModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/BhaRunPropertiesModal.tsx @@ -84,19 +84,19 @@ const BhaRunPropertiesModal = (props: BhaRunPropertiesModalProps): React.ReactEl id={"tubular"} label={"tubular"} required - value={editableBhaRun.tubular ?? ""} - error={editableBhaRun.tubular?.length === 0} + value={editableBhaRun.tubular?.value ?? ""} + error={editableBhaRun.tubular?.value?.length === 0} fullWidth - onChange={(e) => setEditableBhaRun({ ...editableBhaRun, tubular: e.target.value })} + onChange={(e) => setEditableBhaRun({ ...editableBhaRun, tubular: { ...editableBhaRun.tubular, value: e.target.value } })} /> setEditableBhaRun({ ...editableBhaRun, tubularUidRef: e.target.value })} + onChange={(e) => setEditableBhaRun({ ...editableBhaRun, tubular: { ...editableBhaRun.tubular, uidRef: e.target.value } })} /> setEditableTrajectory({ ...editableTrajectory, - mdMin: isNaN(parseFloat(e.target.value)) ? undefined : parseFloat(e.target.value) + mdMin: { + ...editableTrajectory.mdMin, + value: isNaN(parseFloat(e.target.value)) ? undefined : parseFloat(e.target.value) + } }) } /> @@ -129,11 +132,14 @@ const TrajectoryPropertiesModal = (props: TrajectoryPropertiesModalProps): React type="number" disabled fullWidth - value={editableTrajectory.mdMax} + value={editableTrajectory.mdMax?.value ?? ""} onChange={(e) => setEditableTrajectory({ ...editableTrajectory, - mdMax: isNaN(parseFloat(e.target.value)) ? undefined : parseFloat(e.target.value) + mdMax: { + ...editableTrajectory.mdMax, + value: isNaN(parseFloat(e.target.value)) ? undefined : parseFloat(e.target.value) + } }) } /> diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/TrajectoryStationPropertiesModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/TrajectoryStationPropertiesModal.tsx index d790d4c23..31c77abf3 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/TrajectoryStationPropertiesModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/TrajectoryStationPropertiesModal.tsx @@ -4,6 +4,7 @@ import OperationContext from "../../contexts/operationContext"; import { HideModalAction } from "../../contexts/operationStateReducer"; import OperationType from "../../contexts/operationType"; import ObjectReference from "../../models/jobs/objectReference"; +import { measureToString } from "../../models/measure"; import { toObjectReference } from "../../models/objectOnWellbore"; import Trajectory from "../../models/trajectory"; import TrajectoryStation from "../../models/trajectoryStation"; @@ -11,7 +12,6 @@ import JobService, { JobType } from "../../services/jobService"; import formatDateString from "../DateFormatter"; import { DateTimeField } from "./DateTimeField"; import ModalDialog from "./ModalDialog"; -import { measureToString } from "../../models/measure"; export interface TrajectoryStationPropertiesModalInterface { trajectoryStation: TrajectoryStation; @@ -158,7 +158,7 @@ const TrajectoryStationPropertiesModal = (props: TrajectoryStationPropertiesModa fullWidth /> - + diff --git a/Src/WitsmlExplorer.Frontend/contexts/stateReducerTestUtils.ts b/Src/WitsmlExplorer.Frontend/contexts/stateReducerTestUtils.ts index 228233b70..794cca756 100644 --- a/Src/WitsmlExplorer.Frontend/contexts/stateReducerTestUtils.ts +++ b/Src/WitsmlExplorer.Frontend/contexts/stateReducerTestUtils.ts @@ -1,3 +1,4 @@ +import { getMeasureWithDatum } from "../__testUtils__/testUtils"; import BhaRun from "../models/bhaRun"; import ChangeLog from "../models/changeLog"; import FormationMarker from "../models/formationMarker"; @@ -56,7 +57,7 @@ export const BHARUN_1: BhaRun = { wellboreName: "", wellName: "", numStringRun: "", - tubular: "", + tubular: null, dTimStart: null, dTimStop: null, dTimStartDrilling: null, @@ -68,8 +69,7 @@ export const BHARUN_1: BhaRun = { numBitRun: "", reasonTrip: "", objectiveBha: "", - commonData: null, - tubularUidRef: "" + commonData: null }; export const CHANGELOG_1: ChangeLog = { uid: "changelog", @@ -102,8 +102,8 @@ export const TRAJECTORY_1: Trajectory = { wellboreName: "", wellName: "", aziRef: "", - mdMax: 0, - mdMin: 0, + mdMax: getMeasureWithDatum(), + mdMin: getMeasureWithDatum(), trajectoryStations: [], dTimTrajEnd: null, dTimTrajStart: null, diff --git a/Src/WitsmlExplorer.Frontend/models/bhaRun.tsx b/Src/WitsmlExplorer.Frontend/models/bhaRun.tsx index 036d923a7..21ed04398 100644 --- a/Src/WitsmlExplorer.Frontend/models/bhaRun.tsx +++ b/Src/WitsmlExplorer.Frontend/models/bhaRun.tsx @@ -1,11 +1,11 @@ import CommonData from "./commonData"; import Measure from "./measure"; import ObjectOnWellbore from "./objectOnWellbore"; +import RefNameString from "./refNameString"; export default interface BhaRun extends ObjectOnWellbore { numStringRun: string; - tubular: string; - tubularUidRef: string; + tubular: RefNameString; dTimStart: string; dTimStop: string; dTimStartDrilling: string; diff --git a/Src/WitsmlExplorer.Frontend/models/refNameString.tsx b/Src/WitsmlExplorer.Frontend/models/refNameString.tsx new file mode 100644 index 000000000..a6b5ee9ff --- /dev/null +++ b/Src/WitsmlExplorer.Frontend/models/refNameString.tsx @@ -0,0 +1,4 @@ +export default interface RefNameString { + uidRef: string; + value: string; +} diff --git a/Src/WitsmlExplorer.Frontend/models/trajectory.tsx b/Src/WitsmlExplorer.Frontend/models/trajectory.tsx index 341c250bd..443ec35ac 100644 --- a/Src/WitsmlExplorer.Frontend/models/trajectory.tsx +++ b/Src/WitsmlExplorer.Frontend/models/trajectory.tsx @@ -1,10 +1,11 @@ +import CommonData from "./commonData"; +import MeasureWithDatum from "./measureWithDatum"; import ObjectOnWellbore from "./objectOnWellbore"; import TrajectoryStation from "./trajectoryStation"; -import CommonData from "./commonData"; export default interface Trajectory extends ObjectOnWellbore { - mdMin: number; - mdMax: number; + mdMin: MeasureWithDatum; + mdMax: MeasureWithDatum; aziRef: string; dTimTrajStart: string; dTimTrajEnd: string; diff --git a/Src/WitsmlExplorer.Frontend/models/trajectoryStation.tsx b/Src/WitsmlExplorer.Frontend/models/trajectoryStation.tsx index 4377b1475..9cc57b761 100644 --- a/Src/WitsmlExplorer.Frontend/models/trajectoryStation.tsx +++ b/Src/WitsmlExplorer.Frontend/models/trajectoryStation.tsx @@ -1,7 +1,7 @@ import Measure from "./measure"; -import TrajRawData from "./trajRawData"; import StnTrajCorUsed from "./stnTrajCorUsed"; import StnTrajValid from "./stnTrajValid"; +import TrajRawData from "./trajRawData"; export default interface TrajectoryStation { uid: string; @@ -27,7 +27,7 @@ export default interface TrajectoryStation { gravTotalFieldReference?: Measure; magTotalFieldReference?: Measure; magDipAngleReference?: Measure; - statusTrajStation?: Measure; + statusTrajStation?: string; gravAxialRaw?: Measure; gravTran1Raw?: Measure; gravTran2Raw?: Measure;