public static ProjectSummaryDetailModel GetProjectSummaryDetail(int projectId)
        {
            try
            {
                ProjectSummaryDetailModel objSummaryModel = null;
                using (DCSEntities context = new DCSEntities())
                {
                    var result = context.usp_GetProjectSummaryDetails2(projectId).FirstOrDefault();
                    if (result != null)
                    {
                        objSummaryModel = new ProjectSummaryDetailModel();
                        objSummaryModel.AnthemOwner = result.FullName;
                        objSummaryModel.PartnerName = result.PartnerName;
                        objSummaryModel.ETOPlayBookName = result.EtoPlayBookName;
                        objSummaryModel.ProjectAccomplishments = result.Accomplishments;
                        objSummaryModel.ProjectFundingAsk = result.FundingAsk;
                        objSummaryModel.ProjectComplete = result.ProjectComplete.HasValue ? result.ProjectComplete.Value : decimal.MinValue;
                        objSummaryModel.ProjectDescription = result.ProjectDescription;
                        objSummaryModel.ProjectDirection = result.Direction;
                        objSummaryModel.ProjectEndDateString = result.ProjectEndDate.HasValue ? result.ProjectEndDate.Value.ToShortDateString() : DateTime.MinValue.ToShortDateString();
                        objSummaryModel.ProjectExecutiveSummary = result.ExecutiveStatus;
                        objSummaryModel.ProjectId = result.ID;
                        objSummaryModel.ProjectKeyRiskIssues = result.KeyRisksAndIssues;
                        objSummaryModel.ProjectName = result.ProjectName;
                        objSummaryModel.ProjectStartDateString = result.ProjectStartDate.HasValue ? result.ProjectStartDate.Value.ToShortDateString() : DateTime.MinValue.ToShortDateString();
                        objSummaryModel.ProjectStartDate = result.ProjectStartDate.HasValue ? result.ProjectStartDate.Value : DateTime.MinValue;
                        objSummaryModel.ProjectEndDate = result.ProjectEndDate.HasValue ? result.ProjectEndDate.Value : DateTime.MinValue;
                        objSummaryModel.ScopeId = result.ScopeId.HasValue ? result.ScopeId.Value : int.MinValue;
                        objSummaryModel.ResourceId = result.ResourcesId.HasValue ? result.ResourcesId.Value : int.MinValue;
                        objSummaryModel.FinancialId = result.FinancialId.HasValue ? result.FinancialId.Value : int.MinValue;
                        objSummaryModel.OverallStatusId = result.ProjectStatusId.HasValue ? result.ProjectStatusId.Value : int.MinValue;
                        objSummaryModel.ScheduleId = result.ScheduleId.HasValue ? result.ScheduleId.Value : int.MinValue;

                        List<MileStone> lstMileStones = new List<MileStone>();
                        var resultMileStones = context.ProjectMilestones.Where(x => x.ProjectId == projectId).ToList();
                        if (resultMileStones != null && resultMileStones.Count > 0)
                        {
                            foreach (var mileStone in resultMileStones)
                            {
                                MileStone objMileStone = new MileStone();
                                objMileStone.Title = mileStone.Name;
                                objMileStone.MileStoneDate = mileStone.StartDate.HasValue ? mileStone.StartDate.Value : DateTime.MinValue;
                                objMileStone.DateString = mileStone.StartDate.HasValue ? string.Format("{0:MM/dd/yyyy}", mileStone.StartDate.Value.ToShortDateString()) : DateTime.MinValue.ToShortDateString();
                                objMileStone.MilestoneStatus = mileStone.MilestoneStatus.GetValueOrDefault();
                                lstMileStones.Add(objMileStone);
                            }
                        }
                        objSummaryModel.ProjectMileStones = lstMileStones;
                    }
                }
                return objSummaryModel;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //==================================
        public string ConvertHtmlToPpt(int projectId)
        {
            string pptFileName = string.Empty;
            try
            {
                ProjectSummaryDetailModel objSummaryModel = new ProjectSummaryDetailModel();
                objSummaryModel = ProjectSummary.GetProjectSummaryDetail(projectId);

                string pptFilePath = string.Empty;
                string htmlFilePath = string.Empty;

                StringWriter sw = new StringWriter();

                // Create new PPTX file for the attachment purposes.

                pptFileName = projectId + "ProjectName" + Guid.NewGuid().ToString().Substring(0, 6);
                pptFilePath = Server.MapPath("~/Temp/" + pptFileName);

                Microsoft.Office.Interop.PowerPoint.Application powerPointApp = new Microsoft.Office.Interop.PowerPoint.Application();

                // VPS 28-10-2015

                powerPointApp.Visible = MsoTriState.msoTrue;
                Microsoft.Office.Interop.PowerPoint.Application PowerPoint_App = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = PowerPoint_App.Presentations;
                Microsoft.Office.Interop.PowerPoint.Presentation presentation = multi_presentations.Open(Server.MapPath("~/Temp/Template/Slide_Template.pptx"), MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);

                // Copy The Master presentation to the New presentation

                // Now open this new presentation slide and alter this with dynamic data

                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    foreach (var item in presentation.Slides[i + 1].Shapes)
                    {
                        var shape = (Microsoft.Office.Interop.PowerPoint.Shape)item;
                        if (shape.HasTable == MsoTriState.msoTrue)
                        {
                            int columnCount = shape.Table.Columns.Count;
                            if (columnCount == 13) // Detect if this is the duration Table
                            {
                                if (objSummaryModel.ProjectDurationList != null && objSummaryModel.ProjectDurationList.Count > 0)
                                {
                                    // Find single column Width
                                    var column1 = shape.Table.Columns[1];
                                    float column1Width = column1.Width;
                                    float tableHeight = shape.Height;
                                    // Calculate Table Width [Multiply with 7 as initial 7 columns have proper design]
                                    float tableWidth = column1Width * 13;

                                    // Get Total Records
                                    int recordsCount = objSummaryModel.ProjectDurationList.Count;
                                    if (recordsCount < 13)
                                    {
                                        for (int lastColIndex = columnCount; lastColIndex >= recordsCount + 1; lastColIndex--)
                                        {
                                            var colToDelete = shape.Table.Columns[lastColIndex];
                                            colToDelete.Delete();
                                        }
                                    }
                                    // Get new Width of Each Columns;
                                    float newColsWidth = tableWidth / recordsCount;

                                    for (int rec = 0; rec <= recordsCount - 1; rec++)
                                    {
                                        //shape.Table.Columns.Add(-1);
                                        var column = shape.Table.Columns[rec + 1];//[1];
                                        column.Width = newColsWidth;
                                        var cell = shape.Table.Cell(1, rec + 1);//shape.Table.Columns.Count);
                                        var projectDuration = objSummaryModel.ProjectDurationList.ElementAt(rec);
                                        cell.Shape.TextFrame.TextRange.Text = projectDuration.Title;
                                    }
                                    // Delete the default column
                                    //column1.Delete();
                                    shape.Width = tableWidth;
                                    shape.Height = tableHeight;
                                }
                            }
                        }

                        if (shape.HasTextFrame == MsoTriState.msoTrue)
                        {
                            if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                            {
                                var textRange = shape.TextFrame.TextRange;
                                var text = textRange.Text;

                                if (text.IndexOf("Color_O") != -1)
                                {
                                    shape.TextFrame.TextRange.Replace("Color_O", "");//objSummaryModel.OverallStatusId.ToString());
                                    FillShapeColor(shape, objSummaryModel.OverallStatusId);
                                }

                                if (text.IndexOf("Color_Sp") != -1)
                                {
                                    shape.TextFrame.TextRange.Replace("Color_Sp", "");//objSummaryModel.ScopeId.ToString());
                                    FillShapeColor(shape, objSummaryModel.ScopeId);
                                }

                                if (text.IndexOf("Color_Sc") != -1)
                                {
                                    shape.TextFrame.TextRange.Replace("Color_Sc", "");//objSummaryModel.ScheduleId.ToString());
                                    FillShapeColor(shape, objSummaryModel.ScheduleId);
                                }

                                if (text.IndexOf("Color_R") != -1)
                                {
                                    shape.TextFrame.TextRange.Replace("Color_R", "");//objSummaryModel.ResourceId.ToString());
                                    FillShapeColor(shape, objSummaryModel.ResourceId);
                                }

                                if (text.IndexOf("Color_F") != -1)
                                {
                                    shape.TextFrame.TextRange.Replace("Color_F", "");//objSummaryModel.FinancialId.ToString());
                                    FillShapeColor(shape, objSummaryModel.FinancialId);
                                }

                                if (text.IndexOf("Slide_date") != -1)
                                    shape.TextFrame.TextRange.Replace("Slide_date", DateTime.Now.ToString("MM/dd/yyyy"));

                                if (text.IndexOf("Project_Title") != -1)
                                    shape.TextFrame.TextRange.Replace("Project_Title", objSummaryModel.ProjectName);

                                if (text.IndexOf("Project_Owner") != -1)
                                    shape.TextFrame.TextRange.Replace("Project_Owner", objSummaryModel.AnthemOwner);

                                if (text.IndexOf("Project_CoOwner") != -1)
                                    shape.TextFrame.TextRange.Replace("Project_CoOwner", objSummaryModel.PartnerName);

                                if (text.IndexOf("start_Date") != -1)
                                    shape.TextFrame.TextRange.Replace("start_Date", objSummaryModel.ProjectStartDateString);

                                if (text.IndexOf("end_Date") != -1)
                                    shape.TextFrame.TextRange.Replace("end_Date", objSummaryModel.ProjectEndDateString);

                                if (text.IndexOf("perc_Completed") != -1)
                                    shape.TextFrame.TextRange.Replace("perc_Completed", Convert.ToString(objSummaryModel.ProjectComplete));

                                if (text.IndexOf("project_desc_And_Buss_Value") != -1)
                                    shape.TextFrame.TextRange.Replace("project_desc_And_Buss_Value", (!String.IsNullOrEmpty(objSummaryModel.ProjectDescription) ? ReplaceHtmlTags(objSummaryModel.ProjectDescription) : ""));

                                if (text.IndexOf("Project_ExecutionSummary") != -1)
                                    shape.TextFrame.TextRange.Replace("Project_ExecutionSummary", (!String.IsNullOrEmpty(objSummaryModel.ProjectExecutiveSummary) ? ReplaceHtmlTags(objSummaryModel.ProjectExecutiveSummary) : ""));//"The Server Standard Platforms Program provides standard server specifications and pricing in support of:\n Technology Strategies and Planning roadmaps\nInfrastructure Lifecycle Management objectives\nIT Finance Cost Recovery goals\nDemand Management targets\nData Center Services platform Build best practices\nData Center Services platform Run fault isolation/problem determination processes\n\nEssential in providing this support is the Standard Platforms Offerings Quick Reference Guide (SPO QRG). This set of documentation maps  server, operating system, middleware, and storage speculations to costs.");

                                if (text.IndexOf("Project_accomplishments") != -1)
                                    shape.TextFrame.TextRange.Replace("Project_accomplishments", (!String.IsNullOrEmpty(objSummaryModel.ProjectAccomplishments) ? ReplaceHtmlTags(objSummaryModel.ProjectAccomplishments) : ""));//"SPO QRG V09.02.20 published on schedule\n Updated IBM Contract Rates\nEnhanced SPO Cost Codes with OS & Middleware version\nRe-designed Engineering Extract for “One Way Ordering\"");

                                if (text.IndexOf("Project_Issues") != -1)
                                    shape.TextFrame.TextRange.Replace("Project_Issues", (!String.IsNullOrEmpty(objSummaryModel.ProjectKeyRiskIssues) ? ReplaceHtmlTags(objSummaryModel.ProjectKeyRiskIssues) : ""));// "Current documentation tool (Excel) may not be adequate to manage future requirements:\nIBM/ANTM 2015 contract added Harrisonburg and Virginia Beach to data center  options\nIBM/ANTM 2015 contract added IBM hosted cloud based services options\nService Now catalog integration requirements may be difficult to implement and maintain\nServer automated configuration tools integration requirements may be difficult to implement and maintain");

                                if (text.IndexOf("Funding_Ask") != -1)
                                    shape.TextFrame.TextRange.Replace("Funding_Ask", (!String.IsNullOrEmpty(objSummaryModel.ProjectFundingAsk) ? ReplaceHtmlTags(objSummaryModel.ProjectFundingAsk) : ""));// "Capital");

                                if (text.IndexOf("direction_Needed") != -1)
                                    shape.TextFrame.TextRange.Replace("direction_Needed", (!String.IsNullOrEmpty(objSummaryModel.ProjectDirection) ? ReplaceHtmlTags(objSummaryModel.ProjectDirection) : ""));// "Approval to develop a database SPO Catalog tool to replace the SPO Quick Reference Guide Excel workbook.");
                            }
                        }
                    }
                }

                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    foreach (var item in presentation.Slides[i + 1].Shapes)
                    {
                        var shape = (Microsoft.Office.Interop.PowerPoint.Shape)item;

                        if (shape.HasTextFrame == MsoTriState.msoTrue)
                        {
                            if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                            {
                                var textRange = shape.TextFrame.TextRange;
                                var text = textRange.Text;

                                if (objSummaryModel.ProjectDurationList != null && objSummaryModel.ProjectDurationList.Count > 0)
                                {
                                    int recordsCount = objSummaryModel.ProjectDurationList.Count;
                                    for (int rec = 0; rec <= recordsCount - 1; rec++)
                                    {
                                        var projectDuration = objSummaryModel.ProjectDurationList.ElementAt(rec);
                                        if (projectDuration.MileStoneList != null && projectDuration.MileStoneList.Count > 0)
                                        {
                                            int j = 0;
                                            foreach (var milestone in projectDuration.MileStoneList)
                                            {
                                                if (text == "_" + Convert.ToString(rec) + Convert.ToString(j) + "dsc")
                                                {
                                                    Microsoft.Office.Interop.PowerPoint.Slide slide = presentation.Slides[1];
                                                    switch (milestone.MilestoneStatus)
                                                    {
                                                        case 1:
                                                            {
                                                                Microsoft.Office.Interop.PowerPoint.Shape pic = slide.Shapes.AddPicture(Server.MapPath("~/Temp/Template/1.jpg"), Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, shape.Left, shape.Top, 10, 10);
                                                                break;
                                                            }
                                                        case 2:
                                                            {

                                                                Microsoft.Office.Interop.PowerPoint.Shape pic = slide.Shapes.AddPicture(Server.MapPath("~/Temp/Template/2.jpg"), Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, shape.Left, shape.Top, 10, 10);
                                                                break;
                                                            }
                                                        case 3:
                                                            {
                                                                Microsoft.Office.Interop.PowerPoint.Shape pic = slide.Shapes.AddPicture(Server.MapPath("~/Temp/Template/3.jpg"), Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, shape.Left, shape.Top, 10, 10);
                                                                break;
                                                            }
                                                    }
                                                    textRange.Text = "  " + milestone.Title;
                                                }
                                                j++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // Remove all unused shapes
                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    foreach (var item in presentation.Slides[i + 1].Shapes)
                    {
                        var shape = (Microsoft.Office.Interop.PowerPoint.Shape)item;

                        if (shape.HasTextFrame == MsoTriState.msoTrue)
                        {
                            if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                            {
                                var textRange = shape.TextFrame.TextRange;
                                var text = textRange.Text;

                                if (text.IndexOf("dsc") != -1)
                                {
                                    shape.TextFrame.DeleteText();
                                }
                            }
                        }
                    }
                }

                presentation.SaveAs(pptFilePath, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, MsoTriState.msoTrue);
                presentation.Close();
                PowerPoint_App.Quit();
                // VPS Code Ends Here

            }

            catch (Exception ex)
            {
                pptFileName = string.Empty;
            }
            return pptFileName;
        }