public static ReportExecution GetReportExecutionFromRow(GetExecutionFromQueueRow execRow, GetFormatRow formatRow, GetReportRow reportRow, GetSubscriptionRow subscriptionRow, string destTimeZone) { var curPrms = GetActualParameterValuesFromXml(execRow.Parameters, reportRow.ReportPath, execRow.ScheduledStartDate); var baseCoTimeZone = !string.IsNullOrEmpty(destTimeZone) ? destTimeZone : Report.GetBaseCompanyTimeZoneIdentifier(reportRow.ReportPath, curPrms, ServerTimeZoneIdentifier); Logger.TraceEvent(TraceEventType.Verbose, 0, "{0}: Base TranCo Time Zone={1}", System.Threading.Thread.CurrentThread.ManagedThreadId, baseCoTimeZone); var startDateInBaseCoTimeZone = TimeZoneInfoExtension.SafeConvertTimeBySystemTimeZoneId(execRow.ScheduledStartDate.Value, ServerTimeZoneIdentifier, baseCoTimeZone); var schedule = (subscriptionRow != null ? new Schedule( subscriptionRow.ScheduleFrequencyID, subscriptionRow.FrequencyInterval, subscriptionRow.FrequencyRecurrenceFactor, subscriptionRow.FrequencyRelativeInterval, (DateTime?)startDateInBaseCoTimeZone, subscriptionRow.StartTime, subscriptionRow.EndTime) : null); var nextRun = schedule.RecurrenceOption != ScheduleRecurrence.Once ? schedule.GetNextRunDate(startDateInBaseCoTimeZone) : null; var nextPrms = GetActualParameterValuesFromXml(subscriptionRow.Parameters, reportRow.ReportPath, nextRun); //build the execution var exec = new ReportExecution { Id = execRow.ReportExecutionID.ToString(), Name = subscriptionRow.Name, ReportPath = Report.GetSpecificReportPath(reportRow.ReportID.ToString(), reportRow.ReportPath, curPrms), FormatId = formatRow.ReportFormatID, Format = formatRow.SSRSFormat, FileType = formatRow.Extension, DeviceInfo = formatRow.SSRSDeviceInfo, Error = null, HistoryId = null, ParameterLanguage = "en-us", Parameters = (from p in curPrms select new Emdat.InVision.SSRSExecution.ParameterValue { Name = p.Name, Value = p.Value }).ToList(), ScheduledRunTime = execRow.ScheduledStartDate, State = (ReportExecutionStateEnum)execRow.ReportExecutionStatusID, Data = null, SubscriptionId = execRow.ReportSubscriptionID.Value, ReportId = execRow.ReportID.Value, NextScheduledRunTime = nextRun.HasValue ? (DateTime?)TimeZoneInfoExtension.SafeConvertTimeBySystemTimeZoneId(nextRun.Value, baseCoTimeZone, ServerTimeZoneIdentifier) : null, NextScheduledRunParameters = nextPrms, ErrorCount = execRow.ErrorCount.HasValue ? execRow.ErrorCount.Value : 0, SubscriptionOptions = subscriptionRow.Options, ReportOptions = reportRow.Options }; return(exec); }
/// <summary> /// Gets the NextRunInfo /// </summary> /// <returns></returns> public NextRunInfo GetNextRunInfo(DateTime sourceDate) { //TFS #3449: Calculate next run parameter values using the Base //Company Time Zone; otherwise the date variables will be off NextRunInfo nextRunInfo = new NextRunInfo(); nextRunInfo.Date = this.IsActive ? this.Schedule.GetNextRunDate(sourceDate) : null; DateTime?nextRunDateInBaseCoTimeZone = null; if (nextRunInfo.Date.HasValue && false == string.IsNullOrEmpty(this.BaseCompanyTimeZoneIdentifier)) { nextRunDateInBaseCoTimeZone = TimeZoneInfoExtension.SafeConvertTimeBySystemTimeZoneId(nextRunInfo.Date.Value, Subscription.ServerTimeZoneIdentifier, this.BaseCompanyTimeZoneIdentifier); } nextRunInfo.ParametersAsXml = nextRunDateInBaseCoTimeZone.HasValue ? this.GetNextRunParameterValuesXml(nextRunDateInBaseCoTimeZone.Value) : null; return(nextRunInfo); }
public void GetNextRunDatePacificStandardTimeZoneTest() { DateTime scheduledStartDate = new DateTime(2010, 2, 1, 2, 0, 0); string baseTranCoTimeZone = "Pacific Standard Time"; string serverTimeZone = "Central Standard Time"; Schedule sched = new Schedule( 2, //weekly 4, //Monday 1, //every 1 week null, (DateTime?)TimeZoneInfoExtension.SafeConvertTimeBySystemTimeZoneId(scheduledStartDate, serverTimeZone, baseTranCoTimeZone), "000000", "000000"); DateTime?nextRun = sched.GetNextRunDate(TimeZoneInfoExtension.SafeConvertTimeBySystemTimeZoneId(scheduledStartDate, serverTimeZone, baseTranCoTimeZone)); DateTime?expectedNextRun = new DateTime(2010, 2, 8, 0, 0, 0); Assert.AreEqual(expectedNextRun.Value, nextRun.Value); }