示例#1
0
        public static async Task <bool> WaitForRunToBePlannedAsync(
            EventEntity eventEntity,
            CasterApiClient casterApiClient,
            int loopIntervalSeconds,
            int maxWaitMinutes,
            ILogger logger,
            CancellationToken ct)
        {
            if (eventEntity.RunId == null)
            {
                return(false);
            }
            var endTime = DateTime.UtcNow.AddMinutes(maxWaitMinutes);
            var status  = RunStatus.Planning;

            while ((status == RunStatus.Queued || status == RunStatus.Planning) && DateTime.UtcNow < endTime)
            {
                var casterRun = await casterApiClient.GetRunAsync((Guid)eventEntity.RunId, false, false);

                status = casterRun.Status;
                // if not there yet, pause before the next check
                if (status == RunStatus.Planning || status == RunStatus.Queued)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(loopIntervalSeconds));
                }
            }
            if (status == RunStatus.Planned)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        public static async Task <bool> WaitForRunToBeAppliedAsync(
            ImplementationEntity implementationEntity,
            CasterApiClient casterApiClient,
            int loopIntervalSeconds,
            int maxWaitMinutes,
            CancellationToken ct)
        {
            if (implementationEntity.RunId == null)
            {
                return(false);
            }
            var endTime = DateTime.UtcNow.AddMinutes(maxWaitMinutes);
            var status  = "Applying";

            while (status == "Applying" && DateTime.UtcNow < endTime)
            {
                var casterRun = await casterApiClient.GetRunAsync((Guid)implementationEntity.RunId);

                status = casterRun.Status;
                // if not there yet, pause before the next check
                if (status == "Applying")
                {
                    Thread.Sleep(TimeSpan.FromSeconds(loopIntervalSeconds));
                }
            }
            if (status == "Applied")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }