예제 #1
0
 public EntitiesControl()
 {
     InitializeComponent();
     Entities    = new EntityTreeViewModel(this);
     DataContext = Entities;
     Entities.Init();
 }
예제 #2
0
 public EntitiesControl()
 {
     InitializeComponent();
     Entities    = new EntityTreeViewModel(this);
     DataContext = Entities;
     Entities.Init();
     SortCombo.ItemsSource = Enum.GetNames(typeof(EntityTreeViewModel.SortEnum));
 }
예제 #3
0
 public async Task <IHttpActionResult> UpdateEntity([FromBody] EntityTreeViewModel entityTreeViewModel)
 {
     return(await HttpActionResultWithErrorHandling(SecurityActions.ManageEntities, async() =>
     {
         var updatedEntity = await _adminRepo.UpdateEntity(entityTreeViewModel);
         addOrDeleteEntityTypes(entityTreeViewModel);
         var updatedViewModel = Mapper.Map <EntityTreeViewModel>(updatedEntity);
         return Json(true);
     }));
 }
예제 #4
0
        public async Task <IHttpActionResult> DeleteEntity([FromBody] EntityTreeViewModel entityTreeViewModel)
        {
            return(await HttpActionResultWithErrorHandling(SecurityActions.ManageEntities, async() =>
            {
                var result = await _adminRepo.DeleteEntity(entityTreeViewModel.EntityId);

                //Don't need add new value for the function
                entityTreeViewModel.EntityTypeProperties = null;
                addOrDeleteEntityTypes(entityTreeViewModel);

                return Json(result);
            }));
        }
예제 #5
0
        public GridViewModel(MyCubeGrid grid, EntityTreeViewModel tree) : base(grid, tree)
        {
            TorchBase.Instance.InvokeBlocking(() =>
            {
                foreach (var block in grid.GetFatBlocks().Where(b => b is IMyTerminalBlock))
                {
                    Blocks.Add(new BlockViewModel((IMyTerminalBlock)block, tree));
                }
            });
            Blocks.Sort(b => b.Block.GetType().AssemblyQualifiedName);

            grid.OnBlockAdded   += Grid_OnBlockAdded;
            grid.OnBlockRemoved += Grid_OnBlockRemoved;
        }
예제 #6
0
        public async Task <IHttpActionResult> AddEntity([FromBody] EntityTreeViewModel entityTreeViewModel)
        {
            return(await HttpActionResultWithErrorHandling(SecurityActions.ManageEntities, async() =>
            {
                var entityType = _adminRepo.GetEntityTypes().FirstOrDefault(t => t.Id == entityTreeViewModel.EntityTypeId);

                if (entityType != null)
                {
                    entityTreeViewModel.EntityTypeName = entityType.Name;
                }

                var entity = new Entity
                {
                    TenantId = Tenant.Id,
                    EntityName = entityTreeViewModel.EntityName,
                    EntityType = entityType
                                 //TODO: EntityProperties
                };
                _adminRepo.AddEntity(entity);

                var entityTree = new EntityTree
                {
                    TenantId = entity.TenantId,
                    Entity = entity,
                    EntityId = entity.Id,
                    ParentId = entityTreeViewModel.ParentId,
                    IsParent = false, //entityTreeViewModel.ParentId == 0,
                    ReportSequence = entityTreeViewModel.Reports.Count == 0 ? null : string.Join(",", entityTreeViewModel.Reports.Select(x => x.Id))
                };
                _adminRepo.AddEntityTree(entityTree);

                entityTreeViewModel.EntityId = entity.Id;
                addOrDeleteEntityTypes(entityTreeViewModel);

                await _adminRepo.SaveAllAsync();

                entityTreeViewModel.EntityId = entity.Id;
                entityTreeViewModel.EntityTypeId = entity.EntityTypeId;
                entityTreeViewModel.Id = entityTree.Id;

                await _adminRepo.UpdateReports(entityTree, entityTreeViewModel.Reports);

                return Json(entityTreeViewModel);
            }));
        }
예제 #7
0
        public void addOrDeleteEntityTypes(EntityTreeViewModel entityTreeViewModel)
        {
            //Remove all maps By tenantId, entitiyId, entityTypePropertyId
            var removeList = _adminRepo.GetEntityProperty()
                             .Where(t => t.TenantId == Tenant.Id &&
                                    t.EntityId == entityTreeViewModel.EntityId);

            _adminRepo.DeleteEntityProperties(removeList.ToList());

            //Add all mpas by add list
            if (entityTreeViewModel.EntityTypeProperties != null && entityTreeViewModel.EntityTypeProperties.Count > 0)
            {
                var mapedEntityProperty =
                    Mapper.Map <IEnumerable <EntityProperty> >(entityTreeViewModel.EntityTypeProperties);
                foreach (var k in mapedEntityProperty)
                {
                    k.TenantId = Tenant.Id;
                    k.EntityId = entityTreeViewModel.EntityId;
                }
                _adminRepo.AddEntityProperties(mapedEntityProperty.ToList());
            }
        }
예제 #8
0
 public GridViewModel(MyCubeGrid grid, EntityTreeViewModel tree) : base(grid, tree)
 {
     //DescriptiveName = $"{grid.DisplayName} ({grid.BlocksCount} blocks)";
     Blocks.Add(_fillerDefinition, new MtObservableSortedDictionary <long, BlockViewModel>());
 }
예제 #9
0
 public GridViewModel(MyCubeGrid grid, EntityTreeViewModel tree) : base(grid, tree)
 {
     DescriptiveName = $"{grid.DisplayName} ({grid.BlocksCount} blocks)";
     Blocks.Add(new BlockViewModel(null, Tree));
 }
예제 #10
0
 public VoxelMapViewModel(MyVoxelBase e, EntityTreeViewModel tree) : base(e, tree)
 {
 }
예제 #11
0
 public CharacterViewModel(MyCharacter character, EntityTreeViewModel tree) : base(character, tree)
 {
     _character = character;
     character.ControllerInfo.ControlAcquired += ControllerInfo_ControlAcquired;
     character.ControllerInfo.ControlReleased += ControllerInfo_ControlAcquired;
 }
예제 #12
0
 public CharacterViewModel(MyCharacter character, EntityTreeViewModel tree) : base(character, tree)
 {
 }
예제 #13
0
 public CharacterViewModel(MyCharacter character, EntityTreeViewModel tree) : base(character, tree)
 {
     character.ControllerInfo.ControlAcquired += (x) => { OnPropertyChanged(nameof(Name)); };
     character.ControllerInfo.ControlReleased += (x) => { OnPropertyChanged(nameof(Name)); };
 }