Ejemplo n.º 1
0
 private int GetSlideindexByTitle(PresentationPart oPPart, string title)
 {
     Repository.Utility.WriteLog("GetSlideindexByTitle started", System.Diagnostics.EventLogEntryType.Information);
     List<SlidePart> slides = oPPart.GetSlidePartsInOrder().ToList();
     int count = 0;
     foreach (var gridSlidePart in slides)
     {
         var titleShape = gridSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Shape>().ToList();
         if (titleShape.Count > 0)
         {
             if (titleShape[0].TextBody.InnerText.Trim().ToUpper() == title.Trim().ToUpper())
             {
                 Repository.Utility.WriteLog("GetSlideindexByTitle completed successfully", System.Diagnostics.EventLogEntryType.Information);
                 return count;
             }
         }
         count++;
     }
     Repository.Utility.WriteLog("GetSlideindexByTitle completed successfully", System.Diagnostics.EventLogEntryType.Information);
     return -1;
 }
Ejemplo n.º 2
0
        private void CreateUpComingSlides(TaskGroupData taskData, int lowestSLideIndex, ref int createdCount, PresentationPart oPPart)
        {
            Repository.Utility.WriteLog("CreateupComingSlides started", System.Diagnostics.EventLogEntryType.Information);
            try
            {
                if (UpComingSlidePart == null)
                    return;
                #region upComingSlides

                if (taskData.UpComingTaskGroups == null || taskData.UpComingTaskGroups.Count == 0)
                {
                    createdCount++;
                    return;
                }

                foreach (TaskItemGroup upComingTaskgroup in taskData.UpComingTaskGroups)
                {
                    try
                    {
                        SlidePart upComingSlidePart = oPPart.GetSlidePartsInOrder().ToList()[lowestSLideIndex + createdCount];
                        var table = upComingSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Drawing.Table>().FirstOrDefault();

                        if (table != null && upComingTaskgroup.TaskItems.Count > 0)
                        {
                            TableUtilities.PopulateLateOrUpComingTasksTable(table, upComingTaskgroup.TaskItems, taskData.FiscalPeriod);
                        }
                        createdCount++;
                    }
                    catch
                    {
                        continue;
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                Repository.Utility.WriteLog(string.Format("CreateupComingSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information);
            }
            Repository.Utility.WriteLog("CreateupComingSlides completed", System.Diagnostics.EventLogEntryType.Information);
        }
Ejemplo n.º 3
0
        private void CreateSPDLToBLSlides(TaskGroupData taskData, int lowestSLideIndex, ref int createdCount, PresentationPart oPPart, ChartType chartType)
        {
            Repository.Utility.WriteLog("CreateLateSlides started", System.Diagnostics.EventLogEntryType.Information);
            try
            {
                #region LateSlides
                if (chartType == ChartType.SPBaseLineStart && SPDSSlidePart == null)
                    return;
                if (chartType == ChartType.SPBaseLineFinish && SPDFSlidePart == null)
                    return;
                if (chartType == ChartType.SPBEI && SPBEISlidePart == null)
                    return;
                SlidePart chartSlidePart = oPPart.GetSlidePartsInOrder().ToList()[lowestSLideIndex + createdCount];

                if (chartSlidePart.ChartParts.ToList().Count > 0)
                {

                    var chartPart = chartSlidePart.ChartParts.ToList()[0];

                    foreach (IdPartPair part in chartPart.Parts)
                    {
                        var spreadsheet = chartPart.GetPartById(part.RelationshipId) as EmbeddedPackagePart;

                        if (spreadsheet != null)
                        {
                            using (var oSDoc = SpreadsheetDocument.Open(spreadsheet.GetStream(FileMode.OpenOrCreate, FileAccess.ReadWrite), true))
                            {
                                var workSheetPart = oSDoc.WorkbookPart.GetPartsOfType<WorksheetPart>().FirstOrDefault();
                                var sheetData = workSheetPart.Worksheet.Elements<SheetData>().FirstOrDefault();

                                switch (chartType)
                                {
                                    case ChartType.SPBaseLineStart:
                                        if (taskData.SPDLSTartToBL != null && taskData.SPDLSTartToBL.Count > 0 && taskData.SPDLSTartToBL[0].Data != null)
                                        {
                                            WorkbookUtilities.ReplicateRow(sheetData, 2, taskData.SPDLSTartToBL[0].Data.Count - 1);
                                            WorkbookUtilities.LoadGraphSheetData(sheetData, taskData.SPDLSTartToBL, 1, 0);
                                            BarChartUtilities.LoadChartData(chartPart, taskData.SPDLSTartToBL);
                                        }
                                        break;
                                    case ChartType.SPBaseLineFinish:
                                        if (taskData.SPDLFinishToBL != null && taskData.SPDLFinishToBL.Count > 0 && taskData.SPDLFinishToBL[0].Data != null)
                                        {
                                            WorkbookUtilities.ReplicateRow(sheetData, 2, taskData.SPDLFinishToBL[0].Data.Count - 1);
                                            WorkbookUtilities.LoadGraphSheetData(sheetData, taskData.SPDLFinishToBL, 1, 0);
                                            BarChartUtilities.LoadChartData(chartPart, taskData.SPDLFinishToBL);
                                        }
                                        break;
                                    case ChartType.SPBEI:
                                        if (taskData.BEIData != null && taskData.BEIData.Count > 0 && taskData.BEIData[0].Data != null)
                                        {
                                            WorkbookUtilities.ReplicateRow(sheetData, 2, taskData.BEIData[0].Data.Count - 1);
                                            WorkbookUtilities.LoadGraphSheetData(sheetData, taskData.BEIData, 1, 0);
                                            BarChartUtilities.LoadChartData(chartPart, taskData.BEIData);
                                        }
                                        break;
                                }
                            }

                            break;
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                Repository.Utility.WriteLog(string.Format("CreateLateSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information);
            }
            createdCount++;
            Repository.Utility.WriteLog("CreateLateSlides completed", System.Diagnostics.EventLogEntryType.Information);
        }
Ejemplo n.º 4
0
        private void CreateGridSlide(PresentationPart oPPart, int gridSlideIndex, int i, TaskItemGroup group)
        {
            Repository.Utility.WriteLog("CreateGridSlide started", System.Diagnostics.EventLogEntryType.Information);
            try
            {
                if (DPSlidePart == null)
                    return;
                SlidePart gridSlidePart = oPPart.GetSlidePartsInOrder().ToList()[gridSlideIndex + i];

                var dataTable = group.TaskItemsDataTable;
                var table = gridSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Drawing.Table>().FirstOrDefault();

                if (table != null && group.TaskItems != null && group.TaskItems.Count > 0)
                {
                    TableUtilities.PopulateTable(table, group.TaskItems);
                }
                //else
                //{
                //    DocumentFormat.OpenXml.OpenXmlElement parent = table.Parent;
                //    parent.ReplaceChild(new DocumentFormat.OpenXml.Presentation.Text("No Data Avialable"), table);
                //    //table.Remove();
                //}

                var titleShape = gridSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Shape>().ToList();
                if (titleShape.Count > 0)
                {
                    titleShape[0].TextBody = new DocumentFormat.OpenXml.Presentation.TextBody(
                                          new DocumentFormat.OpenXml.Drawing.BodyProperties(),
                                          new DocumentFormat.OpenXml.Drawing.ListStyle(),
                                          new DocumentFormat.OpenXml.Drawing.Paragraph(
                                          new DocumentFormat.OpenXml.Drawing.Run(
                                          new DocumentFormat.OpenXml.Drawing.RunProperties() { FontSize = 3600 },
                                          new DocumentFormat.OpenXml.Drawing.Text { Text = group.Title })));
                }
            }
            catch (Exception ex)
            {
                Repository.Utility.WriteLog(string.Format("CreateGridSlide had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information);
            }
            Repository.Utility.WriteLog("CreateGridSlide completed", System.Diagnostics.EventLogEntryType.Information);
        }
Ejemplo n.º 5
0
        private void CreateCompletedSlides(TaskItemGroup group, int completedSlideIndex, PresentationPart oPPart)
        {
            Repository.Utility.WriteLog("CreateCompletedSlides started", System.Diagnostics.EventLogEntryType.Information);
            try
            {
                if (CPSlidePart == null)
                    return;
                if (group.CompletedTaskgroups != null)
                {
                    IList<TaskItemGroup> CompletedTasks = group.CompletedTaskgroups;
                    if (CompletedTasks != null && CompletedTasks.Count() > 0)
                    {
                        foreach (TaskItemGroup completedTaskgroup in CompletedTasks)
                        {
                            SlidePart completedSlidePart = oPPart.GetSlidePartsInOrder().ToList()[completedSlideIndex];
                            DocumentFormat.OpenXml.Presentation.TextBody numberPart = (DocumentFormat.OpenXml.Presentation.TextBody)completedSlidePart.Slide.CommonSlideData.ShapeTree.Elements().ToList()[3].Elements().ToList()[2];
                            int bulletCount = numberPart.Elements<DocumentFormat.OpenXml.Drawing.Paragraph>().Count();
                            foreach (string task in completedTaskgroup.TaskItems.Select(t => t.Task))
                            {

                                DocumentFormat.OpenXml.Drawing.Paragraph paragraph = (DocumentFormat.OpenXml.Drawing.Paragraph)numberPart.Elements().ToList()[3].Clone();
                                for (int i = paragraph.Elements().Count() - 1; i >=1; i--)
                                {
                                    if (paragraph.ElementAt(i).GetType() == typeof(DocumentFormat.OpenXml.Drawing.Run))
                                    {
                                        paragraph.ElementAt(i).Remove();
                                    }
                                }
                                (paragraph.Elements().ToList()[0] as DocumentFormat.OpenXml.Drawing.Run).Text = new DocumentFormat.OpenXml.Drawing.Text(task);
                                numberPart.Append(paragraph);
                            }

                            //var titleShape = completedSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Shape>().ToList();
                            //if (titleShape.Count > 0)
                            //{
                            //    titleShape[0].TextBody = new DocumentFormat.OpenXml.Presentation.TextBody(
                            //                          new DocumentFormat.OpenXml.Drawing.BodyProperties(),
                            //                          new DocumentFormat.OpenXml.Drawing.ListStyle(),
                            //                          new DocumentFormat.OpenXml.Drawing.Paragraph(
                            //                          new DocumentFormat.OpenXml.Drawing.Run(
                            //                          new DocumentFormat.OpenXml.Drawing.RunProperties() { FontSize = 3600 },
                            //                          new DocumentFormat.OpenXml.Drawing.Text { Text = group.Title })));
                            //}

                            DocumentFormat.OpenXml.Presentation.TextBody numPart = (DocumentFormat.OpenXml.Presentation.TextBody)completedSlidePart.Slide.CommonSlideData.ShapeTree.Elements().ToList()[3].Elements().ToList()[2];
                            for (int i = bulletCount - 2; i >= 0; i--)
                            {
                                ((DocumentFormat.OpenXml.Drawing.Paragraph)numPart.Elements().ToList()[3]).Remove();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Repository.Utility.WriteLog(string.Format("CreateCompletedSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information);
            }
            Repository.Utility.WriteLog("CreateCompletedSlides completed", System.Diagnostics.EventLogEntryType.Information);
        }
Ejemplo n.º 6
0
        private void CreateChartSlides(TaskGroupData taskData, int lowestSLideIndex, ref int createdCount, PresentationPart oPPart)
        {
            Repository.Utility.WriteLog("CreateChartSlides started", System.Diagnostics.EventLogEntryType.Information);
            try
            {
                if (ChartSlidePart == null)
                    return;
                if (taskData.ChartsData == null || taskData.ChartsData.Keys.Count == 0 || !taskData.ChartsData.Keys.Any(t=>t.StartsWith("Show On")))
                {
                    createdCount++;
                    return;
                }

                if (taskData.ChartsData != null)
                {
                    foreach (string key in taskData.ChartsData.Keys)
                    {
                        try
                        {
                            if (key.StartsWith("Show On"))
                            {
                                //Get all Tasks related to  Driving path
                                TaskItemGroup newGroup = new TaskItemGroup() { ChartTaskItems = taskData.ChartsData[key] };
                                var chartDataTable = newGroup.GetChartDataTable(key);

                                #region Charts
                                if (chartDataTable != null)
                                {

                                    SlidePart chartSlidePart = oPPart.GetSlidePartsInOrder().ToList()[lowestSLideIndex + createdCount];

                                    if (chartSlidePart.ChartParts.ToList().Count > 0)
                                    {
                                        createdCount++;
                                        var chartPart = chartSlidePart.ChartParts.ToList()[0];

                                        foreach (IdPartPair part in chartPart.Parts)
                                        {
                                            var spreadsheet = chartPart.GetPartById(part.RelationshipId) as EmbeddedPackagePart;

                                            if (spreadsheet != null)
                                            {
                                                OpenSettings settings  = new OpenSettings();
                                                settings.AutoSave = true;
                                                using (var oSDoc = SpreadsheetDocument.Open(spreadsheet.GetStream(FileMode.OpenOrCreate, FileAccess.ReadWrite), true,settings))
                                                {
                                                    var workSheetPart = oSDoc.WorkbookPart.GetPartsOfType<WorksheetPart>().FirstOrDefault();
                                                    var sheetData = workSheetPart.Worksheet.Elements<SheetData>().FirstOrDefault();
                                                    for (int i = sheetData.Elements().Count() - 1; i >= 2; i--)
                                                    {
                                                        sheetData.ElementAt(i).Remove();
                                                    }
                                                    string reference = workSheetPart.TableDefinitionParts.ElementAt(0).Table.Reference.Value;
                                                    string length = reference.Split(":".ToCharArray())[1].Replace("I","");
                                                    WorkbookUtilities.ReplicateRow(sheetData, 2, chartDataTable.Rows.Count - 1);
                                                    WorkbookUtilities.LoadSheetData(sheetData, chartDataTable, 1, 0);
                                                    workSheetPart.TableDefinitionParts.ElementAt(0).Table.Reference.Value = reference.Replace(length, (chartDataTable.Rows.Count + 1).ToString());
                                                    BarChartUtilities.LoadChartData(chartPart, chartDataTable);
                                                    workSheetPart.TableDefinitionParts.ElementAt(0).Table.Save();
                                                    workSheetPart.Worksheet.Save();

                                                }

                                                break;
                                            }
                                        }

                                        var titleShape = chartSlidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Shape>().ToList();
                                        if (titleShape.Count > 0)
                                        {
                                            titleShape[0].TextBody = new DocumentFormat.OpenXml.Presentation.TextBody(
                                                                  new DocumentFormat.OpenXml.Drawing.BodyProperties(),
                                                                  new DocumentFormat.OpenXml.Drawing.ListStyle(),
                                                                  new DocumentFormat.OpenXml.Drawing.Paragraph(
                                                                  new DocumentFormat.OpenXml.Drawing.Run(
                                                                  new DocumentFormat.OpenXml.Drawing.RunProperties() { FontSize = 3600 },
                                                                  new DocumentFormat.OpenXml.Drawing.Text { Text = key.Replace("Show On_", "") })));
                                        }

                                    }
                                #endregion
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Repository.Utility.WriteLog(string.Format("CreateChartSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information);
                            continue;
                        }

                    }

                }
            }
            catch (Exception ex)
            {
                Repository.Utility.WriteLog(string.Format("CreateChartSlides had an error and the error message={0}", ex.Message), System.Diagnostics.EventLogEntryType.Information);
            }

            Repository.Utility.WriteLog("CreateChartSlides completed", System.Diagnostics.EventLogEntryType.Information);
        }