Beispiel #1
0
        public override void Run(object input = null)
        {
            logger.Debug("=====START======");
            var lastNumber    = _db.Polls.OrderByDescending(p => p.PageId).FirstOrDefault()?.PageId ?? 0;
            var currentNumber = lastNumber;

            while (currentNumber < 20000)
            {
                try
                {
                    var printStr = _webConnector.Get($"http://w1.c1.rada.gov.ua/pls/radan_gs09/ns_golos_print?g_id={currentNumber}&vid=1", null, Encoding.GetEncoding(1251));
                    try
                    {
                        logger.Debug(currentNumber);
                        GetPoll(currentNumber);
                    }
                    catch (Exception ex)
                    {
                        logger.Debug(ex.Message);
                    }
                }
                catch
                {
                }
                currentNumber++;
            }
            //var number = 15550;
            //GetPoll(number);
        }
        public override void Run(object input = null)
        {
            logger.Debug("=====START======");

            //var printStr = _webConnector.Get($"http://www.cvk.gov.ua/pls/vnd2014/wp039?PT001F01=910", null, Encoding.GetEncoding(1251));
            var printStr   = _webConnector.Get($"http://www.cvk.gov.ua/pls/vnd2014/wp039?PT001F01=914", null, Encoding.GetEncoding(1251));
            var rowMatches = numberRegex.Matches(printStr);

            foreach (Match rowMatch in rowMatches)
            {
                var number  = rowMatch.Groups["number"].Value;
                var deputat = rowMatch.Groups["deputat"].Value;

                var deputatParts = deputat.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                var deputatName = $"{deputatParts[0]} {deputatParts[1].ToUpper()[0]}.{deputatParts[2].ToUpper()[0]}.";

                var deputatEntry = _db.Deputats.FirstOrDefault(p => p.NameWithInitials == deputatName);

                if (deputatEntry != null)
                {
                    deputatEntry.TerrNumber = Convert.ToInt32(number);
                    deputatEntry.IsMajor    = true;
                    _db.SaveChanges();
                }
            }
        }
        private void GetPoll(int pollNumber)
        {
            var str      = _webConnector.Get($"http://w1.c1.rada.gov.ua/pls/radan_gs09/ns_golos?g_id={pollNumber}", null, Encoding.GetEncoding(1251));
            var printStr = _webConnector.Get($"http://w1.c1.rada.gov.ua/pls/radan_gs09/ns_golos_print?g_id={pollNumber}&vid=1", null, Encoding.GetEncoding(1251));

            var title = GetMatch(str, titleRegex, "name");

            if (string.IsNullOrWhiteSpace(title))
            {
                return;
            }
            var pollEntry = _db.Polls.FirstOrDefault(p => p.PageId == pollNumber);

            if (pollEntry != null)
            {
                var number = GetMatch(title, numberRegex, "number");
                pollEntry.SubjectNo = number;
                logger.Debug($"Number: {number}");
                _db.SaveChanges();
            }
        }