Beispiel #1
0
        /// <summary>
        /// Purges the history of orchestrations and entities based on a set of filters.
        /// </summary>
        /// <remarks>
        /// This method will purge at most 1000 instances. The caller can purge more than this by calling the method
        /// multiple times, checking for a non-zero return value after each call.
        /// </remarks>
        /// <param name="createdTimeFrom">The minimum creation time filter. Only instances created after this date are purged.</param>
        /// <param name="createdTimeTo">The maximum creation time filter. Only instances created before this date are purged.</param>
        /// <param name="runtimeStatus">The set of orchestration status values to filter orchestrations by.</param>
        /// <returns>Returns the number of purged instances.</returns>
        public override async Task <int> PurgeHistoryByFilters(DateTime createdTimeFrom, DateTime?createdTimeTo, IEnumerable <OrchestrationStatus> runtimeStatus)
        {
            var purgeFilter = new PurgeInstanceFilter(createdTimeFrom, createdTimeTo, runtimeStatus);
            var purgeResult = await this.service.PurgeInstanceStateAsync(purgeFilter);

            return(purgeResult.DeletedInstanceCount);
        }
        public override async Task <PurgeResult> PurgeInstanceStateAsync(PurgeInstanceFilter purgeInstanceFilter)
        {
            var purgeQuery = new SqlOrchestrationQuery
            {
                PageSize        = 1000,
                CreatedTimeFrom = purgeInstanceFilter.CreatedTimeFrom,
                FetchInput      = false,
                FetchOutput     = false,
            };

            if (purgeInstanceFilter.CreatedTimeTo != null)
            {
                purgeQuery.CreatedTimeTo = purgeInstanceFilter.CreatedTimeTo.Value;
            }

            if (purgeInstanceFilter.RuntimeStatus?.Any() == true)
            {
                purgeQuery.StatusFilter = new HashSet <OrchestrationStatus>(purgeInstanceFilter.RuntimeStatus);
            }

            IReadOnlyCollection <OrchestrationState> results = await this.GetManyOrchestrationsAsync(purgeQuery, CancellationToken.None);

            IEnumerable <string> instanceIds = results.Select(r => r.OrchestrationInstance.InstanceId);
            int purgedInstanceCount          = await this.PurgeOrchestrationHistoryAsync(instanceIds);

            return(new PurgeResult(purgedInstanceCount));
        }
Beispiel #3
0
 public abstract Task <PurgeResult> PurgeInstanceStateAsync(PurgeInstanceFilter purgeInstanceFilter);