Beispiel #1
0
 public void SetUp()
 {
     componentService = ComponentService.Create();
     componentService
     .UseAutofac()
     .UseCommonComponent();
 }
Beispiel #2
0
 public LocalStorage(ILocalStorageService localStorage, ComponentService componentService)
 {
     this.localStorage = localStorage;
     ComponentService  = componentService;
     MessageAction     = ComponentService.SendMessage;
     Init();
 }
        protected async Task SubmitAsync()
        {
            if (!form.IsValid())
            {
                return;
            }

            var component = form.GetValue <ComponentEditModel>();

            try
            {
                if (IsCreate)
                {
                    await ComponentService.CreateComponentAsync(ProductVersionId, component);
                }
                else
                {
                    await ComponentService.UpdateComponentAsync(ProductVersionId, ComponentId, component);
                }
                _ = CloseAsync();
            }
            catch (OperationException oe)
            {
                Toast(oe.Message);
            }
        }
Beispiel #4
0
        public ActionResult Index(int?page)
        {
            int pageNumber = (page ?? 1);

            IEnumerable <ComponentDTO> componentDTOs = ComponentService
                                                       .GetAll()
                                                       .ToList();
            IEnumerable <ComponentVM> componentVMs = Mapper.Map <IEnumerable <ComponentVM> >(componentDTOs);

            ViewBag.ComponentTypeId = GetComponentTypeIdSelectList();
            ViewBag.ModelName       = GetModelNameSelectList();
            ViewBag.Name            = GetComponentNameSelectList();

            FilterParamsDTO parameters = new FilterParamsDTO
            {
                ComponentTypeId = Request.QueryString["componentTypeId"],
                ModelName       = Request.QueryString["modelName"],
                Name            = Request.QueryString["Name"]
            };

            IEnumerable <ComponentDTO> filteredComponentDTOList = ComponentService.GetFilteredList(parameters).ToList();
            IEnumerable <ComponentVM>  filteredComponentVMList  = Mapper.Map <IEnumerable <ComponentVM> >(filteredComponentDTOList);

            return(View(filteredComponentVMList.ToPagedList(pageNumber, PageSize)));
        }
Beispiel #5
0
 public DefendBarrackRule(ComponentService componentService, AIDto ai, Vector2Service vector2Service, IPairFactory pairFactory, IEventStoreService eventStoreService)
 {
     _componentService = componentService;
     _ai = ai;
     _vector2Service = vector2Service;
     _pairFactory = pairFactory;
     _eventStoreService = eventStoreService;
 }
Beispiel #6
0
        public IndexedDbStorage(IIndexedDbFactory dbFactory, ComponentService componentService)
        {
            DbFactory        = dbFactory;
            ComponentService = componentService;
            MessageAction    = ComponentService.SendMessage;

            Init();
        }
 public LowHealthUnitsWalkTogetherRule(ComponentService componentService, AIDto ai, IRepository<GameEnvironment> gameEnvironmentRepository, IVector2Service vector2Service, IEventStoreService eventStoreService)
 {
     _componentService = componentService;
     _ai = ai;
     _vector2Service = vector2Service;
     _eventStoreService = eventStoreService;
     _gameEnvironment = gameEnvironmentRepository.Get();
 }
Beispiel #8
0
 public LocalService(ILocalStorageService localStorage, NavigationManager navHelper, ComponentService componentService, IJSRuntime jSRuntime, IStorage storage)
 {
     LocalStorage     = localStorage;
     NavHelper        = navHelper;
     ComponentService = componentService;
     JSRuntime        = jSRuntime;
     Storage          = storage;
     Init();
 }
Beispiel #9
0
 public BuildBarrackRule(ComponentService componentService, AIDto ai, IOrientationService orientationService, IVector2Service vector2Service, IRepository<GameEnvironment> gameEnvironmentRepository, IEventStoreService eventStoreService)
 {
     _componentService = componentService;
     _ai = ai;
     _orientationService = orientationService;
     _vector2Service = vector2Service;
     _eventStoreService = eventStoreService;
     _gameEnvironment = gameEnvironmentRepository.Get();
 }
 public ArtificialIntelligenceJfi(IEventAgent eventAgent, string id)
     : base(eventAgent, id)
 {
     _app = new App(new AIDto {EventAgent = eventAgent, Id = id, AI = this});
     _eventProcessor = _app.Kernel.Get<IEventProcessor>();
     _strategyProcessor = _app.Kernel.Get<ICHProcessor<Strategy>>();
     _strategieFactory = _app.Kernel.Get<IStrategieFactory>();
     _componentService = _app.Kernel.Get<ComponentService>();
 }
    private static void Main(string[] args)
    {
        var service = new ComponentService();

        service.Register(Assembly.GetExecutingAssembly());
        var dbComponent = new DbComponent();

        service.Invoke(dbComponent);
    }
Beispiel #12
0
 public KompService(
     ComponentService componentService,
     ConfigService configService,
     TemplateService templateService,
     AddOnService addOnService)
 {
     _componentService = componentService;
     _configService    = configService;
     _templateService  = templateService;
     _addOnService     = addOnService;
 }
Beispiel #13
0
        public ActionResult FindComponents(string value, string type)
        {
            value = value.Trim().ToLower();

            List <ComponentDTO> componentDTOs = ComponentService
                                                .GetComponentsBy(type, value)
                                                .ToList();

            List <ComponentVM> componentVMs = Mapper.Map <IEnumerable <ComponentVM> >(componentDTOs).ToList();

            return(PartialView(componentVMs));
        }
        internal IRenderableComponent ViewComplexLocatorBuilder(Template viewTemplate)
        {
            if (viewTemplate == Template.None)
            {
                return(null);
            }

            var componentInfo = ViewTemplateProvider.GetTemplate(viewTemplate);
            var component     = ComponentService.GetComponent(componentInfo.fullTypeName);

            return(component);
        }
Beispiel #15
0
        protected void Refresh()
        {
            if (!ClanService.RetrieveDiplomacies(out List <ClanDiplomacyView> diplomacies, out string message, out HttpStatusCode code))
            {
                NotificationService.ShowError(message, "Failed to load diplomacies!");
                if (code == HttpStatusCode.Unauthorized)
                {
                    ComponentService.Show(new Login());
                }
                else
                {
                    ComponentService.Show(new CriticalError());
                }
            }
            else
            {
                Diplomacies = diplomacies;
            }

            if (!ClanService.RetrievePendingDiplomacies(out List <ClanDiplomacyView> pending, out message, out code))
            {
                NotificationService.ShowError(message, "Failed to load pending diplomacies!");
                if (code == HttpStatusCode.Unauthorized)
                {
                    ComponentService.Show(new Login());
                }
                else
                {
                    ComponentService.Show(new CriticalError());
                }
            }
            else
            {
                Pending = pending;
            }

            if (!ClanService.RetrieveSelf(out AccountClanView account, out message, out code))
            {
                NotificationService.ShowError(message, "Failed to load self!");
                if (code == HttpStatusCode.Unauthorized)
                {
                    ComponentService.Show(new Login());
                }
                else
                {
                    ComponentService.Show(new CriticalError());
                }
            }
            else
            {
                Current = account;
            }
        }
Beispiel #16
0
        protected void Query()
        {
            if (!form.IsValid())
            {
                return;
            }

            Components = ComponentService.GetComponents(productId, SelectedVersionId.Value);

            EmptyMessage = null;
            table.MarkAsRequireRender();
            RequireRender = true;
        }
        public BllSelectedComponent MapToBll(DalSelectedComponent entity)
        {
            ComponentService componentService = new ComponentService(uow);
            var bllComponent = entity.Component_id != null?componentService.Get((int)entity.Component_id) : null;

            BllSelectedComponent bllEntity = new BllSelectedComponent
            {
                Id        = entity.Id,
                Component = bllComponent
            };

            return(bllEntity);
        }
        protected override void OnInitialized()
        {
            if (Context == null)
            {
                throw new ContextNullException(
                          "Error! Context cannot be null! Make sure to render UI after context is set!");
            }

            ComponentService.LoadComponents(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            TrySetLayout();
            Wrapper = new ComplexElement(Context, IgnoredFields, PictureFields, Order, Labels);
            base.OnInitialized();
        }
Beispiel #19
0
        public ActionResult Create([Bind(Include = "ComponentTypeId,ModelName,Name,Description,Price,InventNumber,Supplier")] ComponentVM componentVM)
        {
            if (ModelState.IsValid)
            {
                ComponentDTO componentDTO = Mapper.Map <ComponentDTO>(componentVM);
                ComponentService.Add(componentDTO);

                return(RedirectToAction("Index"));
            }
            ViewBag.ComponentTypeId = GetComponentTypeIdSelectList();

            return(View(componentVM));
        }
Beispiel #20
0
        public async Task TestSorting()
        {
            ListComponentViewModel listComponentViewModel = new ListComponentViewModel()
            {
                SortDir   = SortDirConstants.SORT_DIR_DESC,
                SortField = SortFieldConstants.SORT_FIELD_ID
            };

            IComponentService service = new ComponentService();

            var result = (await service.ListComponents(listComponentViewModel)).Components.First();

            Assert.Equal(99, result.Id);
        }
        internal IRenderableComponent ViewGenericBaseLocatorBuilder(PresentationType presentationType, Type typeArg, bool isEnum)
        {
            string buildedComponentName;

            if (isEnum)
            {
                buildedComponentName = $"EnumeratorContainer{presentationType}View`1";
            }
            else
            {
                buildedComponentName = $"ComponentBaseType{presentationType}View`1";
            }
            return(ComponentService.GetGenericComponent(buildedComponentName, typeArg));
        }
Beispiel #22
0
        protected override void OnInit()
        {
            if (!StateService.AccountOverview.Retrieve(out AccountOverview account, out string message, out _))
            {
                NotificationService.ShowError(message, "Failed to load account!");
                ComponentService.Show(new Login());
            }
            else
            {
                Account = account;
            }

            StateService.OnAccountOverviewRefreshed += OnAccountOverviewRefreshed;
        }
Beispiel #23
0
        public async Task TestSortingByType()
        {
            ListComponentViewModel listComponentViewModel = new ListComponentViewModel()
            {
                SortDir   = SortDirConstants.SORT_DIR_ASC,
                SortField = SortFieldConstants.SORT_FIELD_TYPE,
            };

            IComponentService service = new ComponentService();

            var result = (await service.ListComponents(listComponentViewModel)).Components.First();

            Assert.Equal("Audio", result.Type);
        }
Beispiel #24
0
        public async Task TestPageSize()
        {
            ListComponentViewModel listComponentViewModel = new ListComponentViewModel()
            {
                PageSize   = 5,
                PageNumber = 0
            };

            IComponentService service = new ComponentService();

            var result = await service.ListComponents(listComponentViewModel);

            Assert.Equal(listComponentViewModel.PageSize, result.Components.Count());
        }
        public ComponentTests()
        {
            DatabaseContext dbContext = CreateEmptyDatabase();

            this.locationRepository  = new LocationRepository(dbContext);
            this.componentRepository = new ComponentRepository(dbContext);
            this.exerciseRepository  = new ExerciseRepository(dbContext);

            this.azureService     = new AzureServiceMock();
            this.locationService  = new LocationService(this.locationRepository, this.azureService);
            this.componentService = new ComponentService(this.componentRepository, this.locationRepository, this.azureService);
            this.exerciseService  = new ExerciseService(this.exerciseRepository, this.componentRepository);

            this.componentController = new ComponentController(this.componentService, this.exerciseService, this.locationService);
        }
 protected void Refresh()
 {
     if (!ClanService.RetrieveClans(Query, (Page - 1) * 25, 25,
                                    out EnumerableResultView <ClanView> clans, out string message, out HttpStatusCode code))
     {
         NotificationService.ShowError(message, "Failed to load clans!");
         if (code == HttpStatusCode.Unauthorized)
         {
             ComponentService.Show(new Login());
         }
         else
         {
             ComponentService.Show(new CriticalError());
         }
     }
 public ArtificialIntelligenceNku(IEventAgent eventAgent, string id)
     : base(eventAgent, id)
 {
     ComponentService = new ComponentService();
     EventHandler = new EventHandler(this, ComponentService);
     EventHandler.HeadquarterCompleted += EventHandler_HeadquarterCompleted;
     EventHandler.MovementCompleted += EventHandler_MovementCompleted;
     EventHandler.TargetPositionBlocked += EventHandler_TargetPositionBlocked;
     EventHandler.ComponentSpotted += EventHandlerOnComponentSpotted;
     EventHandler.ProductionCompleted += EventHandler_ProductionCompleted;
     EventHandler.ComponentDestroyed += EventHandler_ComponentDestroyed;
     EventHandler.ComponentLost += EventHandler_ComponentLost;
     BuildOrder = new RushBuildOrder(EventHandler);
     BuildOrder.Create();
 }
Beispiel #28
0
        public ActionResult Delete(Guid id)
        {
            try
            {
                ComponentService.Delete(id);
            }
            catch (NotFoundException)
            {
                return(HttpNotFound());
            }
            catch (HasRelationsException)
            {
                return(Content("Удаление невозможно."));
            }

            return(RedirectToAction("Index"));
        }
Beispiel #29
0
        protected void Login()
        {
            Loading = true;
            StateHasChanged();

            if (!AccountService.Login(Username, Password, out string message))
            {
                NotificationService.ShowError(message, "Login failed!");
            }
            else
            {
                ComponentService.Show(new Pages.Dashboard.Dashboard());
                NotificationService.ShowSuccess("redirecting ...", "Login succeded!");
            }

            Reset();
        }
 public void ToggleOpen(object v)
 {
     IsOpen = !IsOpen;
     UpdateDataContext();
     if (IsOpen)
     {
         if (!IsDisabledAutoClose)
         {
             ComponentService.AddAction("openblock", () => { Close(); });
         }
         Open();
     }
     else
     {
         Close();
     }
 }
 internal void TrySetLayout()
 {
     if (Layout != LayoutTypes.Default)
     {
         var layoutInfo = LayoutProvider.GetLayoutInfo(Layout);
         LayoutComponentType = ComponentService.GetLayoutComponentType(layoutInfo.fullTypeName);
     }
     else
     {
         var layoutAttribute = GetAttribute <ContainerAttribute>(Context);
         if (layoutAttribute != null)
         {
             var layoutInfo = LayoutProvider.GetLayoutInfo(layoutAttribute.GetLayout());
             LayoutComponentType = ComponentService.GetLayoutComponentType(layoutInfo.fullTypeName);
         }
     }
 }
Beispiel #32
0
        public ActionResult Details(Guid?id)
        {
            try
            {
                ComponentDTO componentDTO = ComponentService.Get((Guid)id);
                ComponentVM  componentVM  = Mapper.Map <ComponentVM>(componentDTO);

                return(View(componentVM));
            }
            catch (ArgumentNullException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            catch (NotFoundException)
            {
                return(HttpNotFound());
            }
        }
Beispiel #33
0
 // This method gets called by the runtime. Use this method to add services to the container.
 // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddSingleton <IComponentService>(_ =>
     {
         var service = new ComponentService();
         service.LoadComponents(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
         return(service);
     });
     services.AddDbContext <ApplicationDbContext>(options =>
                                                  options.UseSqlite(
                                                      Configuration.GetConnectionString("DefaultConnection")));
     services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
     .AddEntityFrameworkStores <ApplicationDbContext>();
     services.AddRazorPages();
     services.AddServerSideBlazor();
     services
     .AddScoped <AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider <IdentityUser>
                 >();
 }
Beispiel #34
0
        public ActionResult Edit(Guid?id)
        {
            try
            {
                ComponentDTO componentDTO = ComponentService.Get(id);
                ComponentVM  componentVM  = Mapper.Map <ComponentVM>(componentDTO);
                ViewBag.ComponentTypeId = GetComponentTypeIdSelectList(componentVM.ComponentTypeId);

                return(View(componentVM));
            }
            catch (ArgumentNullException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            catch (NotFoundException)
            {
                return(HttpNotFound());
            }
        }
Beispiel #35
0
        public void accountControll_ShowAdminWindow(string arg1, IEnumerable <UserModel> arg2, Window arg3)
        {
            IAdminView adminView = new AdminWindow();

            adminView.EnteredUser = arg1;
            adminView.AllLeads    = arg2;

            IGlobalRepo <ProjectManager.Business.Project> repoProject = new ProjectManager.DataAccess.GlobalRepo <ProjectManager.Business.Project>();
            IProjectService projectService = new ProjectService(repoProject);

            Controllers.ProjectController projControll = new Controllers.ProjectController(projectService, adminView);

            IGlobalRepo <ProjectManager.Business.Component> repoComponent = new ProjectManager.DataAccess.GlobalRepo <ProjectManager.Business.Component>();
            IComponentService componentService = new ComponentService(repoComponent);

            Controllers.ComponentController compoControll = new Controllers.ComponentController(componentService, adminView);

            (adminView as Window).Show();
            arg3.Close();
        }
Beispiel #36
0
        public void ComponentService_GetAsync_ReturnsComponents()
        {
            //Arrange
            var mockDbContextScopeFac = new Mock<IDbContextScopeFactory>();
            var mockDbContextScope = new Mock<IDbContextReadOnlyScope>();
            var mockEfDbContext = new Mock<EFDbContext>();
            mockDbContextScopeFac.Setup(x => x.CreateReadOnly(DbContextScopeOption.JoinExisting)).Returns(mockDbContextScope.Object);
            mockDbContextScope.Setup(x => x.DbContexts.Get<EFDbContext>()).Returns(mockEfDbContext.Object);

            var projectPerson1 = new Person { Id = "dummyUserId1", FirstName = "Firs1", LastName = "Last1" };

            var project1 = new Project { Id = "dummyId1", ProjectName = "Project1", ProjectAltName = "ProjectAlt1", IsActive_bl = true, ProjectCode = "CODE1", 
                ProjectPersons = new List<Person> { projectPerson1 } };

            var dbEntry1 = new Component { Id = "dummyEntryId1", CompName = "Comp1", CompAltName = "CompAlt1", IsActive_bl = false, Comments = "DummyComments1",
                ProgramAddress = "DummyInfo1", AssignedToProject = project1 };
            var dbEntry2 = new Component { Id = "dummyEntryId2", CompName = "Comp2", CompAltName = "CompAlt2", IsActive_bl = true, Comments = "DummyComments2",
                ProgramAddress = "DummyInfo2", AssignedToProject = project1 };
            var dbEntries = (new List<Component> { dbEntry1, dbEntry2 }).AsQueryable();

            var mockDbSet = new Mock<DbSet<Component>>();
            mockDbSet.As<IDbAsyncEnumerable<Component>>().Setup(m => m.GetAsyncEnumerator()).Returns(new MockDbAsyncEnumerator<Component>(dbEntries.GetEnumerator())); 
            mockDbSet.As<IQueryable<Component>>().Setup(m => m.Provider).Returns(new MockDbAsyncQueryProvider<Component>(dbEntries.Provider));
            mockDbSet.As<IQueryable<Component>>().Setup(m => m.Expression).Returns(dbEntries.Expression);
            mockDbSet.As<IQueryable<Component>>().Setup(m => m.ElementType).Returns(dbEntries.ElementType);
            mockDbSet.As<IQueryable<Component>>().Setup(m => m.GetEnumerator()).Returns(dbEntries.GetEnumerator());
            mockDbSet.Setup(x => x.Include(It.IsAny<string>())).Returns(mockDbSet.Object);
            
            mockEfDbContext.Setup(x => x.Components).Returns(mockDbSet.Object);

            var componentService = new ComponentService(mockDbContextScopeFac.Object, projectPerson1.Id);

            //Act
            var resultComponents = componentService.GetAsync(new[] { "dummyEntryId1", "dummyEntryId2" }).Result;
            
            //Assert
            Assert.IsTrue(resultComponents.Count == 1);
            Assert.IsTrue(resultComponents[0].CompAltName.Contains("CompAlt2"));
        }
        public TestController()
        {
            Log.Instance = new TestLogger();

            // Create root services first.
            var systemInformationService = new SystemInformationService();
            var apiService = new ApiService();
            ApiService = new ApiService();
            BackupService = new BackupService();
            StorageService = new StorageService();
            TimerService = new TestTimerService();
            DaylightService = new TestDaylightService();
            DateTimeService = new TestDateTimeService();

            SettingsService = new SettingsService(BackupService, StorageService);
            ResourceService = new ResourceService(BackupService, StorageService, SettingsService);
            SchedulerService = new SchedulerService(TimerService, DateTimeService);
            NotificationService = new NotificationService(DateTimeService, ApiService, SchedulerService, SettingsService, StorageService, ResourceService);
            SystemEventsService = new SystemEventsService(this, NotificationService, ResourceService);
            AutomationService = new AutomationService(SystemEventsService, systemInformationService, apiService);
            ComponentService = new ComponentService(SystemEventsService, systemInformationService, apiService, SettingsService);
            AreaService = new AreaService(ComponentService, AutomationService, SystemEventsService, systemInformationService, apiService, SettingsService);
        }
Beispiel #38
0
 public OrientationService(ComponentService componentService, IRepository<GameEnvironment> gameEnvironmentRepository, IVector2Service vector2Service)
 {
     _componentService = componentService;
     _vector2Service = vector2Service;
     _gameEnvironment = gameEnvironmentRepository.Get();
 }
Beispiel #39
0
 public BuildInfanteryRule(ComponentService componentService, AIDto ai, IEventStoreService eventStoreService)
 {
     _componentService = componentService;
     _ai = ai;
     _eventStoreService = eventStoreService;
 }
 public GetEnemysAroundUnitStrategy(ComponentService componentService, Vector2Service vector2Service, IPairFactory pairFactory)
 {
     _componentService = componentService;
     _vector2Service = vector2Service;
     _pairFactory = pairFactory;
 }
 public AttackingSituationRule(IOut @out, ComponentService componentService)
 {
     _out = @out;
     _componentService = componentService;
 }
Beispiel #42
0
 //Constructors---------------------------------------------------------------------------------------------------------//
 public ComponentSrvController(ComponentService componentService)
 {
     this.componentService = componentService;
 }
Beispiel #43
0
 public StrategieFactory(ComponentService componentService, ITryGetResultHandlingProcessor<UnitBase, Situation> situationHandlingProcessor, ICHProcessor<UnitStratey> unitStrategyProcessor)
 {
     _componentService = componentService;
     _situationHandlingProcessor = situationHandlingProcessor;
     _unitStrategyProcessor = unitStrategyProcessor;
 }