Example #1
0
 // return groups of directories :
 //   print example
 //   ".02_hebdo\\L'express" :
 //     - "Directory" : "g:\\pib\\media\\ebook\\_test\\print\\.02_hebdo\\L'express", "SubDirectory" : ".02_hebdo\\L'express", "Level" : 1
 //     - "Directory" : "g:\\pib\\media\\ebook\\_test\\_dl\\print\\01\\print\\.02_hebdo\\L'express", "SubDirectory" : ".02_hebdo\\L'express", "Level" : 1
 //     - "Directory" : "g:\\pib\\media\\ebook\\_test\\_dl\\print\\02\\print\\.02_hebdo\\L'express", "SubDirectory" : ".02_hebdo\\L'express", "Level" : 1
 //   book example
 //   "Comment faire les fromages" :
 //     - "Directory" : "g:\\pib\\media\\ebook\\_test\\book\\Comment faire les fromages", "SubDirectory" : "Comment faire les fromages", "Level" : 1
 //     - "Directory" : "g:\\pib\\media\\ebook\\_test\\_dl\\book\\01\\book\\Comment faire les fromages", "SubDirectory" : "Comment faire les fromages", "Level" : 1
 //     - "Directory" : "g:\\pib\\media\\ebook\\_test\\_dl\\book\\02\\book\\Comment faire les fromages", "SubDirectory" : "Comment faire les fromages", "Level" : 1
 //public Dictionary<string, List<PrintDirectoryInfo>> GetDirectoryGroups(string[] directories, bool usePrintDirectories = true)
 public Dictionary<string, List<EnumDirectoryInfo>> GetDirectoryGroups(string[] directories, bool usePrintDirectories = true)
 {
     Dictionary<string, List<EnumDirectoryInfo>> directoryGroups = new Dictionary<string, List<EnumDirectoryInfo>>(StringComparer.InvariantCultureIgnoreCase);
     foreach (string directory in directories)
     {
         // directory : "g:\pib\media\print", "c:\pib\_dl\_pib\dl\print"
         directoryGroups.zKeyListAdd(GetDirectories(directory, usePrintDirectories), dir => dir.SubDirectory);
     }
     return directoryGroups;
 }
Example #2
0
 public static Dictionary<string, List<FileGroup>> GetFileGroups(IEnumerable<EnumDirectoryInfo> directories)
 {
     Dictionary<string, List<FileGroup>> fileGroups = new Dictionary<string, List<FileGroup>>(StringComparer.InvariantCultureIgnoreCase);
     foreach (EnumDirectoryInfo directoryInfo in directories)
     {
         //Trace.WriteLine("get files from \"{0}\"", directoryInfo.Directory);
         // followDirectoryTree ????
         // followDirectoryTree: dir => { }
         var query = zdir.EnumerateFilesInfo(directoryInfo.Directory)
         .Select(
             file =>
             {
                 FilenameNumberInfo filenameNumberInfo = FilenameNumberInfo.GetFilenameNumberInfo(file.File);
                 string baseFilename = filenameNumberInfo.BaseFilename;
                 bool badFile = false;
                 if (file.SubDirectory == __badFileDirectory)
                 {
                     baseFilename = __badFileDirectory + "\\" + baseFilename;
                     badFile = true;
                 }
                 return new FileGroup
                 {
                     DirectoryInfo = directoryInfo,
                     SubDirectory = file.SubDirectory,
                     File = file.File,
                     BaseFilename = baseFilename,
                     Number = filenameNumberInfo.Number,
                     BadFile = badFile
                     //PrintInfo = PrintIssue.GetPrintInfo(zPath.GetFileNameWithoutExtension(filenameNumberInfo.BaseFilename))
                 };
             }
             );
         fileGroups.zKeyListAdd(query, fileGroup => fileGroup.BaseFilename);
     }
     return fileGroups;
 }
Example #3
0
 private Dictionary<string, List<FileGroup_v1>> GetFileGroups_v1(IEnumerable<DirectoryGroup> directories)
 {
     Dictionary<string, List<FileGroup_v1>> fileGroups = new Dictionary<string, List<FileGroup_v1>>();
     foreach (DirectoryGroup directoryGroup in directories)
     {
         var query = zDirectory.EnumerateFiles(directoryGroup.Directory, "*.*", SearchOption.AllDirectories).Select(
             file =>
             {
                 //FilenameNumberInfo filenameNumberInfo = zpath.PathGetFilenameNumberInfo(file);
                 FilenameNumberInfo filenameNumberInfo = FilenameNumberInfo.GetFilenameNumberInfo(file);
                 return new FileGroup_v1
                 {
                     DirectoryGroup = directoryGroup,
                     File = file,
                     BaseFilename = filenameNumberInfo.BaseFilename,
                     Number = filenameNumberInfo.Number
                 };
             }
             );
         fileGroups.zKeyListAdd(query, fileGroup => fileGroup.BaseFilename);
     }
     return fileGroups;
 }
Example #4
0
 private Dictionary<string, List<DirectoryGroup>> GetDirectoryGroups_v1(string[] directories, int level)
 {
     Dictionary<string, List<DirectoryGroup>> directoryGroups = new Dictionary<string, List<DirectoryGroup>>();
     foreach (string directory in directories)
     {
         int l = directory.Length;
         var query = from dir in zdir.EnumerateDirectories(directory, minLevel: level, maxLevel: level)
                     select
                         new DirectoryGroup
                         {
                             BaseDirectory = directory,
                             Directory = dir,
                             SubDirectory = dir.Substring(l + 1)
                         };
         directoryGroups.zKeyListAdd(query, dir => dir.SubDirectory);
     }
     return directoryGroups;
 }