Exemple #1
0
        //private static readonly Logger _log = LogManager.GetCurrentClassLogger();

        public SmartChartResponse GetChartsBySmartReportId(int smartReportId)
        {
            var response = new SmartChartResponse();

            try
            {
                var smartChartRepository    = new SmartChartRepository();
                var smartReportRepository   = new SmartReportRepository();
                var chartCommentsRepository = new ChartCommentRepository();
                var smartReport             = smartReportRepository.Query().FirstOrDefault(x => x.idSmartReport == smartReportId);
                if (smartReport != null)
                {
                    response.Delivery = new ServiceDeliveryDto()
                    {
                        DateDelivered  = smartReport.ServiceDelivery.DateDelivered,
                        DeliveryDateTo = smartReport.ServiceDelivery.DeliveryDateTo
                    };
                    response.SmartReport = new SmartReportDto()
                    {
                        ReportName = smartReport.ReportName,
                        Insights   = smartReport.Insights
                    };
                    var smartCharts =
                        smartChartRepository.Query()
                        .Where(x => x.idSmartReport == smartReportId && x.ChartType.idChartType != 10)
                        .OrderBy(x => x.ChartOrder)
                        .ToList();
                    foreach (var smartChart in smartCharts)
                    {
                        response.SmartCharts.Add(new SmartChartDto()
                        {
                            idSmartChart  = smartChart.idSmartChart,
                            IdChartType   = smartChart.IdChartType,
                            ChartType     = null,
                            Insights      = smartChart.Insights,
                            CssClasses    = smartChart.CssClasses,
                            ChartName     = smartChart.ChartName,
                            ChartTypeName = smartChart.ChartType.ChartTypeName,
                            ChartOrder    = smartChart.ChartOrder,
                            CommentsCount = chartCommentsRepository.Query().Where(x => x.IdSmartChart == smartChart.idSmartChart && x.IsActive == true).Count()
                        });
                    }
                    smartChartRepository.Dispose();
                    smartReportRepository.Dispose();
                    response.Acknowledgment = true;
                    response.Message        = "Success";
                }
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error getting SmartCharts. Exception :" + ex.Message;
            }
            return(response);
        }
Exemple #2
0
        public int GetPastDeliveryChart(int smartChartId)
        {
            int response = 0;

            try
            {
                var smartChartRepository  = new SmartChartRepository();
                var deliveryRepository    = new ServiceDeliveryRepository();
                var smartReportRepository = new SmartReportRepository();
                var smartChart            = smartChartRepository.Query().FirstOrDefault(x => x.idSmartChart == smartChartId);

                if (smartChart != null)
                {
                    var idSubscription      = smartChart.SmartReport.ServiceDelivery.ServiceSubscription.idServiceSubscription;
                    var currentDeliveryDate = smartChart.SmartReport.ServiceDelivery.DateDelivered;
                    var currentReportName   = smartChart.SmartReport.ReportName;
                    var pastDelivery        = deliveryRepository.Query().Where(x => x.IdServiceSubscription == idSubscription && x.DateDelivered < currentDeliveryDate).OrderByDescending(x => x.DateDelivered).FirstOrDefault();
                    if (pastDelivery != null)
                    {
                        var pastSmartreports = smartReportRepository.Query().Where(x => x.idServiceDelivery == pastDelivery.idServiceDelivery).ToList();
                        if (pastSmartreports != null)
                        {
                            foreach (var smartReport in pastSmartreports)
                            {
                                if (smartReport.ReportName.Equals(currentReportName))
                                {
                                    var pastChart = smartChartRepository.Query().FirstOrDefault(x => x.idSmartReport == smartReport.idSmartReport &&
                                                                                                x.IdChartType == smartChart.IdChartType &&
                                                                                                x.ChartName.Contains(smartChart.ChartName));
                                    if (pastChart != null && smartChartId != pastChart.idSmartChart)
                                    {
                                        response = pastChart.idSmartChart;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO
                return(0);
            }
            return(response);
        }