public static void Generate(Telerik.ReportViewer.Html5.WebForms.ReportViewer rv, IEnumerable<object> data, string extension, SortDescriptorCollection sortDescriptors, GroupDescriptorCollection grpDescriptors)
        {
            Telerik.Reporting.Report report1 = new Telerik.Reporting.Report();
            report1.DataSource = data;
            string sortCol = "";
            string sortDir = "";

            //multi sort can be done by iterating through collection like for group
            if (sortDescriptors.Count > 0)
            {
                ColumnSortDescriptor sd = sortDescriptors[0] as ColumnSortDescriptor;
                sortCol = sd.Column.UniqueName;
                sortDir = sd.SortDirection.ToString();
            }

            //Page Header Section
            Telerik.Reporting.PageHeaderSection pageHeaderSection1 = new Telerik.Reporting.PageHeaderSection();
            pageHeaderSection1.Height = new Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch);
            pageHeaderSection1.Style.BackgroundColor = Color.Gray;
            Telerik.Reporting.TextBox txtHead = new Telerik.Reporting.TextBox();
            txtHead.Value = "Title";
            txtHead.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(3.2395832538604736D, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(0.02083333395421505D, Telerik.Reporting.Drawing.UnitType.Inch));
            txtHead.Name = "reportTitle";
            txtHead.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(5.5603775978088379D, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(0.20000000298023224D, Telerik.Reporting.Drawing.UnitType.Inch));
            pageHeaderSection1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { txtHead });

            IEnumerator dataColl = data.GetEnumerator();
            int count = 0;
            int first = 0;
            object obj = null;

            while (dataColl.MoveNext())
            {
                if (first == 0)
                {
                    obj = dataColl.Current;
                    foreach (PropertyInfo info in obj.GetType().GetProperties())
                    {
                        count++;
                    }
                    first++;
                }
            }

            Telerik.Reporting.Drawing.Unit x = Telerik.Reporting.Drawing.Unit.Inch(0);
            Telerik.Reporting.Drawing.Unit y = Telerik.Reporting.Drawing.Unit.Inch(0);
            Telerik.Reporting.ReportItemBase[] headColumnList = new Telerik.Reporting.ReportItem[count];
            Telerik.Reporting.ReportItemBase[] detailColumnList = new Telerik.Reporting.ReportItem[count];
            Telerik.Reporting.Group group = new Telerik.Reporting.Group();
            SizeU size = new SizeU(Telerik.Reporting.Drawing.Unit.Inch((double)(22) / count), Telerik.Reporting.Drawing.Unit.Inch(0.6));
            int column = 0;

            foreach (PropertyInfo info in obj.GetType().GetProperties())
            {
                string columnName = info.Name;
                Telerik.Reporting.HtmlTextBox headerCol = CreateTxtHeader(columnName, column);
                headerCol.Style.BackgroundColor = Color.LemonChiffon;
                headerCol.Style.BorderStyle.Default = BorderType.Solid;
                headerCol.Style.BorderWidth.Default = Unit.Pixel(1);
                headerCol.CanGrow = true;
                headerCol.Location = new Telerik.Reporting.Drawing.PointU(x, y);
                headerCol.Size = size;
                headColumnList[column] = headerCol;
                Telerik.Reporting.TextBox textBox = CreateTxtDetail(columnName, column);
                textBox.Style.BorderStyle.Default = BorderType.Solid;
                textBox.Style.BorderWidth.Default = Unit.Pixel(1);
                textBox.CanGrow = true;
                textBox.Location = new Telerik.Reporting.Drawing.PointU(x, y);
                textBox.Size = size;
                detailColumnList[column] = textBox;
                textBox.ItemDataBinding += new EventHandler(textBox_ItemDataBound);
                x += Telerik.Reporting.Drawing.Unit.Inch(headerCol.Size.Width.Value);
                column++;
            }

            Telerik.Reporting.ReportItemBase[] groupColumnList = new Telerik.Reporting.ReportItem[grpDescriptors.Count];
            int i = grpDescriptors.Count;
            if (grpDescriptors.Count > 0)
            {
                Telerik.Reporting.GroupHeaderSection groupHeaderSection1 = new Telerik.Reporting.GroupHeaderSection();
                foreach (ColumnGroupDescriptor grpDescriptor in grpDescriptors)
                {
                    string grpCol = grpDescriptor.Column.UniqueName;
                    group.Groupings.Add(new Grouping("=Fields." + grpCol));
                    if (grpDescriptor.SortDirection.ToString().ToLower() == "descending")
                    {
                        group.Sortings.Add(new Sorting("=Fields." + grpCol, SortDirection.Desc));
                    }
                    else
                    {
                        group.Sortings.Add(new Sorting("=Fields." + grpCol, SortDirection.Asc));
                    }
                    i--;
                    Telerik.Reporting.TextBox hdCol = new Telerik.Reporting.TextBox();
                    hdCol.Style.BackgroundColor = Color.Orange;
                    hdCol.Style.BorderStyle.Default = BorderType.Solid;
                    hdCol.Style.BorderWidth.Default = Unit.Pixel(1);
                    hdCol.KeepTogether = true;
                    hdCol.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(5.5603775978088379D, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(0.20000000298023224D, Telerik.Reporting.Drawing.UnitType.Inch));
                    hdCol.Value = "=[" + grpCol + "]";
                    groupColumnList[i] = hdCol;
                    group.GroupHeader = groupHeaderSection1;
                    //to avoid extra row after group col
                    group.GroupHeader.Height = Telerik.Reporting.Drawing.Unit.Inch(0);
                }
                groupHeaderSection1.Items.AddRange(groupColumnList);
            }
            if (sortCol.Length > 0)
            {
                group.Groupings.Add(new Grouping("=Fields." + sortCol));
                if (sortDir.ToLower() == "descending")
                {
                    group.Sortings.Add(new Sorting("=Fields." + sortCol, SortDirection.Desc));
                }
                else
                {
                    group.Sortings.Add(new Sorting("=Fields." + sortCol, SortDirection.Asc));
                }
            }
            ReportHeaderSection reportHeaderSection1 = new Telerik.Reporting.ReportHeaderSection();
            reportHeaderSection1.Height = new Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch);
            reportHeaderSection1.Items.AddRange(headColumnList);
            report1.Groups.Add(group);

            //Detail Section
            Telerik.Reporting.DetailSection detailSection1 = new Telerik.Reporting.DetailSection();
            detailSection1.Height = new Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch);
            detailSection1.Items.AddRange(detailColumnList);

            //Page Footer Section
            Telerik.Reporting.PageFooterSection pageFooterSection1 = new Telerik.Reporting.PageFooterSection();
            pageFooterSection1.Height = new Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch);
            pageFooterSection1.Style.BackgroundColor = Color.LightGray;
            pageFooterSection1.PrintOnFirstPage = true;
            pageFooterSection1.PrintOnLastPage = true;
            Telerik.Reporting.TextBox txtFooter = new Telerik.Reporting.TextBox();
            txtFooter.Value = "='Page ' + PageNumber + ' of ' + PageCount";
            txtFooter.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(4.2395832538604736D, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(0.02083333395421505D, Telerik.Reporting.Drawing.UnitType.Inch));
            txtFooter.Name = "pageInfoTextBox";
            txtFooter.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(5.5603775978088379D, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(0.20000000298023224D, Telerik.Reporting.Drawing.UnitType.Inch));
            Telerik.Reporting.PictureBox picBoxFooter = new Telerik.Reporting.PictureBox();
            picBoxFooter.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(5.2395832538604736D, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(0.02083333395421505D, Telerik.Reporting.Drawing.UnitType.Inch));
            picBoxFooter.Value = @"C:\CCMSGoldStandard_Local\CCMSGoldStandard\CCMSAppShell\Images\no.png";
            picBoxFooter.Style.TextAlign = Telerik.Reporting.Drawing.
            HorizontalAlign.Center;
            picBoxFooter.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(1, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Inch))), new Telerik.Reporting.Drawing.Unit(.5D, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Inch))));
            picBoxFooter.Sizing = ImageSizeMode.AutoSize;
            pageFooterSection1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { txtFooter, picBoxFooter });

            //add all section to report
            report1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] { pageHeaderSection1, reportHeaderSection1, detailSection1, pageFooterSection1 });
            report1.PageSettings.Landscape = false;
            report1.PageSettings.Margins.Bottom = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Inch);
            report1.PageSettings.Margins.Left = new Telerik.Reporting.Drawing.Unit(.25, Telerik.Reporting.Drawing.UnitType.Inch);
            report1.PageSettings.Margins.Right = new Telerik.Reporting.Drawing.Unit(.25, Telerik.Reporting.Drawing.UnitType.Inch);
            report1.PageSettings.Margins.Top = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Inch);
            Telerik.Reporting.Drawing.SizeU paperSize = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(22, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(22, Telerik.Reporting.Drawing.UnitType.Inch));
            report1.PageSettings.PaperSize = paperSize;
            report1.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Custom;
            Hashtable deviceInfo = new Hashtable();
            deviceInfo["FontEmbedding"] = "Subset";
            if (extension.ToLower() == "csv")
            {
                deviceInfo["NoHeader"] = true;
                deviceInfo["NoStaticText"] = true;
            }
            Telerik.Reporting.Processing.ReportProcessor RP = new Telerik.Reporting.Processing.ReportProcessor();
            byte[] buffer = RP.RenderReport(extension.ToUpper(), report1, deviceInfo).DocumentBytes;
            string myPath = "C:";
            string file = myPath + @"\" + DateTime.Now.ToString("HHmmss") + "." + extension;
            FileStream fs = new FileStream(file, FileMode.Create);
            fs.Write(buffer, 0, buffer.Length);
            fs.Flush();
            fs.Close();

            Process.Start(file);
        }
Example #2
0
    protected void ButtonDene_Click(object sender, EventArgs e)
    {
        //Create new CultureInfo
        var cultureInfo = new System.Globalization.CultureInfo("tr-TR");

        // Set the language for static text (i.e. column headings, titles)
        System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;

        // Set the language for dynamic text (i.e. date, time, money)
        System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;



        EFDal ed = new EFDal();
        var   instanceReportSource = new Telerik.Reporting.InstanceReportSource();

        instanceReportSource.ReportDocument = new KalibrasyonRaporlari.KYS();
        this.KYSReport.ReportSource         = instanceReportSource;
        Telerik.Reporting.Report report = (Telerik.Reporting.Report)instanceReportSource.ReportDocument;



        report.ReportParameters["BolgeKodu"].Value = 1;
        //report.ReportParameters[0].Value = 1;
        report.ReportParameters["BasTar"].Value = DateTime.Parse("2015-01-01");
        report.ReportParameters["SonTar"].Value = DateTime.Parse("2015-06-01");

        Telerik.Reporting.TextBox txtAciklama = report.Items.Find("txtAciklama", true)[0] as Telerik.Reporting.TextBox;
        txtAciklama.Value = ed.BolgeKodundanBolgeAdiniDon(Convert.ToInt32(report.ReportParameters["BolgeKodu"].Value)) +
                            " bölgesi için " + report.ReportParameters["BasTar"].Value.ToString().Replace(" 00:00:00", "") + " ve " + report.ReportParameters["SonTar"].Value.ToString().Replace(" 00:00:00", "") +
                            " tarihleri arasında gecikme sürelerini aşağıda görebilirsiniz";
    }
        /// <summary>
        /// Export report results in a given format
        /// </summary>
        /// <param name="reportToExport">Holds report object</param>
        /// <param name="reportFormat">Hold report format</param>
        /// <returns>Returns generated file name</returns>
        private string Export(Telerik.Reporting.Report reportToExport, string reportFormat)
        {
            var reportProcessor      = new ReportProcessor();
            var instanceReportSource = new InstanceReportSource {
                ReportDocument = reportToExport
            };
            RenderingResult result = reportProcessor.RenderReport(reportFormat, instanceReportSource, null);

            string dateTimeStamp = DateTime.Now.ToString(Constants.DateTimeExtendedFormat);
            string fileName      = string.Format("{0}{1}.{2}", Constants.ModelingReportFileBaseName, dateTimeStamp, result.Extension);

            string path     = GlobalConfigVariable.ReportsFilePath;
            string filePath = Path.Combine(path, fileName);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            using (var fs = new FileStream(filePath, FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
            return(fileName);
        }
Example #4
0
        //public async Task<string> GetAccessToken()
        //{
        //    UserPasswordCredential creds = new UserPasswordCredential("*****@*****.**", "Welcome@123");
        //    AuthenticationResult authenticationResult = null;
        //    var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/token/");

        //    authenticationResult = await authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", "c565eea1-4938-468e-8d5f-35b74ac5e8e5", creds);// new ClientCredential(Secrets.ClientID,Secrets.ClientSecret));
        //    return authenticationResult.AccessToken.ToString();

        //}

        public async Task <string> CreatePGXCaseReport(PGXCaseReportData dataSource)
        {
            string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTemplateLocation"].ToString() + "\\" + dataSource.TemplateName;

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;

            Telerik.Reporting.Report report = null;

            using (XmlReader xmlReader = XmlReader.Create(filePath, settings))
            {
                ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
                report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
            }

            report.DataSource = dataSource;


            ReportProcessor      reportProcessor      = new ReportProcessor();
            InstanceReportSource instanceReportSource = new InstanceReportSource();

            instanceReportSource.ReportDocument = report;
            RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            return(Convert.ToBase64String(result.DocumentBytes));
        }
Example #5
0
        public async Task <string> GenerateSequenceReport(string template, CaseSequenceData dataSource)
        {
            string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTempLocation"].ToString() + "\\" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".trdx";

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;

            Telerik.Reporting.Report report = null;

            byte[] templateBytes = Convert.FromBase64String(template);
            File.WriteAllBytes(filePath, templateBytes);

            using (XmlReader xmlReader = XmlReader.Create(filePath, settings))
            {
                ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
                report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
            }

            report.DataSource = dataSource;

            ReportProcessor      reportProcessor      = new ReportProcessor();
            InstanceReportSource instanceReportSource = new InstanceReportSource();

            instanceReportSource.ReportDocument = report;
            RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            return(Convert.ToBase64String(result.DocumentBytes));
        }
Example #6
0
        public async Task <string> GenerateReport(string template, CaseQualitativeData dataSource)
        {
            //Reference:http://www.telerik.com/forums/programmatically-use-of-trdp-report
            //sample reports:C:\Program Files (x86)\Telerik\Reporting R1 2017\Report Designer\Examples


            string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTempLocation"].ToString() + "\\" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".trdx";

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;

            Telerik.Reporting.Report report = null;

            byte[] templateBytes = Convert.FromBase64String(template);
            File.WriteAllBytes(filePath, templateBytes);

            using (XmlReader xmlReader = XmlReader.Create(filePath, settings))
            {
                ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
                report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
            }

            report.DataSource = dataSource;

            ReportProcessor      reportProcessor      = new ReportProcessor();
            InstanceReportSource instanceReportSource = new InstanceReportSource();

            instanceReportSource.ReportDocument = report;
            RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            return(Convert.ToBase64String(result.DocumentBytes));
        }
Example #7
0
        private void ImprimirXLSGral(ArrayList ALValorParametrosGeneral, Type instance)
        {
            try
            {
                //Reporte de Facturas vigentes
                Telerik.Reporting.Report report1 = (Telerik.Reporting.Report)Activator.CreateInstance(instance);
                for (int i = 0; i <= ALValorParametrosGeneral.Count - 1; i++)
                {
                    report1.ReportParameters[i].AllowNull = true;
                    report1.ReportParameters[i].Value     = ALValorParametrosGeneral[i];
                }
                //report1.ReportParameters[23].Value = 1;
                //report1.ReportParameters[16].Value = 63;
                //report1.ReportParameters[1].Value = "Pendiente por facturar";

                ReportProcessor reportProcessor = new ReportProcessor();
                RenderingResult result          = reportProcessor.RenderReport("XLS", report1, null);
                string          ruta            = Server.MapPath("Reportes") + "\\" + instance.Name + ".xls";
                if (File.Exists(ruta))
                {
                    File.Delete(ruta);
                }
                FileStream fs = new FileStream(ruta, FileMode.Create);
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
                fs.Flush();
                fs.Close();
                RadAjaxManager1.ResponseScripts.Add("startDownload('" + instance.Name + ".xls');");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #8
0
        private void SaveReport(Telerik.Reporting.Report report, string fileName)
        {
            ReportProcessor reportProcessor = new ReportProcessor();

            Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
            instanceReportSource.ReportDocument = report;
            RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            using (FileStream fs = new FileStream(fileName, FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
Example #9
0
        public async Task <string> CreateToxicologyAccessionReport(ReportCaseData dataSource, string templateName)
        {
            int seriesCount    = dataSource.PreviousHistoryChartData.Select(x => x.Name).Distinct().Count();
            int xAxisDataCount = dataSource.PreviousHistoryChartData.Select(x => x.DateCollected).Distinct().Count();

            //dataSource.ChartData = await this.GenerateChartImageFromXlsxFile("", "", dataSource.PreviousHistoryExcelChartData, seriesCount, xAxisDataCount);
            Console.Write(dataSource.ToString());
            Console.WriteLine(templateName);
            //string templateName = "ToxicologyAccessionCaseReport";
            string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTemplateLocation"].ToString() + "\\" + templateName + ".trdx";

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;

            Telerik.Reporting.Report report = null;

            using (XmlReader xmlReader = XmlReader.Create(filePath, settings))
            {
                ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
                report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
            }

            report.DataSource = dataSource;


            ReportProcessor      reportProcessor      = new ReportProcessor();
            InstanceReportSource instanceReportSource = new InstanceReportSource();

            instanceReportSource.ReportDocument = report;
            RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            //var reportLocation = ConfigurationManager.AppSettings["ReportTempLocation"];
            //string reportName = templateName+"_" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".pdf";
            //string reportDestination = Path.Combine(reportLocation, reportName);

            //using (FileStream fs = new FileStream(reportDestination, FileMode.Create))
            //{
            //    fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            //}
            //string reportUrl = dataSource.ServerUrl + "/" + reportName;
            ////byte[] bytes = result.DocumentBytes;
            //string response = Convert.ToBase64String(bytes);

            return(Convert.ToBase64String(result.DocumentBytes));
        }
Example #10
0
        public static void ExportToPDF(Telerik.Reporting.Report reportToExport)
        {
            ReportProcessor reportProcessor = new ReportProcessor();
            //Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
            //instanceReportSource.ReportDocument = reportToExport;
            RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);



            string fileName = result.DocumentName + DateTime.Now.Ticks + "." + result.Extension;


            var directoryInfo = Directory.GetParent(Directory.GetCurrentDirectory()).Parent;

            string projectPath = directoryInfo.FullName;
            string folderName  = Path.Combine(projectPath, "TestDataSource");

            if (!Directory.Exists(folderName))
            {
                Directory.CreateDirectory(folderName);
            }

            string filePath = Path.Combine(folderName, fileName);

            using (FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
            //Response.Clear();
            //Response.ContentType = result.MimeType;
            //Response.Cache.SetCacheability(HttpCacheability.Private);
            //Response.Expires = -1;
            //Response.Buffer = true;

            //Response.AddHeader("Content-Disposition",
            //    string.Format("{0};FileName=\"{1}\"",
            //        "attachment",
            //        fileName));

            //Response.BinaryWrite(result.DocumentBytes);
            //Response.End();
        }
Example #11
0
        public static ReportSource RenderReportData(byte[] ReportBinaryData, Dictionary <string, object> Parameters)
        {
            ReportPackager pack = new ReportPackager();

            Telerik.Reporting.Report doc = pack.Unpackage(new MemoryStream(ReportBinaryData));

            InstanceReportSource instance = new InstanceReportSource();

            instance.ReportDocument = doc;

            if (Parameters != null)
            {
                foreach (KeyValuePair <string, object> kvp in Parameters)
                {
                    instance.Parameters.Add(new Telerik.Reporting.Parameter(kvp.Key, kvp.Value));
                }
            }

            return(instance);
        }
Example #12
0
        public async Task <string> CreateToxLabOrderRequisitionReport(ToxLabOrderReportData dataSource, string templateName = "ToxLabOrderRequisitionReport.trdx")
        {
            string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTemplateLocation"].ToString() + "\\" + templateName;

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;

            Telerik.Reporting.Report report = null;

            using (XmlReader xmlReader = XmlReader.Create(filePath, settings))
            {
                ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
                report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
            }

            report.DataSource = dataSource;


            ReportProcessor      reportProcessor      = new ReportProcessor();
            InstanceReportSource instanceReportSource = new InstanceReportSource();

            instanceReportSource.ReportDocument = report;
            RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            //var reportLocation = ConfigurationManager.AppSettings["ReportTempLocation"];
            //string reportName = dataSource.Id + "_ToxLabOrderRequisition_" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".pdf";
            //string reportDestination = Path.Combine(dataSource.FolderPath, reportName);

            //using (FileStream fs = new FileStream(reportDestination, FileMode.Create))
            //{
            //    fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            //}
            //string reportUrl = dataSource.ServerUrl + "/" + reportName;
            //byte[] bytes = result.DocumentBytes;
            //string response = Convert.ToBase64String(bytes);

            return(Convert.ToBase64String(result.DocumentBytes));
        }
Example #13
0
        public ltrECChineseEnglishFormsEnquiry(List <clsECLetter> objLettera, DataSet dsFooterCountry)
        {
            objLetter = objLettera;
            Telerik.Reporting.Report ReportToDisplay = null;
            //
            // Required for telerik Reporting designer support
            //

            ltrECEnglishFormEnquiry recnewEnglish   = new ltrECEnglishFormEnquiry(objLettera, dsFooterCountry);
            ltrECChineseFormEnquiry rechineseReport = new ltrECChineseFormEnquiry(objLettera, dsFooterCountry);

            InitializeComponent();
            this.subReport2.ReportSource = recnewEnglish;
            this.subReport1.ReportSource = rechineseReport;
            //table1.DataSource = objLetter;
            //ReportToDisplay = new ltrECEnglishFormEnquiry(objLettera, dsFooterCountry);
            if ((dsFooterCountry != null) && (dsFooterCountry.Tables.Count > 0) && (dsFooterCountry.Tables[0].Rows.Count > 0))
            {
                txtCountry.Value = dsFooterCountry.Tables[0].Rows[0]["CompanyName"].ToString();
                txtAddress.Value = dsFooterCountry.Tables[0].Rows[0]["CompContact"].ToString();
                txtMail.Value    = dsFooterCountry.Tables[0].Rows[0]["CompEmail"].ToString();
            }
        }
Example #14
0
        private void ImprimirXLS(ArrayList ALValorParametrosInternos, Type instance, ArrayList ALValorParametrosConsignacion, Type instance2)
        {
            try
            {
                //Reporte de Facturas vigentes
                Telerik.Reporting.Report report1 = (Telerik.Reporting.Report)Activator.CreateInstance(instance);
                for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++)
                {
                    report1.ReportParameters[i].AllowNull = true;
                    report1.ReportParameters[i].Value     = ALValorParametrosInternos[i];
                }
                report1.ReportParameters[23].Value = 1;
                report1.ReportParameters[16].Value = 63;
                report1.ReportParameters[1].Value  = "Pendiente por facturar";

                //Reporte de Facturas vencidas
                Telerik.Reporting.Report reportPXFVEN = (Telerik.Reporting.Report)Activator.CreateInstance(instance);
                for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++)
                {
                    if (i == 23)
                    {
                        reportPXFVEN.ReportParameters[i].AllowNull = true;
                        reportPXFVEN.ReportParameters[i].Value     = 0;
                    }
                    else
                    {
                        reportPXFVEN.ReportParameters[i].AllowNull = true;
                        reportPXFVEN.ReportParameters[i].Value     = ALValorParametrosInternos[i];
                    }
                }
                reportPXFVEN.ReportParameters[23].Value = 0;
                reportPXFVEN.ReportParameters[16].Value = 63;
                reportPXFVEN.ReportParameters[1].Value  = "Pendiente por facturar";

                //Reporte de prueba Vigente
                Telerik.Reporting.Report PruebaVIG = (Telerik.Reporting.Report)Activator.CreateInstance(instance);
                for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++)
                {
                    PruebaVIG.ReportParameters[i].AllowNull = true;
                    PruebaVIG.ReportParameters[i].Value     = ALValorParametrosInternos[i];
                }

                PruebaVIG.ReportParameters[16].Value = 64;
                PruebaVIG.ReportParameters[1].Value  = "Prueba";
                PruebaVIG.ReportParameters[23].Value = 0;  //vigente

                //Reporte de prueba Vencidas
                Telerik.Reporting.Report PruebaVEN = (Telerik.Reporting.Report)Activator.CreateInstance(instance);
                for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++)
                {
                    PruebaVEN.ReportParameters[i].AllowNull = true;
                    PruebaVEN.ReportParameters[i].Value     = ALValorParametrosInternos[i];
                }
                PruebaVEN.ReportParameters[16].Value = 64;
                PruebaVEN.ReportParameters[1].Value  = "Prueba";
                PruebaVEN.ReportParameters[23].Value = 1;  //Vencida



                //Reporte de No conformes Vigente
                Telerik.Reporting.Report NCVIG = (Telerik.Reporting.Report)Activator.CreateInstance(instance);
                for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++)
                {
                    NCVIG.ReportParameters[i].AllowNull = true;
                    NCVIG.ReportParameters[i].Value     = ALValorParametrosInternos[i];
                }

                NCVIG.ReportParameters[16].Value = 65;
                NCVIG.ReportParameters[1].Value  = "Producto no conforme";
                NCVIG.ReportParameters[23].Value = 0;  //vigente

                //Reporte de No Conforme Vencidas
                Telerik.Reporting.Report NCVEN = (Telerik.Reporting.Report)Activator.CreateInstance(instance);
                for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++)
                {
                    NCVEN.ReportParameters[i].AllowNull = true;
                    NCVEN.ReportParameters[i].Value     = ALValorParametrosInternos[i];
                }
                NCVEN.ReportParameters[16].Value = 65;
                NCVEN.ReportParameters[1].Value  = "Producto no conforme";
                NCVEN.ReportParameters[23].Value = 1;  //Vencida


                //Reporte de prueba Vigente
                Telerik.Reporting.Report RepConsignacion = (Telerik.Reporting.Report)Activator.CreateInstance(instance2);
                for (int i = 0; i <= ALValorParametrosConsignacion.Count - 1; i++)
                {
                    RepConsignacion.ReportParameters[i].AllowNull = true;
                    RepConsignacion.ReportParameters[i].Value     = ALValorParametrosConsignacion[i];
                }


                var reportBook = new ReportBook();
                reportBook.Reports.Add(report1);
                reportBook.Reports.Add(reportPXFVEN);
                reportBook.Reports.Add(PruebaVIG);
                reportBook.Reports.Add(PruebaVEN);
                reportBook.Reports.Add(NCVIG);
                reportBook.Reports.Add(NCVEN);
                reportBook.Reports.Add(RepConsignacion);
                reportBook.Reports[0].DocumentName = "PXF_VENCIDA";
                reportBook.Reports[1].DocumentName = "PXF_VIGENTE";
                reportBook.Reports[3].DocumentName = "PRUEBA VENCIDA";
                reportBook.Reports[2].DocumentName = "PRUEBA VIGENTE";
                reportBook.Reports[5].DocumentName = "NC VENCIDA";
                reportBook.Reports[4].DocumentName = "NC VIGENTE";
                reportBook.Reports[6].DocumentName = "Consignacion";

                ReportProcessor reportProcessor = new ReportProcessor();
                RenderingResult result          = reportProcessor.RenderReport("XLS", reportBook, null);
                string          ruta            = Server.MapPath("Reportes") + "\\" + ALValorParametrosConsignacion[2] + instance.Name + ".xls";
                if (File.Exists(ruta))
                {
                    File.Delete(ruta);
                }
                FileStream fs = new FileStream(ruta, FileMode.Create);
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
                fs.Flush();
                fs.Close();
                //   RAM1.ResponseScripts.Add("startDownload('" + instance.Name + ".xls');");

                RadAjaxManager1.ResponseScripts.Add("startDownload('" + ALValorParametrosConsignacion[2] + instance.Name + ".xls');");

                //Telerik.Reporting.Report report1 = (Telerik.Reporting.Report)Activator.CreateInstance(instance);
                //for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++)
                //{
                //    report1.ReportParameters[i].AllowNull = true;
                //    report1.ReportParameters[i].Value = ALValorParametrosInternos[i];
                //}
                //ReportProcessor reportProcessor = new ReportProcessor();
                //RenderingResult result = reportProcessor.RenderReport("XLS", report1, null);
                //string ruta = Server.MapPath("Reportes") + "\\" + instance.Name + ".xls";
                //if (File.Exists(ruta))
                //    File.Delete(ruta);
                //FileStream fs = new FileStream(ruta, FileMode.Create);
                //fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
                //fs.Flush();
                //fs.Close();
                //RadAjaxManager1.ResponseScripts.Add("startDownload('" + instance.Name + ".xls');");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }