Ejemplo n.º 1
0
        public string GetPath(FileGroup_v2 file)
        {
            string pathFile = _destinationDirectory;
            string filename = zPath.GetFileNameWithoutExtension(file.BaseFilename);

            if (!file.BadFile)
            {
                PrintInfo printInfo = PrintIssue.GetPrintInfo(filename);
                //Trace.WriteLine("_MoveFiles() filename \"{0}\" date \"{1}\"", filename, printInfo != null ? printInfo.Date.ToString() : "null");
                if (printInfo != null && printInfo.Date != null)
                {
                    string subDirectory = GetPrintDirectoryDateStorage().GetDirectory((Date)printInfo.Date);
                    if (subDirectory != null)
                    {
                        pathFile = zPath.Combine(pathFile, subDirectory);
                    }
                }
                else if (!file.DestinationDirectoryFile)
                {
                    if (file.SubDirectory != null)
                    {
                        pathFile = zPath.Combine(pathFile, file.SubDirectory);
                    }
                }
                //else if (file.File.StartsWith(destinationDirectory))
                //else // if (file.DestinationDirectoryFile)
                //{
                //    // dont move unknow file of destination directory
                //    if (n <= file.Number)
                //        n = file.Number + 1;
                //    continue;
                //    // pas de continue sinon n n'est pas incrémenté
                //    // keep directory file
                //    //file = fileGroup.DirectoryInfo.Directory;
                //}
            }
            else
            {
                pathFile = zPath.Combine(pathFile, _badFileDirectory);
            }
            pathFile = zPath.Combine(pathFile, filename);
            if (file.Number > 0)
            {
                pathFile += string.Format("[{0}]", file.Number);
            }
            pathFile += zPath.GetExtension(file.BaseFilename);
            return(pathFile);
        }
Ejemplo n.º 2
0
 private void DeleteDuplicateFiles(List <FileGroup_v2> files)
 {
     for (int i1 = 0; i1 < files.Count - 1;)
     {
         FileGroup_v2 file1       = files[i1];
         bool         deleteFile1 = false;
         for (int i2 = i1 + 1; i2 < files.Count;)
         {
             FileGroup_v2 file2       = files[i2];
             bool         deleteFile2 = false;
             if (_simulate)
             {
                 Trace.WriteLine("compare file           \"{0}\"", file1.File);
                 //Trace.WriteLine("        with           \"{0}\"", file2.File);
                 Trace.WriteLine("  with                 \"{0}\"", file2.File);
                 if (_moveInfoFiles)
                 {
                     Trace.WriteLine("  concat info files");
                 }
             }
             else
             {
                 if (zfile.AreFileEqual(file1.File, file2.File))
                 {
                     if (!file1.DestinationDirectoryFile && file2.DestinationDirectoryFile)
                     {
                         deleteFile1 = true;
                     }
                     else if (file1.DestinationDirectoryFile && !file2.DestinationDirectoryFile)
                     {
                         deleteFile2 = true;
                     }
                     else if (file1.Number <= file2.Number)
                     {
                         deleteFile2 = true;
                         //pathFile1 = file2.File;
                         //pathFile2 = file1.File;
                     }
                     else
                     {
                         deleteFile1 = true;
                         //pathFile1 = file1.File;
                         //pathFile2 = file2.File;
                     }
                     string pathFile1, pathFile2;
                     if (deleteFile1)
                     {
                         pathFile1 = file1.File;
                         pathFile2 = file2.File;
                     }
                     else
                     {
                         pathFile1 = file2.File;
                         pathFile2 = file1.File;
                     }
                     Trace.WriteLine("delete file            \"{0}\"", pathFile1);
                     Trace.WriteLine("  identical to         \"{0}\"", pathFile2);
                     zFile.Delete(pathFile1);
                     if (_moveInfoFiles)
                     {
                         string pathInfoFile1 = InfoFile.GetInfoFile(pathFile1);
                         string pathInfoFile2 = InfoFile.GetInfoFile(pathFile2);
                         if (zFile.Exists(pathInfoFile1))
                         {
                             if (zFile.Exists(pathInfoFile2))
                             {
                                 Trace.WriteLine("  append info file     \"{0}\" to \"{0}\"", pathInfoFile1, pathInfoFile2);
                             }
                             else
                             {
                                 Trace.WriteLine("  move info file       \"{0}\" to \"{0}\"", pathInfoFile1, pathInfoFile2);
                             }
                         }
                         else
                         {
                             if (zFile.Exists(pathInfoFile2))
                             {
                                 Trace.WriteLine("  no info file to append");
                             }
                             else
                             {
                                 Trace.WriteLine("  no info file");
                             }
                         }
                         // append pathInfoFile1 to pathInfoFile2
                         InfoFile.ConcatFiles(pathInfoFile2, pathInfoFile1);
                     }
                 }
             }
             if (deleteFile1)
             {
                 break;
             }
             if (deleteFile2)
             {
                 files.RemoveAt(i2);
             }
             else
             {
                 i2++;
             }
         }
         if (deleteFile1)
         {
             files.RemoveAt(i1);
         }
         else
         {
             i1++;
         }
     }
 }