Example #1
0
        /// <summary>
        /// Определяет забанен ли данный пилот
        /// </summary>
        /// <returns>Возвращает true, если пилот в бане и false если не в бане</returns>
        private bool CheckBanned()
        {
            ExpertDB db = new ExpertDB();
            var      bl = db.BanList.ToList();

            if (bl.Exists(x => x.PlayerId == LOGIN))
            {
                var ent     = bl.First(x => x.PlayerId == LOGIN);
                int hours   = ent.HoursBan;
                int minutes = ent.MinuteBan;
                var endban  = ent.CreateDate.AddHours(hours).AddMinutes(minutes);
                if (endban <= DateTime.Now)
                {
                    db.BanList.Remove(ent);
                    db.SaveChanges();
                    db.Dispose();
                    return(false);
                }
                else
                {
                    db.Dispose();
                    return(true);
                }
            }
            else
            {
                db.Dispose();
                return(false);
            }
        }
Example #2
0
        public void Start()
        {
            List <GraphCity> graphs = new List <GraphCity>();
            ExpertDB         db     = new ExpertDB();
            var curgraph            = db.GraphCity.ToList();
            var clear       = db.TempGraphCity.ToList();
            var setup       = db.PreSetupMap.ToList();
            var profileUser = db.ProfileUser.Where(x => x.Coalition > 0).ToList();

            for (int i = 0; i < clear.Count; i++)
            {
                var indexcity = clear[i].IndexCity;
                var coal      = clear[i].Coalitions;
                var fildlist  = db.AirFields.Where(x => x.IndexCity == indexcity).ToList();
                foreach (var item in fildlist)
                {
                    db.AirFields.First(x => x.id == item.id).Coalitions = coal;
                }
                db.GraphCity.First(x => x.IndexCity == indexcity).Coalitions  = coal;
                db.GraphCity.First(x => x.IndexCity == indexcity).Kotel       = false;
                db.GraphCity.First(x => x.IndexCity == indexcity).PointsKotel = 0;
            }
            foreach (var item in setup)
            {
                db.PreSetupMap.First(x => x.id == item.id).Played = false;
            }
            foreach (var item in profileUser)
            {
                db.ProfileUser.First(x => x.GameId == item.GameId).Coalition = 0;
            }
            db.SaveChanges();
            db.Dispose();
        }
 /// <summary>
 /// Событие вызывается когда в таблице БД появилась новая запись.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnDatabaseChange_Speech(object sender, SqlNotificationEventArgs e)
 {
     if (SqlNotificationInfo.Insert.Equals(e.Info))
     {
         ExpertDB db    = new ExpertDB();
         var      state = db.Speech.ToList();
         foreach (var item in state)
         {
             var ent = db.Speech.First(x => x.id == item.id);
             Console.WriteLine(DateTime.Now + " |INFO| " + ent.RecipientMessage + " " + ent.Message + " " + ent.Frequency + " " + ent.Lang);
             Program.QSpeech.Enqueue(item);
             db.Speech.Remove(ent);
         }
         db.SaveChanges();
         db.Dispose();
     }
     ExecuteWatchingQuerySpeech();
 }