コード例 #1
0
        public async Task DeleteAsync(string filterName)
        {
            try
            {
                var repository = new FilterRepository(this.AppUser.Tenant, this.AppUser.LoginId, this.AppUser.UserId);
                await repository.DeleteAsync(filterName).ConfigureAwait(false);
            }
            catch (UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (DataAccessException ex)
            {
                throw new HttpResponseException
                      (
                          new HttpResponseMessage
                {
                    Content    = new StringContent(ex.Message),
                    StatusCode = HttpStatusCode.InternalServerError
                });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }
コード例 #2
0
        public void RemoveDefault(string objectName)
        {
            try
            {
                var repository = new FilterRepository(this.MetaUser.Tenant, this.MetaUser.LoginId, this.MetaUser.UserId);
                repository.RemoveDefault(objectName);
            }
            catch (UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (DataAccessException ex)
            {
                throw new HttpResponseException(new HttpResponseMessage
                {
                    Content    = new StringContent(ex.Message),
                    StatusCode = HttpStatusCode.InternalServerError
                });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }
コード例 #3
0
        public async Task RecreateFiltersAsync(string objectName, string filterName, [FromBody] List <ExpandoObject> collection)
        {
            try
            {
                var repository = new FilterRepository(this.AppUser.Tenant, this.AppUser.LoginId, this.AppUser.UserId);
                await repository.RecreateFiltersAsync(objectName, filterName, collection).ConfigureAwait(false);
            }
            catch (UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (DataAccessException ex)
            {
                throw new HttpResponseException
                      (
                          new HttpResponseMessage
                {
                    Content    = new StringContent(ex.Message),
                    StatusCode = HttpStatusCode.InternalServerError
                });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }
コード例 #4
0
        public static Filter FilterAdd()
        {
            var filter = FilterTestHelper.FilterNew();

            filter = FilterRepository.FilterSave(filter);

            return(filter);
        }
コード例 #5
0
 public void SetUp()
 {
     _filter      = new FakeFilter();
     _filters     = new List <Filter>();
     _mockContext = new Mock <IDataContext>();
     _mockContext.Setup(p => p.Filters).Returns(_filters);
     _repository = new FilterRepository(_mockContext.Object);
 }
コード例 #6
0
 public CategoryController()
 {
     _categoryRepository       = new CategoryRepository();
     _filterRepository         = new FilterRepository();
     _recommendationRepository = new RecommendationRepository();
     _globalRepository         = new DBFirstDAL.Repositories.GlobalOptionRepository();
     _routeItemRepository      = new RouteItemRepository();
 }
コード例 #7
0
        public void Filter_Fetch_Info_List()
        {
            FilterTestHelper.FilterAdd();
            FilterTestHelper.FilterAdd();

            var filters = FilterRepository.FilterFetchInfoList(new FilterDataCriteria());

            Assert.IsTrue(filters.Count() > 1, "Row returned should be greater than one");
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilterController"/> class.
 /// </summary>
 public FilterController(IConfigurationStore configStore, ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler,
                         IProjectProxy projectProxy,
                         IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction,
                         IRepository <IFilterEvent> filterRepo, IRepository <IGeofenceEvent> geofenceRepo)
     : base(configStore, logger, serviceExceptionHandler, projectProxy, productivity3dV2ProxyNotification, productivity3dV2ProxyCompaction, "IFilterEvent")
 {
     Log                = logger.CreateLogger <FilterController>();
     this.filterRepo    = filterRepo as FilterRepository;
     geofenceRepository = geofenceRepo as GeofenceRepository;
 }
コード例 #9
0
        public void Filter_Fetch()
        {
            var filter = FilterTestHelper.FilterNew();

            filter = FilterRepository.FilterSave(filter);

            filter = FilterRepository.FilterFetch(filter.FilterId);

            Assert.IsTrue(filter != null, "Row returned should not equal null");
        }
コード例 #10
0
 public ProductController()
 {
     _productRepository        = new ProductRepository();
     _enumRepositopy           = new EnumValueRepository();
     _categoryRepository       = new CategoryRepository();
     _recommendationRepository = new RecommendationRepository();
     _globalOptionRepository   = new GlobalOptionRepository();
     _filterRepository         = new FilterRepository();
     _routeItemRepository      = new RouteItemRepository();
 }
コード例 #11
0
        public static Filter FilterNew()
        {
            var filter = FilterRepository.FilterNew();

            filter.Name         = DataHelper.RandomString(50);
            filter.FilterQuery  = DataHelper.RandomString(1000);
            filter.SourceTypeId = (int)SourceType.User;

            return(filter);
        }
コード例 #12
0
        public void Filter_Add()
        {
            var filter = FilterTestHelper.FilterNew();

            Assert.IsTrue(filter.IsValid, "IsValid should be true");

            filter = FilterRepository.FilterSave(filter);

            Assert.IsTrue(filter.FilterId != 0, "FilterId should be a non-zero value");

            FilterRepository.FilterFetch(filter.FilterId);
        }
コード例 #13
0
        protected override void SetupRepository()
        {
            var context = CreateDbContext();

            using (var database = context.LiteDatabase)
            {
                var collection      = database.GetCollection <FilterValues>("Filters");
                var filterValuesOne = new FilterValues
                {
                    Field     = "subtitle",
                    Id        = "10",
                    Libraries = new[] { "1", "2" },
                    Values    = new[] { new LabelValuePair {
                                            Label = "1", Value = "1"
                                        }, new LabelValuePair {
                                            Label = "2", Value = "2"
                                        } }
                };

                var filterValuesTwo = new FilterValues
                {
                    Field     = "subtitle",
                    Id        = "11",
                    Libraries = new[] { "1" },
                    Values    = new[] { new LabelValuePair {
                                            Label = "3", Value = "3"
                                        }, new LabelValuePair {
                                            Label = "4", Value = "4"
                                        } }
                };

                var filterValuesThree = new FilterValues
                {
                    Field     = "container",
                    Id        = "12",
                    Libraries = new [] { "1" },
                    Values    = new[] { new LabelValuePair {
                                            Label = "a", Value = "a"
                                        }, new LabelValuePair {
                                            Label = "b", Value = "b"
                                        } }
                };

                collection.InsertBulk(new[] { filterValuesOne, filterValuesTwo, filterValuesThree });
            }

            _filterRepository = new FilterRepository(context);
        }
コード例 #14
0
        //protected IGeofenceProxy GeofenceProxy;
        //protected IUnifiedProductivityProxy UnifiedProductivityProxy;

        public void SetupDI()
        {
            ServiceProvider = new ServiceCollection()
                              .AddLogging()
                              .AddHttpClient()
                              .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Filter.ExecutorTests.log")))
                              .AddSingleton <IConfigurationStore, GenericConfiguration>()
                              .AddTransient <IRepository <IFilterEvent>, FilterRepository>()
                              .AddTransient <IRepository <IProjectEvent>, ProjectRepository>()
                              .AddTransient <IRepository <IGeofenceEvent>, GeofenceRepository>()
                              .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>()

                              // for serviceDiscovery
                              .AddServiceDiscovery()
                              .AddTransient <IWebRequest, GracefulWebRequest>()
                              .AddMemoryCache()
                              .AddSingleton <IDataCache, InMemoryDataCache>()

                              .AddTransient <IAssetResolverProxy, AssetResolverProxy>()
                              .AddTransient <IWebRequest, GracefulWebRequest>()
                              .AddTransient <IProductivity3dV2ProxyNotification, Productivity3dV2ProxyNotification>()
                              .AddTransient <IProductivity3dV2ProxyCompaction, Productivity3dV2ProxyCompaction>()
                              .AddTransient <IErrorCodesProvider, FilterErrorCodesProvider>()
                              .AddSingleton <IDataCache, InMemoryDataCache>()
                              //.AddSingleton<IGeofenceProxy, GeofenceProxy>()
                              //.AddSingleton<IUnifiedProductivityProxy, UnifiedProductivityProxy>()
                              .AddSingleton <IProjectProxy, ProjectV6Proxy>()
                              .AddSingleton <IFileImportProxy, FileImportV6Proxy>()
                              .BuildServiceProvider();

            ConfigStore                       = ServiceProvider.GetRequiredService <IConfigurationStore>();
            Logger                            = ServiceProvider.GetRequiredService <ILoggerFactory>();
            ServiceExceptionHandler           = ServiceProvider.GetRequiredService <IServiceExceptionHandler>();
            FilterRepo                        = ServiceProvider.GetRequiredService <IRepository <IFilterEvent> >() as FilterRepository;
            ProjectRepo                       = ServiceProvider.GetRequiredService <IRepository <IProjectEvent> >() as ProjectRepository;
            GeofenceRepo                      = ServiceProvider.GetRequiredService <IRepository <IGeofenceEvent> >() as GeofenceRepository;
            ProjectProxy                      = ServiceProvider.GetRequiredService <IProjectProxy>();
            FileImportProxy                   = ServiceProvider.GetRequiredService <IFileImportProxy>();
            Productivity3dV2ProxyNotification = ServiceProvider.GetRequiredService <IProductivity3dV2ProxyNotification>();
            Productivity3dV2ProxyCompaction   = ServiceProvider.GetRequiredService <IProductivity3dV2ProxyCompaction>();
            //GeofenceProxy = ServiceProvider.GetRequiredService<IGeofenceProxy>();
            //UnifiedProductivityProxy = ServiceProvider.GetRequiredService<IUnifiedProductivityProxy>();

            Assert.IsNotNull(ServiceProvider.GetService <ILoggerFactory>());
        }
コード例 #15
0
        public void Filter_Edit()
        {
            var filter = FilterTestHelper.FilterNew();

            var name = filter.Name;

            Assert.IsTrue(filter.IsValid, "IsValid should be true");

            filter = FilterRepository.FilterSave(filter);

            filter = FilterRepository.FilterFetch(filter.FilterId);

            filter.Name = DataHelper.RandomString(20);

            filter = FilterRepository.FilterSave(filter);

            filter = FilterRepository.FilterFetch(filter.FilterId);

            Assert.IsTrue(filter.Name != name, "Name should have different value");
        }
コード例 #16
0
        public void Filter_Delete()
        {
            var filter = FilterTestHelper.FilterNew();

            Assert.IsTrue(filter.IsValid, "IsValid should be true");

            filter = FilterRepository.FilterSave(filter);

            filter = FilterRepository.FilterFetch(filter.FilterId);

            FilterRepository.FilterDelete(filter.FilterId);

            try
            {
                FilterRepository.FilterFetch(filter.FilterId);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.GetBaseException() is InvalidOperationException);
            }
        }
コード例 #17
0
        public void Filter_Create()
        {
            var filter = FilterRepository.FilterNew();

            Assert.IsTrue(filter.IsNew, "IsNew should be true");
            Assert.IsTrue(filter.IsDirty, "IsDirty should be true");
            Assert.IsFalse(filter.IsValid, "IsValid should be false");
            Assert.IsTrue(filter.IsSelfDirty, "IsSelfDirty should be true");
            Assert.IsFalse(filter.IsSelfValid, "IsSelfValid should be false");

            Assert.IsTrue(
                ValidationHelper.ContainsRule(filter, DbType.String, "Name"),
               "Name should be required");

            Assert.IsTrue(
                ValidationHelper.ContainsRule(filter, DbType.String, "FilterQuery"),
               "FilterQuery should be required");

            Assert.IsTrue(
                ValidationHelper.ContainsRule(filter, DbType.Int32, "SourceTypeId"),
               "SourceTypeId should be required");
        }
コード例 #18
0
 public FilterController()
 {
     _filterRepository = new FilterRepository();
     _enumRepositopy   = new EnumValueRepository();
 }