示例#1
0
        /// <summary>
        /// Updates the sitemap according to the given structure. Please note
        /// that only the first page that has changed position is moved.
        /// </summary>
        /// <param name="structure">The page structure</param>
        public async Task <bool> MovePages(StructureModel structure)
        {
            var pos = GetPosition(structure.Id, structure.Items);

            if (pos != null)
            {
                var page = await _api.Pages.GetByIdAsync <PageInfo>(structure.Id);

                if (page != null)
                {
                    await _api.Pages.MoveAsync(page, pos.Item1, pos.Item2);

                    return(true);
                }
            }
            return(false);
        }
示例#2
0
        public OStructureDetailViewModel(int?structureId, bool editMode /*, int? parentStructureId*/)
        {
            this.StructureId       = structureId;
            this.ParentStructureId = structureId;// parentStructureId;

            EditMode = editMode;
            if (EditMode && this.StructureId.HasValue)
            {
                //load
                StructureModel structureModel = StructureService.GetStructureModel(this.StructureId.Value);

                this.StructureName        = structureModel.Name;
                this.StructureDescription = structureModel.Description;
                this.SelectedPerson       = StructureService.GetPerson(structureModel.PersonId);
            }

            SaveCommand = new RelayCommand <System.Windows.Window> (SaveAction);
        }
示例#3
0
        public async Task <IActionResult> GetDatabaseInfos([FromBody] Req <SqlSearchDto> request)
        {
            var list = await _sqlOnlineApplication.GetTableShowColumns(AdminDto.Id, request.Data.SqlConnId, request.Data.Database);

            if (list != null)
            {
                Dictionary <string, StructureModel> dict = new Dictionary <string, StructureModel>();
                List <StructureModel> models             = new List <StructureModel>();
                foreach (var item in list)
                {
                    StructureModel model;
                    var            key = item.SchemaName + "." + item.Name;
                    if (dict.TryGetValue(key, out model) == false)
                    {
                        model = new StructureModel();
                        if (string.IsNullOrEmpty(item.SchemaName) || item.SchemaName == "dbo" || item.SchemaName == "public")
                        {
                            model.Name = item.Name;
                        }
                        else
                        {
                            model.Name = key;
                        }
                        model.Comment = item.Comment;
                        if (item.TableType.Trim() == "t" || item.TableType == "BASE TABLE" ||
                            item.TableType.Equals("table", StringComparison.OrdinalIgnoreCase) ||
                            item.TableType.Trim().Equals("u", StringComparison.OrdinalIgnoreCase)
                            )
                        {
                            model.Type = "t";
                        }
                        else
                        {
                            model.Type = "v";
                        }
                        dict[key] = model;
                        models.Add(model);
                    }
                    model.Items.Add(new StructureItemModel(item));
                }
                return(Success(models, request.PasswordString));
            }
            return(Error());
        }
示例#4
0
        private void SaveAction(System.Windows.Window window)
        {
            if (EditMode)
            {
                StructureModel structureModel = StructureService.GetStructureModel(this.StructureId.Value);
                structureModel.Name        = this.StructureName;
                structureModel.Description = this.StructureDescription;
                if (SelectedPerson != null)
                {
                    structureModel.PersonId = this.SelectedPerson.Id;
                }

                structureModel.UpdateModel();
            }
            else
            {
                var structureModel = new StructureModel()
                {
                    Id          = StructureService.GetNewStructureId(),
                    Name        = this.StructureName,
                    Description = this.StructureDescription,

                    PersonId = this.SelectedPerson?.Id,
                };

                if (ParentStructureId.HasValue)
                {
                    var parentStructureModel = StructureService.GetStructureModel(this.ParentStructureId.Value);
                    parentStructureModel.SubStructures.Add(structureModel);
                }
                else
                {
                    GlobalInstance.Instance.Model.StructureModel.RootStructure = new ObservableCollection <StructureModel>();

                    GlobalInstance.Instance.Model.StructureModel.RootStructure.Add(structureModel);
                    structureModel.UpdateModel();
                }

                structureModel.UpdateModel();
            }

            CloseWindow(window);
        }
示例#5
0
        public void Apply_Structure_ShouldMapAsStructure()
        {
            // Arrange
            var          structHandle = (IntPtr)44553;
            RfcErrorInfo errorInfo;

            _interopMock.Setup(x => x.GetStructure(It.IsAny <IntPtr>(), It.IsAny <string>(), out structHandle, out errorInfo));
            var model = new StructureModel {
                Structure = new Structure {
                    Value = 224
                }
            };

            // Act
            InputMapper.Apply(_interopMock.Object, DataHandle, model);

            // Assert
            _interopMock.Verify(x => x.GetStructure(DataHandle, "STRUCTURE", out structHandle, out errorInfo), Times.Once);
            _interopMock.Verify(x => x.SetInt(structHandle, "VALUE", 224, out errorInfo), Times.Once);
        }
示例#6
0
        public async Task <PageListModel> Move([FromBody] StructureModel model)
        {
            if (await _service.MovePages(model))
            {
                var list = await List();

                list.Status = new StatusMessage
                {
                    Type = StatusMessage.Success,
                    Body = _localizer.Page["The sitemap was successfully updated"]
                };
                return(list);
            }
            return(new PageListModel {
                Status = new StatusMessage
                {
                    Type = StatusMessage.Warning,
                    Body = _localizer.Page["No pages changed position"]
                }
            });
        }
    internal void PlaceObjectOnTheMap(Vector3Int position, GameObject structurePrefab, CellType type, int width = 1, int height = 1)
    {
        StructureModel structure = CreateANewStructureModel(position, structurePrefab, type);

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < height; z++)
            {
                var newPosition = position + new Vector3Int(x, 0, z);
                placementGrid[newPosition.x, newPosition.z] = type;

                if (structureDictionary.ContainsKey(position))
                {
                    Destroy(structureDictionary[position].gameObject);
                    structureDictionary.Remove(position);
                }
                //structureDictionary.Add(newPosition, structure);
                DestroyNatureAt(newPosition);
            }
        }
    }
        private void TrySpawningAnAgent(StructureModel startStructure, StructureModel endStructure)
        {
            if (startStructure != null && endStructure != null)
            {
                var startPosition = ((INeedingRoad)startStructure).RoadPosition;
                var endPosition   = ((INeedingRoad)endStructure).RoadPosition;

                var startMarkerPosition = placementManager.GetStructureAt(startPosition).GetNearestMarkerTo(startStructure.transform.position);
                var endMarkerPosition   = placementManager.GetStructureAt(endPosition).GetNearestMarkerTo(endStructure.transform.position);

                var agent = Instantiate(GetRandomPedestrian(), startMarkerPosition, Quaternion.identity);
                var path  = placementManager.GetPathBetween(startPosition, endPosition, true);
                if (path.Count > 0)
                {
                    path.Reverse();
                    List <Vector3> agentPath = GetPedestrianPath(path, startMarkerPosition, endMarkerPosition);
                    var            aiAgent   = agent.GetComponent <AiAgent>();
                    aiAgent.Initialize(agentPath);
                }
            }
        }
示例#9
0
    internal void PlaceObjectOnTheMap(Vector3Int position, GameObject structurePrefab, CellType type, int width = 1, int height = 1, int buildingPrefabIndex = -1)
    {
        StructureModel structure = CreateANewStructureModel(position, structurePrefab, type, buildingPrefabIndex);

        var structureNeedingRoad = structure.GetComponent <INeedingRoad>();

        if (structureNeedingRoad != null)
        {
            structureNeedingRoad.RoadPosition = GetNearestRoad(position, width, height).Value;
            Debug.Log("My nearest road position is: " + structureNeedingRoad.RoadPosition);
        }

        structureDictionary.Add(position, structure);
        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < height; z++)
            {
                var newPosition = position + new Vector3Int(x, 0, z);
                placementGrid[newPosition.x, newPosition.z] = type;

                DestroyNatureAt(newPosition);
            }
        }
    }
示例#10
0
        public async Task <IActionResult> GetOutTableInfo(SqlSearchDto dto)
        {
            var list = await _sqlOnlineApplication.GetTableShowColumns(AdminDto.Id, dto.SqlConnId, dto.Database);

            List <StructureModel> models = new List <StructureModel>();

            if (list != null)
            {
                Dictionary <string, StructureModel> dict = new Dictionary <string, StructureModel>();
                foreach (var item in list)
                {
                    StructureModel model;
                    var            key = item.SchemaName + "." + item.Name;
                    if (dict.TryGetValue(key, out model) == false)
                    {
                        model = new StructureModel();
                        if (string.IsNullOrEmpty(item.SchemaName) || item.SchemaName == "dbo" || item.SchemaName == "public")
                        {
                            model.Name = item.Name;
                        }
                        else
                        {
                            model.Name = key;
                        }
                        model.Comment = item.Comment;
                        if (item.TableType.Trim() == "t" || item.TableType == "BASE TABLE" ||
                            item.TableType.Equals("table", StringComparison.OrdinalIgnoreCase) ||
                            item.TableType.Trim().Equals("u", StringComparison.OrdinalIgnoreCase)
                            )
                        {
                            model.Type = "t";
                        }
                        else
                        {
                            model.Type = "v";
                        }
                        dict[key] = model;
                        models.Add(model);
                    }
                    model.Items.Add(new StructureItemModel(item));
                }
            }
            var           filePath      = MyHostingEnvironment.MapWebRootPath("/_/outTableInfo/index.html");
            var           html          = System.IO.File.ReadAllText(filePath);
            StringBuilder stringBuilder = new StringBuilder(html);

            stringBuilder.Replace("[[DatabaseName]]", dto.Database);
            stringBuilder.Replace("[[data]]", Newtonsoft.Json.JsonConvert.SerializeObject(models));

            using (var archive = ZipArchive.Create()) {
                var folderPath = MyHostingEnvironment.MapWebRootPath("/_/outTableInfo/");
                archive.AddEntry("css/dbs.css", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, "css/dbs.css")).OpenRead(), true);
                archive.AddEntry("css/global.css", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, "css/global.css")).OpenRead(), true);
                archive.AddEntry("img/dbs/bg.gif", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, "img/dbs/bg.gif")).OpenRead(), true);
                archive.AddEntry("img/dbs/icon-proc.gif", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, "img/dbs/icon-proc.gif")).OpenRead(), true);
                archive.AddEntry("img/dbs/icon-table.gif", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, "img/dbs/icon-table.gif")).OpenRead(), true);
                archive.AddEntry("img/dbs/icon-view.gif", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, "img/dbs/icon-view.gif")).OpenRead(), true);

                archive.AddEntry(@"js\layer\skin\default\icon.png", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\layer\skin\default\icon.png")).OpenRead(), true);
                archive.AddEntry(@"js\layer\skin\default\icon-ext.png", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\layer\skin\default\icon-ext.png")).OpenRead(), true);

                archive.AddEntry(@"js\layer\skin\default\layer.css", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\layer\skin\default\layer.css")).OpenRead(), true);
                archive.AddEntry(@"js\layer\skin\default\loading-0.gif", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\layer\skin\default\loading-0.gif")).OpenRead(), true);
                archive.AddEntry(@"js\layer\skin\default\loading-1.gif", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\layer\skin\default\loading-1.gif")).OpenRead(), true);
                archive.AddEntry(@"js\layer\skin\default\loading-2.gif", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\layer\skin\default\loading-2.gif")).OpenRead(), true);


                archive.AddEntry(@"js\layer\layer.js", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\layer\layer.js")).OpenRead(), true);
                archive.AddEntry(@"js\clipboard.js", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\clipboard.js")).OpenRead(), true);
                archive.AddEntry(@"js\doT.min.js", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\doT.min.js")).OpenRead(), true);
                archive.AddEntry(@"js\jquery.min.js", new System.IO.FileInfo(System.IO.Path.Combine(folderPath, @"js\jquery.min.js")).OpenRead(), true);

                archive.AddEntry(@"index.html", new System.IO.MemoryStream(Encoding.UTF8.GetBytes(stringBuilder.ToString())), true);

                using (var ms = new System.IO.MemoryStream()) {
                    archive.SaveTo(ms);
                    return(File(ms.ToArray(), "application/zip", dto.Database + "_tableInfo.zip"));
                }
            }
        }
示例#11
0
 public DefensiveMineModel(StructureModel <DefensiveMineStats> s)
     : base(s)
 {
 }
示例#12
0
 internal void DeleteStructure(StructureModel structureModel)
 {
     GlobalInstance.Instance.Model.DeleteStructure(structureModel);
 }
 private void DeleteStructure(StructureModel selectedStructureModel)
 {
     StructureService.DeleteStructure(selectedStructureModel);
 }