示例#1
0
        public SmartChartDto GetSmartChartById(int smartChartId)
        {
            var response = new SmartChartDto();

            try
            {
                var smartChartRepository = new SmartChartRepository();
                var smartChart           = smartChartRepository.Query().FirstOrDefault(x => x.idSmartChart == smartChartId);
                if (smartChart != null)
                {
                    response = new SmartChartDto()
                    {
                        idSmartReport = smartChart.idSmartReport,
                        SmartReport   = new SmartReportDto()
                        {
                            idServiceDelivery = smartChart.SmartReport.idServiceDelivery,
                        },
                        ChartName = smartChart.ChartName
                    };
                }

                smartChartRepository.Dispose();
            }
            catch (Exception ex)
            {
                //TODO
            }
            return(response);
        }
示例#2
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);
        }
示例#3
0
        public List <int> GetChartsIdByDateRange(int currentChartId, string chartName, string dateFrom, string dateTo)
        {
            var response = new List <int>();

            try
            {
                var serviceDeliveryRepository = new ServiceDeliveryRepository();
                var smartChartRepository      = new SmartChartRepository();
                //_log.Warn("Started");
                var from              = DateTime.Parse(dateFrom).AddDays(1);
                var to                = DateTime.Parse(dateTo);
                var report            = smartChartRepository.Query().FirstOrDefault(x => x.idSmartChart == currentChartId).SmartReport;
                var deliveries        = serviceDeliveryRepository.Query().Where(x => x.IdServiceSubscription == report.ServiceDelivery.IdServiceSubscription && x.DateDelivered <from && x.DateDelivered> to).ToList();
                var currentReportName = report.ReportName;
                foreach (var delivery in deliveries)
                {
                    foreach (var smartReport in delivery.SmartReports)
                    {
                        if (smartReport.ReportName.Equals(currentReportName))
                        {
                            foreach (var smartChart in smartReport.SmartCharts)
                            {
                                if (smartChart.ChartName.Equals(chartName) && currentChartId != smartChart.idSmartChart && smartChart.ChartType.idChartType != 10)
                                {
                                    response.Add(smartChart.idSmartChart);
                                }
                            }
                        }
                    }
                }
                response.Add(currentChartId);
                serviceDeliveryRepository.Dispose();
                smartChartRepository.Dispose();
            }
            catch (Exception ex)
            {
            }
            return(response);
        }