Example #1
0
        public async Task Post([FromBody] FolderDTO folder)
        {
            FolderEntity entity = FolderConverter.ToEntity(folder);

            this.context.Folders.Add(entity);
            await this.context.SaveChangesAsync();
        }
Example #2
0
        public virtual ActionResult Remove(string[] id)
        {
            var result = new Dictionary <string, object>();
            var rev    = false;
            var mess   = "";

            if (id != null)
            {
                var infos = new List <FolderEntity>();
                foreach (var i in id)
                {
                    var info = new FolderEntity
                    {
                        Id       = i.Convert <long>(),
                        SaveType = SaveType.Remove
                    };
                    infos.Add(info);
                }
                rev  = this.SaveEntities(infos);
                mess = rev ? "" : infos.FirstOrDefault()?.Errors?.FirstOrDefault()?.Message;
            }
            result.Add("Status", rev);
            result.Add("Message", mess);
            return(this.Jsonp(result));
        }
Example #3
0
        private FolderEntity GetFolderEntity()
        {
            var folderEntity = new FolderEntity();

            folderEntity.FolderPath = @"c:\Temp\Log";
            return(folderEntity);
        }
Example #4
0
        internal Folder(Profile profile, ProfileElement parent, FolderEntity folderEntity)
        {
            FolderEntity = folderEntity;
            EntityId     = folderEntity.Id;

            Profile = profile;
            Parent  = parent;
            Name    = folderEntity.Name;
            Order   = folderEntity.Order;

            // TODO: Load conditions

            // Load child folders
            foreach (var childFolder in Profile.ProfileEntity.Folders.Where(f => f.ParentId == EntityId))
            {
                _children.Add(new Folder(profile, this, childFolder));
            }
            // Load child layers
            foreach (var childLayer in Profile.ProfileEntity.Layers.Where(f => f.ParentId == EntityId))
            {
                _children.Add(new Layer(profile, this, childLayer));
            }

            // Ensure order integrity, should be unnecessary but no one is perfect specially me
            _children = _children.OrderBy(c => c.Order).ToList();
            for (var index = 0; index < _children.Count; index++)
            {
                var profileElement = _children[index];
                profileElement.Order = index + 1;
            }
        }
Example #5
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="folder">数据实体</param>
        public static void Delete(FolderEntity folder)
        {
            var cmd = new DataCommand("Folder.Delete");

            cmd.SetParameter(folder);
            cmd.ExecuteNonQuery();
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="folder">数据实体</param>
        public void Delete(int id)
        {
            FolderEntity entity = FolderDA.GetById(id);

            if (entity == null)
            {
                throw new BusinessException("数据不存在无法删除");
            }
            bool hasChildren = this.ListByParentId(entity.Id).Any();

            if (hasChildren)
            {
                throw new BusinessException(string.Format("{0}目录下存在子目录,不允许删除该目录", entity.Name));
            }
            bool hasDocument = DocumentBasisService.ListByFolderId(entity.Id, null).Any();

            if (hasDocument)
            {
                throw new BusinessException(string.Format("{0}目录下存在文件,不允许删除该目录", entity.Name));
            }
            FolderDA.Delete(new FolderEntity()
            {
                Id = entity.Id, IsDeleted = DeletedEnums.Deleted
            });
        }
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="folder">数据实体</param>
        public void Update(FolderVO folder)
        {
            // check
            FolderEntity entity = folder.ToFolderEntity();

            this.CheckEntity(entity);
            FolderDA.Update(entity);
        }
Example #8
0
        public async Task <FolderEntity> SubmitFolder(FolderEntity folder)
        {
            await cont.AddAsync(folder);

            await cont.SaveChangesAsync();

            return(folder);
        }
Example #9
0
 /// <summary>
 /// Gets an asset folder for the product.
 /// </summary>
 /// <param name="productCode">The product code.</param>
 /// <returns>An asset folder.</returns>
 private FolderEntity ProductFolder(string productCode)
 {
     if (_productFolder == null)
     {
         _productFolder = GetOrCreateFolderEntity(PackageFolder, productCode);
     }
     return(_productFolder);
 }
Example #10
0
        public static FolderEntity ToEntity(FolderDTO dto)
        {
            FolderEntity entity = new FolderEntity();

            entity.Name = dto.Name;

            return(entity);
        }
Example #11
0
        public static FolderDTO ToDTO(FolderEntity entity)
        {
            FolderDTO dto = new FolderDTO();

            dto.Name = entity.Name;

            return(dto);
        }
 public static FolderModel ToModel(this FolderEntity folder)
 {
     return(new()
     {
         Id = folder.Id.ToItemId(),
         Name = folder.Name,
         DeleteDate = folder.DeleteDate,
     });
 }
Example #13
0
        public Folder(Profile profile, ProfileElement parent, string name)
        {
            FolderEntity = new FolderEntity();
            EntityId     = Guid.NewGuid();

            Profile = profile;
            Parent  = parent;
            Name    = name;
        }
Example #14
0
        public async Task <FolderEntity> UpdateFolder(FolderEntity ent)
        {
            FolderEntity folder = cont.Folders.Single(e => e.Id == ent.Id);

            folder.Label       = ent.Label;
            folder.Description = ent.Description;
            await cont.SaveChangesAsync();

            return(ent);
        }
 /// <summary>
 /// 检查实体
 /// </summary>
 /// <param name="folderEntity">实体校验</param>
 private void CheckEntity(FolderEntity folderEntity)
 {
     if (string.IsNullOrEmpty(folderEntity.Name))
     {
         throw new BusinessException("请输入目录名称");
     }
     else if (folderEntity.Name.Length > 255)
     {
         throw new BusinessException("目录名称最大长度255");
     }
 }
Example #16
0
        public async Task <FolderEntity> Get(string id)
        {
            FolderEntity entity = await this.context.Folders.FirstOrDefaultAsync(folder => folder.Id.Equals(id));

            if (entity != null)
            {
                await this.context.Entry(entity).Collection(e => e.Games).LoadAsync();
            }

            return(entity);
        }
Example #17
0
        public async Task Delete(string id)
        {
            FolderEntity folder = await this.context.Folders.FirstAsync(f => f.Id.Equals(id));

            await this.context.Entry(folder).Collection(e => e.Games).LoadAsync();

            this.context.Games.RemoveRange(folder.Games);

            this.context.Folders.Remove(folder);
            await this.context.SaveChangesAsync();
        }
Example #18
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Folder" /> class and adds itself to the child collection of the provided
        ///     <paramref name="parent" />
        /// </summary>
        /// <param name="parent">The parent of the folder</param>
        /// <param name="name">The name of the folder</param>
        public Folder(ProfileElement parent, string name) : base(parent.Profile)
        {
            FolderEntity = new FolderEntity();
            EntityId     = Guid.NewGuid();

            Parent  = parent ?? throw new ArgumentNullException(nameof(parent));
            Profile = Parent.Profile;
            Name    = name;

            Parent.AddChild(this);
        }
Example #19
0
        public async Task <IActionResult> PostFolder(FolderEntity folder)
        {
            try
            {
                FolderEntity res = await serv.SubmitFolder(folder);

                return(Ok(res));
            }
            catch (Exception E)
            {
                return(StatusCode(500, $"Post service error \n{E.StackTrace}"));
            }
        }
Example #20
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Folder" /> class based on the provided folder entity
        /// </summary>
        /// <param name="profile">The profile the folder belongs to</param>
        /// <param name="parent">The parent of the folder</param>
        /// <param name="folderEntity">The entity of the folder</param>
        public Folder(Profile profile, ProfileElement parent, FolderEntity folderEntity) : base(parent.Profile)
        {
            FolderEntity = folderEntity;
            EntityId     = folderEntity.Id;

            Profile = profile;
            Parent  = parent;
            Name    = folderEntity.Name;
            Enabled = folderEntity.Enabled;
            Order   = folderEntity.Order;

            Load();
        }
Example #21
0
        public async Task <IActionResult> UpdateFolder(FolderEntity folder)
        {
            try
            {
                FolderEntity ent = await serv.UpdateFolder(folder);

                return(Ok(ent));
            }
            catch (Exception E)
            {
                return(StatusCode(500, $"Update method failed for Folder\n {E}"));
            }
        }
Example #22
0
    void deleteFolderHelper(FolderEntity folder)
    {
        foreach (KeyValuePair <string, FolderEntity> Folder in folder.FolderList)
        {
            FolderEntity fold = Folder.Value;
            deleteFolderHelper(fold);
        }

        foreach (KeyValuePair <string, ProjectEntity> proj in folder.ProjectList)
        {
            ProjectEntity project = proj.Value;
            projectDeleteHelperForFolder(project);
        }
    }
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="folder">数据实体</param>
        public void Insert(FolderVO folder)
        {
            FolderEntity entity = folder.ToFolderEntity();

            this.CheckEntity(entity);
            if (!entity.ParentId.HasValue)
            {
                throw new BusinessException("父节点Id不允许为空");
            }
            else if (CheckParentIsDeleted(entity.ParentId.Value))
            {
                throw new BusinessException("父节点已被删除,请重新刷新页面进行操作");
            }
            FolderDA.Insert(entity);
        }
Example #24
0
    string getParentName(FolderEntity parent)
    {
        string source;

        if (parent.parent != null)
        {
            source = getParentName(parent.parent);
            source = source + "/" + parent.name;
        }
        else
        {
            source = parent.name;
        }
        return(source);
    }
Example #25
0
        public async Task <FolderEntity[]> DeleteFolder(int id)
        {
            FolderEntity fold = cont.Folders.Single(e => e.Id == id);

            if (fold.Bookmarks != null)
            {
                cont.Bookmarks.RemoveRange(fold.Bookmarks);
            }
            cont.Folders.Remove(fold);
            cont.SaveChanges();
            FolderEntity[] folders = cont.Folders.ToList().ToArray();
            await cont.SaveChangesAsync();

            return(folders);
        }
    public void selectTag()
    {
        if (proj.parent == null)
        {
            Dropdown     drop      = Dropdown.GetComponent <Dropdown>();
            int          index     = drop.value;
            string       selfolder = tagnames[index];
            FolderEntity newfolder = Homepage.FolderList[selfolder];
            Homepage.ProjectList.Remove(proj.name);
            newfolder.ProjectList.Add(proj.name, proj);
            proj.parent = newfolder;
        }
        else
        {
            Dropdown drop      = Dropdown.GetComponent <Dropdown>();
            int      index     = drop.value;
            string   selfolder = tagnames[index];
            if (selfolder == "back")
            {
                if (proj.parent.parent == null)
                {
                    proj.parent.ProjectList.Remove(proj.name);
                    Homepage.ProjectList.Add(proj.name, proj);
                    proj.parent = null;
                }
                else
                {
                    FolderEntity newfolder = proj.parent.parent;
                    proj.parent.ProjectList.Remove(proj.name);
                    newfolder.ProjectList.Add(proj.name, proj);
                    proj.parent = newfolder;
                }
            }
            else
            {
                FolderEntity newfolder = proj.parent.FolderList[selfolder];
                proj.parent.ProjectList.Remove(proj.name);
                newfolder.ProjectList.Add(proj.name, proj);
                proj.parent = newfolder;
            }
        }

        addTag.BoolRedraw     = true;
        Homepage.BoolRedraw   = true;
        TagPage.BoolRedraw    = true;
        FolderPage.BoolRedraw = true;
        Destroy(gameObject);
    }
Example #27
0
        /// <summary>
        ///     Creates a deep copy of the folder
        /// </summary>
        /// <returns>The newly created copy</returns>
        public Folder CreateCopy()
        {
            if (Parent == null)
            {
                throw new ArtemisCoreException("Cannot create a copy of a folder without a parent");
            }

            FolderEntity entityCopy = CoreJson.DeserializeObject <FolderEntity>(CoreJson.SerializeObject(FolderEntity, true), true) !;

            entityCopy.Id    = Guid.NewGuid();
            entityCopy.Name += " - Copy";

            // TODO Children

            return(new Folder(Profile, Parent, entityCopy));
        }
Example #28
0
        internal Folder(Profile profile, ProfileElement parent, FolderEntity folderEntity)
        {
            FolderEntity = folderEntity;

            EntityId = folderEntity.Id;

            Profile = profile;
            Parent  = parent;
            Name    = folderEntity.Name;
            Enabled = folderEntity.Enabled;
            Order   = folderEntity.Order;

            _layerEffects           = new List <BaseLayerEffect>();
            _expandedPropertyGroups = new List <string>();
            Load();
        }
Example #29
0
        private void LoadConfig()
        {
            if (fileWatcher != null)
            {
                fileWatcher.Dispose();
                fileWatcher = null;
            }

            treeView1.Nodes.Clear();
            var applicationNode = treeView1.Nodes.Add("Structurizr");

            using (var sr = new StreamReader(configPath))
            {
                var configObj = JsonConvert.DeserializeObject <CoreFile>(sr.ReadToEnd());

                FolderEntity newobj = null;

                foreach (var root in configObj.Roots)
                {
                    switch (root.Type)
                    {
                    case "Project":
                        newobj = new Project(new DirectoryInfo(root.Path));

                        var projectNode = applicationNode.Nodes.Add(root.Path);

                        foreach (var chapter in newobj.Children)
                        {
                            var chapterNode = projectNode.Nodes.Add(chapter.Path.Name);

                            foreach (var section in chapter.Children)
                            {
                                var sectionNode = chapterNode.Nodes.Add(section.Path.Name);
                            }
                        }

                        break;
                    }

                    CreateFileWatcher(root.Path);

                    activeRoots.Add(newobj);
                }
            }

            applicationNode.ExpandAll();
        }
        private async Task UpdateIndexes(FolderEntity folder)
        {
            var childFolders = await _fileSystemRepository.GetChildFolders(folder.Id);

            for (var i = 0; i < childFolders.Length; i++)
            {
                childFolders[i].Index = $"{folder.Index}{i + 1}";
                await UpdateIndexes(childFolders[i]);
            }

            var childFiles = await _fileSystemRepository.GetChildFiles(folder.Id);

            for (var i = 0; i < childFiles.Length; i++)
            {
                childFiles[i].Index = $"{folder.Index}{childFolders.Length + i + 1}";
            }
        }