private static async Task <WitsmlTrajectory> GetTrajectory(IWitsmlClient client, TrajectoryReference trajectoryReference) { var trajectoryQuery = TrajectoryQueries.QueryById(trajectoryReference.WellUid, trajectoryReference.WellboreUid, trajectoryReference.TrajectoryUid); var result = await client.GetFromStoreAsync(trajectoryQuery, OptionsIn.All); return(!result.Trajectories.Any() ? null : result.Trajectories.First()); }
public async Task CreateTrajectory_BasedOnExisting() { const string wellUid = ""; const string wellboreUid = ""; const string trajectoryUid = ""; var queryExisting = TrajectoryQueries.QueryById(wellUid, wellboreUid, trajectoryUid); var existingTrajectories = await client.GetFromStoreAsync(queryExisting, OptionsIn.All); var existing = existingTrajectories.Trajectories.First(); var createTrajectoryQuery = CreateTrajectoryQuery( existing.UidWell, existing.NameWell, existing.UidWellbore, existing.NameWellbore, existing.Name + " (copy)", existing.TrajectoryStations, existing.CommonData, existing.AziRef, existing.MdMin, existing.MdMax, existing.DTimTrajStart, existing.DTimTrajEnd ); var result = await client.AddToStoreAsync(createTrajectoryQuery); Assert.True(result.IsSuccessful); output.WriteLine("Created trajectory with uid: " + createTrajectoryQuery.Trajectories.First().Uid); }
public async Task <WorkerResult> Execute(DeleteTrajectoryJob job) { var wellUid = job.TrajectoryReference.WellUid; var wellboreUid = job.TrajectoryReference.WellboreUid; var trajectoryUid = job.TrajectoryReference.TrajectoryUid; var query = TrajectoryQueries.QueryById(wellUid, wellboreUid, trajectoryUid); var result = await witsmlClient.DeleteFromStoreAsync(query); if (result.IsSuccessful) { Log.Information("{JobType} - Job successful.", GetType().Name); return(new WorkerResult(witsmlClient.GetServerHostname(), true, $"Deleted trajectory: ${trajectoryUid}")); } Log.Error("Failed to delete trajectory. WellUid: {WellUid}, WellboreUid: {WellboreUid}, Uid: {TrajectoryUid}", wellUid, wellboreUid, trajectoryUid); query = TrajectoryQueries.QueryById(wellUid, wellboreUid, trajectoryUid); var queryResult = await witsmlClient.GetFromStoreAsync(query, OptionsIn.IdOnly); var trajectory = queryResult.Trajectories.First(); EntityDescription description = null; if (trajectory != null) { description = new EntityDescription { WellName = trajectory.NameWell, WellboreName = trajectory.NameWellbore, ObjectName = trajectory.Name }; } return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to delete trajectory", result.Reason, description)); }
public async Task <List <TrajectoryStation> > GetTrajectoryStations(string wellUid, string wellboreUid, string trajectoryUid) { var query = TrajectoryQueries.QueryById(wellUid, wellboreUid, trajectoryUid); var result = await WitsmlClient.GetFromStoreAsync(query, OptionsIn.All); var witsmlTrajectory = result.Trajectories.FirstOrDefault(); if (witsmlTrajectory == null) { return(null); } return(witsmlTrajectory.TrajectoryStations.Select(tStation => new TrajectoryStation { Uid = tStation.Uid, DTimStn = StringHelpers.ToDateTime(tStation.DTimStn), TypeTrajStation = tStation.TypeTrajStation, Md = StringHelpers.ToDecimal(tStation.Md?.Value), Tvd = StringHelpers.ToDecimal(tStation.Tvd?.Value), Incl = StringHelpers.ToDecimal(tStation.Incl?.Value), Azi = StringHelpers.ToDecimal(tStation.Azi?.Value) }) .OrderBy(tStation => tStation.Md) .ToList()); }