3
Vote

concurrency

description

I am having an error when 2 or more users request a report simultaneously, that is, at the same time, what happens is that all users receive a single report, corresponding to that request any of the users.
How can i fix this?

comments

imran18aug wrote Jun 5, 2016 at 11:42 AM

I have resolved that by the use of Session.
Since report parameter and report name both have concurrency issue
In Controller
ReportViewer reportViewer = new ReportViewer();
.............
...............
After ViewBag.ReportViewer = reportViewer;

Session["ReportPath"] = Set Report path here.
Session["ReportParameter"] = set ReportParameter here

And now in ReportViewerWebForm.aspx.cs file

private void BuildReportViewer()
    {
        if (!IsPostBack)
        {
            ReportViewerForMvc.ReportViewer.ID = ReportViewer1.ID;               
            ReportViewer1.SetProperties(ReportViewerForMvc.ReportViewer);
            //***************For Resolving Concurrancy Issue****************
            try
            {
                if (Session["ReportPath"] != null)
                {
                    ReportViewer1.ServerReport.ReportPath = Convert.ToString(Session["ReportPath"]);
                }
                if (Session["ReportParameter"] != null)
                {
                    ReportViewer1.ServerReport.SetParameters((ReportParameter[])Session["ReportParameter"]);
                }
            }
            catch (Exception ex)
            { 

            }
            ReportViewer1.ServerReport.Refresh();
            //**************************************************************                
        }
    }


dinhnguyencp wrote Jul 1, 2016 at 3:54 PM

I think using Session is the right direction. I think it's better to pass the entire report viewer in session, not just ReportPath and ReportParameter. Like this:
In MVC action
    public ActionResult Index()
    {
        ReportViewer reportViewer = new ReportViewer();
        Session["MyReportViewer"] = reportViewer;

        return View();
    }
In MVC view:
@Html.ReportViewer(Session["MyReportViewer"] as Microsoft.Reporting.WebForms.ReportViewer)
In ReportViewerWebForm.aspx.cs
private void BuildReportViewer()
    {
        if (!IsPostBack)
        {
            var myReportViewer = Session["MyReportViewer"] as ReportViewer;
            ReportViewerForMvc.ReportViewer.ID = ReportViewer1.ID;
            ReportViewer1.SetProperties(myReportViewer);
        }
    }

dinhnguyencp wrote Jul 1, 2016 at 3:56 PM

I think using Session is the right direction. I think it's better to pass the entire report viewer in session, not just ReportPath and ReportParameter. Like this:

In MVC action
    public ActionResult Index()
    {
        ReportViewer reportViewer = new ReportViewer();
        Session["MyReportViewer"] = reportViewer;

        return View();
    }
In MVC view:

@Html.ReportViewer(Session["MyReportViewer"] as Microsoft.Reporting.WebForms.ReportViewer)

In ReportViewerWebForm.aspx.cs

private void BuildReportViewer()
    {
        if (!IsPostBack)
        {
            var myReportViewer = Session["MyReportViewer"] as ReportViewer;
            ReportViewerForMvc.ReportViewer.ID = ReportViewer1.ID;
            ReportViewer1.SetProperties(myReportViewer);
        }
    }

wrote Oct 26, 2016 at 12:09 PM