示例#1
0
        private void LoadListOfInsolvencyAdministrators(string type)
        {
            var resp = Client.PostAsync(BaseUrl + "/public/seznamAction.do", new FormUrlEncodedContent(new[] {
                new KeyValuePair <string, string>("filtrCast", type),
                new KeyValuePair <string, string>("lastSize", "1000"),
                new KeyValuePair <string, string>("size", "1000"),
                new KeyValuePair <string, string>("size", "1000"),
                new KeyValuePair <string, string>("path", "/public/seznamAction.do"),
            })).Result;
            var content = resp.Content.ReadAsStringAsync().Result;

            var doc = new HtmlDocument();

            doc.LoadHtml(content);

            var rows = doc.DocumentNode.SelectNodes("//table[@border='2']/tr");

            foreach (var row in rows.Skip(1))
            {
                var relativeLink = row.ChildNodes[1].FirstChild.ChildAttributes("href").FirstOrDefault().Value.Replace("..", "");
                var t            = "unknown";
                if (relativeLink.Contains("detailFyzOs"))
                {
                    t = "FO";
                }
                else if (relativeLink.Contains("detailVerObchSpol"))
                {
                    t = "VOS";
                }
                else if (relativeLink.Contains("detailHostSpr"))
                {
                    t = "HOST";
                }
                else
                {
                    throw new ArgumentException("Neznamy typ - " + relativeLink);
                }
                var administrator = new InsolvencyAdministrator
                {
                    Name       = row.ChildNodes[1].InnerText,
                    LinkDetail = BaseUrl + relativeLink,
                    Type       = t,
                    Id         = Convert.ToInt32(relativeLink.Split(new[] { '=', '&' })[1])
                };
                Administrators.Enqueue(administrator);
            }
        }
示例#2
0
        private void LoadInsolvencyAdministratorDetail(InsolvencyAdministrator item)
        {
            var resp = Client.PostAsync(BaseUrl + "/public/osobaDetailAction.do", new FormUrlEncodedContent(new[] {
                new KeyValuePair <string, string>("ukazVsechnyProvozovny", "true"),
                new KeyValuePair <string, string>("typOsoby", item.Type),
                new KeyValuePair <string, string>("idOsoby", item.Id.ToString()),
            })).Result;
            var content = resp.Content.ReadAsStringAsync().Result;

            var doc = new HtmlDocument();

            doc.LoadHtml(content);


            if (item.Type == "VOS")
            {
                item.ICO = GetInputValue(doc, "ico");

                item.OldNames = GetInputValue(doc, "predesleNazvy");
            }
            else if (item.Type == "FO")
            {
                item.SureName     = GetInputValue(doc, "prijmeni");
                item.FirstName    = GetInputValue(doc, "jmeno");
                item.OldSureNames = GetInputValue(doc, "predeslaPrijmeni");
                item.BirthDate    = GetInputDate(doc, "datumNarozeni");

                item.ICO = GetInputValue(doc, "ic");

                item.CanDebtRelief = IsInputChecked(doc, "oddluzeni");
                item.CanKonkurs    = IsInputChecked(doc, "konkurs");
            }

            item.Street   = GetInputValue(doc, "ulice_S");
            item.Zip      = GetInputValue(doc, "psc_S");
            item.Number   = GetInputValue(doc, "cp_S");
            item.City     = GetInputValue(doc, "mesto_S");
            item.District = GetInputValue(doc, "okres_S");

            item.DateOfEstablishment = GetInputDate(doc, "denVzniku");
            item.DateOfExam          = GetInputDate(doc, "datumVykonaniZvlZk");
            item.DateOfSuspension    = GetInputDate(doc, "denPozastaveni");
            item.ReasonOfSuspension  = GetInputValue(doc, "duvodPozastaveni");
            item.DateOfTermination   = GetInputDate(doc, "denZaniku");
            item.ReasonOfTermination = GetInputValue(doc, "duvodZaniku");

            if (item.Type == "VOS")
            {
                item.Companions = doc.DocumentNode.SelectNodes("//table[4]/tr").Skip(1).Select(c => new Companion
                {
                    AdministratorId          = item.Id,
                    Name                     = c.ChildNodes[1].InnerText.Trim(),
                    Surename                 = c.ChildNodes[3].InnerText.Trim(),
                    BirthDate                = GetDate(c.ChildNodes[5].InnerText.Trim()),
                    DateOfSpecialExamination = GetDate(c.ChildNodes.Count > 9 ? c.ChildNodes[9].InnerText.Trim() : ""),
                    CanDebtRelief            = c.ChildNodes[7].SelectSingleNode("//input[@id='oddluzeni']").Attributes.Any(a => a.Name == "checked" || a.Name == "checked/"),
                    CanKonkurs               = c.ChildNodes[7].SelectSingleNode("//input[@id='konkurs']").Attributes.Any(a => a.Name == "checked" || a.Name == "checked/"),
                }).ToList();
            }

            item.BranchOffices = doc.DocumentNode.SelectNodes("//table[@width='100%']")
                                 .Where(c => c.Attributes.Count == 1)
                                 .Select(c => new BranchOffice {
                AdministratorId = item.Id,
                Address         = c.ChildNodes[3].ChildNodes[3].InnerText.Trim(),
                District        = c.ChildNodes[5].ChildNodes[3].InnerText.Trim(),
                Region          = c.ChildNodes[7].ChildNodes[3].InnerText.Trim(),
                IsKonkursBranch = c.ChildNodes[9].ChildNodes[3].InnerText.Trim() == "Ano"
            }).ToList();
        }