internal static void Add(string id, ReportViewerSetting item) { lock (_ReportViewers) { _ReportViewers[id] = item; } }
public override void OnExecute(ICommandContext context, CommandConfig config, CommandResult result) { var viewResult = result as ExtendedActionResult; #region 创建ReportViewer ReportViewerSetting reportViewer = new ReportViewerSetting { DataSources = new List <ReportDataSource>(), Parameters = new List <ReportParameter>() }; reportViewer.ReportPath = ReportPath; DataSources.ForEach(p => { var pValue = p.GetValue(context); if (pValue == null) { throw new Exception(string.Format("参数[{0}]不能为空", p.Name)); } reportViewer.DataSources.Add(new ReportDataSource(p.Name, pValue)); }); Parameters.ForEach(p => { var pValue = p.GetValue(context); if (pValue == null) { throw new Exception(string.Format("参数[{0}]不能为空", p.Name)); } reportViewer.Parameters.Add(new ReportParameter(p.Name, pValue.ToString())); }); reportViewer.ContentHeader = string.IsNullOrEmpty(ContentHeader) ? "" : ContentHeader.ReplaceContextParameters(context, context); reportViewer.ContentFooter = string.IsNullOrEmpty(ContentFooter) ? "" : ContentFooter.ReplaceContextParameters(context, context); #endregion string id = Guid.NewGuid().ToString(); ReportViewers.Add(id, reportViewer); viewResult.ActionResult = ReportViewers.Redirect(id, ReportViewerUrl); result.End(NextCommand); context.Execute(NextCommand); }