/// <summary> /// Prcoess the incoming extrapolation 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 GreeksExtrapolationReportEventPayLoad event sent by the ReportDataManagerImpl.</param> /// <exception cref="ArgumentNullException"> thrown if the eventpayload parameter is null.</exception> private void HandleGreeksExtrapolationyReportEvent(GreeksExtrapolationReportEventPayLoad eventPayLoad) { if (eventPayLoad == null) { throw new ArgumentNullException("eventPayLoad"); } if (eventPayLoad.OutputExtrapolation.Count == 0) { MessageBox.Show("No extrapolation data returned for the selected criteria!", "No Report Data To Display", MessageBoxButton.OK, MessageBoxImage.Information); return; } var reportViewModel = new GeneratedReportViewModel { ReportTitle = "Extrapolation Graph Of " + GetRangeVariableDescription(eventPayLoad.RangeVariable) + " For RFQ " + eventPayLoad.RequestId + ":", ReportType = eventPayLoad.ReportType, }; foreach (var extrapolationPoint in eventPayLoad.OutputExtrapolation) { var listOfExtrapolations = extrapolationPoint.Value.ToList(); listOfExtrapolations.Sort(new NumericKeyComparer()); reportViewModel.AddSeries(extrapolationPoint.Key, listOfExtrapolations); } var reportWindow = ServiceLocator.Current.GetInstance <IWindowPopup>(WindowPopupNames.REPORT_WINDOW_POPUP); reportWindow.ShowWindow(reportViewModel); }
/// <summary> /// Requests the greeks extrapolation 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 GreeksExtrapolationReportEvent through the event aggregator. /// </summary> /// <param name="reportType"> the type of report - bar chart, pie chart, etc.</param> /// <param name="rangeVariable"> the range variable to be used for the extrapolation.</param> /// <param name="greeksToBeIncluded"> the set of greeks to be included in the report.</param> /// <param name="requestId"> the request id of the request to be priced.</param> /// <param name="rangeMinimum">the inclusive minimum range input value that will be used to extrapolate the report data.</param> /// <param name="rangeMaximum">the inclusive maximum range input value that will be used to extrapolate the report data.</param> /// <param name="rangeIncrement">the range increment that will be used for the extrapolatrion of the report data.</param> /// <exception cref="ArgumentException"> thrown if reportType parameter is null or empty.</exception> /// <exception cref="ArgumentException"> thrown if rangeVariable parameter is null or empty.</exception> /// <exception cref="ArgumentException"> thrown if rangeMinimum is greater than or equal to the rangeMaximum parameter.</exception> /// <exception cref="ArgumentException"> thrown if greeksTobeIncluded parameter is null or empty.</exception> /// <exception cref="ArgumentException"> thrown if rangeIncrement parameter is less than or equal to zero.</exception> public void CompileGreeksExtrapolationReport(string reportType, string rangeVariable, ISet <string> greeksToBeIncluded, int requestId, double rangeMinimum, double rangeMaximum, double rangeIncrement) { if (String.IsNullOrEmpty(reportType)) { throw new ArgumentException("reportType"); } if (String.IsNullOrEmpty(rangeVariable)) { throw new ArgumentException("rangeVariable"); } if (greeksToBeIncluded == null) { throw new ArgumentException("greeksToBeIncluded"); } if (greeksToBeIncluded.Count == 0) { throw new ArgumentException("greeksToBeIncluded"); } if (rangeMinimum >= rangeMaximum) { throw new ArgumentException("rangeMinimum"); } if (rangeIncrement <= 0) { throw new ArgumentException("rangeIncrement"); } try { var eventPayLoad = new GreeksExtrapolationReportEventPayLoad { ReportType = reportType, RequestId = requestId, RangeVariable = rangeVariable, RangeMinimum = rangeMinimum, RangeMaximum = rangeMaximum, RangeIncrement = rangeIncrement, GreeksToBeIncluded = greeksToBeIncluded }; if (!configManager.IsStandAlone) { var result = reportingContollerProxy.getGreeksExtrapolation(requestId, rangeVariable, rangeMinimum, rangeMaximum, rangeIncrement); if (result != null) { foreach (var output in result.resultSet) { if (greeksToBeIncluded.Contains(GreeksEnum.DELTA.ToString())) { eventPayLoad.AddOutputExtrapolation(output.rangeVariable.ToString(), GreeksEnum.DELTA, output.delta); } if (greeksToBeIncluded.Contains(GreeksEnum.GAMMA.ToString())) { eventPayLoad.AddOutputExtrapolation(output.rangeVariable.ToString(), GreeksEnum.GAMMA, output.gamma); } if (greeksToBeIncluded.Contains(GreeksEnum.VEGA.ToString())) { eventPayLoad.AddOutputExtrapolation(output.rangeVariable.ToString(), GreeksEnum.VEGA, output.vega); } if (greeksToBeIncluded.Contains(GreeksEnum.THETA.ToString())) { eventPayLoad.AddOutputExtrapolation(output.rangeVariable.ToString(), GreeksEnum.THETA, output.theta); } if (greeksToBeIncluded.Contains(GreeksEnum.RHO.ToString())) { eventPayLoad.AddOutputExtrapolation(output.rangeVariable.ToString(), GreeksEnum.RHO, output.rho); } if (greeksToBeIncluded.Contains(GreeksEnum.PREMIUM.ToString())) { eventPayLoad.AddOutputExtrapolation(output.rangeVariable.ToString(), GreeksEnum.PREMIUM, output.price); } } } } eventAggregator.GetEvent <GreeksExtrapolationReportEvent>().Publish(eventPayLoad); } catch (FaultException fe) { if (log.IsErrorEnabled) { log.Error("Exception thrown while compiling extrapolation report data for greeks using the range variable: " + rangeVariable + ": " + fe); } } catch (EndpointNotFoundException epnfe) { if (log.IsErrorEnabled) { log.Error("Exception thrown while compiling extrapolation report data for greeks using the range variable: " + rangeVariable + ": " + epnfe); } } catch (NullReferenceException nre) { if (log.IsErrorEnabled) { log.Error("Exception thrown while compiling extrapolation report data for greeks using the range variable: " + rangeVariable + ": " + nre); } } }