Esempio n. 1
0
        private void MenuItem_Click_ClearItem(object sender, RoutedEventArgs e)
        {
            if (LWHedge.Items.Count < 1)
            {
                return;
            }
            ListViewHedgeData lw = LWHedge.SelectedItems[0] as ListViewHedgeData;

            for (int i = FootData.Count - 1; i >= 0; i--)
            {
                FData item = FootData[i];

                if (lw.Match == item.Team1 + " - " + item.Team2)
                {
                    foreach (KeyValuePair <int, X> it in item.XKoef)
                    {
                        if (Bookmakers[it.Key].Name == lw.Bookie)
                        {
                            it.Value.Koef[0] = 1;
                            it.Value.Koef[1] = 1;
                            it.Value.Koef[2] = 1;
                            break;
                        }
                    }
                    break;
                }
            }
            UpdateHedgeDataInListview();
        }
Esempio n. 2
0
        private void LWDataContextMenu_ClearSelected(object sender, RoutedEventArgs e)
        {
            if (LWData.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewData lw = (ListViewData)LWData.SelectedItems[0];

            for (int i = FootData.Count - 1; i >= 0; i--)
            {
                FData item = FootData[i];

                if (lw.Team1 == item.Team1 && item.Team2 == lw.Team2)
                {
                    foreach (KeyValuePair <int, X> hi in item.XKoef)
                    {
                        hi.Value.Koef[0] = 1;
                        hi.Value.Koef[1] = 1;
                        hi.Value.Koef[2] = 1;
                    }
                    break;
                }
            }
            WriteDataTotable(ComboBoxEvents.Items[ComboBoxEvents.SelectedIndex].ToString());
        }
        public void Calc3WayDutch(List <ListViewData3WayDutch> datalist, List <FData> FootData)
        {
            if (FootData.Count == 0)
            {
                return;
            }
            double limit = FootballHedge.Properties.Settings.Default.plLimit;

            for (int id = FootData.Count - 1; id >= 0; id--)
            {
                FData item = FootData[id];

                foreach (KeyValuePair <int, X> x0 in item.XKoef)
                {
                    if (x0.Value.Koef[0] == 0 || !MainF.Bookmakers[x0.Key].Dutch3Way)
                    {
                        continue;
                    }
                    foreach (KeyValuePair <int, X> x1 in item.XKoef)
                    {
                        if (x0.Key == x1.Key)
                        {
                            continue;
                        }
                        if (x1.Value.Koef[1] == 0 || !MainF.Bookmakers[x1.Key].Dutch3Way)
                        {
                            continue;
                        }
                        foreach (KeyValuePair <int, X> x2 in item.XKoef)
                        {
                            if (x0.Key == x2.Key || x1.Key == x2.Key)
                            {
                                continue;
                            }
                            if (x2.Value.Koef[2] == 0 || !MainF.Bookmakers[x2.Key].Dutch3Way)
                            {
                                continue;
                            }
                            double p = Calc3WayDucth(x0.Value.Koef[0], x1.Value.Koef[1], x2.Value.Koef[2]);
                            if (p >= limit)
                            {
                                ListViewData3WayDutch dd = new ListViewData3WayDutch();
                                dd.Match   = item.Team1 + " - " + item.Team2;
                                dd.League  = item.League;
                                dd.Bookie0 = MainF.Bookmakers[x0.Key].Name;
                                dd.Bookie1 = MainF.Bookmakers[x1.Key].Name;
                                dd.Bookie2 = MainF.Bookmakers[x2.Key].Name;
                                dd.X0      = x0.Value.Koef[0];
                                dd.X1      = x1.Value.Koef[1];
                                dd.X2      = x2.Value.Koef[2];
                                dd.Profit  = Math.Round(p, 2);
                                datalist.Add(dd);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public void WriteDataTotable(string str)
        {
            LWData.Items.Clear();
            if (FootData.Count < 1 || ComboBoxBookies.SelectedIndex < 0)
            {
                return;
            }

            int i = Bookmakers.FindIndex(item => ComboBoxBookies.Items[ComboBoxBookies.SelectedIndex].ToString().ToUpper().Contains(item.Name.ToUpper()));

            string[]      d;
            StringBuilder bufstr = new StringBuilder();

            for (int id = FootData.Count - 1; id >= 0; id--)
            {
                bufstr.Clear();
                FData item = FootData[id];
                if (str != "All" && item.League != str)
                {
                    continue;
                }
                bool         active = FootData[id].XKoef.ContainsKey(i);
                ListViewData lw     = new ListViewData();
                lw.Team1 = item.Team1;
                lw.Team2 = item.Team2;

                if (active)
                {
                    lw.X1         = String.Format("{0} / {1}", item.XKoef[i].Koef[1], item.Lay[1]);
                    lw.X0         = String.Format("{0} / {1}", item.XKoef[i].Koef[0], item.Lay[0]);
                    lw.X2         = String.Format("{0} / {1}", item.XKoef[i].Koef[2], item.Lay[2]);
                    lw.LastUpdate = item.XKoef[i].LastUpdate;
                }
                else
                {
                    lw.X1 = String.Format("{0}", item.Lay[1]);
                    lw.X0 = String.Format("{0}", item.Lay[0]);
                    lw.X2 = String.Format("{0}", item.Lay[2]);
                }
                lw.FullLeague = item.League;
                d             = item.League.Split(' ');
                foreach (string st in d)
                {
                    bufstr.Append(st.Substring(0, 1));
                }
                lw.League = bufstr.ToString();


                lw.Time = ChangeTimeToString(item.time);
                // lw.LastUpdate = item.LastUpdate[i];

                lw.Match = item.Match;

                LWData.Items.Add(lw);
            }
        }
        public static void UpdateMainDataList(List <FData> FootData)
        {
            for (int id = FootData.Count - 1; id >= 0; id--)
            {
                FData  it        = FootData[id];
                string RepPatter = FootballHedge.Properties.Settings.Default.RepPattern;

                it.Match = Regex.Replace(ReturnAltTeamName(it.Team1) + "," + ReturnAltTeamName(it.Team2), RepPatter, "").ToUpper();
            }
        }
Esempio n. 6
0
 public void RemoveLiveMatches()
 {
     for (int i = FootData.Count - 1; i >= 0; i--)
     {
         FData item = FootData[i];
         if (item.time < DateTime.Now)
         {
             FootData.RemoveAt(i);
         }
     }
     UpdateComboboxLeagues();
 }
Esempio n. 7
0
        private void LWDataContextMenu_RemoveSelected(object sender, RoutedEventArgs e)
        {
            if (LWData.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewData lw = (ListViewData)LWData.SelectedItems[0];

            for (int i = FootData.Count - 1; i >= 0; i--)
            {
                FData item = FootData[i];

                if (lw.Team1 == item.Team1 && item.Team2 == lw.Team2)
                {
                    FootData.RemoveAt(i);
                }
            }
            WriteDataTotable(ComboBoxEvents.Items[ComboBoxEvents.SelectedIndex].ToString());
        }
Esempio n. 8
0
        private void MenuItem_Click_Removeitem(object sender, RoutedEventArgs e)
        {
            if (LWHedge.Items.Count < 1)
            {
                return;
            }
            ListViewHedgeData lw = LWHedge.SelectedItems[0] as ListViewHedgeData;

            for (int i = FootData.Count - 1; i >= 0; i--)
            {
                FData item = FootData[i];

                if (lw.Match == item.Team1 + " - " + item.Team2)
                {
                    FootData.RemoveAt(i);
                }
            }
            UpdateHedgeDataInListview();
        }
        public void Load(List <FData> FootData, List <BasicBrokerData> Bookmakers)
        {
            if (File.Exists(pathAllMatches))
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(pathAllMatches);
                FootData.Clear();
                foreach (XmlNode item in xd.SelectNodes("Data/Match"))
                {
                    FData f = new FData();



                    if (item.SelectSingleNode(".//Team1") == null)
                    {
                        continue;
                    }
                    f.Team1 = item.SelectSingleNode(".//Team1").InnerText;

                    if (item.SelectSingleNode(".//Team2") == null)
                    {
                        continue;
                    }
                    f.Team2 = item.SelectSingleNode(".//Team2").InnerText;


                    if (item.SelectSingleNode(".//Match") == null)
                    {
                        continue;
                    }
                    f.Match = item.SelectSingleNode(".//Match").InnerText;

                    if (item.SelectSingleNode(".//League") == null)
                    {
                        continue;
                    }
                    f.League = item.SelectSingleNode(".//League").InnerText;


                    if (item.SelectSingleNode(".//Time") != null)
                    {
                        string time = time = item.SelectSingleNode(".//Time").InnerText;
                        try
                        {
                            DateTime buftime;
                            if (TryToParse.ParseDateTime(time, out buftime))
                            {
                                f.time = buftime;
                            }
                        }
                        catch (FormatException)
                        {
                            f.time = DateTime.Today;
                        }
                    }

                    for (int i = 0; i < Bookmakers.Count; i++)
                    {
                        BasicBrokerData data = Bookmakers[i];
                        if (item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/X0") == null)
                        {
                            continue;
                        }
                        f.AddNewItenToDictionary(i);
                        if (item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LastUpdate") != null)
                        {
                            f.XKoef[i].LastUpdate = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LastUpdate").InnerText;
                        }

                        double value = 1;
                        var    x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/X0");

                        if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                        {
                        }
                        f.XKoef[i].Koef[0] = value;

                        value = 1;
                        x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/X1");
                        if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                        {
                        }
                        f.XKoef[i].Koef[1] = value;

                        value = 1;
                        x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/X2");
                        if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                        {
                        }
                        f.XKoef[i].Koef[2] = value;

                        if (Bookmakers[i].Type == BrokerType.LAY)
                        {
                            value = 1;
                            x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LX0");

                            if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                            {
                            }
                            f.Lay[0] = value;

                            value = 1;
                            x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LX1");
                            if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                            {
                            }
                            f.Lay[1] = value;

                            value = 1;
                            x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LX2");
                            if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                            {
                            }
                            f.Lay[2] = value;
                        }
                    }

                    FootData.Add(f);
                }
            }
        }
        public void Save(MainWindow MainF, List <FData> FootData)
        {
            XmlTextWriter xmlfile = new XmlTextWriter(pathAllMatches, Encoding.UTF8);

            xmlfile.Formatting = Formatting.Indented;
            xmlfile.WriteStartElement("Data");
            for (int i = FootData.Count - 1; i >= 0; i--)
            {
                FData item = FootData[i];
                xmlfile.WriteStartElement("Match");

                xmlfile.WriteStartElement("League");
                xmlfile.WriteString(item.League);
                xmlfile.WriteEndElement();

                xmlfile.WriteStartElement("Team1");
                xmlfile.WriteString(item.Team1);
                xmlfile.WriteEndElement();

                xmlfile.WriteStartElement("Team2");
                xmlfile.WriteString(item.Team2);
                xmlfile.WriteEndElement();

                xmlfile.WriteStartElement("Time");
                xmlfile.WriteString(item.time.ToString());
                xmlfile.WriteEndElement();

                xmlfile.WriteStartElement("Match");
                xmlfile.WriteString(item.Match);
                xmlfile.WriteEndElement();
                xmlfile.WriteStartElement("BookieOdds");

                foreach (KeyValuePair <int, X> it in FootData[i].XKoef)
                {
                    BasicBrokerData data = MainF.Bookmakers[it.Key];
                    xmlfile.WriteStartElement("B_" + data.Name);

                    xmlfile.WriteStartElement("LastUpdate");
                    xmlfile.WriteString(it.Value.LastUpdate);
                    xmlfile.WriteEndElement();

                    xmlfile.WriteStartElement("X1");
                    xmlfile.WriteString(it.Value.Koef[1].ToString());
                    xmlfile.WriteEndElement();

                    xmlfile.WriteStartElement("X0");
                    xmlfile.WriteString(it.Value.Koef[0].ToString());
                    xmlfile.WriteEndElement();

                    xmlfile.WriteStartElement("X2");
                    xmlfile.WriteString(it.Value.Koef[2].ToString());
                    xmlfile.WriteEndElement();



                    if (MainF.Bookmakers[it.Key].Type == BrokerType.LAY)
                    {
                        xmlfile.WriteStartElement("LX1");
                        xmlfile.WriteString(item.Lay[1].ToString());
                        xmlfile.WriteEndElement();

                        xmlfile.WriteStartElement("LX0");
                        xmlfile.WriteString(item.Lay[0].ToString());
                        xmlfile.WriteEndElement();

                        xmlfile.WriteStartElement("LX2");
                        xmlfile.WriteString(item.Lay[2].ToString());
                        xmlfile.WriteEndElement();
                    }



                    xmlfile.WriteEndElement();
                }

/*
 *              for (int id = 0; id < MainF.Bookmakers.Count; id++)
 *              {
 *                  if (item.Koef[id, 1] == 0) continue;
 *                  BasicBrokerData data = MainF.Bookmakers[id];
 *                  xmlfile.WriteStartElement("B_" + data.Name);
 *
 *                  xmlfile.WriteStartElement("LastUpdate");
 *                  xmlfile.WriteString(item.LastUpdate[id]);
 *                  xmlfile.WriteEndElement();
 *
 *                  xmlfile.WriteStartElement("X1");
 *                  xmlfile.WriteString(item.Koef[id, 1].ToString());
 *                  xmlfile.WriteEndElement();
 *
 *                  xmlfile.WriteStartElement("X0");
 *                  xmlfile.WriteString(item.Koef[id, 0].ToString());
 *                  xmlfile.WriteEndElement();
 *
 *                  xmlfile.WriteStartElement("X2");
 *                  xmlfile.WriteString(item.Koef[id, 2].ToString());
 *                  xmlfile.WriteEndElement();
 *
 *                  xmlfile.WriteEndElement();
 *              }
 */

                xmlfile.WriteEndElement();
                xmlfile.WriteEndElement();
            }
            xmlfile.WriteEndElement();
            xmlfile.Close();
        }
        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 Calchedge(ref List <LayData> datalist, List <FData> FootData, CalcParameters cpar)
        {
            if (FootData.Count == 0)
            {
                return;
            }

            for (int id = FootData.Count - 1; id >= 0; id--)
            {
                FData item = FootData[id];
                if (cpar.today && item.time.Day != DateTime.Now.Day)
                {
                    continue;
                }


                foreach (KeyValuePair <int, X> it in item.XKoef)
                {
                    BasicBrokerData bookie = MainF.Bookmakers[it.Key];
                    if (cpar.preferedbookie != "All" && cpar.preferedbookie != bookie.Name)
                    {
                        continue;
                    }
                    if (!cpar.bookielimit.Contains(bookie.Name))
                    {
                        continue;
                    }

                    if (bookie.Type == BrokerType.BACK)
                    {
                        for (int q = 0; q < 3; q++)
                        {
                            if (it.Value.Koef[q] != 0 && item.Lay[q] != 0 && it.Value.Koef[q] >= bookie.Limit && CalcLayPL(it.Value.Koef[q], item.Lay[q]) > cpar.limit)
                            {
                                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;
                                }

                                LayData ld = new LayData();
                                ld.Match      = item.Team1 + " - " + item.Team2;
                                ld.Selection  = selection.ToString();
                                ld.Lay        = item.Lay[q];
                                ld.Back       = it.Value.Koef[q];
                                ld.Profit     = Math.Round(CalcLayPL(it.Value.Koef[q], item.Lay[q]), 3);
                                ld.Size       = item.SizeX[0];
                                ld.Bookie     = bookie.Name;
                                ld.League     = item.League;
                                ld.Time       = ChangeTimeToString(item.time);
                                ld.LastUpdate = it.Value.LastUpdate;
                                datalist.Add(ld);
                            }
                        }
                    } // end type.Back
                    if (bookie.Type == BrokerType.HANDICAP)
                    {
                        foreach (KeyValuePair <int, X> hi in item.XKoef)
                        {
                            if (MainF.Bookmakers[hi.Key].Type != BrokerType.BACK)
                            {
                                continue;
                            }
                            if (!cpar.bookielimit.Contains(MainF.Bookmakers[hi.Key].Name))
                            {
                                continue;
                            }
                            if (cpar.preferedbookie != "All" && cpar.preferedbookie != MainF.Bookmakers[hi.Key].Name)
                            {
                                continue;
                            }

                            if (hi.Value.Koef[1] != 0 && hi.Value.Koef[1] < hi.Value.Koef[2] && hi.Value.Koef[1] >= MainF.Bookmakers[hi.Key].Limit && CalcHandicapPL(hi.Value.Koef[1], it.Value.Koef[2]) > cpar.limit)
                            {
                                LayData ld = new LayData();
                                ld.Match      = item.Team1 + " - " + item.Team2;
                                ld.Selection  = item.Team1;
                                ld.Lay        = it.Value.Koef[2];
                                ld.Back       = hi.Value.Koef[1];
                                ld.Profit     = Math.Round(CalcHandicapPL(ld.Back, ld.Lay), 2);
                                ld.Bookie     = MainF.Bookmakers[hi.Key].Name;
                                ld.League     = item.League;
                                ld.Size       = -1;
                                ld.Time       = ChangeTimeToString(item.time);
                                ld.LastUpdate = hi.Value.LastUpdate + " Hand";
                                datalist.Add(ld);
                            }
                            if (hi.Value.Koef[2] != 0 && hi.Value.Koef[1] > hi.Value.Koef[2] && hi.Value.Koef[2] >= MainF.Bookmakers[hi.Key].Limit && CalcHandicapPL(hi.Value.Koef[2], it.Value.Koef[1]) > cpar.limit)
                            {
                                LayData ld = new LayData();
                                ld.Match      = item.Team1 + " - " + item.Team2;
                                ld.Selection  = item.Team2;
                                ld.Lay        = it.Value.Koef[1];
                                ld.Back       = hi.Value.Koef[2];
                                ld.Profit     = Math.Round(CalcHandicapPL(ld.Back, ld.Lay), 2);
                                ld.Bookie     = MainF.Bookmakers[hi.Key].Name;
                                ld.League     = item.League;
                                ld.Size       = -1;
                                ld.Time       = ChangeTimeToString(item.time);
                                ld.LastUpdate = hi.Value.LastUpdate + " Hand";
                                datalist.Add(ld);
                            }
                        }
                    }
                }
            }
        }
        public void UpHand(List <FData> FootData, List <ParsedDataFromPage> PD, int id)
        {
            double MLimit = FootballHedge.Properties.Settings.Default.MailplLimit;

            foreach (ParsedDataFromPage obj in PD)
            {
                if (obj.League != "0.5")
                {
                    continue;
                }
                for (int j = FootData.Count - 1; j >= 0; j--)
                {
                    FData item = FootData[j];
                    if (!item.XKoef.ContainsKey(id))
                    {
                        item.AddNewItenToDictionary(id);
                    }
                    if (item.Match.Contains(obj.Team1) && item.Match.Contains(obj.Team2))
                    {
                        foreach (KeyValuePair <int, X> it in FootData[j].XKoef)
                        {
                            if (MainF.Bookmakers[it.Key].Type != BrokerType.BACK)
                            {
                                continue;
                            }

                            if (it.Value.Koef[1] < it.Value.Koef[2] && it.Value.Koef[1] >= MainF.Bookmakers[it.Key].Limit && it.Value.Koef[2] < obj.X[2])
                            {
                                double p1 = CalcHandicapPL(it.Value.Koef[1], obj.X[2]);
                                if (p1 >= 1 && MainF.Bookmakers[id].InUse)
                                {
                                    changecolor = true;
                                }
                                if (p1 >= MLimit && p1 >= MainF.Bookmakers[it.Key].PLlimit)
                                {
                                    PrepareMessage(item.Team1 + "-" + item.Team2, item.Team1, obj.X[2], it.Value.Koef[1], MainF.Bookmakers[it.Key].Name, obj.time, item.time);
                                }
                            }

                            if (it.Value.Koef[1] > it.Value.Koef[2] && it.Value.Koef[2] >= MainF.Bookmakers[it.Key].Limit && it.Value.Koef[1] < obj.X[1])
                            {
                                double p2 = CalcHandicapPL(it.Value.Koef[2], obj.X[1]);
                                if (p2 >= 1 && MainF.Bookmakers[id].InUse)
                                {
                                    changecolor = true;
                                }
                                if (p2 >= MLimit && p2 >= MainF.Bookmakers[it.Key].PLlimit)
                                {
                                    PrepareMessage(item.Team1 + "-" + item.Team2, item.Team1, obj.X[1], it.Value.Koef[2], MainF.Bookmakers[it.Key].Name + " handicap", obj.time, item.time);
                                }
                            }
                        }

                        //for (int q = 0; q < MainF.Bookmakers.Count; q++)
                        //{
                        //    if(MainF.Bookmakers[q].Type != BrokerType.BACK) continue;


                        //    if(item.Koef[q,1] == 0) continue;

                        //    if (item.Koef[q, 1] >= MainF.Bookmakers[q].Limit && item.Koef[id, 2] < obj.X[2])
                        //    {
                        //        double p1 = CalcHandicapPL(item.Koef[q,1], obj.X[2]);
                        //        if (p1 >= 1 && MainF.Bookmakers[id].InUse) changecolor = true;
                        //        if (p1 >= MLimit) PrepareMessage(item.Team1 + "-" + item.Team2, item.Team1, obj.X[2], item.Koef[q, 1], MainF.Bookmakers[q].Name, obj.time);
                        //    }

                        //    if (item.Koef[q, 2] >= MainF.Bookmakers[q].Limit && item.Koef[id, 1] < obj.X[1])
                        //    {
                        //        double p2 = CalcHandicapPL(item.Koef[q, 2], obj.X[1]);
                        //        if (p2 >= 1 && MainF.Bookmakers[id].InUse) changecolor = true;
                        //        if (p2 >= MLimit) PrepareMessage(item.Team1 + "-" + item.Team2, item.Team1, obj.X[1], item.Koef[q, 2], MainF.Bookmakers[q].Name+" handicap", obj.time);
                        //    }

                        //}
                        //item.Koef[id, 1] = obj.X[1];
                        //item.Koef[id, 2] = obj.X[2];
                        //item.LastUpdate[id] = DateTime.Now.ToString("HH:mm");
                        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");
                    }
                }
            }
        }
        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");
                }
            }
        }