-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
903 additions
and
813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace Witsml.Extensions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace Witsml.Extensions; | ||
|
||
public static class UriExtensions | ||
{ | ||
/// <summary> | ||
/// Determines whether two specified Uri objects have the same value ignore case. | ||
/// </summary> | ||
/// The first Uri to compare. | ||
/// The second Uri to compare. | ||
/// <returns>True if the value of the <paramref name="firstUri" /> parameter is equal to the value of the <paramref name="secondUri" />, otherwise return false.</returns> | ||
public static bool EqualsIgnoreCase(this Uri firstUri, Uri secondUri) | ||
{ | ||
return string.Equals(firstUri?.AbsoluteUri, secondUri?.AbsoluteUri, StringComparison.OrdinalIgnoreCase); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using WitsmlExplorer.Api.Models; | ||
|
||
namespace WitsmlExplorer.Api.Jobs; | ||
|
||
/// <summary> | ||
/// Job for create trajectory with jobInfo. | ||
/// </summary> | ||
public record CreateTrajectoryJob : Job | ||
{ | ||
/// <summary> | ||
/// Trajectory API model. | ||
/// </summary> | ||
public Trajectory Trajectory { get; init; } | ||
|
||
/// <summary> | ||
/// Getting description of created trajectory. | ||
/// </summary> | ||
/// <returns>String of job info which provide Trajectory Uid and Name, WellUid, WellboreUid.</returns> | ||
public override string Description() | ||
{ | ||
return $"Create Trajectory - Uid: {Trajectory.Uid}; Name: {Trajectory.Name}; WellUid: {Trajectory.WellUid}; WellboreUid: {Trajectory.WellboreUid};"; | ||
} | ||
|
||
/// <summary> | ||
/// Getting name of trajectory. | ||
/// </summary> | ||
/// <returns>String of trajectory name.</returns> | ||
public override string GetObjectName() | ||
{ | ||
return Trajectory.Name; | ||
} | ||
|
||
/// <summary> | ||
/// Getting name of wellbore. | ||
/// </summary> | ||
/// <returns>String of wellbore name.</returns> | ||
public override string GetWellboreName() | ||
{ | ||
return Trajectory.WellboreName; | ||
} | ||
|
||
/// <summary> | ||
/// Getting name of well. | ||
/// </summary> | ||
/// <returns>String of well name.</returns> | ||
public override string GetWellName() | ||
{ | ||
return Trajectory.WellName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
Src/WitsmlExplorer.Api/Workers/Create/CreateTrajectoryWorker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
using Witsml; | ||
using Witsml.Data; | ||
|
||
using WitsmlExplorer.Api.Jobs; | ||
using WitsmlExplorer.Api.Models; | ||
using WitsmlExplorer.Api.Query; | ||
using WitsmlExplorer.Api.Services; | ||
|
||
namespace WitsmlExplorer.Api.Workers.Create; | ||
|
||
/// <summary> | ||
/// Worker for creating new trajectory by specific well and wellbore. | ||
/// </summary> | ||
public class CreateTrajectoryWorker : BaseWorker<CreateTrajectoryJob>, IWorker | ||
{ | ||
public CreateTrajectoryWorker(ILogger<CreateTrajectoryJob> logger, IWitsmlClientProvider witsmlClientProvider) : base(witsmlClientProvider, logger) { } | ||
public JobType JobType => JobType.CreateTrajectory; | ||
|
||
/// <summary> | ||
/// Create new trajectory on wellbore for witsml client. | ||
/// </summary> | ||
/// <param name="job">Job info of created trajectory.</param> | ||
/// <returns>Task of workerResult with refresh objects.</returns> | ||
public override async Task<(WorkerResult, RefreshAction)> Execute(CreateTrajectoryJob job) | ||
{ | ||
Verify(job.Trajectory); | ||
|
||
WitsmlTrajectories trajectoryToCreate = TrajectoryQueries.CreateTrajectory(job.Trajectory); | ||
|
||
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"); | ||
} | ||
} | ||
} |
Oops, something went wrong.