Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.38 KB | None | 0 0
  1. /* CODE QUI FAIT FOIRER */
  2. private void readDataFromCSV()
  3.         {
  4.             try
  5.             {
  6.                 using (StreamReader sr = new StreamReader(chemin_fichiers + fichier_courant))
  7.                 {
  8.                     double[,] tab_csv = new double[nbr_lignes, nbr_colonnes];
  9.                     int i = 0;
  10.                     string currentLine;
  11.  
  12.                     while ((currentLine = sr.ReadLine()) != null)
  13.                     {
  14.                         int j = 0;
  15.                         string[] string_ligne = currentLine.Split(';');
  16.  
  17.                         foreach (string valeur_s in string_ligne)
  18.                         {
  19.                             if (!String.IsNullOrEmpty(valeur_s))
  20.                             {
  21.                                 tab_csv[i, j] = Convert.ToDouble(valeur_s);
  22.                                 j++;
  23.                             }
  24.                         }
  25.  
  26.                         i++;
  27.                     }
  28.  
  29.                     Couche_Impression couche_csv = new Couche_Impression(tab_csv);
  30.                     couche_csv.rang = couches.Count + 1;
  31.                     couche_csv.nom_fichier = fichier_courant;
  32.                     couche_csv.getCadresStats(cadre_poudre, cadre_pieces);
  33.                     couches.Add(couche_csv);
  34.                 }
  35.             }
  36.             catch(IOException)
  37.             {}
  38.         }
  39.  
  40. /* CODE QUI APPELLE LE CODE QUI FAIT FOIRER */
  41. private void loadData()
  42.         {
  43.             bool condition = true;
  44.             DateTime date_recherche = date_job;
  45.             int i = 0;
  46.             Console.WriteLine("date debut: " + date_job);
  47.             Console.ReadKey();
  48.             do
  49.             {
  50.                 // Je regarde si un fichier existe
  51.                 date_recherche = getNextCSVFile(date_recherche);
  52.                 Console.WriteLine("Nom fichier: " + fichier_courant);
  53.                 // SI ce fichier est le 1er je check les dimensions car tous les fichiers auront les memes
  54.                 if (i == 0)
  55.                 {
  56.                     getDimensionsFromCSV(fichier_courant);
  57.                     checkLimitsWithPoints();
  58.                 }
  59.                 Console.WriteLine("je vais lire le fichier dans readDataFromCSV()");
  60.                 Console.WriteLine("date: " + date_recherche);
  61.                 // Je lis le fichier csv
  62.                 readDataFromCSV();
  63.                 Console.WriteLine("je viens de lire !");
  64.                 // J'ajoute le nom du fichier dans la liste des fichiers lus
  65.                 fichiers_lus.Add(fichier_courant);
  66.                 // J'incrémente le compteur de fichiers lus
  67.                 parent.nbr_fichier_lus++;
  68.  
  69.                 if (FormSirrisUI.READ_MODE.Equals(Tools.stringValueOf(FormSirrisUI.read_mode.REAL_TIME)))
  70.                     parent.nbr_fichiers_total++;
  71.                 // Je notifie le père pour qu'il puisse refresh ce nombre dans la Form
  72.                 notifyReadFile(fichier_courant);
  73.                 // Je passe au fichier suivant
  74.                 i++;
  75.  
  76.                 if (FormSirrisUI.READ_MODE.Equals(Tools.stringValueOf(FormSirrisUI.read_mode.STATIC)))
  77.                 {
  78.                     if (i < nbr_fichiers_csv)
  79.                         condition = true;
  80.                     else
  81.                         condition = false;
  82.                 }
  83.                
  84.             } while (condition);
  85.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement