Ejemplo n.º 1
0
        /// <summary>
        /// 以目录为单位导入
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="path"></param>
        private int ImportCat(DocDto dto, string path)
        {
            var qty = 0;

            var dirs = Directory.GetDirectories(path);

            if (dirs != null)
            {
                var docDao = new DocDao();
                foreach (var dir in dirs)
                {
                    var catDto = new CatImgDto();
                    catDto.path  = dir;
                    catDto.names = Path.GetFileName(dir);
                    catDto.pid   = dto.id;
                    docDao.Save(catDto);

                    qty += ImportCat(catDto, path);
                }
            }

            var files = System.IO.Directory.GetFiles(path);

            qty += ImportImg(dto, files);

            return(qty);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建目录
        /// </summary>
        /// <param name="parent"></param>
        public void CreateCat(DocDto parent)
        {
            if (parent == null)
            {
                return;
            }

            parent.BuildCatKeys();

            var dialog = new InputDialog();
            var result = dialog.ShowDialog(_Main, (input, error) =>
            {
                input = (input ?? "").Trim();
                if (input == null)
                {
                    error.Text = "请输入一个有效的目录名称:";
                    return(false);
                }
                if (parent.CatNameExist(input))
                {
                    error.Text = $"已存在名为 {input} 的目录!";
                    return(false);
                }

                var cat   = new CatImgDto();
                cat.names = input;
                cat.path  = parent.FullRelativeFile + "/" + input;
                cat.pid   = parent.id;
                cat.Init(_Cfg);

                parent.AppendCatItem(cat);

                new DocDao().Save(cat);

                if (!Directory.Exists(cat.FullPhysicalFile))
                {
                    Directory.CreateDirectory(cat.FullPhysicalFile);
                }
                return(true);
            });
        }