示例#1
0
        /// <remarks>
        /// Normally, an async method would have an NFW exception filter.  This
        /// one doesn't because it just calls other async methods that already
        /// have filters.
        /// </remarks>
        async Task IInteractiveWindow.SubmitAsync(IEnumerable <string> inputs)
        {
            var completion     = new TaskCompletionSource <object>();
            var submissions    = inputs.ToArray();
            var numSubmissions = submissions.Length;

            PendingSubmission[] pendingSubmissions = new PendingSubmission[numSubmissions];
            if (numSubmissions == 0)
            {
                completion.SetResult(null);
            }
            else
            {
                for (int i = 0; i < numSubmissions; i++)
                {
                    pendingSubmissions[i] = new PendingSubmission(submissions[i], i == numSubmissions - 1 ? completion : null);
                }
            }

            UIThread(uiOnly => uiOnly.Submit(pendingSubmissions));

            // This indicates that the last submission has completed.
            await completion.Task.ConfigureAwait(false);

            // These should all have finished already, but we'll await them so that their
            // statuses are folded into the task we return.
            await Task.WhenAll(pendingSubmissions.Select(p => p.Task)).ConfigureAwait(false);
        }
        internal static void SavePendingRating(RatingInputModel input)
        {
            using (var ctx = new DIHMTEntities())
            {
                var pendingRatingObject = new PendingSubmission
                {
                    GameId            = input.Id,
                    RatingExplanation = input.RatingExplanation,
                    Basically         = input.Basically,
                    TimeOfSubmission  = DateTime.UtcNow,
                    SubmitterIp       = input.SubmitterIp,
                    Comment           = input.Comment
                };

                ctx.PendingSubmissions.Add(pendingRatingObject);

                ctx.SaveChanges();

                ctx.PendingDbGameRatings.AddRange(input.Flags?.Select(x => new PendingDbGameRating {
                    PendingSubmissionId = pendingRatingObject.Id, RatingId = x
                }) ?? new List <PendingDbGameRating>());

                ctx.PendingGameLinks.AddRange(input.Links?.Select(x => new PendingGameLink {
                    PendingSubmissionId = pendingRatingObject.Id, Link = x
                }) ?? new List <PendingGameLink>());

                ctx.SaveChanges();
            }
        }
 public void Submit(PendingSubmission[] pendingSubmissions)
 {
     if (_window._stdInputStart == null)
     {
         if (State == State.WaitingForInput && _window._currentLanguageBuffer != null)
         {
             StoreUncommittedInput();
             PendSubmissions(pendingSubmissions);
             ProcessPendingSubmissions();
         }
         else
         {
             PendSubmissions(pendingSubmissions);
         }
     }
 }
 /// <summary>Implements the core of <see cref="IInteractiveWindow.SubmitAsync"/>.</summary>
 public void Submit(PendingSubmission[] pendingSubmissions)
 {
     if (!ReadingStandardInput)
     {
         if (State == State.WaitingForInput && CurrentLanguageBuffer != null)
         {
             StoreUncommittedInput();
             PendSubmissions(pendingSubmissions);
             ProcessPendingSubmissions();
         }
         else
         {
             PendSubmissions(pendingSubmissions);
         }
     }
 }