Пример #1
1
        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);
        }
Пример #2
0
        public void GetMagneticParticleTestingDetailsPDF(int ProjId, string NDE_Rep_No)
        {
            Random random   = new Random();
            int    fileId   = random.Next(1000, 9999);
            string fileName = $"report_{fileId}.pdf";
            string filePath = $@"C:\Temp\{fileName}";

            MagneticParticleTestingReport report = new MagneticParticleTestingReport();

            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            report.ReportParameters["ProjId"].Value        = ProjId;
            report.ReportParameters["NDE_Report_No"].Value = NDE_Rep_No;

            Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null);

            FileStream fs = new FileStream(filePath, FileMode.Create);

            fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
            fs.Close();

            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}");
            HttpContext.Current.Response.TransmitFile(filePath);
            HttpContext.Current.Response.End();
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            string request = context.Request["request"];

            string[] parts = request.Split('~');


            string Query = string.Empty;

            Query = "SELECT Appointment.ID as Id, person.FirstName as FirstName, person.LastName as LastName,"
                    + " CONVERT(varchar, [ApptDay], 101) as DateOfAppointment,CONVERT(varchar(15), CAST([ApptTime] AS TIME), 100) as TimeOfAppointment,"
                    + " CONVERT(varchar, person.DOB, 101) as DateOfBirth, '0' as Account"
                    + " FROM Appointment"
                    + " inner join webid"
                    + " on webid.ID = appointment.UserID"
                    + " inner join person"
                    + " on person.ID = webid.PersonID"
                    + " where[ApptDay] = '" + parts[0] + "'"
                    //+ " where[ApptDay] = '06/26/2020'"
                    + " and person.locationid = " + parts[1]
                    //+ " and person.locationid = 2"
                    + " order by Appointment.ApptDay, Appointment.ApptTime";

            var report = new PrintSchedule();

            Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource();
            sqlDataSource.ConnectionString = "Server = 64.41.86.25; Database = Appointment; Uid = Appointment; Pwd = 0griswold;";
            sqlDataSource.SelectCommand    = Query;

            report.DataSource = sqlDataSource;
            var reportPackager = new ReportPackager();

            using (var targetStream = System.IO.File.Create(@"C:\temp\PrintReport.trdp"))
            {
                reportPackager.Package(report, targetStream);
            }


            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            var deviceInfo = new System.Collections.Hashtable();

            var reportSource = new Telerik.Reporting.UriReportSource();

            //// reportName is the path to the TRDP/TRDX file
            reportSource.Uri = @"C:\temp\PrintReport.trdp";


            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

            string filePath = System.IO.Path.Combine(@"C:\waldenltd\ionicwithvuedev\fairfield-app-admin\public\", "output.pdf");

            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write("OK");
        }
        public void ProcessRequest(HttpContext context)
        {
            var exportReport = getReport();
            var reportData =generateReportData();
            exportReport.DataSource = reportData;

            Telerik.Reporting.InstanceReportSource exportReportSource = new Telerik.Reporting.InstanceReportSource();
            // Assigning the Report object to the InstanceReportSource
            exportReportSource.ReportDocument = exportReport;

            // set any deviceInfo settings if necessary
            //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            var result = reportProcessor.RenderReport("PDF", exportReportSource, null);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ContentType = result.MimeType;
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Private);
            HttpContext.Current.Response.Expires = -1;
            HttpContext.Current.Response.Buffer = true;

            //Uncomment to handle the file as attachment
            HttpContext.Current.Response.AddHeader("Content-Disposition",
                            string.Format("attachment;FileName=\"標籤{0:yyyyMMddHHmmss}_{1}.pdf\"",
                                            DateTime.Now,
                                            reportData[0].Name
                                            ));

            HttpContext.Current.Response.BinaryWrite(result.DocumentBytes);
            HttpContext.Current.Response.End();
        }
        public void ProcessRequest(HttpContext context)
        {
            var exportReport = getReport();
            var reportData   = generateReportData();

            exportReport.DataSource = reportData;

            Telerik.Reporting.InstanceReportSource exportReportSource = new Telerik.Reporting.InstanceReportSource();
            // Assigning the Report object to the InstanceReportSource
            exportReportSource.ReportDocument = exportReport;

            // set any deviceInfo settings if necessary
            //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            var result          = reportProcessor.RenderReport("PDF", exportReportSource, null);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ContentType = result.MimeType;
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Private);
            HttpContext.Current.Response.Expires = -1;
            HttpContext.Current.Response.Buffer  = true;

            //Uncomment to handle the file as attachment
            HttpContext.Current.Response.AddHeader("Content-Disposition",
                                                   string.Format("attachment;FileName=\"標籤{0:yyyyMMddHHmmss}_{1}.pdf\"",
                                                                 DateTime.Now,
                                                                 reportData[0].Name
                                                                 ));


            HttpContext.Current.Response.BinaryWrite(result.DocumentBytes);
            HttpContext.Current.Response.End();
        }
        public void GetWelderPerformanceMonthlyDetailsPDF(int ProjId, int SUB_CON_ID, string DATE_FROM, string DATE_TO)
        {
            Random random   = new Random();
            int    fileId   = random.Next(1000, 9999);
            string fileName = $"WelderPerformanceMonthly_{fileId}.pdf";
            string filePath = $@"C:\Temp\{fileName}";

            if (string.IsNullOrEmpty(DATE_FROM) && string.IsNullOrEmpty(DATE_TO))
            {
                DATE_FROM = DateTime.Now.ToString("dd-MMM-yyyy");
                DATE_TO   = DateTime.Now.ToString("dd-MMM-yyyy");
            }

            Welder_Performance_Monthly_Report report = new Welder_Performance_Monthly_Report();

            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            report.ReportParameters["ProjId"].Value   = ProjId;
            report.ReportParameters["SubConId"].Value = SUB_CON_ID;
            report.ReportParameters["DateFrom"].Value = DATE_FROM;
            report.ReportParameters["DateTo"].Value   = DATE_TO;

            Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null);

            FileStream fs = new FileStream(filePath, FileMode.Create);

            fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
            fs.Close();

            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}");
            HttpContext.Current.Response.TransmitFile(filePath);
            HttpContext.Current.Response.End();
        }
        public void GetNDEPMIStatusDetailsPDF(int ProjId, string SUB_CON_ID, string CAT_ID, string Inclde_Prod)
        {
            Random random   = new Random();
            int    fileId   = random.Next(1000, 9999);
            string fileName = $"NDE_PMI_Status_{fileId}.pdf";
            string filePath = $@"C:\Temp\{fileName}";

            NDE_PMI_Status_ClassWise_Report report = new NDE_PMI_Status_ClassWise_Report();

            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            report.ReportParameters["ProjId"].Value      = ProjId;
            report.ReportParameters["SubConId"].Value    = SUB_CON_ID;
            report.ReportParameters["CatId"].Value       = CAT_ID;
            report.ReportParameters["IncludeProd"].Value = Inclde_Prod;

            Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null);

            FileStream fs = new FileStream(filePath, FileMode.Create);

            fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
            fs.Close();

            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}");
            HttpContext.Current.Response.TransmitFile(filePath);
            HttpContext.Current.Response.End();
        }
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            base.OnNavigatedTo(navigationContext);
            SelectedFileName = string.Empty;

            // render report as pdf

            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            // set any deviceInfo settings if necessary
            var deviceInfo = new System.Collections.Hashtable();


            var reportSource = new Telerik.Reporting.TypeReportSource();

            // reportName is the Assembly Qualified Name of the report
            reportSource.TypeName = typeof(AccountingHelper.Reporting.EmployeeOffices).AssemblyQualifiedName;


            // Pass parameter value with the Report Source if necessary
            // no parameters required

            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);


            using (System.IO.FileStream fs = new System.IO.FileStream(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Mitarbeiter-Büro-Zuordnung.pdf"), System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }

            SelectedFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Mitarbeiter-Büro-Zuordnung.pdf");
        }
        public void GetSpoolClearanceAndReleaseServicePDF(int ProjId, string SpoolId)
        {
            Random random   = new Random();
            int    fileId   = random.Next(1000, 9999);
            string fileName = $"report_{fileId}.pdf";
            string filePath = $@"C:\Temp\{fileName}";

            Duqm_SpoolClearanceAndReleaseReport report = new Duqm_SpoolClearanceAndReleaseReport();

            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            report.ReportParameters["ProjId"].Value  = ProjId;
            report.ReportParameters["SpoolId"].Value = SpoolId;

            Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null);

            FileStream fs = new FileStream(filePath, FileMode.Create);

            fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
            fs.Close();

            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}");
            HttpContext.Current.Response.TransmitFile(filePath);
            HttpContext.Current.Response.End();
        }
        public async Task <byte[]> GetReport(string Type, string basepath, CustomClearanceBIZSearchDTO arg)
        {
            var helper     = new ReportHelper();
            var datasource = new Telerik.Reporting.ObjectDataSource();

            arg.gmsDashboardSearchFilter.pageNo = 0;
            datasource.DataSource = helper.GetGMSReleaseReportData(arg);
            Telerik.Reporting.Report instanceReport;
            var settings = new System.Xml.XmlReaderSettings();

            settings.IgnoreWhitespace = true;
            var path = basepath + "/Report/GMSStatusReport.trdx";

            using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(path, settings))
            {
                var xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
                instanceReport = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
            }
            Telerik.Reporting.Table tbl = instanceReport.Items.Find("table1", true)[0] as Telerik.Reporting.Table;
            tbl.DataSource = datasource;
            DateTime frmdate;

            if (DateTime.TryParseExact(arg.gmsDashboardSearchFilter.fromDT,
                                       "yyyy-MM-dd HH:mm:ss",
                                       System.Globalization.CultureInfo.InvariantCulture,
                                       System.Globalization.DateTimeStyles.None,
                                       out frmdate))
            {
                instanceReport.ReportParameters["FromDate"].Value = frmdate.ToString("dd/MM/yyyy");
            }
            else
            {
                instanceReport.ReportParameters["FromDate"].Value = string.Empty;
            }

            DateTime todate;

            if (DateTime.TryParseExact(arg.gmsDashboardSearchFilter.toDT,
                                       "yyyy-MM-dd HH:mm:ss",
                                       System.Globalization.CultureInfo.InvariantCulture,
                                       System.Globalization.DateTimeStyles.None,
                                       out todate))
            {
                instanceReport.ReportParameters["ToDate"].Value = todate.ToString("dd/MM/yyyy");
            }
            else
            {
                instanceReport.ReportParameters["ToDate"].Value = string.Empty;
            }

            //instanceReport.ReportParameters.Add("ToDate", parameters[1]);
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            Telerik.Reporting.Processing.RenderingResult result          = reportProcessor.RenderReport(Type, new InstanceReportSource {
                ReportDocument = instanceReport
            }, null);
            byte[] contents = result.DocumentBytes;
            return(contents);
        }
Пример #11
0
        static void Main(string[] args)
        {
            string databaseConnection = System.Configuration.ConfigurationManager.AppSettings["allergyConnection"];
            string reportLocation     = System.Configuration.ConfigurationManager.AppSettings["reportLocation"];
            string outputPath         = System.Configuration.ConfigurationManager.AppSettings["outputPath"];

            string Query = string.Empty;

            Query = "SELECT Appointment.ID as Id,person.HPhone, person.FirstName as FirstName, person.LastName as LastName,"
                    + " CONVERT(varchar, [ApptDay], 101) as DateOfAppointment,CONVERT(varchar(15), CAST([ApptTime] AS TIME), 100) as TimeOfAppointment,"
                    + " CONVERT(varchar, person.DOB, 101) as DateOfBirth, '0' as Account"
                    + " FROM Appointment"
                    + " inner join webid"
                    + " on webid.ID = appointment.UserID"
                    + " inner join person"
                    + " on person.ID = webid.PersonID"
                    + " where[ApptDay] = '" + args[0] + "'"
                    + " and person.locationid = " + args[1]
                    + " order by Appointment.ApptDay, Appointment.ApptTime";
            Console.WriteLine(Query);
            var report = new PrintSchedule();


            Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource();
            sqlDataSource.ConnectionString = databaseConnection;
            sqlDataSource.SelectCommand    = Query;

            report.DataSource = sqlDataSource;
            var reportPackager = new ReportPackager();

            using (var targetStream = System.IO.File.Create(reportLocation))
            {
                reportPackager.Package(report, targetStream);
            }


            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            var deviceInfo = new System.Collections.Hashtable();

            var reportSource = new Telerik.Reporting.UriReportSource();

            //// reportName is the path to the TRDP/TRDX file
            reportSource.Uri = reportLocation;


            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

            string filePath = System.IO.Path.Combine(outputPath, "output.pdf");

            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
Пример #12
0
        public static void RenderReport()
        {
            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            var deviceInfo      = new Hashtable();

            // Depending on the report definition choose ONE of the following REPORT SOURCES
            //                  -1-
            // ***CLR (CSharp) report definitions***
            var reportSource = new Telerik.Reporting.TypeReportSource();

            // reportName is the Assembly Qualified Name of the report
            reportSource.TypeName = "ReportLibraryDemo.Report1, ReportLibraryDemo, Version=14.1.20.618, Culture=neutral, PublicKeyToken=null";
            //                  -1-

            ////                  -2-
            //// ***Declarative (TRDP/TRDX) report definitions***
            //var reportSource = new Telerik.Reporting.UriReportSource();

            //// reportName is the path to the TRDP/TRDX file
            //reportSource.Uri = reportName;
            ////                  -2-

            ////                  -3-
            //// ***Instance of the report definition***
            //var reportSource = new Telerik.Reporting.InstanceReportSource();

            //// Report1 is the class of the report. It should inherit Telerik.Reporting.Report class
            //reportSource.ReportDocument = new Report1();
            ////                  -3-

            // Pass parameter value with the Report Source if necessary
            //object parameterValue = "Some Parameter Value";
            //reportSource.Parameters.Add("ParameterName", parameterValue);

            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

            string fileName      = result.DocumentName + "." + result.Extension;
            var    directoryInfo = Directory.GetParent(Directory.GetCurrentDirectory()).Parent;

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

            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);
            }
        }
Пример #13
0
        /// <summary>
        /// The course report.
        /// </summary>
        /// <returns>
        /// The <see cref="FileStreamResult"/>.
        /// </returns>
        public FileStreamResult CourseReport(int courseId)
        {
            var stream = new MemoryStream();

            var report = ReportHelper.GetReportFromFile(Server.MapPath(@"~\Reports\Course.trdx"));
            report.ReportParameters["CourseId"].Value = courseId;
            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            var renderingResult = reportProcessor.RenderReport("PDF", report, null);
            stream.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
            stream.Position = 0;
            return File(stream, "application/pdf", "Kursteilnehmer.pdf");
        }
Пример #14
0
        public void GetDailyFitupJointDetailsPDF(int PROJECT_ID, string SUB_CON_ID, string CAT_ID, string MAT_TYPE, string DATE_FROM, string DATE_TO)
        {
            Random random   = new Random();
            int    fileId   = random.Next(1000, 9999);
            string fileName = $"DailyFitupWeldingReport_{fileId}.pdf";
            string filePath = $@"C:\Temp\{fileName}";

            if (string.IsNullOrEmpty(DATE_FROM) && string.IsNullOrEmpty(DATE_TO))
            {
                DATE_FROM = DateTime.Now.ToString("dd-MMM-yyyy");
                DATE_TO   = DateTime.Now.ToString("dd-MMM-yyyy");
            }

            if (CAT_ID == "1")
            {
                DailyFitupShopReport report = new DailyFitupShopReport();
                Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                report.ReportParameters["ProjId"].Value   = PROJECT_ID;
                report.ReportParameters["SubConId"].Value = SUB_CON_ID;
                report.ReportParameters["CatId"].Value    = CAT_ID;
                report.ReportParameters["MatType"].Value  = MAT_TYPE;
                report.ReportParameters["DateFrom"].Value = DATE_FROM;
                report.ReportParameters["DateTo"].Value   = DATE_TO;

                Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null);

                FileStream fs = new FileStream(filePath, FileMode.Create);
                fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
                fs.Close();
            }
            else
            {
                DailyFitup_Joint_Field_Report report = new DailyFitup_Joint_Field_Report();
                Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                report.ReportParameters["ProjId"].Value   = PROJECT_ID;
                report.ReportParameters["SubConId"].Value = SUB_CON_ID;
                report.ReportParameters["CatId"].Value    = CAT_ID;
                report.ReportParameters["MatType"].Value  = MAT_TYPE;
                report.ReportParameters["DateFrom"].Value = DATE_FROM;
                report.ReportParameters["DateTo"].Value   = DATE_TO;

                Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null);

                FileStream fs = new FileStream(filePath, FileMode.Create);
                fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
                fs.Close();
            }
            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}");
            HttpContext.Current.Response.TransmitFile(filePath);
            HttpContext.Current.Response.End();
        }
Пример #15
0
        public static void Print_Queue(BOL.Transaction_Queue.objTransactionQueue trans_queue)
        {
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, arg) =>
            {
                try
                {
                    rptQueueTicket report = new rptQueueTicket(trans_queue)
                    {
                        Name = "Queue Ticket"
                    };

                    ReportSource report_source = new InstanceReportSource()
                    {
                        ReportDocument = report
                    };

                    // Obtain the settings of the default printer
                    System.Drawing.Printing.PrinterSettings printerSettings
                        = new System.Drawing.Printing.PrinterSettings();

                    // The standard print controller comes with no UI
                    System.Drawing.Printing.PrintController standardPrintController =
                        new System.Drawing.Printing.StandardPrintController();

                    // Print the report using the custom print controller
                    Telerik.Reporting.Processing.ReportProcessor reportProcessor
                        = new Telerik.Reporting.Processing.ReportProcessor();

                    reportProcessor.PrintController = standardPrintController;

                    //reportProcessor.PrintReport(typeReportSource, printerSettings);
                    reportProcessor.PrintReport(report_source, printerSettings);
                }
                catch (Exception ex)
                {
                    EventLog.WriteEntry("Report", ex.Message, EventLogEntryType.Error);
                }
            };

            //bw.RunWorkerCompleted += (s, arg) =>
            //{
            //    if (arg.Error == null)
            //    {

            //    }
            //    else
            //        throw new Exception(arg.Error.Message);
            //};
            bw.RunWorkerAsync();
        }
Пример #16
0
        public JsonResult CarcharSalary(int idEvaluacion)
        {
            int numberRep        = int.Parse(Session["EmpReporte"].ToString());
            int nivelJefe        = int.Parse(Session["NivelJefe"].ToString());
            var reportProcessor  = new Telerik.Reporting.Processing.ReportProcessor();
            var typeReportSource = new Telerik.Reporting.TypeReportSource();

            if (Session["anterior"].ToString() == "Si")
            {
                if (nivelJefe == 2)
                {
                    typeReportSource.TypeName = typeof(SalarySup).AssemblyQualifiedName;
                }
                else
                {
                    typeReportSource.TypeName = typeof(Salary).AssemblyQualifiedName;
                }
            }
            else
            {
                if (nivelJefe == 2)
                {
                    typeReportSource.TypeName = typeof(SalarySup2).AssemblyQualifiedName;
                }
                else
                {
                    typeReportSource.TypeName = typeof(Salary2).AssemblyQualifiedName;
                }
            }


            if (Session["anterior"].ToString() == "Si")
            {
                typeReportSource.Parameters.Add(name: "NumEmp", value: numberRep);
            }
            else
            {
                typeReportSource.Parameters.Add(name: "NumEmp", value: numberRep);
                typeReportSource.Parameters.Add(name: "idEvaluacion", value: idEvaluacion);
            }



            var deviceInfo = new System.Collections.Hashtable();
            var result     = reportProcessor.RenderReport("PDF", typeReportSource, deviceInfo);

            HttpContext.Response.AddHeader("content-disposition", "inline; filename=MyFile.pdf");
            string fileString = System.Convert.ToBase64String(result.DocumentBytes);

            Session["anterior"] = "No";
            return(Json(fileString));
        }
Пример #17
0
        public async Task <ActionResult> DownloadReport(string targetUrl, string CCode, string UCode, string ReportParameter)
        {
            //	ITokenContainer tokenContainer = new TokenContainer();
            string token = Request.Cookies["MAQTA-LOCAL-TOKEN"].Value;

            if (token == null)
            {
                return(Json(new
                {
                    redirectUrl = Url.Action("LogOff", "Account"),
                    isRedirect = true
                }, JsonRequestBehavior.AllowGet));
            }
            ApiHelper.Client.ApiClient client = new ApiHelper.Client.ApiClient(HttpClientInstance.Instance, token);
            GenericClient cb       = new GenericClient(client);
            var           response = await cb.Get(targetUrl);

            JavaScriptSerializer j = new JavaScriptSerializer();

            ADP.MG.Pcs.Models.EntityModels.Report reportModel = default(ADP.MG.Pcs.Models.EntityModels.Report);
            if (!string.IsNullOrEmpty((response.ResponseResult)))
            {
                reportModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ADP.MG.Pcs.Models.EntityModels.Report>(response.ResponseResult);
            }
            //var typeReportSource = new UriReportSource { Uri = string.Format("Reports/{0}", reportModel.ReportFileName) };
            var typeReportSource = new UriReportSource {
                Uri = string.Format("Report/{0}", "CustomReport.trdx")
            };

            string[] parameters;
            parameters = ReportParameter.ToString().Split(';');
            typeReportSource.Parameters.Add("centerCode", parameters[0]);
            typeReportSource.Parameters.Add("jobNumber", parameters[1]);
            typeReportSource.Parameters.Add("searchString", parameters[2]);
            typeReportSource.Parameters.Add("pageNumber", parameters[3]);
            typeReportSource.Parameters.Add("pageSize", parameters[4]);
            typeReportSource.Parameters.Add("CCode", CCode);
            typeReportSource.Parameters.Add("UCode", UCode);
            typeReportSource.Parameters.Add("token", token);


            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            //Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport(reportModel.DownloadType.ToUpper(), typeReportSource, null);
            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("XLS", typeReportSource, null);
            byte[] contents = result.DocumentBytes;
            //string mimeType = reportModel.DownloadType == "xls" ? "vnd.ms-excel" : "vnd.ms-excel";//reportModel.DownloadType;
            string mimeType = "vnd.ms-excel";            //reportModel.DownloadType;

            //return File(contents, string.Format("application/{0}", mimeType), reportModel.DownloadFileName);
            return(File(contents, string.Format("application/{0}", mimeType), "Chassis Details.xls"));
        }
        private void OnStartCalculation()
        {
            List <EmployeeChangeLog> bdoInformation = createOverView.GetChangeLogItems(SelectedMonth + 1);
            JsonSerializerSettings   settings       = new JsonSerializerSettings();

            settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            settings.MissingMemberHandling = MissingMemberHandling.Ignore;

            string jsonContent = JsonConvert.SerializeObject(bdoInformation, settings);

            string jsonfile = $"C:\\Users\\Public\\Documents\\BdoInformation.json";

            System.IO.File.WriteAllText(jsonfile, jsonContent);

            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            // set any deviceInfo settings if necessary
            var deviceInfo = new System.Collections.Hashtable();


            var reportSource = new Telerik.Reporting.TypeReportSource();

            // reportName is the Assembly Qualified Name of the report
            reportSource.TypeName = typeof(AccountingHelper.Reporting.BDOInformation).AssemblyQualifiedName;


            // Pass parameter value with the Report Source if necessary
            reportSource.Parameters.Add("Source", jsonfile);
            reportSource.Parameters.Add("DataSelector", string.Empty);

            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

            string pdfFile = jsonfile.Replace("json", "pdf");

            using (System.IO.FileStream fs = new System.IO.FileStream(pdfFile, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }

            SelectedFilename = pdfFile;
            RaisePropertyChanged("SelectedFilename");

            result = reportProcessor.RenderReport("XLSX", reportSource, deviceInfo);

            string xlsxFile = jsonfile.Replace("json", "xlsx");

            using (System.IO.FileStream fs = new System.IO.FileStream(xlsxFile, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
        protected void BtnPdf_Click(object sender, EventArgs e)
        {
            return;

            Person person = null;

            if (Session["PASAPORTE"] != null)
            {
                person = (Person)Session["PASAPORTE"];
            }

            if (person == null)
            {
                return;
            }

            Pasaporte rep = new Pasaporte();

            rep.TxtNumPasaporte.Value    = person.noPasaporte;
            rep.TxtApellidos.Value       = person.apellidos;
            rep.TxtNombre.Value          = person.nombre;
            rep.TxtNacionalidad.Value    = person.nacionalidad;
            rep.TxtFechaNacimiento.Value = person.fechaNacimiento;
            rep.TxtCedula.Value          = person.cedulaIdentidad;
            rep.TxtSexo.Value            = person.Sexo;
            rep.TxtLugarNacimiento.Value = person.lugarNacimiento;
            rep.TxtFechaEmision.Value    = person.fechaNacimiento;
            rep.TxtLugarNacimiento.Value = person.lugarNacimiento;
            rep.TxtFechaExpiracion.Value = person.fechaNacimiento;
            rep.TxtOCR.Value             = person.ocr;

            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            System.Collections.Hashtable deviceInfo =
                new System.Collections.Hashtable();

            Telerik.Reporting.InstanceReportSource instanceReportSource =
                new Telerik.Reporting.InstanceReportSource();

            instanceReportSource.ReportDocument = rep;

            Telerik.Reporting.Processing.RenderingResult result =
                reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);

            byte[] ReportePdf = result.DocumentBytes;

            DescargaArchivos da = new DescargaArchivos(Response);

            da.DescargaArchivoBytes(ReportePdf, Constantes.mimeTypePDF, "Pasaporte", Constantes.pdfextension);
        }
Пример #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            System.Collections.Hashtable deviceInfo   = new System.Collections.Hashtable();
            TypeReportSource             reportSource = new TypeReportSource();

            reportSource.TypeName = typeof(PatientRegistrationForm).AssemblyQualifiedName;
            ReportSource myrep = reportSource;

            myrep.Parameters.Add(new Telerik.Reporting.Parameter("patientpk", Session["PatientId"].ToString()));

            reportViewer1.ReportSource          = reportSource;
            reportViewer1.ParametersAreaVisible = false;
            this.reportViewer1.RefreshReport();
        }
Пример #21
0
        private void SavePdf()
        {
            var file = "";

            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.AddExtension     = true;
                saveFileDialog.InitialDirectory = Settings.Current.RepTemplates;
                saveFileDialog.Filter           = "PDF files (*.pdf)|*.pdf";
                saveFileDialog.Title            = "Save report to ...";
                saveFileDialog.FileName         = this.Title + ".pdf";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    file = saveFileDialog.FileName;
                }

                if (!string.IsNullOrEmpty(file))
                {
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }

                    Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                    Telerik.Reporting.Processing.RenderingResult result          = reportProcessor.RenderReport("PDF", this.SourceReport, new System.Collections.Hashtable());

                    using (FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Create))
                    {
                        fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
                    }

                    var param = Settings.Current.GetDialogParameters();
                    param.Content = this.Title + " successfully saved !";
                    RadWindow.Alert(param);
                }
            }
            catch (Exception)
            {
                if (File.Exists(file))
                {
                    File.Delete(file);
                }
                var param = Settings.Current.GetDialogParameters();
                param.Content = "An error occured while saving the template ! Please, try again later.";
                RadWindow.Alert(param);
            }
        }
Пример #22
0
        internal static void ExportReportAsPdf(Telerik.Reporting.InstanceReportSource instanceReportSource, HttpResponse response, string fileName)
        {
            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            var deviceInfo      = new System.Collections.Hashtable();

            var result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);

            response.Clear();
            response.ContentType  = "application/pdf";
            response.BufferOutput = true;
            response.AppendHeader("accept-ranges", "none");
            response.AppendHeader("content-disposition", string.Concat("attachment; filename=", fileName));
            response.BinaryWrite(result.DocumentBytes);
            response.Flush();
            response.End();
        }
Пример #23
0
        // test xuat file
        protected void Button1_Click(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            //set any deviceInfo settings if necessary
            System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();

            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("DOCX", ReportViewer1.Report, deviceInfo);
            string       fileName = result.DocumentName + "." + result.Extension;
            const string path     = @"C:\";
            string       filePath = System.IO.Path.Combine(path, fileName);

            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
Пример #24
0
        public void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Hide();
            RptPagare report = new RptPagare(UsarFolio, UsarCantidad, UsarFecha, UsarCantLetra, UsarNumPagare, UsarNumPagares, UsarNombre, UsarDireccion, UsarColonia, UsarCiudad, UsarEstado);

            ReportViewer.Report = report;

            ReportViewer.RefreshReport();

            //-------Que muestra previsualizador de que se esta imprimiendo
            //System.Drawing.Printing.PrinterSettings printerSettings
            //         = new System.Drawing.Printing.PrinterSettings();


            //Telerik.Reporting.Processing.ReportProcessor reportProcessor
            //    = new Telerik.Reporting.Processing.ReportProcessor();

            //Telerik.Reporting.TypeReportSource typeReportSource =
            //    new Telerik.Reporting.TypeReportSource();

            //reportProcessor.PrintReport(report, printerSettings);
            // ------------codigo


            // Obtain the settings of the default printer
            System.Drawing.Printing.PrinterSettings printerSettings
                = new System.Drawing.Printing.PrinterSettings();

            //--------- The standard print controller comes with no UI----------//
            System.Drawing.Printing.PrintController standardPrintController =
                new System.Drawing.Printing.StandardPrintController();

            // Print the report using the custom print controller
            Telerik.Reporting.Processing.ReportProcessor reportProcessor
                = new Telerik.Reporting.Processing.ReportProcessor();

            reportProcessor.PrintController = standardPrintController;

            Telerik.Reporting.TypeReportSource typeReportSource =
                new Telerik.Reporting.TypeReportSource();



            reportProcessor.PrintReport(report, printerSettings);
        }
Пример #25
0
        protected void test_Click(object sender, EventArgs e)
        {
            LabelRpt report           = new LabelRpt();
            string   convertedfrom    = "2017-11-1";
            string   convertedto      = "2017-11-30";
            var      dt               = GetData(convertedfrom, convertedto);
            var      objectDataSource = new ObjectDataSource {
                DataSource = dt
            };

            report.DataSource = objectDataSource;
            var table = report.Items.Find("list1", true)[0] as Telerik.Reporting.List;

            table.ColumnHeadersPrintOnEveryPage = true;
            table.DataSource = dt;

            Telerik.Reporting.Processing.ReportProcessor reportProcessor =
                new Telerik.Reporting.Processing.ReportProcessor();
            System.Collections.Hashtable deviceInfo =
                new System.Collections.Hashtable();
            Telerik.Reporting.TypeReportSource typeReportSource =
                new Telerik.Reporting.TypeReportSource();
            typeReportSource.TypeName = "reportName";
            Telerik.Reporting.Processing.RenderingResult result =
                reportProcessor.RenderReport("PDF", report, deviceInfo);
            string today    = Convert.ToDateTime(DateTime.Now).ToString("ddMMyyyy");
            string fileName = result.DocumentName + "_" + today + "." + result.Extension;
            string path     = System.IO.Path.GetTempPath();
            string filePath = System.IO.Path.Combine(path, fileName);

            TempPath.Text = filePath;
            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
            if (update(dt))
            {
                RetrieveCombobox();
                Response.Write("<script>alert('File Has been downloaded to your temporary Folder, see information above preview')</script>");
            }
            else
            {
                Response.Write("Error has occurred");
            }
        }
Пример #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IIQCareSystem appManager = (IIQCareSystem)ObjectFactory.CreateInstance("BusinessProcess.Security.BIQCareSystem, BusinessProcess.Security");

            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            System.Collections.Hashtable deviceInfo   = new System.Collections.Hashtable();
            TypeReportSource             reportSource = new TypeReportSource();

            reportSource.TypeName = typeof(PatientSummary).AssemblyQualifiedName;
            ReportSource myrep = reportSource;

            myrep.Parameters.Add(new Telerik.Reporting.Parameter("patientpk", Session["PatientId"].ToString()));
            myrep.Parameters.Add(new Telerik.Reporting.Parameter("logopath", "\\logo.png"));

            reportViewer1.ReportSource          = reportSource;
            reportViewer1.ParametersAreaVisible = false;
            this.reportViewer1.RefreshReport();
        }
Пример #27
0
        public async Task <ActionResult> DownloadApprovalReport(string targetUrl, string CCode, string UCode, string ReportParameter)
        {
            //ITokenContainer tokenContainer = new TokenContainer();
            string token = Request.Cookies["MAQTA-LOCAL-TOKEN"].Value;//Used this as Per Mudassar on 4-July-2019

            if (token == null)
            {
                return(Json(new
                {
                    redirectUrl = Url.Action("LogOff", "Account"),
                    isRedirect = true
                }, JsonRequestBehavior.AllowGet));
            }

            ApiHelper.Client.ApiClient client = new ApiHelper.Client.ApiClient(HttpClientInstance.Instance, token);
            GenericClient cb       = new GenericClient(client);
            var           response = await cb.Get(targetUrl);

            JavaScriptSerializer j = new JavaScriptSerializer();

            ADP.MG.Pcs.Models.EntityModels.Report reportModel = default(ADP.MG.Pcs.Models.EntityModels.Report);
            if (!string.IsNullOrEmpty((response.ResponseResult)))
            {
                reportModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ADP.MG.Pcs.Models.EntityModels.Report>(response.ResponseResult);
            }

            var typeReportSource = new UriReportSource {
                Uri = string.Format("Report/{0}", "Approval.trdx")
            };

            string[] parameters;
            parameters = ReportParameter.ToString().Split(';');
            typeReportSource.Parameters.Add("centerCode", parameters[0]);
            typeReportSource.Parameters.Add("jobNumber", parameters[1]);
            typeReportSource.Parameters.Add("CCode", CCode);
            typeReportSource.Parameters.Add("UCode", UCode);
            typeReportSource.Parameters.Add("token", token);
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            Telerik.Reporting.Processing.RenderingResult result          = reportProcessor.RenderReport("PDF", typeReportSource, null);
            byte[] contents = result.DocumentBytes;
            string mimeType = "PDF";

            return(File(contents, string.Format("application/{0}", mimeType), "Approval.pdf"));
        }
Пример #28
0
        public PrintView(List <Test> lstT)
        {
            if (lstT.Count > 0)
            {
                InitializeComponent();
                this.rpvNav.CommandBarElement.Rows[0].Strips[0].ItemsLayout.Children[0].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
                CommandBarButton btn = new CommandBarButton();
                btn.Click      += new EventHandler(btn_Click);
                btn.DrawText    = false;
                btn.Image       = (System.Drawing.Image)Properties.Resources.save;
                btn.ToolTipText = "Save PDF to a specified location";
                this.rpvNav.CommandBarElement.Rows[0].Strips[0].Items.Insert(0, btn);

                BatchReport          report      = new BatchReport();
                InstanceReportSource rptInstance = new InstanceReportSource();
                rptInstance.ReportDocument = report;

                Test t = new Test();
                t.PrepRun = lstT[0].PrepRun;
                t.DueDate = lstT.Where(te => te.DueDate != null).Select(te => te.DueDate).Min();

                report.DataSource      = t;
                report.DocumentMapText = "Prep Benchsheet";


                Telerik.Reporting.Table tableItem = report.Items.Find("table1", true)[0] as Telerik.Reporting.Table;
                tableItem.DataSource = lstT;

                //Render pdf
                Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
                deviceInfo["FontEmbedding"] = "None";
                result = reportProcessor.RenderReport("PDF", rptInstance, deviceInfo);
                MemoryStream msPDF = new MemoryStream(result.DocumentBytes);
                rpvMain.ViewerMode = FixedDocumentViewerMode.TextSelection;
                rpvMain.LoadDocument(msPDF);
                //msPDF.Dispose();
            }
        }
Пример #29
0
        public void ExportToPDF(Report reportToExport)
        {
            var reportProcessor      = new Telerik.Reporting.Processing.ReportProcessor();
            var instanceReportSource = new InstanceReportSource();

            instanceReportSource.ReportDocument = reportToExport;
            var result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ContentType = result.MimeType;
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Private);
            HttpContext.Current.Response.Expires = -1;
            HttpContext.Current.Response.Buffer  = true;

            /* Uncomment to handle the file as attachment
             * Response.AddHeader("Content-Disposition",
             *              string.Format("{0};FileName=\"{1}\"",
             *                              "attachment",
             *                              fileName));
             */

            HttpContext.Current.Response.BinaryWrite(result.DocumentBytes);
            HttpContext.Current.Response.End();
        }
Пример #30
0
        public void GetSpoolGenExclude3RevisionStatusDetailsPDF(int ProjId)
        {
            Random random   = new Random();
            int    fileId   = random.Next(1000, 9999);
            string fileName = $"SpoolGenProgressExclude3Revision_Status_{fileId}.pdf";
            string filePath = $@"C:\Temp\{fileName}";

            SpoolGenProgress_LotWise_Exclude3RevReport report = new SpoolGenProgress_LotWise_Exclude3RevReport();

            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            report.ReportParameters["ProjId"].Value = ProjId;

            Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null);

            FileStream fs = new FileStream(filePath, FileMode.Create);

            fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
            fs.Close();

            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}");
            HttpContext.Current.Response.TransmitFile(filePath);
            HttpContext.Current.Response.End();
        }
        private void PrintProtocolls(List <TravelExpense> travelExpensesToBeMoved)
        {
            List <int> idList = new List <int>();

            foreach (TravelExpense item in travelExpensesToBeMoved)
            {
                idList.Add(item.Id);

                if (CreateFiles)
                {
                    TravelExpense newItem = dbAccess.SetProvidedToDatev(item);
                    if (item == null)
                    {
                        NotificationRequest.Raise(new Notification()
                        {
                            Title   = "QuantCo Deutschland GmbH",
                            Content = $"Beim Setzen des Datums 'ProvidedToDatev' ({item.Id} ist ein Fehler aufgetreten"
                        });
                    }
                    else
                    {
                        // reload travelexpenses to show the updates made in SetProvidedToDatev

                        travelExpenses.Clear();
                        travelExpenses = new ObservableCollection <TravelExpense>(dbAccess.GetAllTravelExpenses());

                        ListOfTravelExpenses = CollectionViewSource.GetDefaultView(travelExpenses);

                        ListOfTravelExpenses.CurrentChanged -= ListOfTravelExpenses_CurrentChanged;
                        ListOfTravelExpenses.CurrentChanged += ListOfTravelExpenses_CurrentChanged;
                        RaisePropertyChanged("ListOfTravelExpenses");
                        if (travelExpenses.Count > 0)
                        {
                            selectedItem = travelExpenses[0];
                        }
                    }
                }
            }
            if (ShowReport)
            {
                TypeReportSource source = new TypeReportSource();
                source.TypeName = typeof(AccountingHelper.Reporting.TravelExpenses).AssemblyQualifiedName;
                source.Parameters.Add("TravelExpenseIds", idList);
                ViewerParameter parameter = new ViewerParameter()
                {
                    typeReportSource = source
                };
                eventaggregator.GetEvent <ViewerParameterEvent>().Publish(parameter);
            }


            if (CreateFiles)
            {
                // create Report as pdf file
                var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

                // set any deviceInfo settings if necessary
                var deviceInfo = new System.Collections.Hashtable();


                var reportSource = new Telerik.Reporting.TypeReportSource();

                // reportName is the Assembly Qualified Name of the report
                reportSource.TypeName = typeof(AccountingHelper.Reporting.TravelExpenses).AssemblyQualifiedName;


                // Pass parameter value with the Report Source if necessary
                reportSource.Parameters.Add("TravelExpenseIds", idList);

                Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);


                using (System.IO.FileStream fs = new System.IO.FileStream(Path.Combine(csvFolder, "ProtokollReisekosten.pdf"), System.IO.FileMode.Create))
                {
                    fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
                }
            }
        }
Пример #32
0
        public JsonResult CarcharHrlySup(int idEvaluacion)
        {
            int numberRep        = int.Parse(Session["EmpReporte"].ToString());
            int nivelJefe        = int.Parse(Session["NivelJefe"].ToString());
            var reportProcessor  = new Telerik.Reporting.Processing.ReportProcessor();
            var typeReportSource = new Telerik.Reporting.TypeReportSource();

            //validar aqui .....
            int numeroJefe = int.Parse(Session["No_Empleado"].ToString());

            if (Session["anterior"].ToString() == "Si")
            {
                if ((nivelJefe == 2) || (nivelJefe == 4)) //&& numeroJefe == 29) || numeroJefe != 39 || (numeroJefe != 1685 || numeroJefe != 2199 || numeroJefe != 2266))
                {
                    if (numeroJefe == 29 || numeroJefe == 39 || numeroJefe == 1685 || numeroJefe == 2199 || numeroJefe == 2266 || numeroJefe == 3795)
                    {
                        typeReportSource.TypeName = typeof(Hourly).AssemblyQualifiedName;
                    }
                    else if (numeroJefe == 2700 || numeroJefe == 2175 || numeroJefe == 2224)
                    {
                        typeReportSource.TypeName = typeof(HourlyRasSup).AssemblyQualifiedName;
                    }
                    else
                    {
                        typeReportSource.TypeName = typeof(HourlySup).AssemblyQualifiedName;
                    }
                }
                else
                {
                    typeReportSource.TypeName = typeof(Hourly).AssemblyQualifiedName;
                }
            }
            else
            {
                if ((nivelJefe == 2) || (nivelJefe == 4)) //&& numeroJefe == 29) || numeroJefe != 39 || (numeroJefe != 1685 || numeroJefe != 2199 || numeroJefe != 2266))
                {
                    if (numeroJefe == 29 || numeroJefe == 39 || numeroJefe == 1685 || numeroJefe == 2199 || numeroJefe == 2266 || numeroJefe == 3795)
                    {
                        typeReportSource.TypeName = typeof(Hourly2).AssemblyQualifiedName;
                    }
                    else if (numeroJefe == 2700 || numeroJefe == 2175 || numeroJefe == 2224)
                    {
                        typeReportSource.TypeName = typeof(HourlyRasSup2).AssemblyQualifiedName;
                    }
                    else
                    {
                        typeReportSource.TypeName = typeof(HourlySup2).AssemblyQualifiedName;
                    }
                }
                else
                {
                    typeReportSource.TypeName = typeof(Hourly2).AssemblyQualifiedName;
                }
            }


            if (Session["anterior"].ToString() == "Si")
            {
                typeReportSource.Parameters.Add(name: "NumEmp", value: numberRep);
            }
            else
            {
                typeReportSource.Parameters.Add(name: "NumEmp", value: numberRep);
                typeReportSource.Parameters.Add(name: "idEvaluacion", value: idEvaluacion);
            }

            var deviceInfo = new System.Collections.Hashtable();
            // deviceInfo["JavaScript"] = "this.print({bUI: true, bSilent: false, bShrinkToFit: true});";
            var result = reportProcessor.RenderReport("PDF", typeReportSource, deviceInfo);

            HttpContext.Response.AddHeader("content-disposition", "inline; filename=MyFile.pdf");
            string fileString = System.Convert.ToBase64String(result.DocumentBytes);

            Session["anterior"] = "No";
            return(Json(fileString));
        }
        private void OnStartOverview()
        {
            // set PeriodTo to end of Month

            PeriodTo = dateFunctions.MonthEnd(PeriodTo);
            CreateEmployeeSalaryOverview createOverview = new CreateEmployeeSalaryOverview(null, PeriodFrom.Date, PeriodTo.Date);

            overviews = createOverview.GetSalaryOverview();

            if (SortByOffice)
            {
                overviews = overviews.OrderBy(s => s.OfficeLocation).ThenBy(s => s.EmployeeName).ToList();
            }



            // create JsonFile
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            settings.MissingMemberHandling = MissingMemberHandling.Ignore;

            string jsonContent = JsonConvert.SerializeObject(overviews, settings);

            string jsonfile = $"C:\\Users\\Public\\Documents\\Json.json";

            System.IO.File.WriteAllText(jsonfile, jsonContent);

            //TypeReportSource source = new TypeReportSource();
            //source.TypeName = typeof(AccountingHelper.Reporting.AnnualSalarySummary).AssemblyQualifiedName;
            //source.Parameters.Add("Source", jsonfile);
            //source.Parameters.Add("DataSelector", string.Empty);

            //ViewerParameter parameter = new ViewerParameter();
            //parameter.typeReportSource = source;

            //eventAggregator.GetEvent<ViewerParameterEvent>().Publish(parameter);

            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            // set any deviceInfo settings if necessary
            var deviceInfo = new System.Collections.Hashtable();


            var reportSource = new Telerik.Reporting.TypeReportSource();

            // reportName is the Assembly Qualified Name of the report
            reportSource.TypeName = typeof(AccountingHelper.Reporting.AnnualSalarySummary).AssemblyQualifiedName;


            // Pass parameter value with the Report Source if necessary
            reportSource.Parameters.Add("Source", jsonfile);
            reportSource.Parameters.Add("DataSelector", string.Empty);

            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);
            jsonfile = jsonfile.Replace(".json", ".pdf");


            using (System.IO.FileStream fs = new System.IO.FileStream(jsonfile, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }

            SelectedFilename = jsonfile;

            result = reportProcessor.RenderReport("XLSX", reportSource, deviceInfo);
            string excelFileName = $"C:\\Users\\Public\\Documents\\gehaltsuebersicht.xlsx";

            using (System.IO.FileStream fs = new System.IO.FileStream(excelFileName, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
        public string CreateLetterToPutInFrontOfNote(FaxTelephoneNumber faxTelephoneNumber, SignedDocument document)
        {
            Correspondence letter = new Correspondence();
            letter.TodaysDate = DateTime.Now.ToLongDateString();
            letter.MessageFrom = "A patient communications update from the office of " + document.CareProviderName;

            if (string.IsNullOrEmpty(faxTelephoneNumber.AddressLine1))
            {
                faxTelephoneNumber.AddressLine1 = string.Empty;
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.AddressLine2))
            {
                faxTelephoneNumber.AddressLine2 = string.Empty;
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.City))
            {
                faxTelephoneNumber.City = string.Empty;
            }
            else
            {
                faxTelephoneNumber.City = faxTelephoneNumber.City + ", ";
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.State))
            {
                faxTelephoneNumber.State = string.Empty;
            }
            else
            {
                faxTelephoneNumber.State = faxTelephoneNumber.State + " ";
            }

            if (string.IsNullOrEmpty(faxTelephoneNumber.PostalCode))
            {
                faxTelephoneNumber.PostalCode = string.Empty;
            }

            if (faxTelephoneNumber.AddressLine2.Length > 0)
            {
                letter.HeaderText = faxTelephoneNumber.Name + Environment.NewLine
                    + faxTelephoneNumber.AddressLine1 + Environment.NewLine
                    + faxTelephoneNumber.AddressLine2 + Environment.NewLine
                    + faxTelephoneNumber.City
                    + faxTelephoneNumber.State + faxTelephoneNumber.PostalCode;
            }
            else
            {
                string[] credential = faxTelephoneNumber.FullName.Split(' ');
                faxTelephoneNumber.Name = credential[1] + " " + credential[0] + " " + credential[credential.Length - 1];

                letter.HeaderText = credential[1] + " " + credential[0] + " " + credential[credential.Length - 1] + Environment.NewLine
                     + faxTelephoneNumber.AddressLine1 + Environment.NewLine
                     + faxTelephoneNumber.City
                     + faxTelephoneNumber.State + faxTelephoneNumber.PostalCode;
            }

            letter.BodyText = "I saw your patient " + document.PatientName
                + " at your request in consultation regarding the patient’s  orthopedic problem.  "
                + " Thank you for your kind referral." + Environment.NewLine + Environment.NewLine
                + "I’ve enclosed a copy of our office notes which includes "
                + "the diagnosis and treatment plan.  I will continue to keep you updated in the future with "
                + "regard to our patient’s progress .  Please let me know if I can answer any further questions "
                + "regarding our patient’s care." + Environment.NewLine + Environment.NewLine + Environment.NewLine
                + "All the Best,"
                + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine
                + document.CareProviderName
                + Environment.NewLine + Environment.NewLine
                + "Enclosure"
            ;

            AutomatedFaxReports.Letter report1 = new AutomatedFaxReports.Letter(letter);
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
            instanceReportSource.ReportDocument = report1;
            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
            using (var pdfStream = new MemoryStream(result.DocumentBytes))
            using (var reportFile = new FileStream(ConfigurationValues.CorrespondensePath, FileMode.Create))
            {
                pdfStream.CopyTo(reportFile);
            }

            PdfFileEditor pdfEditor = new PdfFileEditor();
            string newDocumentName = Guid.NewGuid().ToString() + ".pdf";

            //ConfigurationValues.FinalFaxPath = ConfigurationValues.FinalFaxPath + Guid.NewGuid().ToString() + ".pdf";
            pdfEditor.Concatenate(ConfigurationValues.CorrespondensePath, ConfigurationValues.CreatePdfPath, ConfigurationValues.FinalFaxPath + newDocumentName);
            return ConfigurationValues.FinalFaxPath + newDocumentName;
        }
 private void Process()
 {
     try
     {
         Hashtable deviceInfo = new Hashtable();
         deviceInfo["OutputFormat"] = "TIFF";
         Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
         Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("IMAGE", report1, deviceInfo);
         using (FileStream fs = new FileStream(@"c:\test.tiff", FileMode.Create))
         {
             fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
         }
     }
     catch (Exception ex)
     {
         string s1 = ex.Message;
     }
 }
Пример #36
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            try
            {

                System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

                // The standard print controller comes with no UI
                System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController();

                // Print the report using the custom print controller
                Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

                //reportProcessor.PrintController = standardPrintController;

                //reportProcessor.PrintReport(ViewRptSumario.Report, printerSettings);

                Hashtable deviceInfo = new Hashtable();
                deviceInfo.Add("ImmediatePrint", true);
                reportProcessor.RenderReport("PDF", ViewRptSumario.Report, deviceInfo);

                reportProcessor.PrintReport(ViewRptSumario.Report, printerSettings);

                //if (m_fDataAlta)
                //{
                //    //Atualiza Data Impressão
                //    m_oSumario.DATA_IMPRESSAO_SUMARIO = Convert.ToDateTime(DateTime.Now);
                //    m_oSumario.SalvarSumario_Impressao(Convert.ToInt32(UtSessao.Sessao["Id058"]));
                //    UtSessao.Sessao["Habilita"] = "N";
                //    ExibirMensagemPopUp("Sumário de Alta foi Fechado com sucesso!!!");
                //}
                //else
                //{
                //    ExibirMensagemPopUp("Data da Alta - não informada!!!");
                //}
            }
            catch (Exception ex)
            {
                ExibirMensagemPopUp(ex.Message);
            }

            if (UtSessao.Sessao["Habilita"].ToString() == "S")
            {
                if (m_fDataAlta)
                {
                    //Atualiza Data Impressão
                    m_oSumario.DATA_IMPRESSAO_SUMARIO = Convert.ToDateTime(DateTime.Now);
                    m_oSumario.SalvarSumario_Impressao(Convert.ToInt32(UtSessao.Sessao["Id058"]));
                    UtSessao.Sessao["Habilita"] = "N";
                    ExibirMensagemPopUp("Sumário de Alta foi Fechado com sucesso!!!");
                }
                else
                {
                    ExibirMensagemPopUp("Data da Alta - não informada!!!");
                }
            }
        }
Пример #37
-5
        public static void ConfirmRegistration(int registrationId, string reportpath)
        {
            var context = new CourseContext();
            var registration = context.Registrations.Include("Courses").FirstOrDefault(r => r.Id == registrationId);

            if (registration != null)
            {

                var myMessage = new SendGridMessage();
                myMessage.AddTo(registration.EMail);
                myMessage.AddTo("*****@*****.**");
                myMessage.From = new MailAddress("*****@*****.**", "Fahrschule Grütter-Stooss");
                var stream = new MemoryStream();
                var report = ReportHelper.GetReportFromFile(reportpath);
                report.ReportParameters["RegistrationId"].Value = registrationId;
                var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                var renderingResult = reportProcessor.RenderReport("PDF", report, null);
                stream.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
                stream.Position = 0;
                myMessage.AddAttachment(stream, "Anmeldung.pdf");
                myMessage.Subject = "Bestätigung Deiner Anmeldung";

                if (registration.Courses.Count == 1)
                {
                    var course = registration.Courses.ElementAt(0);
                    myMessage.Text = string.Format("Für den Kurs {0} am {1}", course.Name, course.StartDateTime);
                }

                if (registration.Courses.Count > 1)
                {
                    var sb = new StringBuilder();
                    sb.AppendLine("Für die Kurse:");
                    foreach (var course in registration.Courses)
                    {
                        sb.AppendLine(string.Format("Für den Kurs {0} am {1}", course.Name, course.StartDateTime));

                        myMessage.Text = sb.ToString();
                    }
                }

                // Create credentials, specifying your user name and password.
                var credentials = new NetworkCredential("*****@*****.**",
                    "*****@*****.**");

                // Create an Web transport for sending email, using credentials...
                //var transportWeb = new Web(credentials);

                // ...OR create a Web transport, using API Key (preferred)
                var transportWeb = new Web("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");

                // Send the email.
                transportWeb.DeliverAsync(myMessage);
            }
        }