コード例 #1
0
        private void InsertPageDetasils(SlidePart tempSlidepart, GanttChartAutomation.GanttReportObject objganttReport)
        {
            Xdr.Paragraph pageDetails    = _shpPageDetails.TextBody.Descendants <Xdr.Paragraph>().FirstOrDefault();
            Xdr.Run       pagedetails    = pageDetails.Descendants <Xdr.Run>().FirstOrDefault();
            Xdr.Paragraph ContactDetails = _shpContactDetails.TextBody.Descendants <Xdr.Paragraph>().FirstOrDefault();
            Xdr.Run       contactdetails = ContactDetails.Descendants <Xdr.Run>().FirstOrDefault();

            //Xdr.Paragraph StatDetails = _shpStatsDetail.TextBody.Descendants<Xdr.Paragraph>().FirstOrDefault();
            //Xdr.Run statDetails = StatDetails.Descendants<Xdr.Run>().FirstOrDefault();
            Xdr.Paragraph HeadingIntegrated = _shpHeadingIntegrated.TextBody.Descendants <Xdr.Paragraph>().FirstOrDefault();
            Xdr.Run       headingIntegrated = HeadingIntegrated.Descendants <Xdr.Run>().FirstOrDefault();

            Xdr.Paragraph TitleDetails   = _shpTitle.TextBody.Descendants <Xdr.Paragraph>().FirstOrDefault();
            Xdr.Run       titleDetails   = TitleDetails.Descendants <Xdr.Run>().FirstOrDefault();
            Xdr.Paragraph HeadingDetails = _shpHeading.TextBody.Descendants <Xdr.Paragraph>().FirstOrDefault();
            Xdr.Run       headingDetails = HeadingDetails.Descendants <Xdr.Run>().FirstOrDefault();


            Xdr.Paragraph FooterDetails = _shpFooterDetails.TextBody.Descendants <Xdr.Paragraph>().FirstOrDefault();
            Xdr.Run       footerDetails = FooterDetails.Descendants <Xdr.Run>().FirstOrDefault();

            pagedetails.Text.Text       = objganttReport.PageDetails;
            contactdetails.Text.Text    = objganttReport.RIdetails;
            headingIntegrated.Text.Text = objganttReport.Title2;
            titleDetails.Text.Text      = objganttReport.Title1;
            headingDetails.Text.Text    = objganttReport.Title3;
            //statDetails.Text.Text = objganttReport.StatusDate.ToString();
            footerDetails.Text.Text = objganttReport.FooterText;
        }
コード例 #2
0
        public string  BuildPresentation(string parameterList, string UserId)
        {
            GanttChartAutomation.GanttChartDataHelper gantt           = new GanttChartAutomation.GanttChartDataHelper();
            GanttChartAutomation.GanttReportObject    ganttReportData = gantt.GenerateGanttChartReport(parameterList, UserId);

            DateTime startDate, endDate;

            startDate = ganttReportData.StatusDate.AddMonths(-2);
            endDate   = ganttReportData.StatusDate.AddMonths(3);
            ganttReportData.SetExplicitStartEndDate(startDate, endDate);
            _dtStatsDate = ganttReportData.StatusDate;

            IList <GanttChartAutomation.GanttReportObject> ganttChartPages = ganttReportData.PaginateDataWithWeightage(15);

            GanttChartAutomation.GanttReportObject testObject = ganttChartPages[0];


            byte[] fileBytes = PPTTemplate;
            using (MemoryStream stream = new MemoryStream())
            {
                stream.Write(fileBytes, 0, fileBytes.Length);

                using (PresentationDocument presentationDocument = PresentationDocument.Open(stream, true))
                {
                    PresentationPart presentationPart  = presentationDocument.PresentationPart;
                    SlidePart        templateSlidePart = presentationPart.SlideParts.LastOrDefault();
                    SlidePart        slidePart         = presentationPart.SlideParts.FirstOrDefault();


                    SlidePart newSlide;
                    _dtstartDate = ganttChartPages[0].StartDate;
                    _dtendDate   = ganttChartPages[0].EndDate;

                    for (int _intPageCount = 0; _intPageCount < ganttChartPages.Count; _intPageCount++)
                    {
                        bool lblnSlide = false;

                        GanttChartAutomation.GanttReportObject objganttReport = ganttChartPages[_intPageCount];

                        temp = templateSlidePart.Slide.CommonSlideData.ShapeTree.ChildElements.OfType <Shape>().Where(item => (item.NonVisualShapeProperties.NonVisualDrawingProperties.Description != null) && (item.NonVisualShapeProperties.NonVisualDrawingProperties.Description.Value.Equals("PositionBox", StringComparison.OrdinalIgnoreCase))).FirstOrDefault();
                        _shpNofillDiamond = templateSlidePart.Slide.CommonSlideData.ShapeTree.ChildElements.OfType <Shape>().Where(item => (item.NonVisualShapeProperties.NonVisualDrawingProperties.Description != null) && (item.NonVisualShapeProperties.NonVisualDrawingProperties.Description.Value.Equals("NoFillDiamond", StringComparison.OrdinalIgnoreCase))).FirstOrDefault();
                        _intCellWidth     = temp.ShapeProperties.Transform2D.Extents.Cx;
                        getheight(temp.ShapeProperties.Transform2D.Extents.Cy, 15);
                        _intSymbolWidth = _shpNofillDiamond.ShapeProperties.Transform2D.Extents.Cx;
                        newSlide        = CloneSlidePart(presentationPart, templateSlidePart);
                        InitializePosition(newSlide);


                        for (int i = 1; i <= objganttReport.RowCollection.Count; i++)
                        {
                            IList <Xdr.TableCell> cells = rows[i].ChildElements.OfType <Xdr.TableCell>().ToList();
                            _intTaskhaving += objganttReport.RowCollection[i - 1].Weightage;
                            SetCellText(cells[2], objganttReport.RowCollection[i - 1].TaskName.ToString(), objganttReport.RowCollection[i - 1].Weightage, rows[i]);
                            InsertTrend(objganttReport.RowCollection[i - 1].Trend, newSlide, i - 1, objganttReport.RowCollection[i - 1].Weightage);
                            SetCellText(cells[1], objganttReport.RowCollection[i - 1].CpValue == null ? "" : objganttReport.RowCollection[i - 1].CpValue.ToString(), objganttReport.RowCollection[i - 1].Weightage, rows[i]);

                            SetCellText(cells[3], objganttReport.RowCollection[i - 1].RaaValue == null ? "" : objganttReport.RowCollection[i - 1].RaaValue.ToString(), objganttReport.RowCollection[i - 1].Weightage, rows[i]);
                            SetCellText(cells[4], objganttReport.RowCollection[i - 1].BacValue == null ? "" : objganttReport.RowCollection[i - 1].BacValue.ToString(), objganttReport.RowCollection[i - 1].Weightage, rows[i]);
                            SetCellText(cells[5], objganttReport.RowCollection[i - 1].SvValue == null ? "" : objganttReport.RowCollection[i - 1].SvValue.ToString(), objganttReport.RowCollection[i - 1].Weightage, rows[i]);
                            SetShapeCe(cells[6], "", newSlide, objganttReport.RowCollection[i - 1].rowImageDetails, i - 1, objganttReport.RowCollection[i - 1].Weightage);
                            InsertPageDetasils(newSlide, objganttReport);
                            //InsertstatusLine(newSlide);
                        }
                        if (objganttReport.RowCollection.Count < 15)
                        {
                            //_cshpStatsLine.ShapeProperties.Transform2D.Extents.Cx = (_intTaskhaving + 1) * _intcellHeight;
                            //_cshpStatsLine.ShapeProperties.Transform2D.Offset.Y = 3848497;

                            for (int i = objganttReport.RowCollection.Count + 1; i <= 15; i++)
                            {
                                rows[i].Remove();
                            }
                        }
                        _intTaskhaving = -1;

                        RemoveShapePosition(newSlide, presentationPart);
                    }

                    DeleteTemplateSlide(presentationPart, templateSlidePart);


                    xVal.OpenXmlValidator validator = new xVal.OpenXmlValidator();
                    var errors = validator.Validate(presentationDocument).ToList();



                    if (errors.Count == 0)
                    {
                        presentationPart.Presentation.Save();
                    }
                    else
                    {
                        throw new ApplicationException("Error in document.");
                    }
                }

                byte[] presentationFile = stream.ToArray();
                string outputFolder     = @"C:\\ReMICS\\OpenXMLPpt\\";
                if (!System.IO.Directory.Exists(outputFolder))
                {
                    System.IO.Directory.CreateDirectory(outputFolder);
                }

                string newPresentation = outputFolder + "OpenXML-PPT-" + Guid.NewGuid().ToString() + ".pptx";
                File.WriteAllBytes(newPresentation, presentationFile);

                return(newPresentation);
            }
        }