Beispiel #1
0
        public OutputGroup GetOutputGroup()
        {
            var outputGroup = new OutputGroup
            {
                Name      = Text,
                IsCurrent = TabControl != null && TabControl.SelectedTabPage == this
            };

            if (PackageRecords.Any())
            {
                outputGroup.Items = new List <OutputItem>(new[]
                {
                    new OutputItem
                    {
                        Name = Text,
                        PresentationSourcePath =
                            Path.Combine(ResourceManager.Instance.TempFolder.LocalPath, Path.GetFileName(Path.GetTempFileName())),
                        SlidesCount           = PackageRecords.Count() / RowsPerSlide + (PackageRecords.Count() % RowsPerSlide > 0 ? 1 : 0),
                        IsCurrent             = true,
                        SlideGeneratingAction = (processor, destinationPresentation) =>
                        {
                            PopulateReplacementsList();
                            processor.AppendWebPackage(this, destinationPresentation);
                        },
                        PreviewGeneratingAction = (processor, filePath) =>
                        {
                            PopulateReplacementsList();
                            processor.PrepareWebPackageEmail(filePath, this);
                        }
                    }
                });
            }
            return(outputGroup);
        }
Beispiel #2
0
        public void PopulateReplacementsList()
        {
            var recordsCount = PackageRecords.Count();
            var rowsPerSlide = RowsPerSlide;

            OutputReplacementsLists = new List <Dictionary <string, string> >();
            for (var i = 0; i < recordsCount; i += rowsPerSlide)
            {
                var slideRows = new Dictionary <string, string>();
                slideRows.Add("Digital Media Campaign: AdvertiserNameHere", _container.EditedContent.ScheduleSettings.BusinessName);
                for (var j = 0; j < rowsPerSlide; j++)
                {
                    if ((i + j) < recordsCount)
                    {
                        var packageRecord = PackageRecords.ElementAt(i + j);
                        var mainInfo      = new List <string>();
                        if (PackageSettings.ShowCategory && !String.IsNullOrEmpty(packageRecord.Category))
                        {
                            mainInfo.Add(packageRecord.Category);
                        }
                        if (PackageSettings.ShowGroup && !String.IsNullOrEmpty(packageRecord.SubCategory))
                        {
                            mainInfo.Add(packageRecord.SubCategory);
                        }
                        if (PackageSettings.ShowProduct && !String.IsNullOrEmpty(packageRecord.Name))
                        {
                            mainInfo.Add(packageRecord.Name);
                        }

                        var additionalInfo = new List <string>();
                        if (PackageSettings.ShowLocation && !String.IsNullOrEmpty(packageRecord.Location))
                        {
                            additionalInfo.Add(packageRecord.Location);
                        }
                        if (PackageSettings.ShowInfo && !String.IsNullOrEmpty(packageRecord.Info))
                        {
                            additionalInfo.Add(packageRecord.Info);
                        }

                        var pricingInfo = new List <string>();
                        if (PackageSettings.ShowImpressions && packageRecord.ImpressionsCalculated.HasValue)
                        {
                            pricingInfo.Add(String.Format("Impressions: {0}", packageRecord.ImpressionsCalculated.Value.ToString("#,##0")));
                        }
                        if (PackageSettings.ShowInvestment && packageRecord.InvestmentCalculated.HasValue)
                        {
                            pricingInfo.Add(String.Format("Investment: {0}", packageRecord.InvestmentCalculated.Value.ToString("$#,###.00")));
                        }
                        if (PackageSettings.ShowCPM && packageRecord.CPMCalculated.HasValue)
                        {
                            pricingInfo.Add(String.Format("CPM: {0}", packageRecord.CPMCalculated.Value.ToString("$#,###.00")));
                        }
                        if (PackageSettings.ShowRate && packageRecord.Rate.HasValue)
                        {
                            pricingInfo.Add(String.Format("Rate: {0}", packageRecord.Rate.Value.ToString("$#,###.00")));
                        }

                        if (pricingInfo.Any())
                        {
                            additionalInfo.Add(String.Join(",   ", pricingInfo));
                        }

                        var mainInfoRow = mainInfo.Any() ?
                                          String.Join("  |  ", mainInfo.ToArray()) :
                                          String.Empty;
                        var additionalInfoRow = additionalInfo.Any() ?
                                                String.Format("{0}{2}{2}{1}", additionalInfo.First(), String.Join("  |  ", additionalInfo.Skip(1)), (char)13) :
                                                String.Empty;


                        if (!String.IsNullOrEmpty(mainInfoRow) && !String.IsNullOrEmpty(additionalInfoRow))
                        {
                            slideRows.Add(String.Format("Category{0}  |  Group{0}  |  Product{0}", j + 1), mainInfoRow);
                            slideRows.Add(String.Format("ScheduleProductInfo{0}{1}{1}NotesandComments{0}", j + 1, (char)13), additionalInfoRow);
                        }
                        else if (!String.IsNullOrEmpty(mainInfoRow))
                        {
                            slideRows.Add(String.Format("Category{0}  |  Group{0}  |  Product{0}", j + 1), mainInfoRow);
                            slideRows.Add(String.Format("ScheduleProductInfo{0}{1}{1}NotesandComments{0}", j + 1, (char)13), "DeleteRow");
                        }
                        else if (!String.IsNullOrEmpty(additionalInfoRow))
                        {
                            slideRows.Add(String.Format("Category{0}  |  Group{0}  |  Product{0}", j + 1), additionalInfoRow);
                            slideRows.Add(String.Format("ScheduleProductInfo{0}{1}{1}NotesandComments{0}", j + 1, (char)13), "DeleteRow");
                        }
                    }
                    else
                    {
                        slideRows.Add(String.Format("Category{0}  |  Group{0}  |  Product{0}", j + 1), "DeleteRow");
                        slideRows.Add(String.Format("ScheduleProductInfo{0}{1}{1}NotesandComments{0}", j + 1, (char)13), "DeleteRow");
                    }
                }
                OutputReplacementsLists.Add(slideRows);
            }
        }