public async Task <(WorkerResult, RefreshWell)> Execute(DeleteWellJob job) { var wellUid = job.WellReference.WellUid; var query = WellQueries.DeleteQuery(wellUid); var result = await witsmlClient.DeleteFromStoreAsync(query); if (result.IsSuccessful) { Log.Information("{JobType} - Job successful.", GetType().Name); var refreshAction = new RefreshWell(witsmlClient.GetServerHostname(), wellUid, RefreshType.Remove); var workerResult = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Deleted well with uid ${wellUid}"); return(workerResult, refreshAction); } Log.Error("Failed to delete well. WellUid: {WellUid}", wellUid); query = WellQueries.QueryByUid(wellUid); var queryResult = await witsmlClient.GetFromStoreAsync(query, OptionsIn.IdOnly); EntityDescription description = null; var wellbore = queryResult.Wells.FirstOrDefault(); if (wellbore != null) { description = new EntityDescription { ObjectName = wellbore.Name }; } return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to delete well", result.Reason, description), null); }
public override async Task <(WorkerResult, RefreshAction)> Execute(DeleteRiskJob job) { var wellUid = job.RiskReference.WellUid; var wellboreUid = job.RiskReference.WellboreUid; var uid = job.RiskReference.Uid; var deleteRequest = RiskQueries.DeleteRiskQuery(wellUid, wellboreUid, uid); var result = await witsmlClient.DeleteFromStoreAsync(deleteRequest); if (result.IsSuccessful) { Log.Information("{JobType} - Job successful", GetType().Name); var refreshAction = new RefreshWell(witsmlClient.GetServerHostname(), wellUid, RefreshType.Remove); var workerResult = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Deleted well with uid ${wellUid}"); return(workerResult, refreshAction); } Log.Error("Failed to delete risk. WellUid: {WellUid}", wellUid); var query = RiskQueries.QueryById(wellUid, wellboreUid, uid); var queryResult = await witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.IdOnly)); EntityDescription description = null; var risk = queryResult.Risks.FirstOrDefault(); if (risk != null) { description = new EntityDescription { ObjectName = risk.Name }; } return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to delete risk", result.Reason, description), null); }
public override async Task <(WorkerResult, RefreshAction)> Execute(CreateWellJob job) { var well = job.Well; Verify(well); var wellToCreate = WellQueries.CreateWitsmlWell(well); var result = await witsmlClient.AddToStoreAsync(wellToCreate); if (result.IsSuccessful) { Log.Information("{JobType} - Job successful", GetType().Name); await WaitUntilWellHasBeenCreated(well); var workerResult = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Well created ({well.Name} [{well.Uid}])"); var refreshAction = new RefreshWell(witsmlClient.GetServerHostname(), well.Uid, RefreshType.Add); return(workerResult, refreshAction); } var description = new EntityDescription { WellName = well.Name }; Log.Error("Job failed. An error occurred when creating well: {Well}", job.Well.PrintProperties()); return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to create well", result.Reason, description), null); }
public override async Task <(WorkerResult, RefreshAction)> Execute(ModifyWellJob job) { Verify(job.Well); var wellUid = job.Well.Uid; var wellName = job.Well.Name; var witsmlWellToUpdate = WellQueries.UpdateWitsmlWell(job.Well); var result = await witsmlClient.UpdateInStoreAsync(witsmlWellToUpdate); if (result.IsSuccessful) { Log.Information("{JobType} - Job successful", GetType().Name); var workerResult = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Well updated ({wellName} [{wellUid}])"); var refreshAction = new RefreshWell(witsmlClient.GetServerHostname(), job.Well.Uid, RefreshType.Update); return(workerResult, refreshAction); } var updatedWells = await witsmlClient.GetFromStoreAsync(witsmlWellToUpdate, new OptionsIn(ReturnElements.IdOnly)); var updatedWell = updatedWells.Wells.First(); var description = new EntityDescription { WellName = updatedWell.Name }; Log.Error("Job failed. An error occurred when modifying well: {Well}", job.Well.PrintProperties()); return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to update well", result.Reason, description), null); }