public void Parse(ref List <LinkInfo> parts, string link)
        {
            Match  m;
            int    code;
            string backlnk, responseFromServer = _net.GetHtmlCode(link), pattern = "(?:href|src)\\s*=\\s*(?:[\"'](?<1>[^\"']*)[\"']|(?<1>\\S+))";

            if (responseFromServer == "")
            {
                return;
            }
            try
            {
                m = Regex.Match(responseFromServer, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled, TimeSpan.FromSeconds(1));
                while (m.Success)
                {
                    backlnk = Cheker(link, m.Groups[1].ToString());
                    if (backlnk != "")
                    {
                        code = _net.GetStatusCode(backlnk);
                        parts.Add(new LinkInfo()
                        {
                            Url = backlnk, Code = code
                        });
                        DisplayInfo.ShowLink(backlnk, code, parts.Count);
                    }
                    m = m.NextMatch();
                }
            }
            catch (RegexMatchTimeoutException e)
            {
                _errorSend.SendMail(e.Message);
                DisplayInfo.ShowInfo("The matching operation timed out.");
            }

            catch (ArgumentNullException e)
            {
                _errorSend.SendMail(e.Message);
                DisplayInfo.ShowInfo(e.Message.ToString());
            }
        }
        static void Main(string[] args)
        {
            /*    MessageBox.Show(
             * "Error when starting LinkParser: не является приложением Win32",
             * "Error occured",
             * MessageBoxButtons.OK,
             * MessageBoxIcon.Error,
             * MessageBoxDefaultButton.Button1,
             * MessageBoxOptions.DefaultDesktopOnly);
             *
             *  return;*/

            // Process proc = new Process(args[0]);
            // proc.Runner();
            NetRequest net   = new NetRequest();
            string     check = net.GetHtmlCode(@"http://cu51882.tmweb.ru/top3rapido.html");

            if (check == "008")
            {
                MessageBox.Show("Нет соединения с интернетом");
                return;
            }

            /*if (check != "123q")
             * {
             *  MessageBox.Show("Возникла ошибка в работе программы обратитесь к разработчику: [email protected]");
             *  return;
             * }*/
            Application.EnableVisualStyles();
            Application.Run(new MainForm());
            //Proccess2 proc = new Proccess2();
            //proc.Start();
            //proc.StartRedio();
            //ISmtpSender m = new MailSender();
            //m.SendMail("hello");
        }
        public void Start()
        {
            Console.WriteLine("Top 3 Started!");
            for (;;)
            {
                // Console.WriteLine(_net.GetHtmlCode(_link));

                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(_net.GetHtmlCode(@"http://www.stoloto.ru/top3/archive"));
                var el = doc.DocumentNode.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("elem"));
                foreach (HtmlNode node in el)
                {
                    var top = new Top3();

                    var znach = node.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("draw_date"));
                    foreach (HtmlNode b in znach)
                    {
                        var znach2 = node.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("container cleared"));
                        top.date = b.InnerText;
                        // Console.Write(b.InnerText + " ");
                        foreach (HtmlNode f in znach2)
                        {
                            Regex rgx = new Regex(@"[^\d]");
                            top.numbers += (rgx.Replace(f.InnerText, ""));
                        }
                    }
                    top3.Add(top);
                }
                int           limit    = Settings.top3Count;
                int           sequence = Settings.top3Seq;
                int[]         chisla   = { 0, 0, 0 };
                int           counter  = 0;
                List <string> list     = new List <string>();
                foreach (Top3 t in top3)
                {
                    if (counter == limit)
                    {
                        break;
                    }
                    int j = 0;
                    foreach (char v in t.numbers)
                    {
                        int mbr = -1;
                        int.TryParse(v.ToString(), out mbr);
                        if (mbr != -1)
                        {
                            if (sequence > 0)
                            {
                                if ((mbr % 2) == 0)
                                {
                                    chisla[j]++;
                                }
                                else
                                {
                                    if (chisla[j] >= sequence)
                                    {
                                        list.Add((j + 1) + "." + chisla[j].ToString());
                                        chisla[j] = 0;
                                    }
                                    else
                                    {
                                        chisla[j] = 0;
                                    }
                                }
                            }
                            else
                            {
                                if ((mbr % 2) != 0)
                                {
                                    chisla[j]++;
                                }
                                else
                                {
                                    if (chisla[j] >= (sequence * (-1)))
                                    {
                                        list.Add((j + 1) + "." + chisla[j].ToString());
                                        chisla[j] = 0;
                                    }
                                    else
                                    {
                                        chisla[j] = 0;
                                    }
                                }
                            }
                        }
                        j++;
                    }
                    // Console.Write(t.date + " " + t.numbers+" ");
                    // Console.WriteLine("\n");
                    counter++;
                }
                FileWriter fl = new FileWriter();
                foreach (string str in list)
                {
                    string outer = "";
                    if (sequence > 0)
                    {
                        outer = "Четное: Ряд: ";
                    }
                    else
                    {
                        outer = "Нечетное: Ряд: ";
                    }
                    foreach (char c in str)
                    {
                        if (c == '.')
                        {
                            outer += " Подрят: ";
                            continue;
                        }
                        outer += c.ToString();
                    }
                    fl.Save(outer);
                }

                Console.WriteLine("TOP 3 data saved in file!");
                Thread.Sleep(Settings.top3Time * 1000);
            }
        }
        public void Start()
        {
            Console.WriteLine("\t\t\rTop 3 Started!");
            for (;;)
            {
                // Console.WriteLine(_net.GetHtmlCode(_link));
                List <Top3> top3 = new List <Top3>();

                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(_net.GetHtmlCode(@"http://www.stoloto.ru/top3/archive"));
                var el = doc.DocumentNode.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("elem"));
                foreach (HtmlNode node in el)
                {
                    var top = new Top3();

                    var znach = node.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("draw_date"));
                    var zn    = node.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("draw"));
                    foreach (HtmlNode b in znach)
                    {
                        var znach2 = node.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("container cleared"));

                        top.date = b.InnerText;
                        // Console.Write(b.InnerText + " ");
                        foreach (HtmlNode f in znach2)
                        {
                            Regex rgx = new Regex(@"[^\d]");
                            top.numbers += (rgx.Replace(f.InnerText, ""));
                        }
                    }
                    foreach (HtmlNode b in zn)
                    {
                        var tt = b.Descendants("a");
                        foreach (HtmlNode bb in tt)
                        {
                            top.date = bb.InnerHtml;
                        }
                    }

                    top3.Add(top);
                }
                int           limit     = Settings.top3Count;
                int           sequence  = Settings.top3Seq;
                int           Nsequence = Settings.top3NSeq;
                int[]         chisla    = { 0, 0, 0 };
                int[]         chisla2   = { 0, 0, 0 };
                int           counter   = 0;
                List <string> list      = new List <string>();
                List <string> Nlist     = new List <string>();
                List <string> points    = new List <string>();
                List <string> Npoints   = new List <string>();
                foreach (Top3 t in top3)
                {
                    if (counter == limit)
                    {
                        break;
                    }

                    int j = 0;
                    foreach (char v in t.numbers)
                    {
                        int mbr = -1;
                        int.TryParse(v.ToString(), out mbr);
                        if (mbr != -1)
                        {
                            if (sequence > 0 && Nsequence > 0)
                            {
                                if ((mbr % 2) == 0)
                                {
                                    chisla[j]++;

                                    if (chisla[j] >= sequence)
                                    {
                                        list.Add((j + 1) + "." + chisla[j].ToString());
                                        points.Add(t.date);//end;
                                        chisla[j] = 0;
                                    }

                                    if (chisla2[j] >= Nsequence)
                                    {
                                        Nlist.Add((j + 1) + "." + chisla2[j].ToString());
                                        Npoints.Add(t.date);//end;
                                        chisla2[j] = 0;
                                    }
                                    else
                                    {
                                        chisla2[j] = 0;
                                    }
                                }
                                else
                                {
                                    chisla2[j]++;

                                    if (chisla2[j] >= Nsequence)
                                    {
                                        Nlist.Add((j + 1) + "." + chisla2[j].ToString());
                                        Npoints.Add(t.date);//end;
                                        chisla2[j] = 0;
                                    }

                                    if (chisla[j] >= sequence)
                                    {
                                        list.Add((j + 1) + "." + chisla[j].ToString());
                                        points.Add(t.date);//end;
                                        chisla[j] = 0;
                                    }
                                    else
                                    {
                                        chisla[j] = 0;
                                    }
                                }
                            }
                        }
                        j++;
                    }
                    // Console.Write(t.date + " " + t.numbers+" ");
                    // Console.WriteLine("\n");
                    counter++;
                }

                /* if (list.Count == 0 && Nlist.Count == 0)
                 * {
                 *   Console.WriteLine("\t\t\rFor TOP 3 No data...");
                 *   continue;
                 * }*/

                string lastFile = Settings.lastFile;

                string     result = "";
                FileWriter fl     = new FileWriter("TOP3");
                int        index  = 0;
                fl.Write("<html><head></head><body><h2>Четные</h2><table><tr><td>Ряд</td><td>Подряд (раз)</td><td>Тираж</td></tr>");
                foreach (string str in list)
                {
                    string outer = "<tr> ";
                    foreach (char c in str)
                    {
                        if (c == '.')
                        {
                            continue;
                        }
                        outer += "<td>" + c.ToString() + "</td>";
                    }
                    int aqq;
                    int.TryParse(points[index], out aqq);
                    outer += " " + "<td>" + (aqq + Settings.top3Seq - 1) + "</td></tr>";
                    fl.Write(outer);
                    result += outer;
                    index++;
                }
                result = "<h2>Четные</h2><table><tr><td>Ряд</td><td>Подряд (раз)</td><td>Тираж</td></tr>" + result + "</table><br>";

                fl.Write("</table><br><h2>Нечетные</h2><table><tr><td>Ряд</td><td>Подряд (раз)</td><td>Тираж</td></tr>");

                index = 0;
                string result2 = "";
                foreach (string str in Nlist)
                {
                    string outer = "<tr> ";

                    foreach (char c in str)
                    {
                        if (c == '.')
                        {
                            continue;
                        }
                        outer += "<td>" + c.ToString() + "</td>";
                    }
                    int aqq;
                    int.TryParse(Npoints[index], out aqq);
                    outer += " " + "<td>" + (aqq + Settings.top3NSeq - 1) + "</td></tr>";
                    fl.Write(outer);
                    result2 += outer;
                    index++;
                }

                result2 = "<h2>Нечетные</h2><table><tr><td>Ряд</td><td>Подряд (раз)</td><td>Тираж</td></tr>" + result2 + "</table>";
                result += result2;
                result  = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><title> TOP 3</title></head><body>" + result + "</body></html>";

                fl.Write("</table></body></html>");

                Console.WriteLine("\t\t\rTOP 3 data saved in file!\t");

                if (Settings.emailOn == 1)
                {
                    _sender.SendMail(result, "TOP 3");
                }

                /*   if(lastFile != null)
                 * if(fl.NotEqualFile(lastFile, Settings.lastFile))
                 * Settings.soundLoop++;*/
                string tmpmd5 = "";
                if (Settings.top3MD5 != null)
                {
                    tmpmd5 = fl.GetMD5();
                    if (tmpmd5 != null)
                    {
                        if (Settings.top3MD5 != tmpmd5)
                        {
                            Settings.soundLoop++;
                            Console.WriteLine("***Top 3 NEW Combination***");
                            Console.WriteLine("{0} != {1}", Settings.top3MD5, tmpmd5);
                        }
                        else
                        {
                            Console.WriteLine("{0} = {1}", Settings.top3MD5, tmpmd5);
                        }
                    }
                }
                Settings.top3MD5 = fl.GetMD5();
                int timer = 0;
                while (true)
                {
                    if (!Settings.top3Thread)
                    {
                        Console.WriteLine("\t\t\rTop 3 stoped!");
                        return;
                    }

                    if (timer >= Settings.top3Time)
                    {
                        break;
                    }

                    timer++;
                    //Console.WriteLine("Next TOP 3 in {0} ", Settings.top3Time - timer);
                    Thread.Sleep(1000);
                }
            }
        }