Exemplo n.º 1
0
        protected async Task Submit(SubmitEntry entry)
        {
            logger.LogInformation("Weight.SubmitRequest '{0}'", entry.Request.ClanName);
            entry.Status.UpdatePhase(SubmitPhase.Running);
            var changes = GetChangesCount(entry.Request);

            logger.LogInformation("Weight.SubmitChanges {0}", changes);
            if (changes < Constants.MIN_WEIGHT_CHANGES_ON_SUBMIT)
            {
                entry.Status.Message = "Too few weight changes since last submit.";
                logger.LogInformation("Weight.SubmitResponse {0}", entry.Status.Message);
                entry.Status.UpdatePhase(SubmitPhase.Failed);
                return;
            }
            entry.Status.Message = "Calling Submit Script";
            entry.Request.Mode   = "submit";
            var submitResponse = await NewSubmit(entry.Request);

            entry.Status.Message = submitResponse.ToString();
            logger.LogInformation("Weight.SubmitResponse {0}", submitResponse.ToString());
            var runningSecs = Convert.ToInt32(DateTime.UtcNow.Subtract(entry.Status.Timestamp).TotalSeconds);

            if (runningSecs > 15)
            {
                logger.LogWarning("Submit took {0} seconds", runningSecs);
            }
            var submitPhase = submitResponse.Status ? SubmitPhase.Succeeded : SubmitPhase.Failed;

            entry.Status.UpdatePhase(submitPhase);
            if (submitResponse.Status)
            {
                await UpdateOnSuccess(entry.Request);
            }
        }
Exemplo n.º 2
0
        public void Queue(SubmitRequest request)
        {
            logger.LogInformation("Queued {0} [{1}]", request.ClanTag, request.Members.Count);

            var entry = new SubmitEntry
            {
                Request = request,
                Status  = new SubmitStatus
                {
                    Phase     = SubmitPhase.Queued,
                    Timestamp = DateTime.UtcNow,
                    Message   = "Queued"
                }
            };

            q.Enqueue(entry);
        }