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 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(); }
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 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 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); }
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); } }
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); } }
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(); }
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); }
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); } }
// 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); } }
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"); } }
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")); }
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(); } }
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 OnPayrollCost() { //TypeReportSource source = new TypeReportSource(); //source.TypeName = typeof(AccountingHelper.Reporting.MonthlySalary).AssemblyQualifiedName; //source.Parameters.Add("EndDate", reportDate); //source.Parameters.Add("StartDate", new DateTime(reportDate.Year, reportDate.Month, 1)); //source.Parameters.Add("MonthYear", $"{reportDate: MMMM yyyy}"); // new Version of MonthlySalary DateTime reportDate = timeFunctions.MonthEnd(timeFunctions.MonthEnd(MonthlySalaryDate)); CreateEmployeeSalaryOverview salaryOverview = new CreateEmployeeSalaryOverview(null, new DateTime(reportDate.Year, 1, 1), reportDate); List <EmployeesMonthlyPayments> monthlyPayments = salaryOverview.GetMonthlyPayments(reportDate.Month); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; settings.MissingMemberHandling = MissingMemberHandling.Ignore; string jsonContent = JsonConvert.SerializeObject(monthlyPayments, settings); string jsonfile = $"C:\\Users\\Public\\Documents\\MonthlyOverview.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.MonthlySalaryOverview).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("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); } ConfirmationRequest.Raise(new Confirmation() { Content = $"Es wurde eine Excel-Datei ({xlsxFile}) erstellt" + Environment.NewLine + Environment.NewLine + "Soll die Excel-Datei als E-Mail verschickt werden?", Title = "QuantCo Deutschland GmbH" }, response => { if (response.Confirmed) { // send E-mail to Property 'CEOto' SendEmailToCEO(xlsxFile); } }); ViewerParameter parameter = new ViewerParameter() { typeReportSource = reportSource }; eventAggregator.GetEvent <ViewerParameterEvent>().Publish(parameter); }
private void OnPrepareTaxableExpenses() { List <int> employeeList = dbAccess.GetEmployeeIdsForOpenTaxableIncome(); if (employeeList.Count == 0) { NotificationRequest.Raise(new Notification() { Title = "QuantCo Deutschland GmbH", Content = "Es sind keine Datensätze vorhanden, die noch nicht versendet wurden" }); return; } TypeReportSource source = new TypeReportSource(); source.TypeName = typeof(AccountingHelper.Reporting.TaxableIncomeReport).AssemblyQualifiedName; ViewerParameter parameter = new ViewerParameter() { typeReportSource = source }; eventaggregator.GetEvent <ViewerParameterEvent>().Publish(parameter); #region Save Report as File // pdf Datei erzeugen und in Datev speichern // specify foldername .../Datev/TaxableIncomeReports/Report yyyyMMdd string foldername = Path.Combine(Properties.Settings.Default.RootDirectory, Properties.Settings.Default.DatevDirectory, "TaxableIncomeReports"); Directory.CreateDirectory(foldername); string filename = $"Report {DateTime.Now.Date:yyyyMMdd}.pdf"; filename = Path.Combine(foldername, filename); // 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.TaxableIncomeReport).AssemblyQualifiedName; Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo); using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } #endregion #region Send File To Taxadvisor // send file to taxAdvisor // prepare Email SendEmailClass sendEmail = new SendEmailClass(); sendEmail.Subject = "Besteuerung von geldwerten Vorteilen "; sendEmail.ToAddress = Properties.Settings.Default.BdoHr; sendEmail.Attachments.Add(filename); sendEmail.Body = $"Sehr geehrte Damen und Herren,{System.Environment.NewLine} {System.Environment.NewLine} als Anlage erhalten Sie eine Aufstellung über die geldwerten Vorteile aus den Reisekostenabrechnungen. " + $"{System.Environment.NewLine} {System.Environment.NewLine} Mit freundlichen Grüßen {System.Environment.NewLine} {System.Environment.NewLine} QuantCo Deutschland GmbH"; bool success = sendEmail.SendEmailToServer(); if (!success) { NotificationRequest.Raise(new Notification() { Title = "QuantCo Deutschland GmbH", Content = $"Das Email an {sendEmail.ToAddress} konnte nicht gesendet werden" }); } //MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem); //mailItem.BodyFormat = OlBodyFormat.olFormatHTML; //mailItem.SendUsingAccount = outlookUsingAccount; //mailItem.Subject = "Besteuerung von geldwerten Vorteilen "; //string BdoHr = Properties.Settings.Default.BdoHr; //string[] emails = BdoHr.Split(';'); //foreach (string email in emails) //{ // Recipient recipTo = mailItem.Recipients.Add(email); // recipTo.Type = (int)OlMailRecipientType.olTo; //} //if (!mailItem.Recipients.ResolveAll()) //{ // NotificationRequest.Raise(new Notification() // { // Title = "QuantCo Deutschland GmbH", // Content = $"Die E-Mail-Adressen '{BdoHr}' enthalten mindestens einen falschen Eintrag" // }); //} //else //{ // mailItem.Body = $"Sehr geehrte Damen und Herren,{System.Environment.NewLine} {System.Environment.NewLine} als Anlage erhalten Sie eine Aufstellung über die geldwerten Vorteile aus den Reisekostenabrechnungen. " + // $"{System.Environment.NewLine} {System.Environment.NewLine} Mit freundlichen Grüßen {System.Environment.NewLine} {System.Environment.NewLine} QuantCo Deutschland GmbH"; // mailItem.Attachments.Add(filename, OlAttachmentType.olByValue); // mailItem.Save(); //} #endregion ConfirmationRequest.Raise(new Confirmation() { Title = "QuantCo Deutschland GmbH", Content = "Sollen die Einträge als 'gesendet' gekennzeichnet werden? " }, response => { if (response.Confirmed) { // send Emails to Employees TaxableIncomeSendEmailsToEmployees(); // mark records as sent int nrOfAmendments = dbAccess.SetProvidedToTaxableIncome(); NotificationRequest.Raise(new Notification() { Title = "QuantCo Deutschland GmbH", Content = $"Es wurden {nrOfAmendments} Datensätze geändert." }); } }); }
private void TaxableIncomeSendEmailsToEmployees() { List <int> employeeList = dbAccess.GetEmployeeIdsForOpenTaxableIncome(); foreach (int employeeId in employeeList) { EmployeesForTravelExpenses employee = dbAccess.FindEmployeeById(employeeId); if (employee == null) { continue; } if (string.IsNullOrEmpty(employee.EmailAddress)) { continue; } // Render Report 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.TaxableIncomeByEmployee).AssemblyQualifiedName; // Pass parameter value with the Report Source if necessary reportSource.Parameters.Add("EmployeeId", employeeId); Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo); // set Directory to Root/Datev/TaxableIncomeReports/ and Filename: Fullname + "Taxable Income" + Date string taxableIncomeFileName = Path.Combine(Properties.Settings.Default.RootDirectory, Properties.Settings.Default.DatevDirectory, "TaxableIncomeReports", $"{employee.FullName} TaxableIncome {DateTime.Now:d}.pdf"); using (System.IO.FileStream fs = new System.IO.FileStream(taxableIncomeFileName, System.IO.FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } // prepare Email SendEmailClass sendEmail = new SendEmailClass(); sendEmail.Subject = "Besteuerung von geldwerten Vorteilen "; sendEmail.ToAddress = employee.EmailAddress; sendEmail.Attachments.Add(taxableIncomeFileName); sendEmail.Body = $"Lieber {employee.FullName},{System.Environment.NewLine} {System.Environment.NewLine} als Anlage erhältst Du eine Liste der geldwerten Vorteile, die in Kürze versteuert werden. " + $"{System.Environment.NewLine} {System.Environment.NewLine} Mit freundlichen Grüßen {System.Environment.NewLine} {System.Environment.NewLine} QuantCo Deutschland GmbH"; bool success = sendEmail.SendEmailToServer(); if (!success) { NotificationRequest.Raise(new Notification() { Title = "QuantCo Deutschland GmbH", Content = $"Das Email an {sendEmail.ToAddress} konnte nicht gesendet werden" }); } //MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem); //mailItem.BodyFormat = OlBodyFormat.olFormatHTML; //mailItem.SendUsingAccount = outlookUsingAccount; //mailItem.Subject = "Besteuerung von geldwerten Vorteilen "; //Recipient recipTo = mailItem.Recipients.Add(employee.EmailAddress); //recipTo.Type = (int)OlMailRecipientType.olTo; //if (!mailItem.Recipients.ResolveAll()) //{ // NotificationRequest.Raise(new Notification() // { // Title = "QuantCo Deutschland GmbH", // Content = $"Die E-Mail Adresse für {employee.FullName} ist ungültig" // }); // continue; //} //mailItem.Body = $"Lieber {employee.FullName},{System.Environment.NewLine} {System.Environment.NewLine} als Anlage erhältst Du eine Liste der geldwerten Vorteile, die in Kürze versteuert werden. " + // $"{System.Environment.NewLine} {System.Environment.NewLine} Mit freundlichen Grüßen {System.Environment.NewLine} {System.Environment.NewLine} QuantCo Deutschland GmbH"; // mailItem.Attachments.Add(taxableIncomeFileName, OlAttachmentType.olByValue); //mailItem.Save(); } }
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); } } }
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); } }