private void ShowExceptionReport() { int month, year; if (!string.IsNullOrEmpty(DateMonth.Text)) { month = DateTime.ParseExact(DateMonth.Text, "yyyy-MM", CultureInfo.InvariantCulture).Month; year = DateTime.ParseExact(DateMonth.Text, "yyyy-MM", CultureInfo.InvariantCulture).Year; } else { month = DateTime.Now.Month; year = DateTime.Now.Year; } var u = Global.db.Streams.AsEnumerable().Where(x => x.CreatedDate.Year == year && x.CreatedDate.Month == month).OrderByDescending(x => x.TotalView).Take(3); ExceptionReportView.Reset(); DataTable dt = u != null?LinqToDataTable.LINQResultToDataTable(u) : new DataTable(); ReportDataSource rds = new ReportDataSource("ExceptionDataSet", dt); ExceptionReportView.LocalReport.DataSources.Add(rds); ExceptionReportView.LocalReport.ReportPath = Server.MapPath("~/AdminAccess/Report/ExceptionReportMostView.rdlc"); ExceptionReportView.LocalReport.SetParameters(new ReportParameter("month", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month))); ExceptionReportView.LocalReport.Refresh(); }
/// <summary> /// Show the ExceptionReport dialog /// </summary> /// <remarks>The <see cref="ExceptionReporter"/> will analyze the <see cref="Exception"/>s and /// create and show the report dialog.</remarks> /// <param name="exceptions">The <see cref="Exception"/>s to show.</param> public void Show(params Exception[] exceptions) { if (exceptions == null) { return; // silently ignore this mistake of passing null - user won't care } try { _reportInfo.SetExceptions(exceptions); var view = new ExceptionReportView(_reportInfo); view.ShowExceptionReport(); } catch (Exception internalException) { MessageBox.Show(internalException.Message, "Failed trying to report an Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }