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"); }
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); } }
protected void Page_Load(object sender, EventArgs e) { string formObjKy = Request.QueryString["formObjKy"]; string formOrdKy = Request.QueryString["formOrdKy"]; string ReptNo = Request.QueryString["ReptNo"]; string formObjCaption = Request.QueryString["formObjCaption"]; if (!Page.IsPostBack) { List <paramClass> listParam = new List <paramClass>(); try { ReportViewer1.Visible = true; string CKy = HTNSession.CKy.ToString(); string UsrKy = HTNSession.UsrKy.ToString(); string UsrNm = HTNSession.UsrId.ToString(); string CNm = HTNSession.CNm.ToString(); string EnvironmentName = HTNSession.Environment; ApiOperation apiOpr = new ApiOperation(); List <ObjMasModel> selectedReportProp = apiOpr.UsrObjPrp_SelectWeb(EnvironmentName, Convert.ToInt32(CKy), Convert.ToInt32(UsrKy), formObjKy, "ReportWeb", null); ObjMasModel selectedReportPropObj = new ObjMasModel(); if (ReptNo == "1") { selectedReportPropObj = selectedReportProp.Where(obj => obj.ObjNm == "SourceReport").SingleOrDefault(); } else { string dynmicObjNm = "SourceReport_" + ReptNo; selectedReportPropObj = selectedReportProp.Where(obj => obj.ObjNm == dynmicObjNm).SingleOrDefault(); } List <ObjMasModel> selectedReportParamProp = apiOpr.UsrObjPrp_SelectWeb(EnvironmentName, Convert.ToInt32(CKy), Convert.ToInt32(UsrKy), selectedReportPropObj.ObjKy.ToString(), "ReportParameter", null); List <ObjMasModel> selectedReportPrameter = apiOpr.UsrObjPrp_SelectWeb(EnvironmentName, Convert.ToInt32(CKy), Convert.ToInt32(UsrKy), selectedReportParamProp[0].ObjKy.ToString(), null, null); var uriReportSource = new Telerik.Reporting.UriReportSource(); string URL = AppDomain.CurrentDomain.BaseDirectory + @"\Reports\TelericcSample\" + selectedReportProp[0].ReportPath; foreach (ObjMasModel dynobj in selectedReportPrameter) { paramClass param = new paramClass(); string ObjNm = dynobj.ObjNm.ToString(); param.Paramname = ObjNm; if (string.Equals(ObjNm, "CKy", StringComparison.CurrentCultureIgnoreCase)) { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, Convert.ToInt32(CKy))); } else if (string.Equals(ObjNm, "UsrKy", StringComparison.CurrentCultureIgnoreCase)) { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, Convert.ToInt32(UsrKy))); } else if (ObjNm == "ObjKy") { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, selectedReportPropObj.ObjKy.ToString())); } else if (string.Equals(ObjNm, "CNm", StringComparison.CurrentCultureIgnoreCase)) { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, CNm)); } else if (string.Equals(ObjNm, "UsrID", StringComparison.CurrentCultureIgnoreCase)) { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, UsrNm)); } else if (string.Equals(ObjNm, "RtpTitle", StringComparison.CurrentCultureIgnoreCase)) { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, selectedReportPropObj.ObjCaptn)); } else if (string.Equals(ObjNm, "RptTitle", StringComparison.CurrentCultureIgnoreCase)) { uriReportSource.Parameters.Add(ObjNm, selectedReportPropObj.ObjCaptn); } else if (ObjNm == "EnvironmentName") { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, EnvironmentName)); } else if (ObjNm == "TrnKy") { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, Convert.ToInt32(formOrdKy))); } else if (ObjNm == "OdrKy") { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, formOrdKy)); } else if (ObjNm == "OrdKy") { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, formOrdKy)); } else if (ObjNm == "FromTrnKy") { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, formOrdKy)); } else if (ObjNm == "RptNm") { uriReportSource.Parameters.Add(new Telerik.Reporting.Parameter(ObjNm, selectedReportPropObj.ObjCaptn)); } else { } } uriReportSource.Uri = URL; ReportViewer1.ReportSource = uriReportSource; ReportViewer1.ParametersAreaVisible = false; ReportViewer1.ShowHistoryButtons = false; ReportViewer1.ShowParametersButton = false; ReportViewer1.RefreshReport(); } catch (Exception ex) { string errMsg = ex.Message.ToString(); throw new Exception(ex.Message.ToString()); } } }