/// <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); } }
/// <summary> /// Подменяет лог файл. В лог добавляются аэродромы подскока /// </summary> /// <param name="str">Лог списком строк</param> /// <param name="i">Номер строки</param> /// <param name="strA">Номер тика</param> /// <param name="path">Путь к фалу</param> private void ReWriteAType9(List <string> str, int i, string strA, string path) { List <string> fakefields = new List <string>(); ExpertDB db = new ExpertDB(); var tick = reg_tick.Match(strA).Value; var rearFields = db.RearFields.ToList(); var allfields = db.AirFields.Where(x => x.idMap == 2).ToList(); List <AirFields> fields = new List <AirFields>(); foreach (var item in allfields) { if (!rearFields.Exists(x => x.IndexFiled == item.IndexCity)) { fields.Add(item); } } int counter = 1; foreach (var item in fields) { fakefields.Add("T:" + tick + " AType:9 AID:" + counter + " COUNTRY:" + item.Coalitions + " POS(" + item.XPos.ToString().Replace(",", ".") + ", " + item.YPos.ToString().Replace(",", ".") + ", " + item.ZPos.ToString().Replace(",", ".") + ") IDS()"); counter++; } fakefields = GetInfluenceArea(db, tick, fakefields, counter); str.InsertRange(i, fakefields); db.Dispose(); FileInfo fi = new FileInfo(path); var npath = SetApp.Config.DirStatLogs + fi.Name; File.WriteAllLines(npath, str); }
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> public void SpecStart() { Host = SetApp.Config.HostSignalR; ExpertDB db = new ExpertDB(); Token = db.Tokens.First(x => x.id == "Map").Token; db.Dispose(); }
/// <summary> /// Стартовый метод. /// </summary> public void Start() { Host = SetApp.Config.HostSignalR; ExpertDB db = new ExpertDB(); Token = db.Tokens.First(x => x.id == "Map").Token; sqlWatcher = new SqlWatcher(); sqlWatcher.EventDBChange += SqlWatcher_EventDBChange; db.Dispose(); }
private TypeAtype12 GetTypeAtype12() { ExpertDB db = new ExpertDB(); var Planeset = db.PlaneSet.ToList(); db.Dispose(); if (Planeset.Exists(x => x.LogType == TYPE)) { return(TypeAtype12.AirCraft); } if (TYPE.Contains("BotPilot_")) { return(TypeAtype12.BotBotPilot); } return(TypeAtype12.Unknown); }
/// <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(); }
public ATC(RearFields rear, string voice, string lang) { ExpertDB db = new ExpertDB(); var allfields = db.AirFields.ToList(); VoiceName = voice; Lang = lang; var ent = allfields.FirstOrDefault(x => x.IndexCity == rear.IndexFiled && x.XPos == rear.XPos && x.ZPos == rear.ZPos); if (lang.Equals("ru-RU")) { if (ent != null) { WhosTalking = ent.NameRu.Replace(" ", "-"); } else { WhosTalking = "Dispatcher"; } } if (lang.Equals("en-US")) { if (ent != null) { WhosTalking = ent.NameEn.Replace(" ", "-"); } else { WhosTalking = "Dispatcher"; } } if (string.IsNullOrEmpty(WhosTalking)) { WhosTalking = "Dispatcher"; } XPos = rear.XPos; ZPos = rear.ZPos; db.Dispose(); }