Exemplo n.º 1
0
        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();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            const string reportTemplateName = "ChangesReportTemplate.docx";
            var foundryName = Request.Params["FOUNDRY_NAME"];
            var fromDate = Request.Params["FROM_DATE"];
            var toDate = Request.Params["TO_DATE"];

            //date is expected in dd/MM/yyyy format from the url

            if (!String.IsNullOrEmpty(fromDate))
            {
                fromDate = DateTime.Parse(fromDate, CustomCulture).ToString("dd-MM-yyyy");
            }

            if(!String.IsNullOrEmpty(toDate))
            {
                toDate = DateTime.Parse(toDate, CustomCulture).ToString("dd-MM-yyyy");
            }

            if (string.IsNullOrEmpty(reportTemplateName))
                return;

            var generationInfo = GetDocumentGenerationInfo("ChangesReportGenerator", "1.0", GetDataContext(),
                                        reportTemplateName, false);

            var sampleDocumentGenerator
                = new ChangesReportGenerator(generationInfo,
                                                String.IsNullOrEmpty(foundryName) ? "All" : foundryName,
                                                fromDate,
                                                toDate);

            byte[] result = sampleDocumentGenerator.GenerateDocument();
            var filePath = WriteOutputToFile("ChangesReportTemplate" + 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

            string filename = "ChangesReport" + foundryName + ".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();
        }
Exemplo n.º 3
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 reportTemplateName = Request.Params["TEMPLATE_NAME"];
            var ReportNumber = Request.Params["REPORT_NUMBER"];
            var RGReportID = Request.Params["REPORT_ID"];
            var cellNo = Request.Params["CELL_NO"];

            //date is expected in dd/MM/yyyy format from the url

            if (string.IsNullOrEmpty(reportTemplateName))
                return;

            var generationInfo = GetDocumentGenerationInfo("AddressStickerGenerator", "1.0", GetDataContext(),
                                        reportTemplateName, false);

            var addressStickerGenerator
                = new AddressStickerGenerator(generationInfo);

            byte[] result = addressStickerGenerator.GenerateDocument();
            var filePath = WriteOutputToFile("AddressStickerReport" + 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

            string filename = "AddressStickerReport.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 reportTemplateName = Request.Params["Template"];
            var IsFilmSizeInCms = Convert.ToBoolean(Request.Params["FilmSize"]);

            if (string.IsNullOrEmpty(reportTemplateName))
                return;

            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo("FinalRGReportGenerator", "1.0", GetDataContext(),
                                        reportTemplateName, false);

            FinalRGReportGenerator sampleDocumentGenerator = new FinalRGReportGenerator(generationInfo);
            sampleDocumentGenerator.IsFilmSizeInCms = IsFilmSizeInCms;
            byte[] result = 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

            string filename = "RTNo" + Request.Params["RTNo"] + ".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();
        }