/// <summary> /// /// </summary> /// <param name="game"></param> /// <returns></returns> private bool Launch4One(IGame game) { ITrace.WriteLine($"[Launch4One] process for {game.Title}"); ImageDetails[] images = game.GetAllImagesWithDetails(); ITrace.WriteLine($"[Launch4One] Images Found: {images.Length}"); //ExtImageDetails[] extImages = ExtImageDetails.Convert(images); var extImages = Array.ConvertAll(images, item => (ExtImageDetails)item); Md5Func Md5Job = new Md5Func(); Md5Job.CurrentPosition += (x) => { DxProgressB1.SCurrentProgress = x; }; Md5Job.CurrentFile += (file) => { DxProgressB1.SCurrentOP = file; }; Task t1 = Task.Run(() => Md5Job.Calculate_MD5(extImages, 10)); t1.ContinueWith((antecedant) => DxProgressB1.AsyncCloseIt()); //Calculate_MD5(extImages); // La fenêtre bloque la suite tant qu'elle n'est pas fermée DxProgressB1.ModalShow("[Launch4One] CleanImages - Calculate MD5", images.Length); ITrace.WriteLine("[Launch4One] Fin de Calculate Md5"); // Scan des doublons; List <List <ExtImageDetails> > Doublons = Scan(extImages); int dNumber = Doublons.Count(); if (dNumber < 1) { DxMBox.ShowDial($"{Lang.Duplicate_No_Res}: {game.Title}", Lang.Scan_Title, DxButtons.Ok); } //ManualProcess PManualDuplicates(Doublons, game); ITrace.WriteLine("[Launch4One] Fin"); return(true); }
/// <summary> /// /// </summary> /// <param name="games"></param> /// <returns></returns> private async Task <bool> LaunchThem(IGame[] games) { ITrace.WriteLine("[LaunchThem] Begin"); cProgress = new DxCollecProgress(); cProgress.SetCollection <IGame>(games, "Title"); //cProgress.CurrentTotal = 100; cProgress.MaxProgress = 100; cProgress.MaxTotal = games.Length; cProgress.Show(); foreach (IGame game in games) { ITrace.WriteLine($"[Launch] process for {game.Title}"); cProgress.CurrentOP = Lang.Search_Images; ImageDetails[] images = game.GetAllImagesWithDetails(); ITrace.WriteLine($"[Launch] Images Found: {images.Length}"); cProgress.MaxProgress = images.Length; var extImages = Array.ConvertAll(images, item => (ExtImageDetails)item); Md5Func Md5Job = new Md5Func(); ITrace.WriteLine($"[LaunchThem] {Lang.Md5_Begin}\n"); cProgress.CurrentOP = Lang.Md5_Begin; Md5Job.CurrentPosition += (x) => { cProgress.CurrentProgress = x; }; await Md5Job.Calculate_MD5(extImages, 10); #region Scan des doublons; cProgress.CurrentOP = Lang.Duplicate_Begin; ITrace.WriteLine($"[LaunchThem] {Lang.Duplicate_Begin}"); List <List <ExtImageDetails> > doublons = Scan(extImages); cProgress.CurrentTotal++; int dNumber = doublons.Count(); if (dNumber < 1) { cProgress.SetCurrentFinished(Lang.Duplicate_No_Res); ITrace.WriteLine($"[LaunchThem] {Lang.Duplicate_No_Res}"); continue; } #endregion if (cProgress.StopIt) { ITrace.WriteLine("[LaunchThem] Stopped by user"); cProgress.Close(); return(false); } //ManualProcess bool resDupli = PManualDuplicates(doublons, game); ITrace.WriteLine($"Resultat de resDupli {resDupli}"); if (!resDupli) { ITrace.WriteLine("[LaunchThem] Stopped by user 2"); cProgress.Close(); return(false); } cProgress.SetCurrentFinished(""); } ITrace.WriteLine("[LaunchThem] End"); return(true); #region obsolète /* * Dictionary<IGame, List<List<ExtImageDetails>>> AllDoublons = new Dictionary<IGame, List<List<ExtImageDetails>>>(); * bool poursuite = false; * Task t1 = Task * .Run(() => LaunchThemProcess(games, AllDoublons)) * .ContinueWith((tResult) => * { * * if (!tResult.Result) * { * ITrace.WriteLine("Task aborded"); * cProgress.AsyncClose(); * * * } * * if (tResult.Result) * { * ITrace.WriteLine("Task ended normally"); * cProgress.AsyncClose(); * poursuite = true; * * } * }); * * * cProgress.ShowDialog(); * * if (!poursuite) return poursuite; * * ITrace.WriteLine("Taille du dico" + AllDoublons.Count()); * if (AllDoublons.Count() < 1) DxMBox.ShowDial("No doublon", "info", DxButtons.Ok); * * // Traitement manuel * bool res; * foreach (IGame game in games) * { * res = PManualDuplicates(AllDoublons[game], game); * if (!res) break; * } * * ITrace.WriteLine("[LaunchThem] End"); * return true;*/ #endregion }