예제 #1
0
        private void GeneratePalcementTable(Partner partner, string quarter, Table tbl)
        {
            var list = GetPlacementTargets(partner.PartnerId, quarter);

            var rows = tbl.Descendants <TableRow>().ToList();

            var headerPlaceHolders = new Dictionary <string, string>();

            headerPlaceHolders.Add("varQuarter", quarter);
            PptHelper.ReplaceRowContent(rows[1], headerPlaceHolders);

            var templateRow = rows[2];

            foreach (var item in list)
            {
                var placeHolders = new Dictionary <string, string>();
                placeHolders.Add("varProduct", item.PlacementProductDescription);
                placeHolders.Add("varStores", item.Stores.ToString());
                placeHolders.Add("varUnits", item.Units.ToString());

                TableRow newRow = (TableRow)templateRow.Clone();
                PptHelper.ReplaceRowContent(newRow, placeHolders);

                tbl.Append(newRow);
            }
            rows[2].Remove();
        }
예제 #2
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            var list = GetData(partner.PartnerId, quarter);

            var tblList      = slide.Slide.Descendants <Table>().ToList();
            var tblMain      = tblList[0];
            var tblPlacement = tblList[1];

            var rows = tblMain.Descendants <TableRow>().ToList();

            var headerPlaceHolders = new Dictionary <string, string>();

            headerPlaceHolders.Add("varQuarter", quarter);
            PptHelper.ReplaceRowContent(rows[0], headerPlaceHolders);

            var templateRow = rows[1];

            foreach (var item in list)
            {
                var placeHolders = new Dictionary <string, string>();
                placeHolders.Add("varGoal", item.TargetedGoalName);
                placeHolders.Add("varPlan", item.QuarterPlan);
                placeHolders.Add("varPrevious", item.PreviousQuarter);
                placeHolders.Add("varWantToBe", item.TargetGoal);

                TableRow newRow = (TableRow)templateRow.Clone();
                PptHelper.ReplaceRowContent(newRow, placeHolders);

                tblMain.Append(newRow);
            }
            rows[1].Remove();

            GeneratePalcementTable(partner, quarter, tblPlacement);
        }
예제 #3
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            var    list        = GetData(partner.PartnerId, quarter);
            var    tbl         = slide.Slide.Descendants <Table>().First();
            var    rows        = tbl.Descendants <TableRow>().ToList();
            var    templateRow = rows[1];
            string imageRel    = "imageRelId";
            int    imageRelId  = 0;

            var categoryItems = (from b in list
                                 group b by b.CategoryName into g
                                 select new { Name = g.First().CategoryName, ItemCount = g.Count() }).ToList();

            foreach (var item in list)
            {
                var placeHolders = new Dictionary <string, string>();
                placeHolders.Add("varCategory", item.CategoryName);
                placeHolders.Add("varCompetitor", item.CompetitorName);
                placeHolders.Add("varShare", item.Share.ToString());
                placeHolders.Add("varPresence", item.BrandPresenc.ToString());
                placeHolders.Add("varPriceStrategy", item.PriceStrategy);
                placeHolders.Add("varInvestment", item.StoreInvestment);
                placeHolders.Add("varComments", item.AdditionalComment);

                TableRow newRow = (TableRow)templateRow.Clone();
                PptHelper.ReplaceRowContent(newRow, placeHolders);

                var fileName    = "/Content/images/hp.gif";
                var imgPartType = ImagePartType.Jpeg;
                var imgArr      = PptHelper.GetImageData(fileName, ref imgPartType);

                ImagePart imagePart = slide.AddImagePart(imgPartType, imageRel + imageRelId);
                PptHelper.GenerateImagePart(imagePart, imgArr);


                var cells = newRow.Descendants <TableCell>().ToList();
                //cells[2].Remove();

                var newImgCell = PptHelper.CreateDrawingCell(imageRel + imageRelId);
                //newRow.InsertAt(newImgCell, 2);

                if (categoryItems.Any(c => c.Name == item.CategoryName))
                {
                    var categoryItem = categoryItems.First(c => c.Name == item.CategoryName);
                    cells[0].VerticalMerge = true;
                    cells[0].RowSpan       = categoryItem.ItemCount;
                    categoryItems.Remove(categoryItem);
                }

                tbl.Append(newRow);

                imageRelId++;
            }
            rows[1].Remove();
        }
예제 #4
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            var placeHolders = new Dictionary <string, string>();

            placeHolders.Add("varPartnerName", partner.PartnerName);
            placeHolders.Add("varCity", partner.City.Description);
            placeHolders.Add("varPartnerCategory", partner.PartnerCategory.Description);
            placeHolders.Add("varQuarter", quarter);
            placeHolders.Add("varDate", DateTime.Now.ToString("dd/MMM/yyyy"));

            PptHelper.ReplacePlaceHolders(slide, placeHolders);
        }
예제 #5
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            string description  = "";
            var    placeHolders = new Dictionary <string, string>();

            var plan = _db.OpenHouses.FirstOrDefault(p => p.PartnerId == partner.PartnerId && p.Quarter == quarter);

            if (plan != null)
            {
                description = plan.Description;
            }

            placeHolders.Add("varOpenHouse", description);
            PptHelper.ReplacePlaceHolders(slide, placeHolders); //replace text by placeholder name
        }
예제 #6
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            var placeHolders = new Dictionary <string, string>();

            placeHolders.Add("varPartnerName", partner.PartnerName);
            placeHolders.Add("varPartnerCategory", partner.PartnerCategory.Description);
            placeHolders.Add("varContactPerson", partner.ContactPerson);
            placeHolders.Add("varCoreBusiness", partner.CoreBusiness);
            placeHolders.Add("varCurrentBrands", partner.CurrentBrands);
            placeHolders.Add("varNoOfStaff", partner.StaffCount.ToString());
            placeHolders.Add("varMainCompetitors", partner.MainCompetitors);
            placeHolders.Add("varSegmentsAddressed", partner.CustomerSegmentsAddressed);
            placeHolders.Add("varAccountManager", partner.User.Name);
            placeHolders.Add("varFrequencyOfVisit", partner.FrequencyOfEngagement);
            placeHolders.Add("varRelationshipStatus", partner.RelationshipStatus);

            PptHelper.ReplacePlaceHolders(slide, placeHolders); //replace text by placeholder name
        }
예제 #7
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            var list        = GetData(partner.PartnerId, quarter);
            var tbl         = slide.Slide.Descendants <Table>().First();
            var rows        = tbl.Descendants <TableRow>().ToList();
            var templateRow = rows[1];

            var goals = (from b in list
                         group b by b.GoalName into g
                         select new { Name = g.First().GoalName, ItemCount = g.Count() }).ToList();

            foreach (var item in list)
            {
                var placeHolders = new Dictionary <string, string>();
                placeHolders.Add("varGoals", item.GoalName);
                placeHolders.Add("varPrevious", item.PreviousQuarter);
                placeHolders.Add("varCurrent", item.QuarterPlan);
                placeHolders.Add("varAction", item.ActionRequired);
                placeHolders.Add("varUser", string.Join(",", item.Users.Select(x => x.Name)));

                TableRow newRow = (TableRow)templateRow.Clone();
                PptHelper.ReplaceRowContent(newRow, placeHolders);

                var cells = newRow.Descendants <TableCell>().ToList();

                if (goals.Any(c => c.Name == item.GoalName))
                {
                    var goalItem = goals.First(c => c.Name == item.GoalName);
                    cells[0].VerticalMerge = true;
                    cells[0].RowSpan       = goalItem.ItemCount;

                    cells[1].VerticalMerge = true;
                    cells[1].RowSpan       = goalItem.ItemCount;

                    cells[2].VerticalMerge = true;
                    cells[2].RowSpan       = goalItem.ItemCount;

                    goals.Remove(goalItem);
                }

                tbl.Append(newRow);
            }
            rows[1].Remove();
        }
예제 #8
0
        public static void ReplacePlaceHolders(SlidePart slide, Dictionary <string, string> placeHolders)
        {
            var paragraphs = slide.Slide.Descendants <Paragraph>().ToList(); //get all paragraphs in the slide

            foreach (var paragraph in paragraphs)
            {
                var result = false;
                foreach (var placeholder in placeHolders)
                {
                    if (PptHelper.ReplaceParaText(paragraph, placeholder.Key, placeholder.Value))
                    {
                        result = true;
                    }
                }

                if (result)
                {
                    paragraph.Remove();//delete placeholder
                }
            }
        }
예제 #9
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            var list        = GetData(partner.PartnerId, quarter);
            var tbl         = slide.Slide.Descendants <Table>().First();
            var rows        = tbl.Descendants <TableRow>().ToList();
            var templateRow = rows[1];

            foreach (var item in list)
            {
                var placeHolders = new Dictionary <string, string>();
                placeHolders.Add("varObjectives", item.BusinessObjective);
                placeHolders.Add("varStrategies", item.Strategies);
                placeHolders.Add("varMetrics", item.Metrics);
                placeHolders.Add("varCheckpoint", item.CheckpointState);


                TableRow newRow = (TableRow)templateRow.Clone();
                PptHelper.ReplaceRowContent(newRow, placeHolders);

                tbl.Append(newRow);
            }
            rows[1].Remove();
        }
예제 #10
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            string strength = "", weakness = "", opportunity = "", supportReqd = "";
            var    placeHolders = new Dictionary <string, string>();

            placeHolders.Add("varQuarter", quarter);

            var plan = _db.OverviewPlans.FirstOrDefault(p => p.PartnerId == partner.PartnerId && p.Quarter == quarter);

            if (plan != null)
            {
                strength    = plan.Strength;
                weakness    = plan.Weakness;
                opportunity = plan.Opportunity;
                supportReqd = plan.SupportReqd;
            }

            placeHolders.Add("varStrengthList", strength);
            placeHolders.Add("varWeaknessList", weakness);
            placeHolders.Add("varOpportunityList", opportunity);
            placeHolders.Add("varSupportReqdList", supportReqd);

            PptHelper.ReplacePlaceHolders(slide, placeHolders); //replace text by placeholder name
        }
예제 #11
0
        public void Generate(Partner partner, string quarter, SlidePart slide)
        {
            var list = GetData(partner.PartnerId, quarter);
            var tbl  = slide.Slide.Descendants <Table>().First();

            RemoveExtraQuarters(tbl, quarter);

            var rows = tbl.Descendants <TableRow>().ToList();

            var currentYear  = quarter.Split(' ')[1];
            var previousYear = (Convert.ToInt32(currentYear) - 1).ToString();

            var headerPlaceHolders = new Dictionary <string, string>();

            headerPlaceHolders.Add("varHPYQ1", "Q1 " + previousYear);
            headerPlaceHolders.Add("varHPYQ2", "Q2 " + previousYear);
            headerPlaceHolders.Add("varHPYQ3", "Q3 " + previousYear);
            headerPlaceHolders.Add("varHPYQ4", "Q4 " + previousYear);

            headerPlaceHolders.Add("varHCYQ1", "Q1 " + currentYear);
            headerPlaceHolders.Add("varHCYQ2", "Q2 " + currentYear);
            headerPlaceHolders.Add("varHCYQ3", "Q3 " + currentYear);
            headerPlaceHolders.Add("varHCYQ4", "Q4 " + currentYear);

            headerPlaceHolders.Add("varHM1", Utility.QuarterHelper.GetMonthName(quarter, 1));
            headerPlaceHolders.Add("varHM2", Utility.QuarterHelper.GetMonthName(quarter, 2));
            headerPlaceHolders.Add("varHM3", Utility.QuarterHelper.GetMonthName(quarter, 3));
            PptHelper.ReplaceRowContent(rows[0], headerPlaceHolders);

            var templateRow = rows[1];

            var categoryItems = (from b in list
                                 group b by b.ProductDescription into g
                                 select new { Name = g.First().ProductDescription, ItemCount = g.Count() }).ToList();

            foreach (var item in list)
            {
                var placeHolders = new Dictionary <string, string>();
                placeHolders.Add("varCat", item.ProductDescription);
                placeHolders.Add("varProduct", item.ProductCategory);
                placeHolders.Add("varPYQ1", item.PQ1.ToString());
                placeHolders.Add("varPYQ2", item.PQ2.ToString());
                placeHolders.Add("varPYQ3", item.PQ3.ToString());
                placeHolders.Add("varPYQ4", item.PQ4.ToString());
                placeHolders.Add("varCYQ1", item.CQ1.ToString());
                placeHolders.Add("varCYQ2", item.CQ2.ToString());
                placeHolders.Add("varCYQ3", item.CQ3.ToString());
                placeHolders.Add("varCYQ4", item.CQ4.ToString());
                placeHolders.Add("varM1", item.M1.ToString());
                placeHolders.Add("varM2", item.M2.ToString());
                placeHolders.Add("varM3", item.M3.ToString());
                placeHolders.Add("varYoy", item.YoY.ToString());
                placeHolders.Add("varGrowth", item.SegGrowth.ToString());

                TableRow newRow = (TableRow)templateRow.Clone();
                PptHelper.ReplaceRowContent(newRow, placeHolders);

                var cells = newRow.Descendants <TableCell>().ToList();

                if (categoryItems.Any(c => c.Name == item.ProductDescription))
                {
                    var categoryItem = categoryItems.First(c => c.Name == item.ProductDescription);
                    cells[0].VerticalMerge = true;
                    cells[0].RowSpan       = categoryItem.ItemCount;
                    categoryItems.Remove(categoryItem);
                }
                tbl.Append(newRow);
            }
            rows[1].Remove();
        }