/// <summary> /// Requests the RFQs per catgeory report data from the web services back-end and sends this data along with other parameter information /// to the report generation viewmodel by publishing an RequestsCountByCategoryReportEvent through the event aggregator. /// </summary> /// <param name="reportType"> the type of report - bar chart, pie chart, etc.</param> /// <param name="categoryType"> the category by which the RFQs will be grouped - this is passed onto the web service.</param> /// <param name="fromDate"> the RFQs trade date.</param> /// <param name="minimumCount">the minimum count of RFQs that will be excluded from the report data.</param> /// <exception cref="ArgumentException"> thrown if reportType parameter is null or empty.</exception> /// <exception cref="ArgumentException"> thrown if categoryType parameter is null or empty.</exception> public void CompileRequestCountByCategoryReport(string reportType, string categoryType, DateTime fromDate, int minimumCount) { if (String.IsNullOrEmpty(reportType)) { throw new ArgumentException("reportType"); } if (String.IsNullOrEmpty(categoryType)) { throw new ArgumentException("categoryType"); } try { var eventPayLoad = new RequestsCountByCategoryReportEventPayLoad { ReportType = reportType, Category = categoryType, FromDate = fromDate, MinimumCount = minimumCount, }; if (!configManager.IsStandAlone) { var result = reportingContollerProxy.getRequestsByCategory(categoryType, fromDate, minimumCount); if (result != null) { foreach (var categoryCount in result) { eventPayLoad.CountByCategory.Add(categoryCount.categoryValue, categoryCount.requestCount); } } } eventAggregator.GetEvent <RequestsCountByCategoryReportEvent>().Publish(eventPayLoad); } catch (FaultException fe) { if (log.IsErrorEnabled) { log.Error("Exception thrown while compile report data for requests by category: " + categoryType + ": " + fe); } } catch (EndpointNotFoundException epnfe) { if (log.IsErrorEnabled) { log.Error("Exception thrown while compile report data for requests by category: " + categoryType + ": " + epnfe); } } catch (NullReferenceException nre) { if (log.IsErrorEnabled) { log.Error("Exception thrown while compile report data for requests by category: " + categoryType + ": " + nre); } } }
/// <summary> /// Prcoess the incoming report data event message, and creates and shows an instance of the report popup window with the appropriate chart. /// It uses the service locator to get an instance of the report popup window. /// </summary> /// <param name="eventPayLoad"> the RequestsCountByCategoryReportEventPayLoad event sent by the ReportDataManagerImpl.</param> /// <exception cref="ArgumentNullException"> thrown if the eventpayload paramter is null.</exception> private void HandleRequestsCountByCategoryReportEvent(RequestsCountByCategoryReportEventPayLoad eventPayLoad) { if (eventPayLoad == null) { throw new ArgumentNullException("eventPayLoad"); } if (eventPayLoad.CountByCategory.Count == 0) { MessageBox.Show("No RFQ data returned for the selected criteria!", "No Report Data To Display", MessageBoxButton.OK, MessageBoxImage.Information); return; } var reportViewModel = new GeneratedReportViewModel() { ReportTitle = "Request Count By " + eventPayLoad.Category + ":", ReportType = eventPayLoad.ReportType }; reportViewModel.AddSeries(GeneratedReportViewModel.ONLY_ONE_SERIES, eventPayLoad.CountByCategory.ToList()); var reportWindow = ServiceLocator.Current.GetInstance <IWindowPopup>(WindowPopupNames.REPORT_WINDOW_POPUP); reportWindow.ShowWindow(reportViewModel); }