Exemplo n.º 1
0
        private void DownloadCompleted(object sender, ReportDownloadedEventArgs e)
        {
            this.LastUpdated = e.Timestamp;

            // Update with the currently selected transfer unit
            var temp = new List <MonthlyValue>(e.Monthly);

            temp.ForEach(x => x.ChangeTransferUnit(this.TransferUnit));
            this.AllValues = temp;

            this.Filters = e.Monthly.Select(x => new Filter(x)).ToList();

            // Disable the filtering so that setting FilterStart/End
            // does not cause filtering.
            this.FilteringDisabled = true;

            if (this.AllValues.HasElements())
            {
                if (null == this.FilterStart)
                {
                    this.FilterStart = new Filter(e.Monthly.FirstOrDefault());
                }

                if (null == this.FilterEnd)
                {
                    this.FilterEnd = new Filter(e.Monthly.LastOrDefault());
                }
            }

            this.FilteringDisabled = false;

            this.FilterValues();
        }
Exemplo n.º 2
0
 private void ReportDownloaded(object sender, ReportDownloadedEventArgs e)
 {
     this.IsBusy = false;
     if (null != e.Error)
     {
         this.ReportErrorToUser(e.Error);
     }
     else
     {
         this.ErrorMessage = null;
         this.Error        = null;
     }
 }
Exemplo n.º 3
0
        private void PublishEventsForPreviouslyDownloadedReports(IReportRequestEntryService reportRequestService)
        {
            var reportsReadyForCallback = reportRequestService.GetAllFromQueueOfReportsReadyForCallback(_merchantId, _region);

            foreach (var reportEntry in reportsReadyForCallback)
            {
                try
                {
                    var reportType  = reportEntry.ReportType;
                    var handledId   = reportEntry.TargetHandlerId;
                    var handlerArgs = (reportEntry.TargetHandlerArgs == null) ? null : new ReadOnlyDictionary <string, object>(JsonConvert.DeserializeObject <Dictionary <string, object> >(reportEntry.TargetHandlerArgs));

                    if (reportEntry.Details == null && reportEntry.LastAmazonReportProcessingStatus == AmazonReportProcessingStatus.DoneNoData && !_options.EventPublishingOptions.EventPublishingForReportStatusDoneNoData)
                    {
                        _logger.Debug($"An attempt will not be made to publish event ReportDownloaded for the following report in queue : {reportEntry.EntryIdentityDescription}, because AmazonProcessingStatus for this report is _DONE_NO_DATA_ but EventPublishingForReportStatusDoneNoData EasyMwsOption is FALSE.");
                    }
                    else if (reportEntry.Details == null && reportEntry.LastAmazonReportProcessingStatus == AmazonReportProcessingStatus.DoneNoData && _options.EventPublishingOptions.EventPublishingForReportStatusDoneNoData)
                    {
                        _logger.Warn($"Attempting to publish event ReportDownloaded for the following report in queue : {reportEntry.EntryIdentityDescription}, but the AmazonProcessingStatus for this report is _DONE_NO_DATA_ therefore the Stream argument will be null at invocation time.");
                        var eventArgs = new ReportDownloadedEventArgs(null, reportType, handledId, handlerArgs);
                        OnReportDownloaded(eventArgs);
                    }
                    else
                    {
                        _logger.Debug($"Attempting to publish event ReportDownloaded for the next downloaded report in queue : {reportEntry.EntryIdentityDescription}.");
                        var reportContent = ZipHelper.ExtractArchivedSingleFileToStream(reportEntry.Details?.ReportContent);
                        var eventArgs     = new ReportDownloadedEventArgs(reportContent, reportType, handledId, handlerArgs);
                        OnReportDownloaded(eventArgs);
                    }

                    reportRequestService.Delete(reportEntry);
                    _logger.Info($"Event publishing has succeeded for {reportEntry.EntryIdentityDescription}.");
                }
                catch (SqlException e)
                {
                    _logger.Error($"ReportDownloaded event publishing failed for {reportEntry.EntryIdentityDescription} due to an internal error '{e.Message}'. The event publishing will be retried at the next poll request", e);
                    reportRequestService.Unlock(reportEntry, "Unlocking single report request entry - an SQL exception occurred while trying to invoke callback.");
                    reportRequestService.Update(reportEntry);
                }
                catch (Exception e)
                {
                    _logger.Error($"ReportDownloaded event publishing failed for {reportEntry.EntryIdentityDescription}. Current retry count is :{reportEntry.InvokeCallbackRetryCount}. {e.Message}", e);
                    reportEntry.InvokeCallbackRetryCount++;
                    reportRequestService.Unlock(reportEntry, "Unlocking single report request entry - an exception occurred while trying to invoke callback.");
                    reportRequestService.Update(reportEntry);
                }
            }

            reportRequestService.SaveChanges();
        }
Exemplo n.º 4
0
 private void OnReportDownloaded(ReportDownloadedEventArgs e) => ReportDownloadedInternal?.Invoke(this, e);