Ejemplo n.º 1
0
        //int time;
        private void threadVerification(object sender, DoWorkEventArgs e)
        {//ici la modification
            bool parsed = true;

            if (parsed)
            {
                fin             = 0;
                AncienneVersion = this.nbfichier(dFile + text[0] + "\\jeu\\normal", new List <string>());
                newVersion      = this.nbfichier(sFile, new List <string>());
                files           = new List <filupdate>();

                //On supprime les fichiers qui ne sont pas présent dans la nouvelle version
                foreach (string oldVersion in AncienneVersion)
                {
                    if (!newVersion.Contains(oldVersion))
                    {
                        filupdate tempo = new filupdate();
                        tempo.Fichier = oldVersion;
                        tempo.Type    = 2;
                        files.Add(tempo);
                    }
                }

                counter         = 0;
                newVersionCount = newVersion.Count;
                //time = DateTime.Now.Millisecond;
                Directory.CreateDirectory(chemin + "\\patch\\");
                List <BackgroundWorker> travailleur = new List <BackgroundWorker>();
                for (int i = 0; i < nbThread; i++)
                {
                    BackgroundWorker travail = new BackgroundWorker();
                    travail.DoWork             += new DoWorkEventHandler(calculStart);
                    travail.RunWorkerCompleted += new RunWorkerCompletedEventHandler(finiThreadVerification);
                    travail.RunWorkerAsync();
                }

                /*while(fin != nbThread)
                 * {
                 *  Thread.Sleep(1000);
                 * }*/
                //List<filupdate> files = vérificationFichier(dFile + text[0] + "\\jeu\\normal", sFile, AncienneVersion, newVersion);
                //vérificationFichier(dFile + text[0] + "\\jeu\\normal", sFile, AncienneVersion, newVersion, newVersion.Count);
                //WriteFile(files);
            }
            else
            {
                MessageBox.Show("Entrez un chiffre en entier dans thread");
            }
        }
Ejemplo n.º 2
0
        private void vérificationFichier(string route, string routeinit, List <string> oldVersion, string newVersion, int totalFichier, int counterP)
        {
            compteur++;
            //A faire ailleurs car newVersion contiendra un seul fichier
            ecrirelabel((counterP * 100) / totalFichier, newVersion);

            //t2.ReportProgress((int)(counter * 100) / newVersion.Count);
            int    valuer  = oldVersion.IndexOf(newVersion);
            string laroute = "";

            if (valuer != -1)
            {
                laroute = oldVersion[valuer];
            }
            filupdate tempo     = new filupdate();
            bool      needWrite = true;

            if (valuer != -1 && System.IO.File.Exists(route + laroute))
            {
                //   tempo.JupdateList =   BinaryDiff(route + laroute, routeinit + t);
                if (!compareFileWithSha(route + laroute, routeinit + newVersion))
                {
                    tempo.Fichier  = newVersion;
                    tempo.Updateur = "/patch/" + (counterP + 1) + ".patch";
                    fileUpdate(route + laroute, routeinit + newVersion, tempo.Updateur);
                }
                else
                {
                    needWrite = false;
                }
                // ici faire calculer les fichier avec le nouveau système et retourner la liste des fichier à modifiers

                tempo.Type = 1;
            }
            else
            {
                tempo.Fichier = newVersion;
                tempo.Type    = 0;
            }
            if (needWrite)
            {
                files.Add(tempo);
            }
        }