Exemplo n.º 1
0
        static string GetCall(ProgressBar progressBar, string uri)
        {
            var urlItem       = new KuUrlItem();
            var kUDownloaders = new KuDownloaders(progressBar, urlItem);

            return(kUDownloaders.DownloadHtmlString(uri));
        }
Exemplo n.º 2
0
        //static string GetCall(string Url)
        //{
        //    var request = WebRequest.Create(Url);
        //    var response = request.GetResponse();
        //    var dataStream = response.GetResponseStream();

        //    var reader = new StreamReader(dataStream);
        //    var responseFromServer = reader.ReadToEnd();
        //    reader.Close();
        //    response.Close();
        //    return responseFromServer;
        //}

        private static void GetUrlItems(ProgressBar progressBar)
        {
            _mainList = new List <KuUrlItem>();
            try
            {
                var htmlParser = new HtmlParser();

                var iHtmlDocument = htmlParser.Parse(GetCall(progressBar, KuConfigurator.BaseUrl));
                var links         = iHtmlDocument.Links;

                foreach (var link in links)
                {
                    var fullName = link.TextContent;

                    var tmp = new List <string>(fullName.Split(Delimiter, 3));

                    tmp = KuFilter.Normalize(tmp);

                    var isStableVersion = KuFilter.StableVersion(tmp);

                    if (tmp.Count <= 0 || !isStableVersion)
                    {
                        continue;
                    }
                    var urlItem = new KuUrlItem
                    {
                        FullName  = fullName,
                        SplitName = tmp
                    };

                    _mainList.Add(urlItem);
                }
            }
            catch (Exception e)
            {
                Program.Log.LogError("Error", e);
            }
        }
Exemplo n.º 3
0
        public bool DownloadFile(KuUrlItem urlItem)
        {
            var downloader = new File(_progressBar, urlItem);

            return(downloader.Download(urlItem));
        }
Exemplo n.º 4
0
 public KuDownloaders(ProgressBar progressBar, KuUrlItem urlItem)
 {
     _progressBar = progressBar;
     _urlItem     = urlItem;
 }
Exemplo n.º 5
0
 public static bool DownloadFile(ProgressBar progressBar, KuUrlItem urlItem)
 {
     return(DownloadFile(progressBar, urlItem.Uri, urlItem.FilePath, urlItem.FileName));
 }
Exemplo n.º 6
0
 public bool Download(KuUrlItem urlItem)
 {
     return(Download(urlItem.Uri, urlItem.FilePath, urlItem.FileName));
 }
Exemplo n.º 7
0
 public File(ProgressBar progressBar, KuUrlItem urlItem) : base(progressBar, urlItem)
 {
 }
Exemplo n.º 8
0
 public HtmlString(ProgressBar progressBar, KuUrlItem urlItem) : base(progressBar, urlItem)
 {
 }