示例#1
0
        /// <summary>
        /// Add (or not) the file in the collection
        /// </summary>
        /// <param name="file">File path</param>
        /// <param name="crc">crc of the file</param>
        private void NdsFileIntegration(string file, string crc)
        {
            // string crc = GetCRC32FromFile(file);
            NDS_Rom romInfo = DataAcessLayer.FindCRCDataBase(crc.ToUpper());

            if (romInfo != null)
            {
                if (DataAcessLayer.IsCRCInCollection(crc.ToUpper()))
                {
                    RomInCollection(romInfo, file);
                }
                else
                {
                    TypeAvancement infoAvancement    = TypeAvancement.RomIntegrated;
                    string         complementNomXXXX = (romInfo.RomNumber == "xxxx") ? string.Format("({0})", romInfo.Serial) : string.Empty;
                    if (DataAcessLayer.IsRomNumberInCollection(romInfo.RomNumber))
                    {
                        NDS_Rom romBadDump = DataAcessLayer.GetCollectionRom(romInfo.RomNumber);

                        /*
                         * string fileArchive = string.Format(
                         *  "{0}{1}\\({2}) {3}{4}.7z",
                         *  NDSDirectories.PathRom,
                         *  NDSDirectories.GetDirFromReleaseNumber(romBadDump.RomNumber),
                         *  romBadDump.RomNumber,
                         *  romBadDump.title,
                         *  complementNomXXXX);
                         */
                        string badDump = string.Format("{0}{1}", Parameter.Config.Paths.DirTrash, Path.GetFileName(romBadDump.RomPath));
                        if (File.Exists(badDump))
                        {
                            File.Delete(badDump);
                        }

                        if (File.Exists(romBadDump.RomPath))
                        {
                            File.Move(romBadDump.RomPath, badDump);
                        }

                        DataAcessLayer.NdsCollection.Remove(romBadDump);
                        infoAvancement = TypeAvancement.RomIntegratedBadDump;
                    }

                    tos.SetIntituleTraitement(string.Format("CRC : {0} => {1} => Compressing ...", crc.ToUpper(), romInfo.Title));

                    ReportProgress(tos.Avance(infoAvancement), tos);

                    Directory.CreateDirectory(Parameter.Config.Paths.DirTemp + crc.ToUpper());

                    string source = string.Format("{0}{1}\\{2}{3}.nds", Parameter.Config.Paths.DirTemp, crc.ToUpper(), romInfo.Title, complementNomXXXX);
                    File.Move(file, source);

                    string zipFile = string.Format("{0}({1}) {2}{3}.7z", Parameter.Config.Paths.DirTemp, romInfo.RomNumber, romInfo.Title, complementNomXXXX);
                    try
                    {
                        ZipRom(zipFile, source);
                        tos.SetIntituleTraitement(string.Format("Compressing {0} done", romInfo.Title));
                        File.Delete(source);
                        Directory.Delete(Path.GetDirectoryName(source));
                        tos.SetRomInfo(romInfo);
                        tos.SetRomInfoIntegration(infoAvancement, Path.GetFileName(file));
                        ReportProgress(tos.PourcentageAvancement(), tos);

                        Directories.ArchiveRom(zipFile, romInfo.RomNumber);
                        DataAcessLayer.NdsCollection.Add(romInfo);
                        DataAcessLayer.SaveCollectionXML();
                    }
                    catch (Exception ex)
                    {
                        // throw;
                        tos.SetIntituleTraitement(string.Format("Une erreur est survenue pendant la compression:{0}{1}", Environment.NewLine, ex.Message));
                        File.Move(source, file);
                        tos.SetRomInfo(romInfo);
                        tos.SetRomInfoIntegration(TypeAvancement.Nothing, Path.GetFileName(file));
                        ReportProgress(tos.PourcentageAvancement(), tos);
                    }
                }
            }
            else
            {
                RomNotFound(file, crc);
            }

            tos.SetRomInfo(null);
            tos.SetRomInfoIntegration(TypeAvancement.Nothing, null);
        }
示例#2
0
 /// <summary>
 /// Szip_Extracting
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">ProgressEventArgs</param>
 private void Szip_Extracting(object sender, ProgressEventArgs e)
 {
     ReportProgress(tosCmp.Avance(e.PercentDone), tosCmp);
 }