コード例 #1
0
        public static void DeleteData(IEnumerable <string> ids, IDataApiClient dataApiClient)
        {
            var tasks = new List <Task>();

            foreach (var id in ids)
            {
                var task = dataApiClient.DeleteAsync <UnitTestSearchObject>(id);
                tasks.Add(task);
            }
            Task.WaitAll(tasks.ToArray());
        }
コード例 #2
0
 private async Task RemovePostponedObject(string objectId)
 {
     postponedObjects.Remove(objectId);
     try
     {
         await dataApiClient.DeleteAsync <PostponedProcessingObject>(objectId);
     }
     catch (ApiException apiException)
     {
         if (apiException.StatusCode != HttpStatusCode.NotFound)
         {
             throw;
         }
     }
 }
コード例 #3
0
        public async Task <ExecutionResult> Action(CancellationToken cancellationToken)
        {
            var now            = DateTime.UtcNow;
            var cutoffDateTime = now - logPreservationTimeSpan;
            var query          = "SELECT _id "
                                 + $"FROM {DataApiClient.GetCollectionName<DataProcessingServiceLog>()} "
                                 + $"WHERE SubmissionTimeUtc < '{cutoffDateTime:yyyy-MM-dd HH:mm:ss}'";
            var resultStream = await dataApiClient.SearchAsync(query, ResultFormat.Json);

            var ids           = (await resultStream.ReadAllSearchResultsAsync()).Select(jObject => jObject.Value <string>("_id"));
            var deletionCount = 0;

            foreach (var id in ids)
            {
                cancellationToken.ThrowIfCancellationRequested();
                dataApiClient.DeleteAsync <DataProcessingServiceLog>(id).Wait(cancellationToken);
                deletionCount++;
            }
            return(new ExecutionResult(true, deletionCount > 0,
                                       $"Deleted all {nameof(DataProcessingServiceLog)} before '{cutoffDateTime:yyyy-MM-dd HH:mm:ss}' (count: {deletionCount})"));
        }
コード例 #4
0
        private async Task Delete()
        {
            if (StaticMessageBoxSpawner.Show(
                    $"Are you sure you want to delete '{Id}'",
                    "Delete?",
                    MessageBoxButtons.YesNo)
                != MessageBoxResult.Yes)
            {
                return;
            }

            try
            {
                await dataApiClient.DeleteAsync(DataType, Id);

                deletionCallback(this);
            }
            catch (Exception e)
            {
                StaticMessageBoxSpawner.Show($"Could not delete '{Id}': {e.InnermostException().Message}");
            }
        }