protected void Page_Load(object sender, EventArgs e)
        {
            var data = GetDataContext();
            var reportTemplate = data.FixedPattern.Customer.Foundry.ReportTemplate;

            var generationInfo = GetDocumentGenerationInfo("RGReportGenerator", "1.0", data,
                                        reportTemplate, false);

            var sampleDocumentGenerator = new RGReportGenerator(generationInfo);
            byte[] result = sampleDocumentGenerator.GenerateDocument();
            var filePath = WriteOutputToFile("RadiographyReportTemplate_Out" + DateTime.Now.ToString("SSMIHH") + ".docx", result);

            using (var wordDocument = WordprocessingDocument.Open(filePath, true))
            {
                wordDocument.ChangeDocumentType(WordprocessingDocumentType.Document);
                var mainDocumentPart = wordDocument.MainDocumentPart;
                var document = mainDocumentPart.Document;
                // Clean up: The user will appreciate a clean document!
                var helper = new OpenXmlHelper(DocumentGenerationInfo.NamespaceUri);
                helper.RemoveContentControlsAndKeepContents(document);
                document.Save();
            }

            //download the file to the user

            var filename = "ReportNo" + Request.Params["ReportNo"] + ".docx";
            Response.ContentType = "application/ms-word";
            Response.AddHeader("content-disposition", "attachment; filename="+filename);
            Response.TransmitFile(filePath);
            Response.Flush();

            //clean up the file
            File.Delete(filePath);
            Response.End();
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var data = GetDataContext();

            if (data.StatusID == 2)
            {
                if (data.RGReportRows.SelectMany(p => p.Classifications).Count() > 0)
                {
                    data.Status.Status = "CASTING ACCEPTABLE AS PER LEVEL " + data.RGReportRows.SelectMany(p => p.Classifications.Split(',')).Where(m => !string.IsNullOrEmpty(m)).Select(int.Parse).Max();
                }
                else
                {
                    data.Status.Status = "CASTING ACCEPTABLE AS PER LEVEL 1";
                }
            }
            var reportTemplate = data.FixedPattern.Customer.Foundry.ReportTemplate;

            var generationInfo = GetDocumentGenerationInfo("RGReportGenerator", "1.0", data,
                                                           reportTemplate, false);

            var IsFilmSizeInCms = Convert.ToBoolean(Request.Params["FilmSize"]);

            var sampleDocumentGenerator = new RGReportGenerator(generationInfo);

            sampleDocumentGenerator.IsFilmSizeInCms = IsFilmSizeInCms;

            byte[] result   = sampleDocumentGenerator.GenerateDocument();
            var    filePath = WriteOutputToFile("RadiographyReportTemplate_Out" + DateTime.Now.ToString("SSMIHH") + ".docx", result);

            using (var wordDocument = WordprocessingDocument.Open(filePath, true))
            {
                wordDocument.ChangeDocumentType(WordprocessingDocumentType.Document);
                var mainDocumentPart = wordDocument.MainDocumentPart;
                var document         = mainDocumentPart.Document;
                // Clean up: The user will appreciate a clean document!
                var helper = new OpenXmlHelper(DocumentGenerationInfo.NamespaceUri);
                helper.RemoveContentControlsAndKeepContents(document);
                document.Save();
            }

            //download the file to the user

            var filename = "ReportNo" + Request.Params["ReportNo"] + ".docx";

            Response.ContentType = "application/ms-word";
            Response.AddHeader("content-disposition", "attachment; filename=" + filename);
            Response.TransmitFile(filePath);
            Response.Flush();

            //clean up the file
            File.Delete(filePath);
            Response.End();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var data = GetDataContext();
            if (data.StatusID == 2)
            {
                if (data.RGReportRows.SelectMany(p => p.Classifications).Count() > 0)
                    data.Status.Status = "CASTING ACCEPTABLE AS PER LEVEL " + data.RGReportRows.SelectMany(p => p.Classifications.Split(',')).Where(m => !string.IsNullOrEmpty(m)).Select(int.Parse).Max();
                else
                    data.Status.Status = "CASTING ACCEPTABLE AS PER LEVEL 1";
            }
            var reportTemplate = data.FixedPattern.Customer.Foundry.ReportTemplate;

            var generationInfo = GetDocumentGenerationInfo("RGReportGenerator", "1.0", data,
                                        reportTemplate, false);

            var IsFilmSizeInCms = Convert.ToBoolean(Request.Params["FilmSize"]);

            var sampleDocumentGenerator = new RGReportGenerator(generationInfo);
            sampleDocumentGenerator.IsFilmSizeInCms = IsFilmSizeInCms;

            byte[] result = sampleDocumentGenerator.GenerateDocument();
            var filePath = WriteOutputToFile("RadiographyReportTemplate_Out" + DateTime.Now.ToString("SSMIHH") + ".docx", result);

            using (var wordDocument = WordprocessingDocument.Open(filePath, true))
            {
                wordDocument.ChangeDocumentType(WordprocessingDocumentType.Document);
                var mainDocumentPart = wordDocument.MainDocumentPart;
                var document = mainDocumentPart.Document;
                // Clean up: The user will appreciate a clean document!
                var helper = new OpenXmlHelper(DocumentGenerationInfo.NamespaceUri);
                helper.RemoveContentControlsAndKeepContents(document);
                document.Save();
            }

            //download the file to the user

            var filename = "ReportNo" + Request.Params["ReportNo"] + ".docx";
            Response.ContentType = "application/ms-word";
            Response.AddHeader("content-disposition", "attachment; filename=" + filename);
            Response.TransmitFile(filePath);
            Response.Flush();

            //clean up the file
            File.Delete(filePath);
            Response.End();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var data           = GetDataContext();
            var reportTemplate = data.FixedPattern.Customer.Foundry.ReportTemplate;

            var generationInfo = GetDocumentGenerationInfo("RGReportGenerator", "1.0", data,
                                                           reportTemplate, false);

            var sampleDocumentGenerator = new RGReportGenerator(generationInfo);

            byte[] result   = sampleDocumentGenerator.GenerateDocument();
            var    filePath = WriteOutputToFile("RadiographyReportTemplate_Out" + DateTime.Now.ToString("SSMIHH") + ".docx", result);

            using (var wordDocument = WordprocessingDocument.Open(filePath, true))
            {
                wordDocument.ChangeDocumentType(WordprocessingDocumentType.Document);
                var mainDocumentPart = wordDocument.MainDocumentPart;
                var document         = mainDocumentPart.Document;
                // Clean up: The user will appreciate a clean document!
                var helper = new OpenXmlHelper(DocumentGenerationInfo.NamespaceUri);
                helper.RemoveContentControlsAndKeepContents(document);
                document.Save();
            }

            //download the file to the user

            var filename = "ReportNo" + Request.Params["ReportNo"] + ".docx";

            Response.ContentType = "application/ms-word";
            Response.AddHeader("content-disposition", "attachment; filename=" + filename);
            Response.TransmitFile(filePath);
            Response.Flush();

            //clean up the file
            File.Delete(filePath);
            Response.End();
        }