internal void ParseData(FonbetResponse data) { if (_bd == null) { _bd = new UnicDataDecorator(UnicData.Load("bd.data")); UnicDataDecorator.UpdateBase += UnicDataDecorator_UpdateBase; } lock (_lockObj) { if (IsFirstLoad) { LoadLink(data); } else { if (FromVersion != data.FromVersion) { IsFirstLoad = true; throw new ArgumentException($"Пришел не тот пакет обновления {FromVersion} != {data.FromVersion}"); } UpdateLink(data); } _line.LastUpdate = DateTime.Now; } FromVersion = data.PacketVersion; }
public bool Save() { try { //Отменяем текущие сохранения. Иначе получаеться, что те что отредактирвоали сегодня //Просто исчезают. и Перед импортом нужно заново прогружать //SiteRow.Save("Fonbet.data", FonbetData); //SiteRow.Save("Olimp.data", OlimpData); //SiteRow.Save("Marafon.data", MarafonData); //SiteRow.Save("Zenit.data", ZenitData); //SiteRow.Save("PariMatch.data", PariMatchData); } catch (Exception ex) { MessageBox.Show(ex.Message); } try { UnicData.Save("bd.data", Base.ToList()); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } return(true); }
private static void Joining() { OpenFileDialog dlg = new OpenFileDialog { Title = "Укажите базу для добавления", Multiselect = false, Filter = "Файл базы данных(*.data)|*.data" }; dlg.ShowDialog(); if (string.IsNullOrEmpty(dlg.FileName)) { return; } List <UnicData> bd = UnicData.Load("bd_new.data"); List <UnicData> newBdOne = UnicData.Load(dlg.FileName); List <UnicData> newBdTwo = UnicData.Load("bd.data"); List <UnicData> x1 = newBdOne.Except(bd, new Comp()).ToList(); List <UnicData> x2 = newBdTwo.Except(bd, new Comp()).ToList(); int last = bd.Count; foreach (UnicData key in x1) { List <UnicData> dt = newBdOne.Where(x => x.Id == key.Id).ToList(); int mainId = bd.Select(x => x.Id).Max(); mainId++; foreach (UnicData mt in dt) { UnicData tmp = mt.Clone(); tmp.Id = mainId; bd.Add(tmp); } } foreach (UnicData key in x2) { List <UnicData> dt = newBdTwo.Where(x => x.Id == key.Id).ToList(); int mainId = bd.Select(x => x.Id).Max(); mainId++; foreach (UnicData mt in dt) { UnicData tmp = mt.Clone(); tmp.Id = mainId; bd.Add(tmp); } } MessageBox.Show($"Успешно добавленно {bd.Count - last} команд"); UnicData.Save("bd_new.data", bd); UnicData.Save("bd.data", bd); }
private void ImportData() { if (!File.Exists("bd.data")) { return; } List <UnicData> db = UnicData.Load("bd.data"); List <UnicData> rezultList = new List <UnicData>(); List <string> filesData = new List <string>() { "Fonbet.data", "Marafon.data", "Olimp.data", "Zenit.data" }; foreach (string fileName in filesData) { List <SiteRow> data = SiteRow.Load(fileName); foreach (SiteRow siteRow in data) { UnicData rez = FindData(siteRow.TeamName, db); if (rez != null) { var team2 = siteRow.Match.Replace(siteRow.TeamName, "").Replace(" - ", "").Trim(); UnicData rez2 = FindData(siteRow.TeamName, db); if (rez2 != null) { rezultList.Add(rez); } } } } rezultList = rezultList.OrderBy(x => x.Id).ToList(); rezultList = ToUnic(rezultList); UnicData.Save("bd_Import.data", rezultList); Loger.Add($"База для импорта готова. В ней {rezultList.Count} записей"); }
//Редактирует ID в базе, при ошибке private void Edit() { UnicData tmp = DataSelected; if (tmp == null) { MessageBox.Show("Выбирете, что-нибудь"); return; } for (int i = 0; i < Base.Count; i++) { if (Base[i].Value == tmp.Value) { Base.Remove(DataSelected); tmp.Id = NewId; Base.Add(tmp); break; } } }
public IEnumerable <UnicData> Compare(UnicData dt, IEnumerable <UnicData> coll) { return(new List <UnicData>()); }
public EditBaseViewModel() { Base = new ObservableCollection <UnicData>(UnicData.Load("base_new_two.data")); Maximum = Base.Select(x => x.Id).Max(); Base.CollectionChanged += Base_CollectionChanged; }
internal List <LinkData> GetLives() { var rezult = new List <LinkData>(); if (_req == null) { _req = new HttpRequest(); _req.CharacterSet = Encoding.UTF8; _req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36 OPR/41.0.2353.46"; //if (UsingProxy) // _req.Proxy = ProxyClient.Parse(ProxySingleManager.GetProxy()); } string respone = _req.Get($"{_url}/su/live/popular").ToString(); var pr = new HtmlParser(); var doc = pr.Parse(respone); var lives = doc.QuerySelectorAll("div.event-info"); foreach (IElement element in lives) { var id = element.Attributes["data-event-treeid"].Value; var linkdata = new LinkData(); linkdata.Id = id; try { linkdata.Teams = element.Children[2].TextContent.Replace(" @ ", " - "); linkdata.Score = element.Children[element.ChildElementCount - 2].FirstElementChild.TextContent; if (element.Children[element.ChildElementCount - 2].ChildElementCount == 2) { linkdata.TimeData = element.Children[element.ChildElementCount - 2].LastElementChild.TextContent; } } catch (Exception e) { continue; } rezult.Add(linkdata); } if (_bd == null) { _bd = new UnicDataDecorator(UnicData.Load("bd.data")); UnicDataDecorator.UpdateBase += UnicDataDecorator_UpdateBase; } var dt = new List <LinkData>(); foreach (LinkData linkData in rezult) { var teams = linkData.Teams.Replace(" - ", "|").Split('|'); if (teams.Length != 2) { continue; } linkData.Team1Id = _bd.GetNumber(teams[0]); if (linkData.Team1Id == -1) { continue; } linkData.Team2Id = _bd.GetNumber(teams[1]); if (linkData.Team2Id == -1) { dt.Add(linkData); } } Logger.AddLog($"Всего lives: {rezult.Count}. Из них отобранно {dt.Count}", Logger.LogTarget.Marafon); return(dt); }
private List <Fork> CheckMain(Bet one, Bet two) { List <Fork> rezult = new List <Fork>(); if (one.Bookmaker == two.Bookmaker) { return(rezult); } if (_bd == null) { _bd = new UnicDataDecorator(UnicData.Load("bd.data")); UnicDataDecorator.UpdateBase += UnicDataDecorator_UpdateBase; } //if (one.Team1Id == -2) // one.Team1Id = _bd.GetNumber(one.Team1); if (one.Team1Id == -1) { return(rezult); } //if (one.Team2Id == -2) // one.Team2Id = _bd.GetNumber(one.Team2); if (one.Team2Id == -1) { return(rezult); } //if (two.Team1Id == -2) // two.Team1Id = _bd.GetNumber(two.Team1); if (two.Team1Id == -1) { return(rezult); } //if (two.Team2Id == -2) // two.Team2Id = _bd.GetNumber(two.Team2); if (two.Team2Id == -1) { return(rezult); } if (one.Team1Id != two.Team1Id) { return(rezult); } if (one.Team2Id != two.Team2Id) { return(rezult); } _betCheck++; rezult.AddRange(Check(one, two)); foreach (var key in one.Parts) { if (two.Parts.ContainsKey(key.Key)) { rezult.AddRange(Check(one.Parts[key.Key], two.Parts[key.Key])); } } return(rezult); }
//Добавляем данные из нижнего списка private void Add(object id) { string siteName = id.ToString(); UnicData dt = null; if (siteName == "Fonbet") { if (FonbetSelected == null) { MessageBox.Show("Выбирете, что-нибудь"); return; } dt = new UnicData(FonbetId, FonbetSelected.TeamName, StaticData.Shared.Enums.ParserType.Fonbet); FonbetData.Remove(FonbetSelected); Fonbet.Remove(FonbetSelected); } else if (siteName == "Olimp") { if (OlimpSelected == null) { MessageBox.Show("Выбирете, что-нибудь"); return; } dt = new UnicData(OlimpId, OlimpSelected.TeamName, StaticData.Shared.Enums.ParserType.Olimp); OlimpData.Remove(OlimpSelected); Olimp.Remove(OlimpSelected); } else if (siteName == "Marafon") { if (MarafonSelected == null) { MessageBox.Show("Выбирете, что-нибудь"); return; } dt = new UnicData(MarafonId, MarafonSelected.TeamName, StaticData.Shared.Enums.ParserType.Marafon); MarafonData.Remove(MarafonSelected); Marafon.Remove(MarafonSelected); } else if (siteName == "Zenit") { if (ZenitSelected == null) { MessageBox.Show("Выбирете, что-нибудь"); return; } dt = new UnicData(ZenitId, ZenitSelected.TeamName, StaticData.Shared.Enums.ParserType.Zenit); ZenitData.Remove(ZenitSelected); Zenit.Remove(ZenitSelected); } else if (siteName == "PariMatch") { if (PariMacthSelected == null) { MessageBox.Show("Выбирете, что-нибудь"); return; } dt = new UnicData(PariMatchId, PariMacthSelected.TeamName, StaticData.Shared.Enums.ParserType.PariMatch); PariMatchData.Remove(PariMacthSelected); PariMatch.Remove(PariMacthSelected); } Base.Add(dt); }
private void LoadData() { try { FonbetData = SiteRow.Load("Fonbet.data"); OlimpData = SiteRow.Load("Olimp.data"); MarafonData = SiteRow.Load("Marafon.data"); ZenitData = SiteRow.Load("Zenit.data"); PariMatchData = SiteRow.Load("PariMatch.data"); Base = new ObservableCollection <UnicData>(UnicData.Load("bd.data").OrderBy(x => x.Id)); } catch { Base = new ObservableCollection <UnicData>(); } Base.CollectionChanged += Base_CollectionChanged; if (Base.Count != 0) { foreach (UnicData key in Base) { foreach (SiteRow t in FonbetData) { if (t.TeamName == key.Value) { t.IsUsed = true; } } foreach (SiteRow t in OlimpData) { if (t.TeamName == key.Value) { t.IsUsed = true; } } foreach (SiteRow t in MarafonData) { if (t.TeamName == key.Value) { t.IsUsed = true; } } foreach (SiteRow t in ZenitData) { if (t.TeamName == key.Value) { t.IsUsed = true; } } foreach (SiteRow t in PariMatchData) { if (t.TeamName == key.Value) { t.IsUsed = true; } } } } Fonbet = new ObservableCollection <SiteRow>(FonbetData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart)); Olimp = new ObservableCollection <SiteRow>(OlimpData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart)); Marafon = new ObservableCollection <SiteRow>(MarafonData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart)); Zenit = new ObservableCollection <SiteRow>(ZenitData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart)); PariMatch = new ObservableCollection <SiteRow>(PariMatchData.OrderBy(x => x.Sport).ThenBy(x => x.TimeStart)); }