Commit 88b98a18aa94e797948f0751fee782171f2b89b1

Authored by Schwirg László
1 parent 64b58678

Vrh.OneReport v4.5.2.0

- HttpContext kezelésének javítása
Vrh.OneReport/Properties/AssemblyInfo.cs
... ... @@ -32,6 +32,6 @@ using System.Runtime.InteropServices;
32 32 // You can specify all the values or you can default the Build and Revision Numbers
33 33 // by using the '*' as shown below:
34 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 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 39 \ No newline at end of file
... ...
Vrh.OneReport/ReportService.cs
... ... @@ -849,20 +849,13 @@ namespace Vrh.OneReport
849 849 using (var reportViewer = new ReportViewer { ProcessingMode = ProcessingMode.Local })
850 850 {
851 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 859 reportViewer.LocalReport.SetParameters(GetReportParameters());
867 860  
868 861 string format;
... ... @@ -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 924 #endregion ReportToByteArray private method
889 925  
890 926 #region PrepareRdl
... ...