예제 #1
0
        private void Addtask(string url)
        {
            url = url.Replace("index.php", "2019");
            var result = UrlValidator.IsValidUrl(url, out var country, out var year);

            if (!result && url.EndsWith("/")) //try harder
            {
                url   += "2019";
                result = UrlValidator.IsValidUrl(url, out country, out year);
            }

            if (!result)
            {
                return;
            }

            url = url.ToLower();
            var htmlDocument = new HtmlWeb().Load(url);
            var tableSource  = htmlDocument.DocumentNode.Descendants("Table")
                               .FirstOrDefault(e => e.Attributes["class"].Value == "list-table");
            var tableBody = tableSource?.Descendants("tbody").FirstOrDefault();

            if (tableBody == null)
            {
                return;
            }

            var holidayList = new List <HolidayRow>();

            foreach (var row in tableBody.Descendants("tr").Where(e => e.Attributes["class"].Value == "holiday"))
            {
                holidayList.Add(new HolidayRow(row));
            }

            var knownHolidays = KnownHolidays.GetList(year, holidayList.Exists(e => e.Name.Contains("Orthodox")));

            holidayList.Sort((x, y) => x.Date.CompareTo(y.Date));

            GenerateCSharpFile(knownHolidays, holidayList, htmlDocument, country);
            GenerateDelphiFile(knownHolidays, holidayList, htmlDocument, country);
        }
예제 #2
0
 protected override bool ResolveCore(string source)
 {
     return(UrlValidator.IsValidUrl(source));
 }
예제 #3
0
 protected override string ResolveCore(string source)
 {
     return(UrlValidator.IsValidUrl(source) ? new UriBuilder(source).Uri.ToString() : source);
 }
예제 #4
0
 private Boolean OnCanConnect()
 {
     return(!IsConnecting && !String.IsNullOrWhiteSpace(ProjectUrl) && UrlValidator.IsValidUrl(ProjectUrl));
 }