public void SelectLoadReport()

in sqlnexus/fmnexus.as.resource.cs [1203:1345]


        public void SelectLoadReport(string report, bool master, ReportParameter[] parameters)
        {
            Cursor save = StartWaiting();
            try
            {
                try
                {
                    LogMessage(sqlnexus.Properties.Resources.Msg_LoadingReport+report, MessageOptions.Silent);

                    bool fullpath = false;
                    string filename;
                    //special handling resource report
                    if (Globals.resourceReport.ContainsKey(report))
                    {
                        filename = report;
                    }
                    else if ("" == Path.GetExtension(report))
                    {
                        filename = GetFullReportPath(report, (master ? RDL_EXT : RDLC_EXT));
                    }
                    else  //Assume full path to file
                    {
                        fullpath = true;
                        filename = report;
                        report = ExtractReportName(report);
                    }

                    int i = tcReports.TabPages.IndexOfKey(report);
                    // This report isn't currently open; create a new tab and associated ReporterViewer instance. 
                    if (-1 == i) 
                    {

                        ReportViewer rv = new ReportViewer();
                        rv.Name = "rv" + report;

                        rv.LocalReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence);
                        //rv.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

                        AddCustomAssemblies(filename, rv);

                        //rv.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                        //rv.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("RenderBitmap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); 

                        if (Globals.resourceReport.ContainsKey(report)) //handle resource report
                        {
                            rv.LocalReport.LoadReportDefinition(new StringReader(Globals.resourceReport[report].reportDefinition));
                        }
                        else
                            rv.LocalReport.ReportPath = filename;


                        rv.LocalReport.EnableHyperlinks = true;
                        rv.LocalReport.EnableExternalImages = true;
                        rv.LocalReport.DisplayName = report;
                        if (null != parameters)
                        {
                            rv.LocalReport.SetParameters(parameters);
                        }
                        SetReportQueryParameters(rv.LocalReport);
                        SetReportUserProvidedParameters(rv.LocalReport);

                        FixupDataSources(filename, report, rv.LocalReport.DataSources, rv.LocalReport.GetParameters());

                        TabPage p = new TabPage(report);
                        
                        p.Name = report;
                        p.Controls.Add(rv);

                        rv.Dock = DockStyle.Fill;

                        rv.ShowContextMenu = false;

                        rv.ContextMenuStrip = cmReport;
                        rv.ShowToolBar = false;

                        tcReports.TabPages.Add(p);
                        if (rv.LocalReport.DisplayName == null || rv.LocalReport.DisplayName.Length == 0)
                            throw new ArgumentException("you must set display name");
                        tcReports.SelectTab(tcReports.TabPages.Count - 1);

                        //Hide the damned tabs!
                        if (!this.tsiShowReportTabs.Checked)
                        {
                            tcReports.ItemSize = new Size(0, 1);
                        }

                        //Hook up event syncs
                        rv.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(ProcessSubreport);

                        rv.ReportRefresh += new System.ComponentModel.CancelEventHandler(this.rvTemplate_ReportRefresh);
                        rv.Hyperlink += new Microsoft.Reporting.WinForms.HyperlinkEventHandler(this.rvTemplate_Hyperlink);
                        rv.Back += new Microsoft.Reporting.WinForms.BackEventHandler(this.rvTemplate_Back);
                        rv.Drillthrough += new Microsoft.Reporting.WinForms.DrillthroughEventHandler(this.rvTemplate_Drillthrough);
                        rv.Toggle += new System.ComponentModel.CancelEventHandler(this.rvTemplate_Toggle);
                        rv.RenderingBegin += new System.ComponentModel.CancelEventHandler(this.rvTemplate_RenderingBegin);
                        rv.RenderingComplete += new Microsoft.Reporting.WinForms.RenderingCompleteEventHandler(this.rvTemplate_RenderingComplete);
                        rv.ReportError += new Microsoft.Reporting.WinForms.ReportErrorEventHandler(this.rvTemplate_ReportError);
                        rv.Click += new System.EventHandler(this.rvTemplate_Click);

                        if ((master) && (fmReportParameters.HasReportParameters(rv.LocalReport, true)))
                            fmNexus.GetReportParameters(false,"");

                        rv.RefreshReport();
                        toolbarReport.Visible = reportToolStripMenuItem.Checked;
                        TreeNode n = AddFindReportNode(report, null);
                        n.ImageIndex = 1;
                        n.SelectedImageIndex = 1;
                        
                        this.tvReports.AfterSelect -= new System.Windows.Forms.TreeViewEventHandler(this.tvReports_AfterSelect);
                        tvReports.SelectedNode = n;
                        this.tvReports.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvReports_AfterSelect);

                        if (fullpath)
                            n.Tag = 1;

                        paTasksBody.Enabled = true;

                    }
                    else
                    {   // This report is already open -- select the tab and refresh the report. 
                        tcReports.SelectTab(i);
                        if (!master)
                        {
                            if (null != parameters)
                                CurrentReport.SetParameters(parameters);
                            SetReportQueryParameters(CurrentReport);
                            RefreshReport(CurrentReport, CurrentReportViewer);
                        }
                    }
                    LogMessage(sqlnexus.Properties.Resources.Msg_Loaded);
                    UpdateTitle();
                    UpdateReportButtons();
                }
                catch (Exception ex)
                {
                    Globals.HandleException(ex, this, this);
                }
            }
            finally
            {
                StopWaiting(save);
            }
        }