public bool ParseSource(string str, string fname) { int key = MainF.Bookmakers.FindIndex(item => fname.ToUpper().Contains(item.Name.ToUpper())); if (key == -1) { MainF.ErrorLabel("Unidentified " + fname); return(false); } ParseBookies book = MainF.Bookmakers[key].Book; MainF.LastBrokerTestLabel(MainF.Bookmakers[key].Name); List <ParsedDataFromPage> ParsDataList = new List <ParsedDataFromPage>(); if (book.Parse(str, ref ParsDataList)) { MainF.UpdateDataBase(ParsDataList, key); } else { MainF.ErrorLabel(fname); WriteBreakToFile.LogParseSave("Error Parsing " + fname); return(false); } return(true); }
public MainWindow() { InitializeComponent(); timer1.Interval = new TimeSpan(0, 0, 2); timer1.Tick += timer1_Tick; PD = new ParsedData(this); XMLData.LoadSettings(this); XMLData xd = new XMLData(); xd.Load(FootData, Bookmakers); UpdateControls(); WriteBreakToFile.ClearFile(); WriteDataTotable("All"); }
public void PrepareMessage(string match, string selection, double x1, double x2, string b1, string tt, DateTime eventdate) { Task.Factory.StartNew(() => { //int index = MainF.Bookmakers.FindIndex(item => item.Name == b1); //if (index == -1) return; //if (!MainF.Bookmakers[index].EMailing) return; // double profit = CalcLayPL(x1, x2); if (!Mail.CheckIfEmailsAllowed() || !Mail.CheckIfSingleMailIsAllowed()) { return; } string tytle = eventdate.Day == DateTime.Now.Day? String.Format("{0} [{1}] | {2}/{3} ({4}) {5}", match, selection, x1, x2, b1, tt): String.Format("!{0} [{1}] | {2}/{3} ({4}) {5} {6}", match, selection, x1, x2, b1, tt, ChangeTimeToString(eventdate)); WriteBreakToFile.LogSave(tytle); Mail.SendMail(tytle, tytle); }); }
private void CheckDirectory(string path) { string[] files; try { files = Directory.GetFiles(path); } catch (Exception) { if (path == FootballHedge.Properties.Settings.Default.Dir1Path) { FootballHedge.Properties.Settings.Default.Dir1 = false; } if (path == FootballHedge.Properties.Settings.Default.Dir2Path) { FootballHedge.Properties.Settings.Default.Dir2 = false; } MainF.ErrorLabel(path); return; } foreach (string fname in files) { StreamReader ReadFile; try { ReadFile = new StreamReader(fname); } catch (Exception) { continue; } string str = ReadFile.ReadToEnd(); ReadFile.Close(); if (fname.Contains(".mht")) { str = str.Replace("=\r\n", ""); str = str.Replace("=3D", "="); } if (ParseSource(str, fname)) { try { File.Delete(fname); } catch (Exception) { WriteBreakToFile.LogParseSave("Can't delete file " + fname); //MessageBox.Show("Can't delete " + fname); } } else { try { //string destination = fname.Replace(@"\Football", @"\New Folder"); //File.Move(fname, destination); File.Delete(fname); } catch (Exception) { WriteBreakToFile.LogParseSave("Can't delete file " + fname); // WriteBreakToFile.LogParseSave("File.Move Error " + fname); } } } }
public void UpLay(List <FData> FootData, List <ParsedDataFromPage> PD, int id) { double MLimit = FootballHedge.Properties.Settings.Default.MailplLimit; foreach (ParsedDataFromPage item in PD) { int i; for (i = FootData.Count - 1; i >= 0; i--) { if (FootData[i].Team1 == item.Team1 && FootData[i].Team2 == item.Team2) { if (item.delete) { FootData.RemoveAt(i); } else { FootData[i].SizeX[0] = item.Size[0]; FootData[i].SizeX[1] = item.Size[1]; FootData[i].SizeX[2] = item.Size[2]; MainF.LastMatchbookUpdate(); foreach (KeyValuePair <int, X> it in FootData[i].XKoef) { if (MainF.Bookmakers[it.Key].Type != BrokerType.BACK) { continue; } for (int q = 0; q < 3; q++) { if (it.Value.Koef[q] >= MainF.Bookmakers[it.Key].Limit && FootData[i].Lay[q] > item.Lay[q]) { double p0 = CalcLayPL(it.Value.Koef[q], item.Lay[q]); if (p0 >= 1 && MainF.Bookmakers[it.Key].InUse) { WriteBreakToFile.LogSave("Lay " + MainF.Bookmakers[it.Key].Name + " | " + item.Team1 + "-" + item.Team2 + " [" + q.ToString() + "] " + FootData[i].Lay[q].ToString() + " -> " + item.Lay[q].ToString()); changecolor = true; } if (p0 >= MLimit && p0 >= MainF.Bookmakers[it.Key].PLlimit && MainF.Bookmakers[it.Key].EMailing) { StringBuilder selection = new StringBuilder(); switch (q) { case 0: selection.Append("Draw"); break; case 1: selection.Append(item.Team1); break; case 2: selection.Append(item.Team2); break; default: selection.Append("uknown"); break; } PrepareMessage(item.Team1 + "-" + item.Team2, selection.ToString(), it.Value.Koef[q], item.Lay[q], MainF.Bookmakers[it.Key].Name, it.Value.LastUpdate, FootData[i].time); } } } } FootData[i].XKoef[id].Koef[0] = item.X[0]; FootData[i].XKoef[id].Koef[1] = item.X[1]; FootData[i].XKoef[id].Koef[2] = item.X[2]; FootData[i].Lay[0] = item.Lay[0]; FootData[i].Lay[1] = item.Lay[1]; FootData[i].Lay[2] = item.Lay[2]; } break; } } if (i < 0) { if (item.delete) { continue; } if (MainF.SuspendedMatches.Count > 0 && MainF.SuspendedMatches.FindIndex(str => str == item.Team1 + " - " + item.Team2) != -1) { continue; } string RepPatter = FootballHedge.Properties.Settings.Default.RepPattern; DateTime dt = DateTime.Parse(item.time, System.Globalization.CultureInfo.CurrentCulture); FData NI = new FData(id); NI.Team1 = item.Team1; NI.Team2 = item.Team2; NI.Match = Regex.Replace(XMLData.ReturnAltTeamName(item.Team1) + "|" + XMLData.ReturnAltTeamName(item.Team2), RepPatter, "").ToUpper(); NI.League = item.League; NI.SizeX = item.Size; //NI.Koef[id, 0] = item.X[0]; //NI.Koef[id, 1] = item.X[1]; //NI.Koef[id, 2] = item.X[2]; NI.XKoef[id].Koef[0] = item.X[0]; NI.XKoef[id].Koef[1] = item.X[1]; NI.XKoef[id].Koef[2] = item.X[2]; NI.Lay[0] = item.Lay[0]; NI.Lay[1] = item.Lay[1]; NI.Lay[2] = item.Lay[2]; NI.time = dt; FootData.Add(NI); MainF.LastMatchbookUpdate(); if (item.League != null) { MainF.CheckAndUpdateEventsCombobox(item.League); } } } }
public void UpBack(List <FData> FootData, List <ParsedDataFromPage> PD, int id) { double MLimit = FootballHedge.Properties.Settings.Default.MailplLimit; foreach (ParsedDataFromPage obj in PD) { for (int j = FootData.Count - 1; j >= 0; j--) { FData item = FootData[j]; int del = item.Match.IndexOf("|"); if (del == -1) { continue; } if (item.Match.IndexOf(obj.Team1, 0, del) == -1) { continue; } if (item.Match.IndexOf(obj.Team2, del) == -1) { continue; } if (!item.XKoef.ContainsKey(id)) { item.AddNewItenToDictionary(id); } for (int q = 0; q < 3; q++) { if (item.XKoef[id].Koef[q] >= MainF.Bookmakers[id].Limit && item.XKoef[id].Koef[q] < obj.X[q]) { double p0 = CalcLayPL(obj.X[q], item.Lay[q]); if (p0 >= 1 && MainF.Bookmakers[id].InUse) { WriteBreakToFile.LogSave("Back " + MainF.Bookmakers[id].Name + " | " + item.Team1 + "-" + item.Team2 + " [" + q.ToString() + "] " + item.XKoef[id].Koef[q].ToString() + " -> " + obj.X[q].ToString()); changecolor = true; } if (p0 >= MLimit && p0 >= MainF.Bookmakers[id].PLlimit && MainF.Bookmakers[id].EMailing) { StringBuilder selection = new StringBuilder(); switch (q) { case 0: selection.Append("Draw"); break; case 1: selection.Append(item.Team1); break; case 2: selection.Append(item.Team2); break; default: selection.Append("uknown"); break; } PrepareMessage(item.Team1 + "-" + item.Team2, selection.ToString(), obj.X[q], item.Lay[q], MainF.Bookmakers[id].Name, obj.time, item.time); WriteBreakToFile.LogSave("EMAIL Back " + MainF.Bookmakers[id].Name + " | " + item.Team1 + "-" + item.Team2 + " [" + q.ToString() + "] " + item.XKoef[id].Koef[q].ToString() + " -> " + obj.X[q].ToString()); } } } item.XKoef[id].Koef[0] = obj.X[0]; item.XKoef[id].Koef[1] = obj.X[1]; item.XKoef[id].Koef[2] = obj.X[2]; item.XKoef[id].LastUpdate = DateTime.Now.ToString("HH:mm"); } } }