示例#1
0
        internal override void Render(Rdl.Render.Container box, Rdl.Runtime.Context context)
        {
            // Find the ActionElement
            Rdl.Render.ActionElement ae = null;

            foreach (Rdl.Render.Element e in box.Children)
            {
                if (e is Rdl.Render.ActionElement)
                {
                    ae = (Rdl.Render.ActionElement)e;
                }
            }

            if (ae == null)
            {
                throw new Exception("An action is defined where no textbox or image is contained");
            }

            if (_hyperlink != null)
            {
                ae.Hyperlink = _hyperlink.ExecAsString(context);
            }
            if (_bookmarkLink != null)
            {
                ae.BookmarkLink = _bookmarkLink.ExecAsString(context);
            }
            if (_drillthrough != null)
            {
                ae.DrillThroughReportName = _drillthrough.ReportName;
                foreach (Parameter parm in _drillthrough.Parameters)
                {
                    ae.DrillThroughParameterList.Add(
                        new Rdl.Render.ActionElement.ActionParameter(parm.Name,
                                                                     parm.Value(context)));
                }
            }
        }
示例#2
0
        void btnAction_Click(object sender, EventArgs e)
        {
            if (FindControl("tbAction") != null)
            {
                // Get the ID of the element which triggered the action
                string actionID = ((HiddenField)FindControl("tbAction")).Value;
                // Prevent recursion
                if (actionID != string.Empty)
                {
                    // Find the named text action element.
                    Rdl.Render.ActionElement ae = (Rdl.Render.ActionElement)_htmlReport.SourceReport.BodyContainer.FindNamedElement(actionID);

                    if (ae != null)
                    {
                        // If the action is a drill-through, then load the new report,
                        // set the parameters and open the report.
                        if (ae.DrillThroughReportName != null)
                        {
                            string reportName = ae.DrillThroughReportName;

                            Rdl.Engine.Report rpt;

                            System.Runtime.Remoting.ObjectHandle oh = null;
                            try
                            {
                                oh = Activator.CreateInstance(reportName, "Rdl.Runtime." + reportName.Replace(' ', '_'));
                            }
                            catch  { }
                            if (oh != null)
                            {
                                rpt = ((Rdl.Runtime.RuntimeBase)oh.Unwrap()).Report;
                            }
                            else
                            {
                                if (!reportName.Contains("\\"))
                                {
                                    reportName = _htmlReport.SourceReport.Report.ReportPath + reportName;
                                }
                                if (!reportName.Contains(".rdl"))
                                {
                                    if (File.Exists(reportName + ".rdl"))
                                    {
                                        reportName += ".rdl";
                                    }
                                    else if (File.Exists(reportName + ".rdlc"))
                                    {
                                        reportName += ".rdlc";
                                    }
                                }
                                if (!File.Exists(reportName))
                                {
                                    throw new Exception("Unable to locate sub report " + reportName);
                                }

                                rpt = new Rdl.Engine.Report();
                                FileStream fs = new FileStream(reportName,
                                                               FileMode.Open, FileAccess.Read, FileShare.Read);
                                rpt.Load(fs,
                                         _htmlReport.SourceReport.Report.ReportPath);
                                fs.Close();
                                fs.Dispose();
                            }

                            foreach (Rdl.Render.ActionElement.ActionParameter parm in ae.DrillThroughParameterList)
                            {
                                rpt.ReportParameters[parm.Name].Value  = parm.Value;
                                rpt.ReportParameters[parm.Name].Hidden = true;
                            }
                            Rdl.Render.GenericRender render = rpt.Run();

                            _reportSessionID = "RenderedReport_" + (reportIndex++).ToString();
                            ((HiddenField)FindControl("tbReportID")).Value = _reportSessionID;

                            SetReport(render);
                            return;
                        }
                    }
                }
            }
        }