예제 #1
0
        // Token: 0x06000024 RID: 36 RVA: 0x000030E0 File Offset: 0x000012E0
        public void HandleEvent(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item)
        {
            MailboxTransportSubmissionAssistant.IdentifyProbeMessage(mapiEvent);
            Thread currentThread = Thread.CurrentThread;

            try
            {
                Interlocked.Increment(ref this.concurrentEvents);
                this.SubmissionsInProgress[currentThread] = new SubmissionsInProgress.Entry(ExDateTime.UtcNow, this.databaseInfo.Guid, mapiEvent);
                using (new SenderGuidTraceFilter(this.databaseInfo.Guid, mapiEvent.MailboxGuid))
                {
                    bool flag = true;
                    MailboxTransportSubmissionAssistant.LatencyRecord latencyRecord;
                    LatencyTracker latencyTracker;
                    if (MailboxTransportSubmissionAssistant.eventCounterToLatencyMap.TryGetValue(mapiEvent.EventCounter, out latencyRecord))
                    {
                        MailboxTransportSubmissionAssistant.eventCounterToLatencyMap.Remove(mapiEvent.EventCounter);
                        latencyTracker = latencyRecord.LatencyTracker;
                        LatencyTracker.EndTrackLatency(latencyRecord.LatencyComponent, latencyTracker, true);
                        flag = false;
                    }
                    else
                    {
                        latencyTracker = LatencyTracker.CreateInstance(LatencyComponent.MailboxTransportSubmissionService);
                        LatencyTracker.TrackPreProcessLatency(LatencyComponent.SubmissionAssistant, latencyTracker, mapiEvent.CreateTime);
                    }
                    LatencyTracker.BeginTrackLatency(LatencyComponent.MailboxTransportSubmissionService, latencyTracker);
                    string text = this.FormatMapiEventInfo(mapiEvent);
                    this.LogMapiEventIntoCrimsonChannelPeriodically(text);
                    this.SubmissionsInProgress[Thread.CurrentThread].LatencyTracker = latencyTracker;
                    if (MailboxTransportSubmissionAssistant.ShouldLogNotifyEvents && (flag || MailboxTransportSubmissionAssistant.ShouldLogTemporaryFailures))
                    {
                        LatencyFormatter       latencyFormatter = new LatencyFormatter(latencyTracker, Components.Configuration.LocalServer.TransportServer.Fqdn, mapiEvent.CreateTime, mapiEvent.CreateTime, true, false, false);
                        MsgTrackMapiSubmitInfo msgTrackInfo     = new MsgTrackMapiSubmitInfo(text, null, string.Empty, StoreDriverSubmission.LocalIPAddress, Components.Configuration.LocalServer.TransportServer.Name, string.Empty, string.Empty, MailboxTransportSubmissionAssistant.ItemEntryId(mapiEvent), latencyFormatter.FormatAndUpdatePerfCounters(), null, false, true);
                        MessageTrackingLog.TrackNotify(msgTrackInfo, false);
                    }
                    MSExchangeSubmission.PendingSubmissions.Increment();
                    new HashSet <string>();
                    DateTime createTime = mapiEvent.CreateTime;
                    MailboxTransportSubmissionService.StoreDriverTracer.ServiceTracer.TracePfdPass <int, Guid, long>(MailboxTransportSubmissionService.StoreDriverTracer.MessageProbeActivityId, (long)this.GetHashCode(), "PFD EMS {0} SubmitMail for mailbox {1} at entry {2}", 22427, mapiEvent.MailboxGuid, mapiEvent.EventCounter);
                    LatencyFormatter latencyFormatter2 = new LatencyFormatter(latencyTracker, Components.Configuration.LocalServer.TransportServer.Fqdn, createTime, createTime, false, true, false);
                    bool             isPublicFolder    = mapiEvent.ExtendedEventFlags.HasFlag(MapiExtendedEventFlags.PublicFolderMailbox);
                    LatencyTracker.BeginTrackLatency(LatencyComponent.MailboxTransportSubmissionStoreDriverSubmission, latencyTracker);
                    ISubmissionProvider  submissionProvider   = (ISubmissionProvider)Components.StoreDriverSubmission;
                    MailSubmissionResult mailSubmissionResult = submissionProvider.SubmitMessage(Components.Configuration.LocalServer.TransportServer.ExchangeLegacyDN, mapiEvent.MailboxGuid, this.databaseInfo.Guid, this.databaseInfo.DatabaseName, mapiEvent.EventCounter, mapiEvent.ItemEntryId, mapiEvent.ParentEntryId, Components.Configuration.LocalServer.TransportServer.Fqdn, new IPAddress(StoreDriverSubmission.LocalIPAddress.GetAddressBytes()), mapiEvent.CreateTime, isPublicFolder, (mapiEvent.TenantHint == null) ? null : TenantPartitionHint.FromPersistablePartitionHint(mapiEvent.TenantHint), latencyFormatter2.FormatAndUpdatePerfCounters(), MailboxTransportSubmissionService.QuarantineHandler, MailboxTransportSubmissionService.SubmissionPoisonHandler, latencyTracker);
                    MailSubmissionResult result = mailSubmissionResult;
                    LatencyTracker.EndTrackLatency(LatencyComponent.MailboxTransportSubmissionStoreDriverSubmission, latencyTracker);
                    LatencyTracker.EndTrackLatency(LatencyComponent.MailboxTransportSubmissionService, latencyTracker);
                    this.LogAndUpdateCounters(mapiEvent, latencyTracker, createTime, result);
                    this.HandleEventError(mapiEvent, result, latencyTracker, text);
                }
            }
            finally
            {
                MSExchangeSubmission.PendingSubmissions.Decrement();
                Interlocked.Decrement(ref this.concurrentEvents);
                this.SubmissionsInProgress.Remove(currentThread);
            }
        }
예제 #2
0
        public async Task <ActionResult <SubmissionMetadata> > Submit([FromBody] SubmitData data)
        {
            if (await _workspace.Problems.Has(data.ProblemId) == false)
            {
                return(NotFound());
            }

            if (await _workspace.Users.Has(data.UserId) == false)
            {
                return(NotFound());
            }

            SubmissionMetadata meta = new SubmissionMetadata
            {
                Id        = Guid.NewGuid().ToString(),
                ProblemId = data.ProblemId,
                UserId    = data.UserId,
                Language  = data.Language,
                Time      = DateTimeOffset.Now,
            };
            ISubmissionProvider sub = await _workspace.Submissions.Create(meta);

            if (sub == null)
            {
                return(Forbid());
            }
            try
            {
                if (data.CodeFile != null)
                {
                    using (System.IO.Stream s = data.CodeFile.OpenReadStream())
                    {
                        meta.CodeLength = (uint)s.Length;
                        await sub.SetCode(s);
                    }
                }
                else
                {
                    meta.CodeLength = (uint)Encoding.UTF8.GetByteCount(data.Code);
                    using (System.IO.Stream ms = TextIO.ToStream(data.Code ?? ""))
                        await sub.SetCode(ms);
                }
                await sub.SetMetadata(meta);

                SendJudgeRequest(sub.Id);
                return(Created($"submissions/{meta.Id}", await sub.GetMetadata()));
            }
            catch
            {
                await _workspace.Submissions.Delete(sub.Id);

                return(Forbid());
            }
        }
예제 #3
0
        public async Task <ActionResult> GetCode(string id)
        {
            ISubmissionProvider res = await _workspace.Submissions.Get(id);

            if (res == null)
            {
                return(NotFound());
            }
            System.IO.Stream code = await res.GetCode();

            ProgrammingLanguage lang = (await res.GetMetadata()).Language;

            return(File(code, "text/plain", $"{id}.{ProgrammingLanguageHelper.Extends[lang]}"));
        }
예제 #4
0
        public async Task <ActionResult> SetResult(string id, [FromBody] SubmissionResult value)
        {
            ISubmissionProvider res = await _workspace.Submissions.Get(id);

            if (res != null)
            {
                await res.SetResult(value);

                return(Accepted());
            }
            else
            {
                return(NotFound());
            }
        }
예제 #5
0
        public async Task <ActionResult> Rejudge(string id)
        {
            ISubmissionProvider res = await _workspace.Submissions.Get(id);

            if (res != null)
            {
                await res.SetResult(null);

                try
                {
                    SendJudgeRequest(res.Id);
                    return(Accepted());
                }
                catch
                {
                    return(Forbid());
                }
            }
            else
            {
                return(NotFound());
            }
        }