Esempio n. 1
0
        public ShowHtmlDataDto GetReportViewer2(string reportID, string loginDomain, string loginSite, string printTemplateID)
        {
            List <ProcedureDto> procedureDtos = GetProcedureByReportID(reportID).ToList();
            ProcedureDto        procedure     = procedureDtos[0];

            DataTable dt;
            string    templateInfo = "";

            //use store procedure
            Order           order           = _dbContext.Set <Order>().Where(p => p.UniqueID == procedure.OrderID).FirstOrDefault();
            string          accNo           = order.AccNo;
            string          modalityType    = procedure.ModalityType;
            ReportDBService reportDBService = new ReportDBService();
            string          templateID      = "";

            reportDBService.GetReportPrintTemplate(accNo, modalityType, reportID, loginSite, out templateID, out dt);


            //print templateID
            if (!string.IsNullOrEmpty(printTemplateID))
            {
                Report report = _dbContext.Set <Report>().Where(r => r.UniqueID == reportID).FirstOrDefault();
                if (report != null && report.Status < (int)RPStatus.FirstApprove)
                {
                    templateID = printTemplateID;
                }
            }

            if (templateID != "")
            {
                PrintTemplate printTemplate = _dbContext.Set <PrintTemplate>().Where(p => p.UniqueID == templateID).FirstOrDefault();
                if (printTemplate != null)
                {
                    templateInfo = generatePrintTemplate(printTemplate);
                }
            }
            else
            {
                return(null);
            }


            string templateGuid = ReportUtils.GetFirstRowValueFromDataSet(dt.DataSet, ReportCommon.FIELDNAME_tbReport__PrintTemplateGuid);

            DataTable newdt = generateDataTable4PrintingForReport(dt.DataSet, ref templateInfo, reportID, loginDomain);

            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, newdt);

                return(new ShowHtmlDataDto {
                    Template = templateInfo, data = Convert.ToBase64String(ms.ToArray())
                });
            }
        }
Esempio n. 2
0
        private string GetRenderedReportHtml(DataSet dsReportData, string templateInfo)
        {
            if (dsReportData == null || dsReportData.Tables.Count < 1)
            {
                return(string.Empty);
            }

            string content = "";

            string rptGuid = ReportUtils.GetFirstRowValueFromDataSet(dsReportData, "TBREPORT__REPORTGUID");

            string savePath = GenerateTempSaveFolder();
            string saveFile = Path.Combine(savePath, rptGuid + ".htm");

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(templateInfo);
            using (C1Report c1rpt = new C1Report())
            {
                c1rpt.Load(xmlDocument, "Template");
                c1rpt.DataSource.Recordset = dsReportData.Tables[0];

                c1rpt.RenderToFile(saveFile, FileFormatEnum.HTML);
            }

            content = File.ReadAllText(saveFile);

            int startIndex = content.IndexOf("src=\"");

            while (startIndex > 0)
            {
                int endIndex = content.IndexOf("\"", startIndex + 6);
                if (endIndex > 0)
                {
                    string imagePath  = content.Substring(startIndex + 5, endIndex - startIndex - 5);
                    byte[] imageArray = System.IO.File.ReadAllBytes(savePath + "\\" + imagePath);
                    string base64ImageRepresentation = Convert.ToBase64String(imageArray);
                    content = content.Substring(0, startIndex + 5) + "data:image/jpeg;base64," + base64ImageRepresentation + content.Substring(endIndex);
                }

                startIndex = content.IndexOf("src=\"", startIndex + 6);
            }

            return(content);
        }
Esempio n. 3
0
        public string GetReportViewer(string reportID, string loginDomain, string loginSite)
        {
            List <ProcedureDto> procedureDtos = GetProcedureByReportID(reportID).ToList();
            ProcedureDto        procedure     = procedureDtos[0];

            DataTable dt;
            string    templateInfo = "";

            //use store procedure
            Order           order           = _dbContext.Set <Order>().Where(p => p.UniqueID == procedure.OrderID).FirstOrDefault();
            string          accNo           = order.AccNo;
            string          modalityType    = procedure.ModalityType;
            ReportDBService reportDBService = new ReportDBService();
            string          templateID      = "";

            reportDBService.GetReportPrintTemplate(accNo, modalityType, reportID, loginSite, out templateID, out dt);
            if (templateID != "")
            {
                PrintTemplate printTemplate = _dbContext.Set <PrintTemplate>().Where(p => p.UniqueID == templateID).FirstOrDefault();
                if (printTemplate != null)
                {
                    templateInfo = generatePrintTemplate(printTemplate);
                }
            }
            else
            {
                return(null);
            }


            string templateGuid = ReportUtils.GetFirstRowValueFromDataSet(dt.DataSet, ReportCommon.FIELDNAME_tbReport__PrintTemplateGuid);

            DataTable newdt = generateDataTable4PrintingForReport(dt.DataSet, ref templateInfo, reportID, loginDomain);

            DataSet newds = new DataSet();

            newds.Tables.Add(newdt);
            //get html
            return(GetRenderedReportHtml(newds, templateInfo));
        }