예제 #1
0
        internal void GetReportData(AgencyReport report)
        {
            string selectionHtml = webClient.DownloadString($"http://{serverName}/{report.Url}");
            var    htmlDoc       = new HtmlDocument();

            htmlDoc.LoadHtml(selectionHtml);

            string format = "1";
            string order  = null;

            var formatOpts = htmlDoc.DocumentNode.SelectNodes("//select[@name='crv_template']//option");

            foreach (var option in formatOpts)
            {
                if (option.NextSibling.InnerText == "Tab-delimited file")
                {
                    format = option.Attributes["value"].Value;
                }
            }
            var orderOpt = htmlDoc.DocumentNode.SelectSingleNode("//select[@name='crv_order']/option");

            if (orderOpt != null)
            {
                order = orderOpt.Attributes["value"].Value;
            }

            NameValueCollection values = new NameValueCollection();

            values.Add("action", "generate");
            values.Add("crv_template", format);
            if (order != null)
            {
                values.Add("crv_order", order);
            }

            webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            byte[] rawBytes = webClient.UploadValues($"http://{serverName}/{report.Url}", "POST", values);
            System.Console.WriteLine(Encoding.ASCII.GetString(rawBytes));
            webClient.Headers.Clear();
        }
        private void AgencyImportButton_Click(object sender, RoutedEventArgs e)
        {
            AgencyReport report = (AgencyReport)ReportList.SelectedItem;

            agencyClient.GetReportData(report);
        }