Inheritance: IReportComponent
Esempio n. 1
0
        public IEnumerable <ReportComponent> GetAll()
        {
            const string sql = @"SELECT * FROM [dbo].[ReportComponents] WHERE [IsDeleted] = 0";

            using (var command = new SqlCommand(sql, _connection))
            {
                _connection.Open();
                using (var reader = command.ExecuteReader())
                {
                    var list = new List <ReportComponent>();
                    while (reader.Read())
                    {
                        var component = new ReportComponent();
                        component.Id    = reader.GetInt32(0);
                        component.Title = reader.GetString(1);
                        component.Type  = reader.GetInt32(2);

                        var json = new JavaScriptSerializer();
                        var data = json.Deserialize <ComponentData>(reader.GetString(3));
                        component.Data = data;

                        component.CreationDate     = reader.GetString(4);
                        component.ModificationDate = reader.GetString(5);
                        list.Add(component);
                    }
                    _connection.Close();
                    return(list.AsEnumerable());
                }
            }
        }
Esempio n. 2
0
        public ReportComponent Get(int id)
        {
            const string sql = @"SELECT * FROM [dbo].[ReportComponents] WHERE [Id] = @Id";

            using (var command = new SqlCommand(sql, _connection))
            {
                _connection.Open();
                command.Parameters.AddWithValue("@Id", id);
                using (var reader = command.ExecuteReader())
                {
                    reader.Read();
                    var component = new ReportComponent();
                    component.Id    = reader.GetInt32(0);
                    component.Title = reader.GetString(1);
                    component.Type  = reader.GetInt32(2);

                    var json = new JavaScriptSerializer();
                    var data = json.Deserialize <ComponentData>(reader.GetString(3));
                    component.Data = data;

                    _connection.Close();
                    return(component);
                }
            }
        }
Esempio n. 3
0
        public void ShouldAddDashboardComponent()
        {
            //Arrange
            var reportComponent = new ReportComponent
            {
                CreationDate = "deittoim.neu",
                Data         = new ComponentData {
                    Dimensions = null, Filters = null, Metrics = null
                },
                Id    = 1,
                Title = "test",
                Type  = 1
            };

            var dashboardComponentRepository = new Mock <IDashboardComponentRepository>();

            dashboardComponentRepository.Setup(x => x.Add(It.IsAny <DashboardComponent>())).Returns(1);

            var reportComponentRepository = new Mock <IReportComponentRepository>();

            reportComponentRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(reportComponent);

            var handler = new DashboardComponentAddHandler(dashboardComponentRepository.Object, reportComponentRepository.Object);

            //Act
            var result = handler.HandleCore(1, 1);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DashboardComponentResponse));
        }
Esempio n. 4
0
        public int Add(ReportComponent reportComponent)
        {
            const string sql = @"INSERT INTO [dbo].[ReportComponents] (Title, Type, Definition, CreationDate, ModificationDate) VALUES (@componentTitle, @componentType, @definition, @creationDate, @modificationDate); SELECT @@IDENTITY;";

            using (var command = new SqlCommand(sql, _connection))
            {
                _connection.Open();
                command.Parameters.AddWithValue("@componentTitle", reportComponent.Title);
                command.Parameters.AddWithValue("@componentType", reportComponent.Type);
                command.Parameters.AddWithValue("@definition", _jsonSerialiser.Serialize(reportComponent.Data));
                command.Parameters.AddWithValue("@creationDate", DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"));
                command.Parameters.AddWithValue("@modificationDate", DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"));
                int    id     = 0;
                object result = command.ExecuteScalar();

                if (result != null)
                {
                    id = Convert.ToInt32(result);
                }

                _connection.Close();

                return(id);
            }
        }
Esempio n. 5
0
        public override ReportComponentResponse HandleCore(ReportComponentDto request)
        {
            var mapping = new Mapping();

            request.SubmissionDate = DateTime.UtcNow.ToString();
            ReportComponent reportComponent = mapping.DtoToReportComponent(request);
            int             id = _repository.Add(reportComponent);

            request.Id = id;
            return(new ReportComponentResponse(request));
        }
Esempio n. 6
0
        public void CheckReportsExists()
        {
            bool tabExists;

            NavigateToReturnPage();
            Wait.WaitTillAllAjaxCallsComplete();

            TabComponent objTab = new TabComponent();

            tabExists = objTab.CheckTabExists(SchoolSummaryTab);

            if (tabExists)
            {
                objTab.ClickTab(SchoolSummaryTab);
                Wait.WaitTillAllAjaxCallsComplete();

                string[] strReports = { Absentee_Det_Rpt
                                        , Address_Det_Rpt
                                        , Adopt_From_Care_Rpt
                                        , Attendance_Det_Rpt
                                        , Class_Det_Rpt
                                        , Early_Years_Rpt
                                        , Exclusion_Det_Rpt
                                        , Free_School_Meals_Rpt
                                        , General_Det_Rpt
                                        , Leaver_Basic_Det_Rpt
                                        , Preview_Summary_Report
                                        , All
                                        , Pupils_Basic_Det_Rpt
                                        , School_Dinners_Rpt
                                        , SEN_Det_Rpt
                                        , Top_Up_Funding_Rpt
                                        , Preview_Summary_Report };


                bool reportExists = false;

                ReportComponent objReport = new ReportComponent();

                for (int i = 0; i < strReports.Length; i++)
                {
                    reportExists = objReport.CheckReportExists(SeleniumHelper.AutomationId(GetReportName(strReports[i])));

                    if (!reportExists)
                    {
                        Assert.IsTrue(false);
                    }
                }
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Esempio n. 7
0
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            string[]        choices   = new string[] { "No View" };
            ReportComponent component = context.Instance as ReportComponent;

            if (component != null)
            {
                choices = (from s in component.Report.Views select s.Name).ToArray();
            }

            return(new StandardValuesCollection(choices));
        }
Esempio n. 8
0
        List <ReportView> getViewList(PropertyDescriptor descriptor, ReportComponent component)
        {
            List <ReportView> result = null;

            if (descriptor.Name == "ReferenceViewGUID")
            {
                result = component.Report.FullViewList.Where(i => i.GUID != component.GUID).ToList();
            }
            else
            {
                result = component.Report.Views;
            }
            return(result);
        }
Esempio n. 9
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            ReportComponent component = context.Instance as ReportComponent;

            if (component != null && value != null)
            {
                ReportView view = component.Report.Views.FirstOrDefault(i => i.Name == value.ToString());
                if (view != null)
                {
                    return(view.GUID);
                }
            }
            return(base.ConvertFrom(context, culture, value));
        }
Esempio n. 10
0
        public void CheckReportsExists()
        {
            bool tabExists;

            new Return().NavigateToReturnPage();
            Wait.WaitTillAllAjaxCallsComplete();

            TabComponent objTab = new TabComponent();

            tabExists = objTab.CheckTabExists(Constant.SchoolSummaryTab);

            if (tabExists)
            {
                objTab.ClickTab(Constant.SchoolSummaryTab);
                Wait.WaitTillAllAjaxCallsComplete();

                string[] strReports = { Constant.Absentee_Det_Rpt
                                        , Constant.Address_Det_Rpt
                                        , Constant.Adopt_From_Care_Rpt
                                        , Constant.Attendance_Det_Rpt
                                        , Constant.Exclusion_Det_Rpt
                                        , Constant.Free_School_Meals_Rpt
                                        , Constant.Leaver_Basic_Det_Rpt
                                        , Constant.All
                                        , Constant.Pupils_Basic_Det_Rpt
                                        , Constant.School_Dinners_Rpt
                                        , Constant.SEN_Det_Rpt
                                        , Constant.Top_Up_Funding_Rpt
                                        , Constant.Attendance_Det_Rpt_2nd_Half };


                bool reportExists = false;

                ReportComponent objReport = new ReportComponent();

                for (int i = 0; i < strReports.Length; i++)
                {
                    reportExists = objReport.CheckReportExists(SeleniumHelper.AutomationId(strReports[i] + Constant.periodAutumn));

                    if (!reportExists)
                    {
                        Assert.IsTrue(false);
                    }
                }
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Esempio n. 11
0
        public DashboardComponent ReportComponentToDashboardComponent(ReportComponent reportComponent)
        {
            var dashboardComponent = new DashboardComponent();

            dashboardComponent.Title            = reportComponent.Title;
            dashboardComponent.Type             = reportComponent.Type;
            dashboardComponent.CreationDate     = DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss");
            dashboardComponent.ModificationDate = dashboardComponent.CreationDate;

            var serializer = new JavaScriptSerializer();

            dashboardComponent.Definition = serializer.Serialize(reportComponent.Data);

            return(dashboardComponent);
        }
Esempio n. 12
0
        public ReportComponentDto ReportComponentToDto(ReportComponent report)
        {
            var dto = new ReportComponentDto
            {
                Id               = report.Id,
                Title            = report.Title,
                Type             = report.Type,
                ModificationDate = report.ModificationDate,
                Metrics          = MetricToDto(report.Data.Metrics),
                SubmissionDate   = report.CreationDate,
                Dimensions       = report.Data.Dimensions,
                Filters          = report.Data.Filters
            };

            return(dto);
        }
Esempio n. 13
0
        public ReportComponent DtoToReportComponent(ReportComponentDto dto)
        {
            var report = new ReportComponent
            {
                Id               = dto.Id,
                Title            = dto.Title,
                CreationDate     = dto.SubmissionDate,
                Type             = dto.Type,
                ModificationDate = dto.ModificationDate,
                Data             = new ComponentData {
                    Dimensions = dto.Dimensions, Filters = dto.Filters, Metrics = DtoToMetric(dto.Metrics)
                }
            };

            return(report);
        }
Esempio n. 14
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType)
 {
     if (context != null)
     {
         ReportComponent component = context.Instance as ReportComponent;
         if (component != null && value != null)
         {
             var        list = getViewList(context.PropertyDescriptor, component);
             ReportView view = list.FirstOrDefault(i => i.GUID == value.ToString());
             if (view != null)
             {
                 return(view.Name);
             }
         }
     }
     return(base.ConvertTo(context, culture, value, destType));
 }
Esempio n. 15
0
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            List <string>   choices   = new List <string>();
            ReportComponent component = context.Instance as ReportComponent;

            if (component != null)
            {
                var list = getViewList(context.PropertyDescriptor, component);
                choices = (from s in list select s.Name).ToList();
                if (context.PropertyDescriptor.Name == "ReferenceViewGUID")
                {
                    choices.Insert(0, "");
                }
            }

            return(new StandardValuesCollection(choices.OrderBy(i => i).ToList()));
        }
Esempio n. 16
0
        public void GetHandler_ValidatesData()
        {
            //Arrange
            var repository = new Mock <IReportComponentRepository>();
            var report     = new ReportComponent
            {
                Data = new ComponentData
                {
                    Dimensions = new List <Dimension> {
                        new Dimension {
                            DimensionId = 1
                        }
                    },
                    Metrics = new List <Metric> {
                        new Metric {
                            MetricId = 1
                        }
                    },
                    Filters = new List <Filter> {
                        new Filter {
                            FilterId = 1
                        }
                    }
                },
                Title = "Test",
                Id    = 1,
                Type  = 1
            };

            repository.Setup(x => x.Get(It.IsAny <int>())).Returns(report);
            var handler = new GetHandler(repository.Object);

            //Act
            var result = handler.HandleCore(1);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.ReportComponentDtos[0]);
            Assert.AreEqual(report.Title, result.ReportComponentDtos[0].Title);
            Assert.AreEqual(report.Id, result.ReportComponentDtos[0].Id);
            Assert.AreEqual(report.Type, result.ReportComponentDtos[0].Type);
        }
Esempio n. 17
0
        public void ShouldMapDtoToComponent()
        {
            //Arrange
            var mapping = new Mapping();
            var source  = new ReportComponentDto
            {
                Id         = 1,
                Title      = "Test",
                Type       = 1,
                Dimensions = new List <Dimension> {
                    new Dimension {
                        DimensionId = 1
                    }
                },
                Filters = new List <Filter> {
                    new Filter {
                        FilterId = 1
                    }
                },
                Metrics = new List <MetricDto> {
                    new MetricDto {
                        DataType = " ", Description = " ", DisplayName = " ", Group = new MetricGroup {
                            GroupId = 1, GroupName = " "
                        }, MetricId = 1, Mnemonic = " "
                    }
                },
                SubmissionDate = "now"
            };

            //Act
            ReportComponent destination = mapping.DtoToReportComponent(source);

            //Assert
            Assert.AreNotSame(source, destination);
            Assert.IsInstanceOfType(destination, typeof(ReportComponent));
            Assert.AreEqual(source.Title, destination.Title);
            Assert.AreEqual(source.Id, destination.Id);
            Assert.AreEqual(source.Type, destination.Type);
            Assert.AreEqual(source.Dimensions.Count, destination.Data.Dimensions.Count);
            Assert.AreEqual(source.Filters.Count, destination.Data.Filters.Count);
            Assert.AreEqual(source.Metrics.Count, destination.Data.Metrics.Count);
        }
Esempio n. 18
0
        public void ShouldMapReportComponentToDto()
        {
            //Arrange
            var mapping = new Mapping();
            var source  = new ReportComponent
            {
                Id    = 1,
                Title = "Test",
                Type  = 1,
                Data  = new ComponentData
                {
                    Dimensions = new List <Dimension> {
                        new Dimension {
                            DimensionId = 1
                        }
                    },
                    Filters = new List <Filter> {
                        new Filter {
                            FilterId = 1
                        }
                    },
                    Metrics = new List <Metric> {
                        new Metric {
                            MetricId = 1
                        }
                    }
                }
            };

            //Act
            ReportComponentDto destination = mapping.ReportComponentToDto(source);

            //Assert
            Assert.AreNotSame(source, destination);
            Assert.IsInstanceOfType(destination, typeof(ReportComponentDto));
            Assert.AreEqual(source.Title, destination.Title);
            Assert.AreEqual(source.Id, destination.Id);
            Assert.AreEqual(source.Data.Metrics.Count, destination.Metrics.Count);
            Assert.AreEqual(source.Data.Filters.Count, destination.Filters.Count);
            Assert.AreEqual(source.Data.Dimensions.Count, destination.Dimensions.Count);
            Assert.AreEqual(source.Type, destination.Type);
        }
Esempio n. 19
0
        public int Update(ReportComponent reportComponent)
        {
            const string sql = @"UPDATE [dbo].[ReportComponents] SET [Title] = @reportTitle, [Type] = @reportType, [Definition] = @definition, [ModificationDate] = @modificationDate WHERE [Id] = @Id";

            using (var command = new SqlCommand(sql, _connection))
            {
                _connection.Open();
                command.Parameters.AddWithValue("@reportTitle", reportComponent.Title);
                command.Parameters.AddWithValue("@reportType", reportComponent.Type);
                command.Parameters.AddWithValue("@definition", _jsonSerialiser.Serialize(reportComponent.Data));
                command.Parameters.AddWithValue("@Id", reportComponent.Id);
                command.Parameters.AddWithValue("@modificationDate", DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"));
                int    id     = 0;
                object result = command.ExecuteScalar();
                if (result != null)
                {
                    id = Convert.ToInt32(result);
                }
                _connection.Close();
                return(id);
            }
        }
Esempio n. 20
0
 /// The constructor.
 public Movement(Robot _robot)
     : base(_robot)
 {
     Report = new ReportComponent(_robot);
     ManualDrive = new ManualDriveComponent(_robot);
     TuningParameters = new TuningParametersComponent(_robot);
     MCUReport = new MCUReportComponent(_robot);
 }