IEnumerable<ProgramScheduleOutputModel> PrepareOutput(bool includeDigital)
		{
			var outputPages = new List<ProgramScheduleOutputModel>();
			var defaultProgram = _sectionContainer.SectionData.Programs.FirstOrDefault();
			if (defaultProgram == null) return outputPages;
			var defaultSpotsNotEmpy = defaultProgram.SpotsNotEmpty;
			var programsPerSlide = includeDigital ? ProgramScheduleOutputModel.MaxMediaProductsCobinedWithDigital : ProgramScheduleOutputModel.MaxSingleMediaProducts;
			programsPerSlide = _sectionContainer.SectionData.Programs.Count > programsPerSlide ? programsPerSlide : _sectionContainer.SectionData.Programs.Count;
			var totalSpotsCount = 0;
			if (_sectionContainer.SectionData.ShowSpots)
				totalSpotsCount = _sectionContainer.SectionData.ShowEmptySpots ? defaultProgram.Spots.Count : defaultSpotsNotEmpy.Length;
			var spotsPerSlide = _sectionContainer.SectionData.OutputMaxPeriods ?? 26;
			spotsPerSlide = totalSpotsCount == 0 || totalSpotsCount > spotsPerSlide ? spotsPerSlide : totalSpotsCount;
			var spotIntervals = GetSpotIntervals().ToList();
			foreach (var spotInterval in spotIntervals)
			{
				for (var i = 0; i < _sectionContainer.SectionData.Programs.Count; i += programsPerSlide)
				{
					for (var k = spotInterval.Start; k < (spotInterval.End == 0 ? 1 : spotInterval.End); k += spotsPerSlide)
					{
						var outputPage = new ProgramScheduleOutputModel(_sectionContainer.SectionData);

						outputPage.Advertiser = _sectionContainer.SectionData.ParentScheduleSettings.BusinessName;
						outputPage.DecisionMaker = _sectionContainer.SectionData.ParentScheduleSettings.DecisionMaker;
						outputPage.Demo = String.Format("{0}{1}",
								_sectionContainer.SectionData.ParentScheduleSettings.Demo,
								!String.IsNullOrEmpty(_sectionContainer.SectionData.ParentScheduleSettings.Source) ? (" (" + _sectionContainer.SectionData.ParentScheduleSettings.Source + ")") : String.Empty);

						outputPage.IncludeDigital = includeDigital;
						if (includeDigital)
						{
							var temp = new List<string>();
							if (_sectionContainer.SectionData.DigitalInfo.ShowMonthlyInvestemt && _sectionContainer.SectionData.DigitalInfo.MonthlyInvestment.HasValue)
								temp.Add(String.Format("Monthly Digital Investment: {0}", _sectionContainer.SectionData.DigitalInfo.MonthlyInvestment.Value.ToString("$#,###.00")));
							if (_sectionContainer.SectionData.DigitalInfo.ShowTotalInvestemt && _sectionContainer.SectionData.DigitalInfo.TotalInvestment.HasValue)
								temp.Add(String.Format("Total Digital Investment: {0}", _sectionContainer.SectionData.DigitalInfo.TotalInvestment.Value.ToString("$#,###.00")));
							outputPage.DigitalInfo.SummaryInfo = String.Join("     ", temp);
						}
						else
							outputPage.DigitalInfo.SummaryInfo = String.Empty;

						outputPage.Color = MediaMetaData.Instance.SettingsManager.SelectedColor ??
							BusinessObjects.Instance.OutputManager.ScheduleColors.Items.Select(ci => ci.Name).FirstOrDefault();
						outputPage.Quarter = spotInterval.Name;

						outputPage.ProgramsPerSlide = programsPerSlide;
						outputPage.SpotsPerSlide = totalSpotsCount > 0 ? spotsPerSlide : 0;
						outputPage.ShowRates = _sectionContainer.SectionData.ShowRate;
						outputPage.ShowRating = _sectionContainer.SectionData.ShowRating;
						outputPage.ShowCPP = _sectionContainer.SectionData.ShowCPP;
						outputPage.ShowGRP = _sectionContainer.SectionData.ShowGRP;
						outputPage.ShowCost = _sectionContainer.SectionData.ShowCost;
						outputPage.ShowStation = _sectionContainer.SectionData.ShowStation;
						outputPage.ShowProgram = _sectionContainer.SectionData.ShowProgram;
						outputPage.ShowStationInBrackets = !_sectionContainer.SectionData.OutputNoBrackets;
						outputPage.ShowDay = _sectionContainer.SectionData.ShowDay;
						outputPage.ShowTime = _sectionContainer.SectionData.ShowTime;
						outputPage.ShowLength = _sectionContainer.SectionData.ShowLenght;
						outputPage.ShowTotalSpots = _sectionContainer.SectionData.ShowTotalSpots;
						outputPage.ShowSpots = _sectionContainer.SectionData.ShowSpots;
						outputPage.ShowLogo = _sectionContainer.SectionData.ShowLogo;

						#region Set Totals

						if (_sectionContainer.SectionData.ShowTotalPeriods)
							outputPage.Totals.Add(
								_sectionContainer.SectionData.ParentScheduleSettings.SelectedSpotType == SpotType.Week ? TotalWeeksTag : TotalMonthsTag,
								_sectionContainer.TotalPeriodsValueFormatted);
						if (_sectionContainer.SectionData.ShowTotalSpots)
							outputPage.Totals.Add(TotalSpotsTag, _sectionContainer.TotalSpotsValueFormatted);
						if (_sectionContainer.SectionData.ShowTotalGRP)
							outputPage.Totals.Add(
								_sectionContainer.SectionData.ParentScheduleSettings.DemoType == DemoType.Rtg ? TotalGRPTag : TotalImpsTag,
								_sectionContainer.TotalGRPValueFormatted);
						if (_sectionContainer.SectionData.ShowTotalCPP)
							outputPage.Totals.Add(
								_sectionContainer.SectionData.ParentScheduleSettings.DemoType == DemoType.Rtg ? TotalCPPTag : TotalCPMTag,
								_sectionContainer.TotalCPPValueFormatted);
						if (_sectionContainer.SectionData.ShowAverageRate)
							outputPage.Totals.Add(AvgRateTag, _sectionContainer.AvgRateValueFormatted);
						if (_sectionContainer.SectionData.ShowTotalRate)
							outputPage.Totals.Add(TotalCostTag, _sectionContainer.TotalCostValuesFormatted);
						if (_sectionContainer.SectionData.ShowNetRate)
							outputPage.Totals.Add(NetRateTag, _sectionContainer.NetRateValueFormatted);
						if (_sectionContainer.SectionData.ShowDiscount)
							outputPage.Totals.Add(TotalDiscountTag, _sectionContainer.TotalDiscountValueFormatted);

						#endregion

						#region Set OutputMediaProgram Values

						for (var j = 0; j < programsPerSlide; j++)
						{
							if ((i + j) < _sectionContainer.SectionData.Programs.Count)
							{
								var program = _sectionContainer.SectionData.Programs[i + j];
								var outputProgram = new ProgramOutputModel(outputPage);
								outputProgram.Name = program.Name + (_sectionContainer.SectionData.ShowDaypart ? ("-" + program.Daypart) : string.Empty);
								outputProgram.LineID = program.Index.ToString("00");
								outputProgram.Station = program.Station;
								outputProgram.Days = program.Day;
								outputProgram.Time = program.Time;
								outputProgram.Length = program.Length;
								outputProgram.Rate = _sectionContainer.SectionData.ShowRate && program.Rate.HasValue ? program.Rate.Value.ToString(_sectionContainer.SectionData.UseDecimalRates ? "$#,##0.00" : "$#,##0") : string.Empty;
								outputProgram.Rating = _sectionContainer.SectionData.ShowRating && program.Rating.HasValue ? program.Rating.Value.ToString(_sectionContainer.SectionData.ParentScheduleSettings.DemoType == DemoType.Rtg ? "#,###.0" : "#,##0") : string.Empty;
								outputProgram.CPP = _sectionContainer.SectionData.ShowCPP ? program.CPP.ToString("$#,###.00") : String.Empty;
								outputProgram.GRP = _sectionContainer.SectionData.ShowGRP ? program.GRP.ToString(_sectionContainer.SectionData.ParentScheduleSettings.DemoType == DemoType.Rtg ? "#,###.0" : "#,##0") : String.Empty;
								outputProgram.TotalRate = _sectionContainer.SectionData.ShowCost ? program.Cost.ToString(_sectionContainer.SectionData.UseDecimalRates ? "$#,##0.00" : "$#,##0") : String.Empty;
								outputProgram.TotalSpots = program.TotalSpots.ToString("#,##0");
								outputProgram.Logo = program.Logo?.Clone<ImageSource, ImageSource>();

								#region Set Spots Values

								var spotsNotEmpy = program.SpotsNotEmpty;
								for (var l = 0; l < spotsPerSlide; l++)
								{
									if ((k + l) < spotInterval.End)
									{
										var value = !program.Parent.ShowEmptySpots ?
											(spotsNotEmpy[k + l].Count > 0 ? spotsNotEmpy[k + l].Count.ToString() : "-") :
											(program.Spots[k + l].Count > 0 ? program.Spots[k + l].Count.ToString() : "-");
										outputProgram.Spots.Add(value);
									}
									else
										break;
									Application.DoEvents();
								}

								#endregion

								outputPage.Programs.Add(outputProgram);
								Application.DoEvents();
							}
							else
								break;
						}

						#endregion

						#region Set OutputDigitalProduct Values

						if (includeDigital && (i + programsPerSlide) >= _sectionContainer.SectionData.Programs.Count)
						{
							foreach (var digitalInfoRecord in _sectionContainer.SectionData.DigitalInfo.Records)
							{
								var outputProduct = new DigitalInfoRecordOutputModel();
								outputProduct.LineID = String.Format("{0}", (_sectionContainer.SectionData.Programs.Count + digitalInfoRecord.Index).ToString("00"));
								outputProduct.Logo = _sectionContainer.SectionData.DigitalInfo.ShowLogo
									? digitalInfoRecord.Logo?.Clone<ImageSource, ImageSource>()
									: null;
								outputProduct.Details = digitalInfoRecord.OneSheetDetails;
								outputPage.DigitalInfo.Records.Add(outputProduct);
								Application.DoEvents();
							}
						}

						#endregion

						#region Set Total Values
						for (var l = 0; l < spotsPerSlide; l++)
						{
							if ((k + l) < spotInterval.End)
							{
								var outputTotalSpot = new TotalSpotOutputModel();
								outputTotalSpot.Day = !defaultProgram.Parent.ShowEmptySpots ? (defaultSpotsNotEmpy[k + l].Date.Day.ToString()) : (defaultProgram.Spots[k + l].Date.Day.ToString());
								outputTotalSpot.Month = Spot.GetMonthAbbreviation(!defaultProgram.Parent.ShowEmptySpots ? defaultSpotsNotEmpy[k + l].Date.Month : defaultProgram.Spots[k + l].Date.Month);

								int sum;
								if (!defaultProgram.Parent.ShowEmptySpots)
									sum = defaultProgram.Parent.Programs.Select(x => x.SpotsNotEmpty.FirstOrDefault(y => y.Date.Equals(defaultSpotsNotEmpy[k + l].Date))).Where(z => z.Count.HasValue).Select(z => z.Count.Value).Sum();
								else
									sum = defaultProgram.Parent.Programs.Select(x => x.Spots.FirstOrDefault(y => y.Date.Equals(defaultProgram.Spots[k + l].Date))).Where(z => z.Count.HasValue).Select(z => z.Count.Value).Sum();
								outputTotalSpot.Value = sum > 0 ? sum.ToString() : "-";
								outputPage.TotalSpots.Add(outputTotalSpot);
							}
							else
								break;
							Application.DoEvents();
						}

						outputPage.TotalCost = _sectionContainer.SectionData.TotalCost.ToString(_sectionContainer.SectionData.UseDecimalRates ? "$#,##0.00" : "$#,##0");
						outputPage.TotalSpot = _sectionContainer.SectionData.TotalSpots.ToString("#,##0");
						outputPage.TotalCPP = _sectionContainer.SectionData.TotalCPP.ToString("$#,###.00");
						outputPage.TotalGRP = _sectionContainer.SectionData.TotalGRP.ToString(_sectionContainer.SectionData.ParentScheduleSettings.DemoType == DemoType.Rtg ? "#,###.0" : "#,##0");

						#endregion

						outputPage.GetLogos();
						outputPage.DigitalInfo.GetLogos();
						outputPage.PopulateReplacementsList();

						outputPages.Add(outputPage);
					}
				}
			}
			return outputPages;
		}
		private StandaloneDigitalInfoOneSheetOutputModel PrepareOneSheetOutput()
		{
			var outputPage = new StandaloneDigitalInfoOneSheetOutputModel(_dataContainer);

			outputPage.Advertiser = _dataContainer.ParentScheduleSettings.BusinessName;
			outputPage.DecisionMaker = _dataContainer.ParentScheduleSettings.DecisionMaker;

			var temp = new List<string>();
			if (_digitalInfo.ShowMonthlyInvestemt && _digitalInfo.MonthlyInvestment.HasValue)
				temp.Add(String.Format("Monthly Digital Investment: {0}", _digitalInfo.MonthlyInvestment.Value.ToString("$#,###.00")));
			if (_digitalInfo.ShowTotalInvestemt && _digitalInfo.TotalInvestment.HasValue)
				temp.Add(String.Format("Total Digital Investment: {0}", _digitalInfo.TotalInvestment.Value.ToString("$#,###.00")));
			outputPage.SummaryInfo = temp.Any() ? String.Join("     ", temp) : String.Empty;

			outputPage.Color = MediaMetaData.Instance.SettingsManager.SelectedColor ??
				BusinessObjects.Instance.OutputManager.ScheduleColors.Items.Select(ci => ci.Name).FirstOrDefault();

			#region Set OutputDigitalProduct Values
			for (var j = 0; j < _digitalInfo.Records.Count; j++)
			{
				var digitalInfoRecord = _digitalInfo.Records[j];
				var outputProduct = new DigitalInfoRecordOutputModel();
				outputProduct.LineID = digitalInfoRecord.Index.ToString("00");
				outputProduct.Logo = _digitalInfo.ShowLogo ?
					digitalInfoRecord.Logo?.Clone<ImageSource, ImageSource>() :
					null;
				outputProduct.Details = digitalInfoRecord.OneSheetDetails;
				outputPage.Records.Add(outputProduct);
				Application.DoEvents();
			}
			#endregion

			outputPage.GetLogos();
			outputPage.PopulateReplacementsList();

			return outputPage;
		}