Commit 88b98a18aa94e797948f0751fee782171f2b89b1
1 parent
64b58678
Vrh.OneReport v4.5.2.0
- HttpContext kezelésének javítása
Showing
2 changed files
with
51 additions
and
15 deletions
Show diff stats
Vrh.OneReport/Properties/AssemblyInfo.cs
| @@ -32,6 +32,6 @@ using System.Runtime.InteropServices; | @@ -32,6 +32,6 @@ using System.Runtime.InteropServices; | ||
| 32 | // You can specify all the values or you can default the Build and Revision Numbers | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
| 33 | // by using the '*' as shown below: | 33 | // by using the '*' as shown below: |
| 34 | // [assembly: AssemblyVersion("1.0.*")] | 34 | // [assembly: AssemblyVersion("1.0.*")] |
| 35 | -[assembly: AssemblyVersion("4.5.1.0")] | ||
| 36 | -[assembly: AssemblyFileVersion("4.5.1.0")] | ||
| 37 | -[assembly: AssemblyInformationalVersion("4.5.1")] | ||
| 38 | \ No newline at end of file | 35 | \ No newline at end of file |
| 36 | +[assembly: AssemblyVersion("4.5.2.0")] | ||
| 37 | +[assembly: AssemblyFileVersion("4.5.2.0")] | ||
| 38 | +[assembly: AssemblyInformationalVersion("4.5.2")] | ||
| 39 | \ No newline at end of file | 39 | \ No newline at end of file |
Vrh.OneReport/ReportService.cs
| @@ -849,20 +849,13 @@ namespace Vrh.OneReport | @@ -849,20 +849,13 @@ namespace Vrh.OneReport | ||
| 849 | using (var reportViewer = new ReportViewer { ProcessingMode = ProcessingMode.Local }) | 849 | using (var reportViewer = new ReportViewer { ProcessingMode = ProcessingMode.Local }) |
| 850 | { | 850 | { |
| 851 | reportViewer.LocalReport.ReportPath = PrepareRdl(this.Report, autopurgeparameters: this.Report.AutoPurge); | 851 | reportViewer.LocalReport.ReportPath = PrepareRdl(this.Report, autopurgeparameters: this.Report.AutoPurge); |
| 852 | - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 853 | - // Ez a rész azért kell ide, mert egyébként nem web-es környezetben (az iSchedulerMonitor-ból való hívás esetén) | ||
| 854 | - // itt exception jön a reportViewer.Dispose()-ból annak ellenére, hogy az rr tartalmazza a byte sorozatot?! | ||
| 855 | - // A reportViewer HttpContext-et igényel, és ezzel a kódrésszel kell ezt megteremteni. | ||
| 856 | - if (System.Web.HttpContext.Current == null) | 852 | + SetHttpContextCurrent(1); |
| 853 | + foreach (var dataset in this.Report.Datasets) | ||
| 857 | { | 854 | { |
| 858 | - System.Web.HttpContext.Current = new System.Web.HttpContext( | ||
| 859 | - new System.Web.HttpRequest(System.IO.Path.GetRandomFileName(), "https://www.stackoverflow.com", string.Empty), | ||
| 860 | - new System.Web.HttpResponse(System.IO.TextWriter.Null) | ||
| 861 | - ); | 855 | + if (dataset.Type == DatasetTypes.DataPlugin || dataset.Type == DatasetTypes.SQLTextPlugin) SetHttpContextCurrent(2); |
| 856 | + var ds = CreateOneDataSource(dataset, this.Report.Parameters); | ||
| 857 | + reportViewer.LocalReport.DataSources.Add(ds); | ||
| 862 | } | 858 | } |
| 863 | - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 864 | - | ||
| 865 | - foreach (var dataset in this.Report.Datasets) { reportViewer.LocalReport.DataSources.Add(CreateOneDataSource(dataset,this.Report.Parameters)); } | ||
| 866 | reportViewer.LocalReport.SetParameters(GetReportParameters()); | 859 | reportViewer.LocalReport.SetParameters(GetReportParameters()); |
| 867 | 860 | ||
| 868 | string format; | 861 | string format; |
| @@ -885,6 +878,49 @@ namespace Vrh.OneReport | @@ -885,6 +878,49 @@ namespace Vrh.OneReport | ||
| 885 | ); | 878 | ); |
| 886 | } | 879 | } |
| 887 | } | 880 | } |
| 881 | + | ||
| 882 | + /// <summary> | ||
| 883 | + /// Web-es és nem web-es környezetben való futtatás esetére az exception-ök elkerülése érdekében szükséges hívások. | ||
| 884 | + /// NEM TELJESEN TISZTA A FUNKCIÓJUK!!!! | ||
| 885 | + /// </summary> | ||
| 886 | + /// <param name="mode"> | ||
| 887 | + /// mode==1 | ||
| 888 | + /// Ez a rész azért kell ide, mert egyébként nem web-es környezetben (az iSchedulerMonitor-ból való hívás esetén) | ||
| 889 | + /// itt exception jön a reportViewer.Dispose()-ból annak ellenére, hogy az rr tartalmazza a byte sorozatot?! | ||
| 890 | + /// A reportViewer HttpContext-et igényel, és ezzel a kódrésszel kell ezt megteremteni. | ||
| 891 | + /// mode==2 | ||
| 892 | + /// Ez a rész azért kell ide, mert egyébként a Hangfire-ral együttműködve hibára megy a plugin hívás a dbcontext használatakor | ||
| 893 | + /// "The virtual path '/' maps to another application, which is not allowed." | ||
| 894 | + /// exception-nal | ||
| 895 | + /// </param> | ||
| 896 | + private static void SetHttpContextCurrent(int mode) | ||
| 897 | + { | ||
| 898 | + if (mode==1) | ||
| 899 | + { | ||
| 900 | + if (System.Web.HttpContext.Current == null) | ||
| 901 | + { | ||
| 902 | + System.Web.HttpContext.Current = new System.Web.HttpContext( | ||
| 903 | + new System.Web.HttpRequest(System.IO.Path.GetRandomFileName(), "https://www.stackoverflow.com", string.Empty), | ||
| 904 | + new System.Web.HttpResponse(System.IO.TextWriter.Null) | ||
| 905 | + ); | ||
| 906 | + } | ||
| 907 | + } | ||
| 908 | + if (mode == 2) | ||
| 909 | + { | ||
| 910 | + string urlroot = null; | ||
| 911 | + if (System.Web.HttpContext.Current == null) { urlroot = "http://localhost"; } | ||
| 912 | + else | ||
| 913 | + { | ||
| 914 | + var rq = System.Web.HttpContext.Current.Request; | ||
| 915 | + urlroot = rq.Url.GetLeftPart(UriPartial.Authority) + rq.ApplicationPath; | ||
| 916 | + } | ||
| 917 | + System.Web.HttpContext.Current = new System.Web.HttpContext( | ||
| 918 | + new System.Web.HttpRequest("", urlroot, string.Empty), | ||
| 919 | + new System.Web.HttpResponse(System.IO.TextWriter.Null) | ||
| 920 | + ); | ||
| 921 | + } | ||
| 922 | + } | ||
| 923 | + | ||
| 888 | #endregion ReportToByteArray private method | 924 | #endregion ReportToByteArray private method |
| 889 | 925 | ||
| 890 | #region PrepareRdl | 926 | #region PrepareRdl |