コード例 #1
0
ファイル: PanelGestionLogs.cs プロジェクト: KiwiJaune/GoBot
        void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            lblDatePlusVieux.Text = plusVieux.ToString();
            lblNombreLogs.Text = nbLogs.ToString();
            TailleDossier tailleDossier = new TailleDossier(FolderSize(Config.PathData + "/Logs/"));
            lblTailleTotale.Text = tailleDossier.ToString();

            dataGridViewHistoLog.DataSource = dataSet.Tables[0];
            dataGridViewArchives.DataSource = dataSetArchivage.Tables[0];
            progressBar.Visible = false;
        }
コード例 #2
0
ファイル: PanelGestionLogs.cs プロジェクト: KiwiJaune/GoBot
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            plusVieux = DateTime.Now;

            int currentLog = 0;

            List<String> dossiers = (List<String>)Directory.EnumerateDirectories(Config.PathData + "/Logs/").ToList<String>();
            nbLogs = dossiers.Count;

            dossiers.Sort(OrdreAlphabetiqueInverse);

            foreach (String dossier in dossiers)
            {
                if (Config.Shutdown)
                    return;

                currentLog++;
                String dossier1 = Path.GetFileName(dossier);
                DateTime date;

                int nbElements = 0;

                try
                {
                    String[] tab = dossier1.Split(new char[5] { '.', ' ', 'h', 'm', 's' });
                    date = new DateTime(Convert.ToInt16(tab[0]), Convert.ToInt16(tab[1]), Convert.ToInt16(tab[2]), Convert.ToInt16(tab[3]), Convert.ToInt16(tab[4]), Convert.ToInt16(tab[5]));

                    if (date < plusVieux)
                        plusVieux = date;

                    long taille = FolderSize(dossier);

                    Object[] datas = new Object[7];

                    datas[0] = date;
                    datas[1] = new TailleDossier(taille);

                    foreach (String fichier in Directory.EnumerateFiles(dossier))
                    {
                        if (Path.GetFileName(fichier) == "ActionsGros.elog")
                        {
                            EventsReplay r = new EventsReplay();
                            if (r.Charger(fichier))
                            {
                                datas[5] = r.Events.Count;
                                nbElements += r.Events.Count;
                            }
                            else
                                datas[5] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "ActionsPetit.elog")
                        {
                            EventsReplay r = new EventsReplay();
                            r.Charger(fichier);
                            if (r.Charger(fichier))
                            {
                                datas[6] = r.Events.Count;
                                nbElements += r.Events.Count;
                            }
                            else
                                datas[6] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "ConnexionPi.tlog")
                        {
                            Replay r = new Replay();
                            r.Charger(fichier);
                            if (r.Charger(fichier))
                            {
                                datas[3] = r.Trames.Count;
                                nbElements += r.Trames.Count;
                            }
                            else
                                datas[3] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "ConnexionMove.tlog")
                        {
                            Replay r = new Replay();
                            r.Charger(fichier);
                            if (r.Charger(fichier))
                            {
                                datas[2] = r.Trames.Count;
                                nbElements += r.Trames.Count;
                            }
                            else
                                datas[2] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "ConnexionMiwi.tlog")
                        {
                            Replay r = new Replay();
                            r.Charger(fichier);
                            if (r.Charger(fichier))
                            {
                                datas[4] = r.Trames.Count;
                                nbElements += r.Trames.Count;
                            }
                            else
                                datas[4] = -1;
                        }
                    }

                    // Si il n'y a aucune trame ni aucun evenement dans le dossier, on le supprime
                    if (nbElements == 0)
                        Directory.Delete(dossier);
                    else
                        dataSet.Tables[0].Rows.Add(datas);
                }
                catch (Exception)
                {
                }

                worker.ReportProgress((int)(currentLog * 100 / nbLogs));
            }

            foreach (String dossier in Directory.EnumerateDirectories(Config.PathData + "/Archives/"))
            {
                if (Config.Shutdown)
                    return;

                currentLog++;
                String dossier1 = Path.GetFileName(dossier);
                DateTime date;

                try
                {
                    String[] tab = dossier1.Split(new char[5] { '.', ' ', 'h', 'm', 's' });
                    date = new DateTime(Convert.ToInt16(tab[0]), Convert.ToInt16(tab[1]), Convert.ToInt16(tab[2]), Convert.ToInt16(tab[3]), Convert.ToInt16(tab[4]), Convert.ToInt16(tab[5]));

                    if (date < plusVieux)
                        plusVieux = date;

                    long taille = FolderSize(dossier);

                    Object[] datas = new Object[8];

                    datas[1] = date;
                    datas[2] = new TailleDossier(taille);

                    foreach (String fichier in Directory.EnumerateFiles(dossier))
                    {
                        if (Path.GetFileName(fichier) == "ActionsGros.elog")
                        {
                            EventsReplay r = new EventsReplay();
                            if (r.Charger(fichier))
                                datas[6] = r.Events.Count;
                            else
                                datas[6] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "ActionsPetit.elog")
                        {
                            EventsReplay r = new EventsReplay();
                            r.Charger(fichier);
                            if (r.Charger(fichier))
                                datas[7] = r.Events.Count;
                            else
                                datas[7] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "ConnexionPi.tlog")
                        {
                            Replay r = new Replay();
                            r.Charger(fichier);
                            if (r.Charger(fichier))
                                datas[4] = r.Trames.Count;
                            else
                                datas[4] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "ConnexionMove.tlog")
                        {
                            Replay r = new Replay();
                            r.Charger(fichier);
                            if (r.Charger(fichier))
                                datas[3] = r.Trames.Count;
                            else
                                datas[3] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "ConnexionMiwi.tlog")
                        {
                            Replay r = new Replay();
                            r.Charger(fichier);
                            if (r.Charger(fichier))
                                datas[5] = r.Trames.Count;
                            else
                                datas[5] = -1;
                        }
                        else if (Path.GetFileName(fichier) == "Archivage")
                        {
                            StreamReader reader = new StreamReader(fichier);
                            datas[0] = reader.ReadLine();
                            reader.Close();
                        }
                    }

                    dataSetArchivage.Tables[0].Rows.Add(datas);
                }
                catch (Exception)
                {
                }
            }
        }