Example #1
0
        public async static void GetStaticinIndexAsync(IndexoftheMatch beginindex, IndexoftheMatch endindex, Answer _answ = null, int id_queue = -1, Progress _prog = null)// считывание матчей от индекса а до б(accинхронный)
        {
            if (beginindex.CompareTo(endindex) == 1)
            {
                throw DataExeption.DataProcessingExeptions.ErrorWriteData("Initial index is greater than the final");
            }
            var ChromeService = ChromeDriverService.CreateDefaultService(System.IO.Directory.GetCurrentDirectory());

            ChromeService.HideCommandPromptWindow = true;     //скрываем консоль веб драйвера
            var WebBrowser = new ChromeDriver(ChromeService); //Иницализация веб драйвера Chrome
            int partproc   = endindex.Subtraction(beginindex) + 1;
            var output     = new List <string>();

            _prog(0);
            while (beginindex.CompareTo(endindex) != 1)
            {
                output.AddRange(await GetStaticinIndexHide(beginindex, WebBrowser));
                _prog?.Invoke((100 - endindex.Subtraction(beginindex) * 100 / partproc));
                beginindex.Increment();
            }
            WebBrowser.Quit();
            WebBrowser.Dispose();
            ChromeService.Dispose();
            _answ?.Invoke(output.ToArray(), id_queue);
        }
Example #2
0
 public int Subtraction(IndexoftheMatch _index)//вычетание
 {
     if (_index.type != type)
     {
         throw DataExeption.DataProcessingExeptions.ErrorCompare("It is impossible to subtract indices of different types");
     }
     if (_index.season != season)
     {
         throw DataExeption.DataProcessingExeptions.ErrorCompare("It is impossible to subtract indices of different seasons");
     }
     return(index - _index.index);
 }
Example #3
0
 public int CompareTo(IndexoftheMatch _index)//сравнение идексов
 {
     if (_index.type != type)
     {
         throw DataExeption.DataProcessingExeptions.ErrorCompare("It is impossible to compare indices of different types");
     }
     if (_index.season != season)
     {
         throw DataExeption.DataProcessingExeptions.ErrorCompare("It is impossible to compare indices of different seasons");
     }
     return(index.CompareTo(_index.index));
 }
Example #4
0
        public static string[] GetStaticinIndex(IndexoftheMatch beginindex)//получение показателей по индексу
        {
            var ChromeService = ChromeDriverService.CreateDefaultService(System.IO.Directory.GetCurrentDirectory());

            ChromeService.HideCommandPromptWindow = true;     //скрываем консоль веб драйвера
            var WebBrowser = new ChromeDriver(ChromeService); //Иницализация веб драйвера Chrome
            var output     = GetStaticinIndex(beginindex, WebBrowser);

            WebBrowser.Quit();
            WebBrowser.Dispose();
            ChromeService.Dispose();
            return(output);
        }
Example #5
0
        public static async void GetStaticinIndexAsync(IndexoftheMatch beginindex, Answer _answ = null, int id_queue = -1, Progress _prog = null)//получение показателей по индексу(ассинхронный)
        {
            var ChromeService = ChromeDriverService.CreateDefaultService(System.IO.Directory.GetCurrentDirectory());

            ChromeService.HideCommandPromptWindow = true;     //скрываем консоль веб драйвера
            var WebBrowser = new ChromeDriver(ChromeService); //Иницализация веб драйвера Chrome

            _prog?.Invoke(0);
            var output = await GetStaticinIndexHide(beginindex, WebBrowser);

            _prog?.Invoke(100);
            WebBrowser.Quit();
            WebBrowser.Dispose();
            ChromeService.Dispose();
            _answ?.Invoke(output, id_queue);
        }
Example #6
0
        private static string[] GetStaticinIndex(IndexoftheMatch _index, ChromeDriver chrome)//получение показателей матча
        {
            chrome.Navigate().GoToUrl($"http://stats.nba.com/game/{_index.IndexGame}/");
            IReadOnlyCollection <IWebElement> ListNamesTeam;
            IEnumerator <IWebElement>         ListIndecatorsTeam;

            ListNamesTeam      = chrome.FindElements(By.CssSelector("div.game-summary-team__name a"));
            ListIndecatorsTeam = chrome.FindElements(By.CssSelector("div.nba-stat-table__overflow tfoot td")).GetEnumerator();
            if (ListNamesTeam.Count != 2)
            {
                throw DataExeption.DataProcessingExeptions.ErrorWriteData("Reading names teams");
            }
            string names = "";

            foreach (var _name in ListNamesTeam)
            {
                names += _name.Text + '\t';
            }
            List <string> indecatorsteam = new List <string>();

            while (ListIndecatorsTeam.MoveNext())
            {
                if (ListIndecatorsTeam.Current.Text == "Totals:")
                {
                    if (!ListIndecatorsTeam.MoveNext())
                    {
                        chrome.Quit();
                        chrome.Dispose();
                        ListIndecatorsTeam.Dispose();
                        throw DataExeption.DataProcessingExeptions.ErrorWriteData("Reading indecators");
                    }
                    indecatorsteam.Add(Default.Usual.ReadIndecatorsTeam(ListIndecatorsTeam));
                }
            }
            if (indecatorsteam.Count != 2)
            {
                chrome.Quit();
                chrome.Dispose();
                ListIndecatorsTeam.Dispose();
                throw DataExeption.DataProcessingExeptions.ErrorWriteData("Reading indecators");
            }
            ListIndecatorsTeam.Dispose();
            return(new string[] { names, indecatorsteam[0], indecatorsteam[1] });
        }
Example #7
0
 private static Task <string[]> GetStaticinIndexHide(IndexoftheMatch _index, ChromeDriver chrome)//срытый ассинхорный получение показателей матча
 {
     return(Task.Run(() => GetStaticinIndex(_index, chrome)));
 }