예제 #1
0
 public static aeroportEntities Aeroport()
 {
     if (aeroportEntitie == null)
     {
         aeroportEntitie = new aeroportEntities();
     }
     return(aeroportEntitie);
 }
예제 #2
0
        /// <summary>
        /// Obtenir la connexion avec EntityFramework
        /// </summary>
        /// <returns></returns>
        public static aeroportEntities Instance()
        {
            if (instance == null)
            {
                instance = new aeroportEntities();
            }

            return(instance);
        }
예제 #3
0
        private bool Retire()
        {
            int itemsToDequeue = retirePhoneList.Count;

            using (db = DB2.Aeroport())
            {
                try
                {
                    while (itemsToDequeue-- > 0)
                    {
                        Notification item;
                        bool         isTaken = retirePhoneList.TryDequeue(out item);

                        if (isTaken)
                        {
                            var dbelem = db.Notifications.Find(item.Id);
                            if (dbelem != null)
                            {
                                twilloInstance.WriteNewNotification(item);
                                item.Statut = true;
                            }
                            else
                            {
                                notFoundPhoneList.Enqueue(item);
                            }
                        }
                        else
                        {
                            if (retirePhoneList.IsEmpty)
                            {
                                db.SaveChanges();
                                return(true);
                            }
                        }
                    }
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #4
0
        public void verifyNotification()
        {
            DateTime            todayOffset = DateTime.Now.AddDays(-2);
            List <Notification> notifList;

            using (db = DB2.Aeroport())
            {
                notifList = db.Notifications.ToList();
                notifList.ForEach((m) =>
                {
                    if (m.Date_Notification.CompareTo(todayOffset) < 0 && m.Statut != true)
                    {
                        db.Entry(m).Property(u => u.Statut).CurrentValue = true;
                    }
                });

                db.SaveChanges();
            }
        }
예제 #5
0
        public void MAJVolsCedules()
        {
            List <VolsCedule> vols = new List <VolsCedule>(LoadJson());

            using (db = DB2.Aeroport())
            {
                try
                {
                    for (int i = 0; i < vols.Count; i++)
                    {
                        string     num = vols[i].Numero_Vol;
                        VolsCedule vol = db.VolsCedules.SingleOrDefault(m => m.Numero_Vol == num);

                        if (vol != null)
                        {
                            vols[i].Id_Date_Depart = vol.Id_Date_Depart;
                            bool IsEqual = vol.IsEqual(vols[i]);
                            if (!IsEqual)
                            {
                                vol.Date_Depart_Revisee  = vols[i].Date_Depart_Revisee;
                                vol.Date_Arrivee_Revisee = vols[i].Date_Arrivee_Revisee;
                                vol.Etat   = vols[i].Etat;
                                vol.Statut = vols[i].Statut;
                            }
                            else
                            {
                                vols.Remove(vols[i]);
                            }
                        }
                    }

                    db.SaveChanges();
                    UpdateNotification(vols);
                }
                catch (Exception e) {
                    return;
                }
            }
        }
예제 #6
0
        private VolsCedule[] LoadJson()
        {
            List <VolsCedule> items;

            using (StreamReader r = new StreamReader(_FILELOCATION))
            {
                string json = r.ReadToEnd();
                items = new List <VolsCedule>(JsonConvert.DeserializeObject <VolsCedule[]>(json));
            }

            using (db = DB2.Aeroport())
            {
                try
                {
                    items.ForEach((item) =>
                    {
                        VolsCedule vol = db.VolsCedules.FirstOrDefault(m => m.Numero_Vol == item.Numero_Vol);
                        if (vol != null)
                        {
                            db.Entry(vol).Property(u => u.Date_Arrivee_Revisee).CurrentValue = item.Date_Arrivee_Revisee;
                            db.Entry(vol).Property(u => u.Date_Depart_Revisee).CurrentValue  = item.Date_Depart_Revisee;
                            db.Entry(vol).Property(u => u.Etat).CurrentValue           = item.Etat;
                            db.Entry(vol).Property(u => u.Statut).CurrentValue         = item.Statut;
                            db.Entry(vol).Property(u => u.Id_Date_Depart).CurrentValue = item.Id_Date_Depart;
                        }
                    });
                    if (items.Count > 0)
                    {
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                }
            }

            return(items.ToArray());
        }
예제 #7
0
 public static void disconnect()
 {
     aeroportEntitie = null;
 }
예제 #8
0
 /// <summary>
 /// Deconnexion avec EntityFramework
 /// </summary>
 public static void disconnect()
 {
     instance = null;
 }
예제 #9
0
 public SMSController()
 {
     dbcontext      = DB.Instance();
     twilloInstance = new TwilloInstance();
 }