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);
        }
Beispiel #2
0
        private async Task WaitUntilWellHasBeenCreated(Well well)
        {
            var isWellCreated = false;
            var query         = WellQueries.QueryByUid(well.Uid);
            var maxRetries    = 30;

            while (!isWellCreated)
            {
                if (--maxRetries == 0)
                {
                    throw new InvalidOperationException($"Not able to read newly created well with name {well.Name} (id={well.Uid})");
                }
                Thread.Sleep(1000);
                var wellResult = await witsmlClient.GetFromStoreAsync(query, OptionsIn.IdOnly);

                isWellCreated = wellResult.Wells.Any();
            }
        }
Beispiel #3
0
        private async Task <IEnumerable <Well> > GetWellsInformation(string wellUid = null)
        {
            var start  = DateTime.Now;
            var query  = string.IsNullOrEmpty(wellUid) ? WellQueries.QueryAll() : WellQueries.QueryByUid(wellUid);
            var result = await WitsmlClient.GetFromStoreAsync(query, OptionsIn.Requested);

            var wells = result.Wells
                        .Select(well => new Well
            {
                Uid                = well.Uid,
                Name               = well.Name,
                Field              = well.Field,
                Operator           = well.Operator,
                TimeZone           = well.TimeZone,
                DateTimeCreation   = StringHelpers.ToDateTime(well.CommonData.DTimCreation),
                DateTimeLastChange = StringHelpers.ToDateTime(well.CommonData.DTimLastChange),
                ItemState          = well.CommonData.ItemState
            }
                                ).ToList();
            var elapsed = DateTime.Now.Subtract(start).Milliseconds / 1000.0;

            Log.Debug($"Fetched {wells.Count} wells in {elapsed} seconds");
            return(wells);
        }