private void SetReportStage(ReportStage reportStage)
        {
            this._currentReportStage = reportStage;

            var logMessage = string.Format(
                "ts:{0};logId:{1};clientId:{2};rptdDate:{3};reportType:{4};reportStage:{5}",
                DateTime.Now,
                this._rptlogId,
                this._clientId,
                this._rptdDate.ToString("yyyyMMdd"),
                this._currentReportType,
                this._currentReportStage);

            Console.WriteLine(logMessage);

            bool complete = false;

            // remove the current report type if it completed
            if (reportStage == ReportStage.LoadCompleted)
            {
                this._reportTypesToDownload = this._reportTypesToDownload.Except(this._currentReportType);
                // if there are no more report types to download then we are complete
                complete = this._reportTypesToDownload == ReportTypes.None;
            }

            Repository.UpdateReportLogStatus(this._rptlogId, this._currentReportType, this._currentReportStage, complete);
        }
示例#2
0
        public static void UpdateReportLogStatus(long rptlogId, ReportTypes reportType, ReportStage reportStage, bool complete)
        {
            var cmd = _db.GetStoredProcCommand("[dbo].[uspReportLog_StatusUpdate]");

            _db.AddInParameter(cmd, "rptlogId", SqlDbType.BigInt, rptlogId);
            _db.AddInParameter(cmd, "reportType", SqlDbType.VarChar, reportType.ToString());
            _db.AddInParameter(cmd, "reportStage", SqlDbType.VarChar, reportStage.ToString());
            _db.AddInParameter(cmd, "complete", SqlDbType.Bit, complete);

            _db.ExecuteNonQuery(cmd);
        }
        public void Execute()
        {
            try
            {
                // account report downloads are different than all other report types
                // we unconditionally download account data to determine if the account has impressions
                // the load for account data is conditionally executed based on the report types to download
                this._currentReportType  = ReportTypes.Account;
                this._currentReportStage = ReportStage.NotSet;
                bool hasImpressions   = false;
                bool hasVideoCampaign = false;
                LoadAccountPerformanceReport(out hasImpressions);

                if (!hasImpressions) // no impressions means we don't do anything else besides update the log appropriately
                {
                    Repository.SetReportLogZeroImpressions(this._rptlogId);
                }
                else // impressions means we may need to download other reports
                {
                    // only load if the report type is being requested
                    if (this._reportTypesToDownload.Contains(ReportTypes.Campaign))
                    {
                        this._currentReportType  = ReportTypes.Campaign;
                        this._currentReportStage = ReportStage.NotSet;
                        LoadCampaignPerformanceReport(out hasVideoCampaign);
                        //Only load if the report type is being requested and if it is a video campaign
                        if (hasVideoCampaign)
                        {
                            if (this._reportTypesToDownload.Contains(ReportTypes.Age))
                            {
                                this._currentReportType  = ReportTypes.Age;
                                this._currentReportStage = ReportStage.NotSet;
                                LoadYoutubeAgePerformanceReport();
                            }
                            if (this._reportTypesToDownload.Contains(ReportTypes.Gender))
                            {
                                this._currentReportType  = ReportTypes.Gender;
                                this._currentReportStage = ReportStage.NotSet;
                                LoadYoutubeGenderPerformanceReport();
                            }
                            if (this._reportTypesToDownload.Contains(ReportTypes.Video))
                            {
                                this._currentReportType  = ReportTypes.Video;
                                this._currentReportStage = ReportStage.NotSet;
                                LoadYoutubeVideoPerformanceReport();
                            }
                        }
                    }

                    // only load if the report type is being requested
                    if (this._reportTypesToDownload.Contains(ReportTypes.AdGroup))
                    {
                        this._currentReportType  = ReportTypes.AdGroup;
                        this._currentReportStage = ReportStage.NotSet;
                        LoadAdGroupPerformanceReport();
                    }

                    // only load if the report type is being requested
                    if (this._reportTypesToDownload.Contains(ReportTypes.Ad))
                    {
                        this._currentReportType  = ReportTypes.Ad;
                        this._currentReportStage = ReportStage.NotSet;
                        LoadAdPerformanceReport();
                    }

                    // only load if the report type is being requested
                    if (this._reportTypesToDownload.Contains(ReportTypes.Keyword))
                    {
                        this._currentReportType  = ReportTypes.Keyword;
                        this._currentReportStage = ReportStage.NotSet;
                        LoadKeywordPerformanceReport();
                    }
                }
            }
            catch (Exception ex)
            {
                // give extra execution info
                var wrappedEx = new System.ApplicationException(string.Format("Failed to process report logid:{0}", this._rptlogId), ex);
                // log exception
                var errlogId = Repository.LogError(wrappedEx.ToString(), string.Format("ReportProcessor - {0}", this._currentReportType));
                // mark log entry failed
                Repository.SetReportLogErrorId(this._rptlogId, errlogId);
            }
        }