internal static void CheckAndProcess(bool ForceRefresh, bool UserForced = false)
        {
            bool newFiles = ChangedFolders.Count > 0 || ChangedPackages.Count > 0;

            Logger.LogPrint($"ChangedFolders: {ChangedFolders.Count}\nChangedPackages: {ChangedPackages.Count}");

            if (newFiles)
            {
                InvokeOnStatusUpdate(LocalisationManager.GetString(OsuString.BeatmapManager_LoadingNewFilesOnly));

                ProcessBeatmaps(true);

                if (pulledOnlineStatsOnce) //save some bandwidth when adding a single new song if possible.
                {
                    GetOnlineBeatmapInfo(NewFilesList);
                }
            }

            if ((!newFiles && ForceRefresh) || Beatmaps.Count == 0)
            {
                InvokeOnStatusUpdate(LocalisationManager.GetString(OsuString.BeatmapManager_ReloadingDatabase));
                ProcessBeatmaps(false, !UserForced);
            }

            if (!pulledOnlineStatsOnce)
            {
                GetOnlineBeatmapInfo();
                pulledOnlineStatsOnce = true;
            }

            ChangedFolders.Clear();
            ChangedPackages.Clear();
            NewFilesList.Clear();
        }
Beispiel #2
0
        private void DoUpdate()
        {
            NewFilesList.Clear();
            List <string> lstLinks = new List <string>();

            HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
            WebRequest request = WebRequest.Create(HTMLLink);

            htmlDocument.Load(request.GetResponse().GetResponseStream());
            string             buildNewLink = null;
            bool               moveToRoot   = false;
            HtmlNodeCollection links        = htmlDocument.DocumentNode.SelectNodes("//a");

            foreach (HtmlNode link in links)
            {
                HtmlAttribute att = link.Attributes["href"];

                if (att == null)
                {
                    continue;
                }
                string newLink = att.Value;
                if (!MatchUpdateSign(newLink))
                {
                    continue;
                }
                if (!newLink.StartsWith("http://"))
                {
                    if (newLink.StartsWith("/"))
                    {
                        newLink    = newLink.Remove(0, 1);
                        moveToRoot = true;
                    }
                    if (newLink.StartsWith("wenxue"))
                    {
                        newLink = newLink.Substring(newLink.LastIndexOf("/") + 1);
                    }

                    if (!moveToRoot)
                    {
                        buildNewLink = HTMLLink.Substring(0, HTMLLink.LastIndexOf("/") + 1) + newLink;
                    }
                    else
                    {
                        buildNewLink = HTMLLink.Substring(0, HTMLLink.IndexOf("/", 7) + 1) + newLink;
                        moveToRoot   = false;
                    }
                }
                else
                {
                    buildNewLink = newLink;
                }

                if (!FilesList.Contains(buildNewLink))
                {
                    NewFilesList.Add(buildNewLink);
                }
            }

            if (SortBeforeDownload)
            {
                NewFilesList = DoSort(NewFilesList);
            }
            PreviousStepCount = GetPreviousStepCount();
        }
Beispiel #3
0
 public void Clear()
 {
     FilesList.Clear();
     NewFilesList.Clear();
     ProcessQueue.Clear();
 }
        private void DoUpdate()
        {
            NewFilesList.Clear();
            NewChapterNamesList.Clear();
            List <string> lstLinks = new List <string>();

            //Trust all certificates
            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
            WebRequest request = WebRequest.Create(HTMLLink);

            htmlDocument.Load(request.GetResponse().GetResponseStream(), ContentEncoding);
            string             buildNewLink = null;
            bool               moveToRoot   = false;
            HtmlNodeCollection links        = htmlDocument.DocumentNode.SelectNodes("//a");

            foreach (HtmlNode link in links)
            {
                HtmlAttribute att = link.Attributes["href"];

                if (att == null)
                {
                    continue;
                }
                string newLink = att.Value;
                if (!MatchUpdateSign(newLink))
                {
                    continue;
                }
                if (!newLink.StartsWith("http://") && !newLink.StartsWith("https://"))
                {
                    if (newLink.StartsWith("/"))
                    {
                        newLink    = newLink.Remove(0, 1);
                        moveToRoot = true;
                    }
                    if (newLink.StartsWith("wenxue"))
                    {
                        newLink = newLink.Substring(newLink.LastIndexOf("/") + 1);
                    }

                    if (!moveToRoot)
                    {
                        buildNewLink = HTMLLink.Substring(0, HTMLLink.LastIndexOf("/") + 1) + newLink;
                    }
                    else
                    {
                        int startPoint = HTMLLink.StartsWith("https") ? 8 : 7;
                        buildNewLink = HTMLLink.Substring(0, HTMLLink.IndexOf("/", startPoint) + 1) + newLink;
                        moveToRoot   = false;
                    }
                }
                else
                {
                    buildNewLink = newLink;
                }

                if (!FilesList.Contains(buildNewLink))
                {
                    NewFilesList.Add(buildNewLink);
                    NewChapterNamesList.Add(GetUTF8Content(HTMLLink, link.InnerHtml, ContentEncoding));
                }
            }

            if (SortBeforeDownload)
            {
                NewFilesList = DoSort(NewFilesList);
            }
            PreviousStepCount = GetPreviousStepCount();
        }