Ejemplo n.º 1
0
        private static TrendsViewModel GetTrendsSeriesPackageData(int id, DateTime startDate, DateTime endDate)
        {
            var model = new TrendsViewModel();

            try
            {
                using (_certonaService = new CertonaServiceClient())
                {
                    try
                    {
                        UserDTO user = FormsAuthenticationWrapper.User;

                        model.TrendSeries = new List <TrendSeries>();

                        var getRequest = new GetTrendsDataPackageRequest()
                        {
                            PackageID = id, StartDate = startDate, EndDate = endDate, User = user
                        };
                        var getResponse = _certonaService.GetTrendsDataPackage(getRequest);
                        if (getResponse.Success && getResponse.TrendsData != null && getResponse.TrendsData.Count > 0)
                        {
                            foreach (var dto in getResponse.TrendsData)
                            {
                                var seriesDataPoint = new TrendSeries()
                                {
                                    Category = dto.Category, Group = dto.Group, Data = dto.Data
                                };
                                model.TrendSeries.Add(seriesDataPoint);
                            }
                        }
                        else
                        {
                            var seriesDataPoint = new TrendSeries()
                            {
                                Category = "No Data", Group = "No Data"
                            };
                            model.TrendSeries.Add(seriesDataPoint);
                        }
                    }
                    catch (TimeoutException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                    catch (CommunicationException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                _certonaService.Abort();
                throw;
            }

            return(model);
        }