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(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);
        }
Beispiel #3
0
        public override async Task <(WorkerResult, RefreshAction)> Execute(ModifyWellboreJob job)
        {
            Verify(job.Wellbore);

            var witsmlWellbore = WellboreQueries.UpdateWitsmlWellbore(job.Wellbore);
            var result         = await witsmlClient.UpdateInStoreAsync(witsmlWellbore);

            if (result.IsSuccessful)
            {
                Log.Information("{JobType} - Job successful", GetType().Name);
                var workerResult  = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Wellbore updated ({job.Wellbore.Name} [{job.Wellbore.Uid}])");
                var refreshAction = new RefreshWellbore(witsmlClient.GetServerHostname(), job.Wellbore.WellUid, job.Wellbore.Uid, RefreshType.Update);
                return(workerResult, refreshAction);
            }
            var updatedWellbores = await witsmlClient.GetFromStoreAsync(witsmlWellbore, new OptionsIn(ReturnElements.IdOnly));

            var updatedWellbore = updatedWellbores.Wellbores.First();
            var description     = new EntityDescription
            {
                WellName     = updatedWellbore.NameWell,
                WellboreName = updatedWellbore.Name
            };

            Log.Error("Job failed. An error occurred when modifying wellbore: {Wellbore}", job.Wellbore.PrintProperties());
            return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to update wellbore", result.Reason, description), null);
        }
Beispiel #4
0
        public override async Task <(WorkerResult, RefreshAction)> Execute(CreateRiskJob job)
        {
            var risk = job.Risk;

            Verify(risk);

            var riskToCreate = SetupRiskToCreate(risk);

            var result = await witsmlClient.AddToStoreAsync(riskToCreate);

            if (result.IsSuccessful)
            {
                await WaitUntilRiskHasBeenCreated(risk);

                Log.Information("{JobType} - Job successful", GetType().Name);
                var workerResult  = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Risk created ({risk.Name} [{risk.Uid}])");
                var refreshAction = new RefreshWellbore(witsmlClient.GetServerHostname(), risk.UidWell, risk.Uid, RefreshType.Add);
                return(workerResult, refreshAction);
            }

            var description = new EntityDescription {
                WellboreName = risk.NameWellbore
            };

            Log.Error($"Job failed. An error occurred when creating Risk: {job.Risk.PrintProperties()}");
            return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to create Risk", 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);
        }
Beispiel #6
0
        public async Task <(WorkerResult, RefreshAction)> Execute(ModifyWellJob job)
        {
            Verify(job.Well);
            var wellUid  = job.Well.Uid;
            var wellName = job.Well.Name;
            var query    = WellQueries.UpdateQuery(wellUid, wellName);

            var result = await witsmlClient.UpdateInStoreAsync(query);

            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(query, OptionsIn.IdOnly);

            var updatedWell = updatedWells.Wells.First();
            var description = new EntityDescription
            {
                WellName = updatedWell.Name
            };

            Log.Error($"Job failed. An error occurred when modifying well: {job.Well.PrintProperties()}");
            return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to update well", result.Reason, description), null);
        }
        public async Task <(WorkerResult, RefreshAction)> Execute(CreateWellboreJob job)
        {
            var wellbore = job.Wellbore;

            Verify(wellbore);

            var wellboreToCreate = SetupWellboreToCreate(wellbore);

            var result = await witsmlClient.AddToStoreAsync(wellboreToCreate);

            if (result.IsSuccessful)
            {
                await WaitUntilWellboreHasBeenCreated(wellbore);

                Log.Information("{JobType} - Job successful", GetType().Name);
                var workerResult  = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Wellbore created ({wellbore.Name} [{wellbore.Uid}])");
                var refreshAction = new RefreshWellbore(witsmlClient.GetServerHostname(), wellbore.WellUid, wellbore.Uid, RefreshType.Add);
                return(workerResult, refreshAction);
            }

            var description = new EntityDescription {
                WellboreName = wellbore.Name
            };

            Log.Error($"Job failed. An error occurred when creating wellbore: {job.Wellbore.PrintProperties()}");
            return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to create wellbore", result.Reason, description), null);
        }
Beispiel #8
0
        public override async Task <(WorkerResult, RefreshAction)> Execute(CreateMudLogJob job)
        {
            var mudLog = job.MudLog;

            Verify(mudLog);

            var mudLogToCreate = SetupMudLogToCreate(mudLog);

            var result = await witsmlClient.AddToStoreAsync(mudLogToCreate);

            if (result.IsSuccessful)
            {
                await WaitUntilMudLogHasBeenCreated(mudLog);

                Log.Information("{JobType} - Job successful", GetType().Name);
                var workerResult  = new WorkerResult(witsmlClient.GetServerHostname(), true, $"MudLog created ({mudLog.Name} [{mudLog.Uid}])");
                var refreshAction = new RefreshWellbore(witsmlClient.GetServerHostname(), mudLog.WellUid, mudLog.Uid, RefreshType.Add);
                return(workerResult, refreshAction);
            }

            var description = new EntityDescription {
                WellboreName = mudLog.WellboreName
            };

            Log.Error($"Job failed. An error occurred when creating MudLog: {job.MudLog.PrintProperties()}");
            return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to create MudLog", result.Reason, description), null);
        }
 public WorkerResult(Uri serverUrl, bool isSuccess, string message, string reason = null, EntityDescription description = null)
 {
     ServerUrl   = serverUrl;
     IsSuccess   = isSuccess;
     Message     = message;
     Reason      = reason;
     Description = description;
 }
        public async Task <(WorkerResult, RefreshAction)> Execute(ModifyLogObjectJob job)
        {
            Verify(job.LogObject);

            var wellUid     = job.LogObject.WellUid;
            var wellboreUid = job.LogObject.WellboreUid;
            var logUid      = job.LogObject.Uid;

            var query = CreateRequest(wellUid, wellboreUid, logUid,
                                      new WitsmlLog
            {
                Uid         = logUid,
                UidWell     = wellUid,
                UidWellbore = wellboreUid,
                Name        = job.LogObject.Name
            });
            var result = await witsmlClient.UpdateInStoreAsync(query);

            if (result.IsSuccessful)
            {
                Log.Information("{JobType} - Job successful", GetType().Name);
                var refreshAction = new RefreshWellbore(witsmlClient.GetServerHostname(), wellUid, wellboreUid, RefreshType.Update);
                return(new WorkerResult(witsmlClient.GetServerHostname(), true, $"Log updated ({job.LogObject.Name} [{logUid}])"), refreshAction);
            }

            Log.Error($"Job failed. An error occurred when modifying logobject: {job.LogObject.PrintProperties()}");
            var logQuery = LogQueries.QueryById(wellUid, wellboreUid, logUid);
            var logs     = await witsmlClient.GetFromStoreAsync(logQuery, OptionsIn.IdOnly);

            var log = logs.Logs.FirstOrDefault();
            EntityDescription description = null;

            if (log != null)
            {
                description = new EntityDescription
                {
                    WellName     = log.NameWell,
                    WellboreName = log.NameWellbore,
                    ObjectName   = log.Name
                };
            }

            return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to update log", result.Reason, description), null);
        }
        public override async Task <(WorkerResult, RefreshAction)> Execute(DeleteMnemonicsJob job)
        {
            var wellUid         = job.LogObject.WellUid;
            var wellboreUid     = job.LogObject.WellboreUid;
            var logUid          = job.LogObject.LogUid;
            var mnemonics       = new ReadOnlyCollection <string>(job.Mnemonics.ToList());
            var mnemonicsString = string.Join(", ", mnemonics);

            var query  = LogQueries.DeleteMnemonics(wellUid, wellboreUid, logUid, mnemonics);
            var result = await witsmlClient.DeleteFromStoreAsync(query);

            if (result.IsSuccessful)
            {
                Log.Information("{JobType} - Job successful", GetType().Name);
                var refreshAction = new RefreshLogObject(witsmlClient.GetServerHostname(), wellUid, wellboreUid, logUid, RefreshType.Update);
                var workerResult  = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Deleted mnemonics: {mnemonicsString} for log: {logUid}");
                return(workerResult, refreshAction);
            }

            Log.Error("Failed to delete mnemonics for log object. WellUid: {WellUid}, WellboreUid: {WellboreUid}, Uid: {LogUid}, Mnemonics: {MnemonicsString}",
                      wellUid,
                      wellboreUid,
                      logUid,
                      mnemonics);

            query = LogQueries.GetWitsmlLogById(wellUid, wellboreUid, logUid);
            var queryResult = await witsmlClient.GetFromStoreAsync(query, new OptionsIn(ReturnElements.IdOnly));

            var log = queryResult.Logs.First();
            EntityDescription description = null;

            if (log != null)
            {
                description = new EntityDescription
                {
                    WellName     = log.NameWell,
                    WellboreName = log.NameWellbore,
                    ObjectName   = log.Name
                };
            }

            return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to delete mnemonics", result.Reason, description), null);
        }
        public override async Task <(WorkerResult, RefreshAction)> Execute(DeleteTrajectoryJob job)
        {
            var wellUid       = job.TrajectoryReference.WellUid;
            var wellboreUid   = job.TrajectoryReference.WellboreUid;
            var trajectoryUid = job.TrajectoryReference.TrajectoryUid;

            var witsmlTrajectory = TrajectoryQueries.GetWitsmlTrajectoryById(wellUid, wellboreUid, trajectoryUid);
            var result           = await witsmlClient.DeleteFromStoreAsync(witsmlTrajectory);

            if (result.IsSuccessful)
            {
                Log.Information("{JobType} - Job successful", GetType().Name);
                var refreshAction = new RefreshWellbore(witsmlClient.GetServerHostname(), wellUid, wellboreUid, RefreshType.Update);
                return(new WorkerResult(witsmlClient.GetServerHostname(), true, $"Deleted trajectory: ${trajectoryUid}"), refreshAction);
            }

            Log.Error("Failed to delete trajectory. WellUid: {WellUid}, WellboreUid: {WellboreUid}, Uid: {TrajectoryUid}",
                      wellUid,
                      wellboreUid,
                      trajectoryUid);

            witsmlTrajectory = TrajectoryQueries.GetWitsmlTrajectoryById(wellUid, wellboreUid, trajectoryUid);
            var queryResult = await witsmlClient.GetFromStoreAsync(witsmlTrajectory, new OptionsIn(ReturnElements.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), null);
        }
Beispiel #13
0
        public override async Task <(WorkerResult, RefreshAction)> Execute(DeleteWellboreJob job)
        {
            var wellUid     = job.WellboreReference.WellUid;
            var wellboreUid = job.WellboreReference.WellboreUid;

            var witsmlWellbore = WellboreQueries.DeleteWitsmlWellbore(wellUid, wellboreUid);
            var result         = await witsmlClient.DeleteFromStoreAsync(witsmlWellbore);

            if (result.IsSuccessful)
            {
                Log.Information("{JobType} - Job successful", GetType().Name);
                var refreshAction = new RefreshWellbore(witsmlClient.GetServerHostname(), wellUid, wellboreUid, RefreshType.Remove);
                var workerResult  = new WorkerResult(witsmlClient.GetServerHostname(), true, $"Deleted wellbore: ${wellboreUid}");
                return(workerResult, refreshAction);
            }

            Log.Error("Failed to delete wellbore. WellUid: {WellUid}, WellboreUid: {WellboreUid}",
                      wellUid,
                      wellboreUid);

            witsmlWellbore = WellboreQueries.GetWitsmlWellboreByUid(wellUid, wellboreUid);
            var queryResult = await witsmlClient.GetFromStoreAsync(witsmlWellbore, new OptionsIn(ReturnElements.IdOnly));

            EntityDescription description = null;
            var wellbore = queryResult.Wellbores.FirstOrDefault();

            if (wellbore != null)
            {
                description = new EntityDescription
                {
                    WellName   = wellbore.NameWell,
                    ObjectName = wellbore.Name
                };
            }

            return(new WorkerResult(witsmlClient.GetServerHostname(), false, "Failed to delete wellbore", result.Reason, description), null);
        }