Пример #1
0
        public static string start()
        {
            string lastUpdatedDate = ClassFileManagement.getLastLine("dataPhase2/dataATPSingle.txt");

            lastUpdatedDate = lastUpdatedDate.Substring(0, 8);
            deleteLastUpdatedDate(lastUpdatedDate, "dataPhase2/dataATPSingle.txt");

            Boolean      startUpdate = false;
            string       interDate   = "";
            StreamReader sr          = new StreamReader("dataPhase1/listOfDays.txt");

            while (!sr.EndOfStream)
            {
                interDate = sr.ReadLine();
                if (interDate == lastUpdatedDate)
                {
                    startUpdate = true;
                }
                if (startUpdate)
                {
                    string path = "dataPhase1/" + interDate + ".html";
                    getEachTour(interDate, ClassFileManagement.readFile(path));
                }
            }
            sr.Close();
            return("The Phase II is Successfully Updated! Date: " + interDate + ".");
        }
Пример #2
0
        public static string start()
        {
            ClassFileManagement.writeToFile("dataPhase3/coefficientUpcomingATPSingle.txt", "", false);
            string url = "https://olimp.kz/betting/tennis";

            getEachURLTitle(ClassHttpWebRequest.source(url));
            DateTime today = DateTime.Today;

            return("The Phase III is Successfully Updated! Date: " + today.ToString("yyyyMMdd") + ".");
        }
Пример #3
0
        private static void updateLastUpdatedDate(DateTime interDate, DateTime lastUpdatedDate)
        {
            int currentDate = int.Parse(interDate.ToString("yyyyMMdd"));
            int lastDate    = int.Parse(lastUpdatedDate.ToString("yyyyMMdd"));

            if (currentDate > lastDate)
            {
                string line = "\n" + interDate.ToString("yyyyMMdd");
                ClassFileManagement.writeToFile("dataPhase1/listOfDays.txt", line, true);
            }
        }
Пример #4
0
        private static DateTime getLastUpdatedDate()
        {
            int    y = 0, m = 0, d = 0;
            string tempLastDate = ClassFileManagement.getLastLine("dataPhase1/listOfDays.txt");

            y = int.Parse(tempLastDate.Substring(0, 4));
            m = int.Parse(tempLastDate.Substring(4, 2));
            d = int.Parse(tempLastDate.Substring(6, 2));
            DateTime temp = new DateTime(y, m, d);

            return(temp);
        }
Пример #5
0
        public static string start()
        {
            DateTime lastDate  = getLastUpdatedDate();
            DateTime interDate = lastDate.AddDays(-1);
            DateTime today     = DateTime.Today;

            today = today.AddDays(1);
            while (interDate.AddDays(1) <= today)
            {
                string url     = "https://olimp.kz/index.php?action=set_tmz&id=-360&use_DST=0&page=print_res&id=3&day=" + interDate.Day + "&month=" + interDate.Month + "&year=" + interDate.Year;
                string content = ClassHttpWebRequest.source(url);
                if (isResultsAvailable(content) == true)
                {
                    string fileName = interDate.ToString("yyyyMMdd") + ".html";
                    ClassFileManagement.createFile("dataPhase1/", fileName, content);
                    updateLastUpdatedDate(interDate, lastDate);
                }
                interDate = interDate.AddDays(1);
            }
            return("The Phase I is Successfully Updated! Date: " + interDate.Date.AddDays(-1).ToString("yyyyMMdd") + ".");
        }
Пример #6
0
        public static void deleteLastUpdatedDate(string lastDate, string path)
        {
            string line;

            using (StreamReader sr = new StreamReader(path))
            {
                using (StreamWriter sw = new StreamWriter("dataPhase2/temp.txt"))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        string interDate = line.Substring(0, 8);
                        if (int.Parse(interDate) >= int.Parse(lastDate))
                        {
                            continue;
                        }
                        else
                        {
                            sw.WriteLine(line);
                        }
                    }
                }
            }
            ClassFileManagement.replaceFile(path, "dataPhase2/temp.txt");
        }
Пример #7
0
        public static void parseATPSinge(string url, string[] title)
        {
            string sourceCode = ClassHttpWebRequest.source(url);

            for (int i = 0; i != -1; i = sourceCode.IndexOf("(+"))
            {
                string coefficients = "";
                for (int a = 0; a < title.Length; a++)
                {
                    coefficients += title[a] + ",";
                }

                int dateStartIndex = sourceCode.IndexOf("(+") + 16;
                sourceCode = sourceCode.Substring(dateStartIndex, sourceCode.Length - dateStartIndex);

                int    nameEndIndex = sourceCode.IndexOf("</a></span></b></font></td>");
                string eachDateName = sourceCode.Substring(0, nameEndIndex);

                int    nameStartIndex = eachDateName.LastIndexOf(">");
                string playerNames    = eachDateName.Substring(nameStartIndex + 1, eachDateName.Length - nameStartIndex - 1);

                Boolean  isPalyerSingle = true;
                Boolean  isWritable     = true;
                string[] player         = new string[3];
                player = ClassParsePlayersName.parseName(playerNames);
                if (player[0] == "false")
                {
                    isPalyerSingle = false; isWritable = false; continue;
                }

                coefficients += player[1] + ",";
                coefficients += player[2] + ",";

                int d, m, y, h, n;
                try
                {
                    d = int.Parse(eachDateName.Substring(0, 2));
                    m = int.Parse(eachDateName.Substring(3, 2));
                    y = int.Parse(eachDateName.Substring(6, 4));
                    h = int.Parse(eachDateName.Substring(11, 2));
                    n = int.Parse(eachDateName.Substring(14, 2));
                }
                catch (Exception) { isWritable = false;  continue; }

                string date, time, day, month, year, hour, min;
                if (d < 10)
                {
                    day = "0" + d;
                }
                else
                {
                    day = d.ToString();
                }
                if (m < 10)
                {
                    month = "0" + m;
                }
                else
                {
                    month = m.ToString();
                }
                year = y.ToString();
                if (h < 10)
                {
                    hour = "0" + h;
                }
                else
                {
                    hour = h.ToString();
                }
                if (n < 10)
                {
                    min = "0" + n;
                }
                else
                {
                    min = n.ToString();
                }
                date         = year + month + day;
                time         = hour + ":" + min;
                coefficients = time + "," + coefficients;
                coefficients = date + "," + coefficients;

                int    koefsStartIndex = sourceCode.IndexOf("П1") - 64;
                string eachGameKoefs   = sourceCode.Substring(koefsStartIndex, sourceCode.Length - koefsStartIndex);
                eachGameKoefs = eachGameKoefs.Substring(0, eachGameKoefs.IndexOf("Тот(") + 800);

                string koefName = "";
                int    koefTotalOverStartIndex = eachGameKoefs.LastIndexOf("googleStatKef") + 15;
                string koefTotalOver           = eachGameKoefs.Substring(koefTotalOverStartIndex, eachGameKoefs.Length - koefTotalOverStartIndex);
                int    koefTotalOverEndIndex   = koefTotalOver.IndexOf("</span>");
                koefTotalOver = koefTotalOver.Substring(0, koefTotalOverEndIndex);

                int coefCounter = 0;
                for (int a = 0; a != -1; a = eachGameKoefs.IndexOf("googleStatIssueName"))
                {
                    try
                    {
                        int koefNameStartIndex = eachGameKoefs.IndexOf("googleStatIssueName") + 21;
                        eachGameKoefs = eachGameKoefs.Substring(koefNameStartIndex, eachGameKoefs.Length - koefNameStartIndex);

                        int    koefNameEndIndex = eachGameKoefs.IndexOf("googleStatKef") + 40;
                        string eachNameKoef     = eachGameKoefs.Substring(0, eachGameKoefs.Length - koefNameEndIndex);

                        int kNameEndIndex = eachNameKoef.IndexOf("</span>");
                        koefName = eachNameKoef.Substring(0, kNameEndIndex);

                        int    koefStartIndex = eachNameKoef.IndexOf("googleStatKef") + 15;
                        string koef           = eachNameKoef.Substring(koefStartIndex, eachNameKoef.Length - koefStartIndex);

                        int koefEndIndex = koef.IndexOf("</span>");
                        koef = koef.Substring(0, koefEndIndex);

                        if (koefName.Contains("Тот("))
                        {
                            koefName += ":U";
                        }

                        koefName      = ClassParseCoefficientName.parseCoefficientName(koefName);
                        coefficients += koefName + "=" + koef + ",";
                    }
                    catch (Exception) { coefficients = "";  continue; }
                    coefCounter++;
                }

                if (coefCounter != 9)
                {
                    coefficients = ""; continue;
                }

                koefName      = koefName.Substring(0, koefName.Length - 1);
                koefName     += "O";
                coefficients += koefName + "=" + koefTotalOver + "\n";
                if (coefficients.Contains(")=") && coefficients.Contains("):U="))
                {
                    ClassFileManagement.writeToFile("dataPhase3/coefficientUpcomingATPSingle.txt", coefficients, true);
                    isWritable = isCoefficientUnique(date, player[1], player[2]);
                    if (isWritable)
                    {
                        ClassFileManagement.writeToFile("dataPhase3/coefficientATPSingle.txt", coefficients, true);
                    }
                }
                else
                {
                    continue;
                }
            }
        }