コード例 #1
0
        /// <summary>AffichierBinaire est une methode de la classe Conversion .
        /// <para>Affichier les donées d'un fichier  binaire (Chemin) qui contier les données meterologique d'une wilaya</para>
        /// </summary>
        public static void AffichierBinaire(string dossierSource, int wilaya)
        {
            DataWilaya DonnesMeteo = IOData.LireDonnesWilaya(dossierSource, wilaya);

            DonnesMeteo.Afficher();
            Console.WriteLine("Le nombre d'element:" + DonnesMeteo.NombreDeJour());
        }
コード例 #2
0
 /// <summary>EcrireDonnesWilaya est une methode statique de la classe IOData .
 /// <para>Ecrure l'objet "donnesMeteo" dans un fichier qui sera ciéer dans le dossier "dossier"</para>
 /// </summary>
 public static void EcrireDonnesWilaya(DataWilaya donnesMeteo, string dossier, int numDeWilaya)
 {
     if (!Directory.Exists(dossier))
     {
         Directory.CreateDirectory(dossier);
     }
     try
     {
         BinaryFormatter binaryFormatter = new BinaryFormatter();
         using (Stream stream = File.Open(dossier + "\\" + numDeWilaya + ".bin", FileMode.Create))
         {
             binaryFormatter.Serialize(stream, donnesMeteo);
         }
     }
     catch
     {
         Console.WriteLine("Erreur !!!");
     }
 }
コード例 #3
0
        /// <summary>LireDonnesWilaya est une methode statique de la classe IOData .
        /// <para>Lire un objet de type DataWilaya de la wilaya numero "numDeWilaya"</para>
        /// </summary>
        public static DataWilaya LireDonnesWilaya(string dossier, int numDeWilaya)
        {
            DataWilaya donnesMeteo = new DataWilaya();

            if (!Directory.Exists(dossier))
            {
                Directory.CreateDirectory(dossier);
            }
            try
            {
                using (Stream stream = File.Open(dossier + "/" + numDeWilaya + ".bin", FileMode.Open))
                {
                    var binaryFormatter = new BinaryFormatter();
                    donnesMeteo = (DataWilaya)binaryFormatter.Deserialize(stream);
                }
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message);
            }
            return(donnesMeteo);
        }
コード例 #4
0
ファイル: Statistique.cs プロジェクト: MostefaMourad/EsiScope
        public StatAnnee(int VM, int Wilaya)
        {
            int i, jrs = 0, jrs2 = 0;

            //Sauvegarde de la wilaya
            this.Wilaya = Wilaya;
            DataWilaya Donnees = IOData.LireDonnesWilaya("../../Donnee", Wilaya);

            if (Donnees != null && Donnees.NombreDeJour() != 0)
            {
                startDate = Donnees.GetElementAt(0).DateDuJour;
                endDate   = Donnees.GetElementAt(Donnees.NombreDeJour() - 1).DateDuJour;
            }
            //Initialisation de max et min
            Tuple <int, int, int, float> Max = new Tuple <int, int, int, float>(0, 0, 0, -1000), Min = new Tuple <int, int, int, float>(0, 0, 0, 1000);
            List <Tuple <int, float> >   Tableau = new List <Tuple <int, float> >();
            float  somme        = 0;
            double sommeMoyenne = 0;

            for (i = 0; i < Donnees.NombreDeJour(); i++)
            {
                switch (VM)
                {
                case 1:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideTempuratureMin())
                    {
                        somme += Donnees.GetElementAt(i).TempuratureMin;
                        jrs++;
                        if (Donnees.GetElementAt(i).TempuratureMin >= Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).TempuratureMin);
                        }
                        if (Donnees.GetElementAt(i).TempuratureMin < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).TempuratureMin);
                        }
                    }
                    break;

                case 2:     // Temperature max
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideTempuratureMax())
                    {
                        somme += Donnees.GetElementAt(i).TempuratureMax;
                        jrs++;
                        if (Donnees.GetElementAt(i).TempuratureMax >= Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).TempuratureMax);
                        }
                        if (Donnees.GetElementAt(i).TempuratureMax < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).TempuratureMax);
                        }
                    }
                    break;

                case 3:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideHumidite())
                    {
                        somme += Donnees.GetElementAt(i).Humidite;
                        jrs++;
                        if (Donnees.GetElementAt(i).Humidite > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Humidite);
                        }
                        if (Donnees.GetElementAt(i).Humidite < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Humidite);
                        }
                    }
                    break;

                case 4:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VidePression())
                    {
                        somme += Donnees.GetElementAt(i).Pression;
                        jrs++;
                        if (Donnees.GetElementAt(i).Pression > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Pression);
                        }
                        if (Donnees.GetElementAt(i).Pression < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Pression);
                        }
                    }
                    break;

                case 5:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VidePrecipitation())
                    {
                        somme += Donnees.GetElementAt(i).Humidite;
                        jrs++;
                        if (Donnees.GetElementAt(i).Precipitation > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Precipitation);
                        }
                        if (Donnees.GetElementAt(i).Precipitation < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Precipitation);
                        }
                    }
                    break;

                case 6:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideDistanceDeVisibilite())
                    {
                        somme += Donnees.GetElementAt(i).DistanceDeVisibilite;
                        jrs++;
                        if (Donnees.GetElementAt(i).DistanceDeVisibilite > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).DistanceDeVisibilite);
                        }
                        if (Donnees.GetElementAt(i).DistanceDeVisibilite < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).DistanceDeVisibilite);
                        }
                    }
                    break;

                case 7:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideVitesseDuVent())
                    {
                        somme += Donnees.GetElementAt(i).VitesseDuVent;
                        jrs++;
                        if (Donnees.GetElementAt(i).VitesseDuVent > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).VitesseDuVent);
                        }
                        if (Donnees.GetElementAt(i).VitesseDuVent < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).VitesseDuVent);
                        }
                    }
                    break;

                case 8:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideNebulosite())
                    {
                        somme += Donnees.GetElementAt(i).Nebulosite;
                        jrs++;
                        if (Donnees.GetElementAt(i).Nebulosite > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Nebulosite);
                        }
                        if (Donnees.GetElementAt(i).Nebulosite < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Nebulosite);
                        }
                    }
                    break;
                }
                // Ajout du Tuple si fin de l'année
                if (i + 1 < Donnees.NombreDeJour())
                {
                    if (Donnees.GetElementAt(i).DateDuJour.Year != Donnees.GetElementAt(i + 1).DateDuJour.Year&& jrs != 0)
                    {
                        jrs2         += jrs;
                        sommeMoyenne += somme;
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Year, somme / jrs));
                        somme = 0;
                        jrs   = 0;
                    }
                }
            }

            if (jrs2 != 0)
            {
                moyenne = (float)(sommeMoyenne / jrs2);
            }
            this.Tableau = Tableau;
            this.Max     = Max;
            this.Min     = Min;
        }
コード例 #5
0
ファイル: Statistique.cs プロジェクト: MostefaMourad/EsiScope
        //Constructeur de la classe
        public StatJour(int VM, int Wilaya, int Annee, int Mois)
        {
            int i;

            //Sauvegarde du mois et de l'annee
            this.Mois   = Mois;
            this.Annee  = Annee;
            this.Wilaya = Wilaya;
            //Initialisation de max et min
            Tuple <int, float>         Max = new Tuple <int, float>(0, -1000), Min = new Tuple <int, float>(0, 1000);
            List <Tuple <int, float> > Tableau = new List <Tuple <int, float> >();
            DataWilaya Donnees = IOData.LireDonnesWilaya("../../Donnee", Wilaya);

            for (i = 0; i < Donnees.NombreDeJour(); i++)
            {
                if ((Donnees.GetElementAt(i).DateDuJour.Month == Mois) && (Donnees.GetElementAt(i).DateDuJour.Year == Annee))
                {
                    switch (VM)
                    {
                    case 1:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMin));
                        if (Donnees.GetElementAt(i).TempuratureMin <= Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMin);
                        }
                        if (Donnees.GetElementAt(i).TempuratureMin > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMin);
                        }
                        break;

                    case 2:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMax));
                        if (Donnees.GetElementAt(i).TempuratureMax <= Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMax);
                        }
                        if (Donnees.GetElementAt(i).TempuratureMax > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMax);
                        }
                        break;

                    case 3:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Humidite));
                        if (Donnees.GetElementAt(i).Humidite < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Humidite);
                        }
                        if (Donnees.GetElementAt(i).Humidite > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Humidite);
                        }
                        break;

                    case 4:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Pression));
                        if (Donnees.GetElementAt(i).Pression < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Pression);
                        }
                        if (Donnees.GetElementAt(i).Pression > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Pression);
                        }
                        break;

                    case 5:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Precipitation));
                        if (Donnees.GetElementAt(i).Precipitation < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Precipitation);
                        }
                        if (Donnees.GetElementAt(i).Precipitation > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Precipitation);
                        }
                        break;

                    case 6:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DistanceDeVisibilite));
                        if (Donnees.GetElementAt(i).DistanceDeVisibilite < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DistanceDeVisibilite);
                        }
                        if (Donnees.GetElementAt(i).DistanceDeVisibilite > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DistanceDeVisibilite);
                        }
                        break;

                    case 7:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).VitesseDuVent));
                        if (Donnees.GetElementAt(i).VitesseDuVent < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).VitesseDuVent);
                        }
                        if (Donnees.GetElementAt(i).VitesseDuVent > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).VitesseDuVent);
                        }
                        break;

                    case 8:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Nebulosite));
                        if (Donnees.GetElementAt(i).Nebulosite < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Nebulosite);
                        }
                        if (Donnees.GetElementAt(i).Nebulosite > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Nebulosite);
                        }
                        break;
                    }
                }
            }
            this.Tableau = Tableau;
            this.Max     = Max;
            this.Min     = Min;
        }
コード例 #6
0
        /// <summary>Convertir est une methode de la classe Conversion .
        /// <para>Convertir un fichier excel de la  wilaya nommée (NumDeWilaya.csv) qui est dans le dossier "DossierSource" en binaire dans le dossier "DossierDesstination"</para>
        /// </summary>
        public static void Convertir(string dossierSource, string dossierDesstination, int numDeWilaya)
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo("en-US");
            string     ligne;
            DayData    enreg       = new DayData();
            DataWilaya donnesMeteo = new DataWilaya();

            try
            {
                StreamReader fichier = new StreamReader(dossierSource + "\\" + numDeWilaya + ".csv");
                while ((ligne = fichier.ReadLine()) != null)
                {
                    string[] substrings   = ligne.Split(';');
                    string[] DateCompHeur = substrings[0].Split(' ');
                    string[] DateComp     = DateCompHeur[0].Split('.');
                    DateTime UneDate      = new DateTime(int.Parse(DateComp[2]), int.Parse(DateComp[1]), int.Parse(DateComp[0]));
                    enreg.DateDuJour = UneDate;
                    if (substrings[1].Length != 0)
                    {
                        enreg.TempuratureMin = (sbyte)float.Parse(substrings[1]);
                    }
                    if (substrings[2].Length != 0)
                    {
                        enreg.Pression = float.Parse(substrings[2]);
                    }
                    if (substrings[3].Length != 0)
                    {
                        enreg.Humidite = byte.Parse(substrings[3]);
                    }
                    if (substrings[4].Length != 0)
                    {
                        string[] DirectVn = substrings[4].Split('.');
                        enreg.DirectionDuVent[0] = (Direction)int.Parse(DirectVn[0]);
                        enreg.DirectionDuVent[1] = (Direction)int.Parse(DirectVn[1]);
                    }

                    if (substrings[5].Length != 0)
                    {
                        enreg.VitesseDuVent = byte.Parse(substrings[5]);
                    }
                    if (substrings[6].Length != 0)
                    {
                        enreg.Nebulosite = (byte)float.Parse(substrings[6]);
                    }
                    if (substrings[7].Length != 0)
                    {
                        enreg.DistanceDeVisibilite = float.Parse(substrings[7]);
                    }
                    if (substrings[8].Length != 0)
                    {
                        enreg.Precipitation = float.Parse(substrings[8]);
                    }
                    if (substrings[9].Length != 0)
                    {
                        enreg.Neige = (byte.Parse(substrings[9]) == 1) ? true : false;
                    }
                    if (substrings[10].Length != 0)
                    {
                        enreg.TempuratureMax = (sbyte)float.Parse(substrings[10]);
                    }
                    enreg.Existe = true;
                    //L'ajout de l'instance dans la liste
                    donnesMeteo.AjouterUnJour(enreg);
                    //DateActuel = DateActuel.AddDays(1);
                    enreg = new DayData();
                }
                fichier.Close();
                //La serialisation de la liste dans le fichier
                IOData.EcrireDonnesWilaya(donnesMeteo, dossierDesstination, numDeWilaya);
            }
            catch (Exception e)
            {
                Console.WriteLine("Erreur !!!!!!");
                MessageBox.Show(e.Message);
            }
        }