Ejemplo n.º 1
0
        /// <summary>
        /// </summary>
        public static void CheckUpdates()
        {
            try {
                Process[] updaters = Process.GetProcessesByName("FFXIVAPP.Updater");
                foreach (Process updater in updaters)
                {
                    updater.Kill();
                }

                if (File.Exists("FFXIVAPP.Updater.exe"))
                {
                    File.Delete("FFXIVAPP.Updater.Backup.exe");
                }
                else
                {
                    if (File.Exists("FFXIVAPP.Updater.Backup.exe"))
                    {
                        File.Move("FFXIVAPP.Updater.Backup.exe", "FFXIVAPP.Updater.exe");
                    }
                }
            }
            catch (Exception ex) {
                Logging.Log(Logger, new LogItem(ex, true));
            }

            Func <bool> update = delegate {
                var current = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                AppViewModel.Instance.CurrentVersion = current;
                var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/Icehunter/ffxivapp/releases");
                httpWebRequest.UserAgent = "Icehunter-FFXIVAPP";
                httpWebRequest.Headers.Add("Accept-Language", "en;q=0.8");
                httpWebRequest.ContentType = "application/json; charset=utf-8";
                httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                using (var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse()) {
                    using (Stream response = httpResponse.GetResponseStream()) {
                        var responseText = string.Empty;
                        if (response != null)
                        {
                            using (var streamReader = new StreamReader(response)) {
                                responseText = streamReader.ReadToEnd();
                            }
                        }

                        var latestBuild  = new BuildNumber();
                        var currentBuild = new BuildNumber();
                        if (httpResponse.StatusCode != HttpStatusCode.OK || string.IsNullOrWhiteSpace(responseText))
                        {
                            AppViewModel.Instance.HasNewVersion = false;
                            AppViewModel.Instance.LatestVersion = "Unknown";
                        }
                        else
                        {
                            JArray releases = JArray.Parse(responseText);
                            JToken release  = releases.FirstOrDefault(r => r?["target_commitish"].ToString() == "master");
                            var    latest   = release?["name"].ToString() ?? "Unknown";
                            latest = latest.Split(' ')[0];
                            AppViewModel.Instance.LatestVersion = latest;
                            switch (latest)
                            {
                            case "Unknown":
                                AppViewModel.Instance.HasNewVersion = false;
                                break;

                            default:
                                AppViewModel.Instance.DownloadUri   = string.Format("https://github.com/Icehunter/ffxivapp/releases/download/{0}/{0}.zip", latest);
                                AppViewModel.Instance.HasNewVersion = BuildUtilities.NeedsUpdate(latest, current, ref latestBuild, ref currentBuild);
                                break;
                            }

                            if (AppViewModel.Instance.HasNewVersion)
                            {
                                var title   = $"{AppViewModel.Instance.Locale["app_DownloadNoticeHeader"]} {AppViewModel.Instance.Locale["app_DownloadNoticeMessage"]}";
                                var message = new StringBuilder();
                                try {
                                    DateTime latestBuildDateTime  = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * latestBuild.Build + TimeSpan.TicksPerSecond * 2 * latestBuild.Revision));
                                    DateTime currentBuildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * currentBuild.Build + TimeSpan.TicksPerSecond * 2 * currentBuild.Revision));
                                    TimeSpan timeSpan             = latestBuildDateTime - currentBuildDateTime;
                                    if (timeSpan.TotalSeconds > 0)
                                    {
                                        message.AppendLine(string.Format("Missing {0} days, {1} hours and {2} seconds of updates.{3}", timeSpan.Days, timeSpan.Hours, timeSpan.Seconds));
                                    }
                                }
                                catch (Exception ex) {
                                    Logging.Log(Logger, new LogItem(ex, true));
                                }
                                finally {
                                    message.AppendLine(AppViewModel.Instance.Locale["app_AlwaysReadUpdatesMessage"]);
                                }

                                MessageBoxHelper.ShowMessageAsync(title, message.ToString(), () => ShellView.CloseApplication(true), delegate { });
                            }
                        }
                    }
                }

                return(true);
            };

            update.BeginInvoke(delegate { }, update);
        }
Ejemplo n.º 2
0
        public static void LoadAvailablePlugins()
        {
            UpdateView.View.AvailableLoadingInformation.Visibility = Visibility.Visible;
            UpdateViewModel.Instance.AvailablePlugins.Clear();

            UpdateView.View.PluginUpdateSpinner.Spin = true;
            ShellView.View.PluginUpdateSpinner.Spin  = true;

            Func <bool> update = delegate {
                List <PluginSourceItem> pluginSourceList = new List <PluginSourceItem>();
                try {
                    var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://github.com/Icehunter/ffxivapp/raw/master/PACKAGES.json");
                    httpWebRequest.UserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4";
                    httpWebRequest.Headers.Add("Accept-Language", "en;q=0.8");
                    httpWebRequest.ContentType = "application/text; charset=utf-8";
                    httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                    using (var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse()) {
                        using (Stream response = httpResponse.GetResponseStream()) {
                            var responseText = string.Empty;
                            if (response != null)
                            {
                                using (var streamReader = new StreamReader(response)) {
                                    responseText = streamReader.ReadToEnd();
                                }
                            }

                            if (httpResponse.StatusCode == HttpStatusCode.OK || !string.IsNullOrWhiteSpace(responseText))
                            {
                                JArray jsonResult = JArray.Parse(responseText);
                                foreach (JToken jToken in jsonResult)
                                {
                                    bool enabled;
                                    bool.TryParse(jToken["Enabled"].ToString(), out enabled);
                                    var sourceURI = jToken["SourceURI"].ToString();

                                    if (enabled)
                                    {
                                        pluginSourceList.Add(
                                            new PluginSourceItem {
                                            Enabled   = true,
                                            Key       = Guid.NewGuid(),
                                            SourceURI = sourceURI,
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    Logging.Log(Logger, new LogItem(ex, true));
                }

                foreach (PluginSourceItem pluginSourceItem in UpdateViewModel.Instance.AvailableSources)
                {
                    if (pluginSourceList.Any(p => string.Equals(p.SourceURI, pluginSourceItem.SourceURI, Constants.InvariantComparer)))
                    {
                        continue;
                    }

                    pluginSourceList.Add(pluginSourceItem);
                }

                foreach (PluginSourceItem item in pluginSourceList)
                {
                    if (item.Enabled)
                    {
                        try {
                            var httpWebRequest = (HttpWebRequest)WebRequest.Create(item.SourceURI);
                            httpWebRequest.UserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4";
                            httpWebRequest.Headers.Add("Accept-Language", "en;q=0.8");
                            httpWebRequest.ContentType = "application/text; charset=utf-8";
                            httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                            using (var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse()) {
                                using (Stream response = httpResponse.GetResponseStream()) {
                                    var responseText = string.Empty;
                                    if (response != null)
                                    {
                                        using (var streamReader = new StreamReader(response)) {
                                            responseText = streamReader.ReadToEnd();
                                        }
                                    }

                                    if (httpResponse.StatusCode == HttpStatusCode.OK || !string.IsNullOrWhiteSpace(responseText))
                                    {
                                        JObject  jsonResult     = JObject.Parse(responseText);
                                        JToken   pluginInfo     = jsonResult["PluginInfo"];
                                        JToken[] pluginFiles    = pluginInfo["Files"].ToArray();
                                        var      pluginDownload = new PluginDownloadItem {
                                            Files = new List <PluginFile>(
                                                pluginFiles.Select(
                                                    pluginFile => new PluginFile {
                                                Location = pluginFile["Location"].ToString(),
                                                Name     = pluginFile["Name"].ToString(),
                                                Checksum = pluginFile["Checksum"] == null
                                                                       ? string.Empty
                                                                       : pluginFile["Checksum"].ToString(),
                                            })),
                                            Name         = pluginInfo["Name"].ToString(),
                                            FriendlyName = pluginInfo["FriendlyName"] == null
                                                               ? pluginInfo["Name"].ToString()
                                                               : pluginInfo["FriendlyName"].ToString(),
                                            Description = pluginInfo["Description"] == null
                                                              ? string.Empty
                                                              : pluginInfo["Description"].ToString(),
                                            SourceURI     = pluginInfo["SourceURI"].ToString(),
                                            LatestVersion = pluginInfo["Version"].ToString(),
                                        };
                                        PluginInstance found = App.Plugins.Loaded.Find(pluginDownload.Name);
                                        if (found != null)
                                        {
                                            var latest  = pluginDownload.LatestVersion;
                                            var current = found.Instance.Version;
                                            pluginDownload.CurrentVersion = current;
                                            pluginDownload.Status         = PluginStatus.Installed;
                                            var latestBuild  = new BuildNumber();
                                            var currentBuild = new BuildNumber();
                                            if (BuildUtilities.NeedsUpdate(latest, current, ref latestBuild, ref currentBuild))
                                            {
                                                pluginDownload.Status = PluginStatus.UpdateAvailable;
                                                AppViewModel.Instance.HasNewPluginUpdate = true;

                                                DispatcherHelper.Invoke(() => UpdateViewModel.Instance.AvailablePluginUpdates++);
                                            }
                                            else
                                            {
                                                if (!found.Loaded)
                                                {
                                                    pluginDownload.Status = PluginStatus.OutOfDate;
                                                }
                                            }
                                        }

                                        DispatcherHelper.Invoke(() => UpdateViewModel.Instance.AvailablePlugins.Add(pluginDownload));
                                    }
                                }
                            }
                        }
                        catch (Exception ex) {
                            Logging.Log(Logger, new LogItem(ex, true));
                        }
                    }
                }

                DispatcherHelper.Invoke(
                    delegate {
                    if (UpdateView.View.AvailableDG.Items.Count == UpdateViewModel.Instance.AvailablePlugins.Count)
                    {
                        UpdateView.View.AvailableLoadingInformation.Visibility = Visibility.Collapsed;
                    }

                    UpdateView.View.AvailableDG.Items.Refresh();

                    UpdateViewModel.Instance.SetupGrouping();

                    UpdateView.View.PluginUpdateSpinner.Spin = false;
                    ShellView.View.PluginUpdateSpinner.Spin  = false;
                });

                return(true);
            };

            update.BeginInvoke(delegate { }, update);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// </summary>
        public static void CheckUpdates()
        {
            try
            {
                var updaters = Process.GetProcessesByName("FFXIVAPP.Updater");
                foreach (var updater in updaters)
                {
                    updater.Kill();
                }
                if (File.Exists("FFXIVAPP.Updater.exe"))
                {
                    File.Delete("FFXIVAPP.Updater.Backup.exe");
                }
                else
                {
                    if (File.Exists("FFXIVAPP.Updater.Backup.exe"))
                    {
                        File.Move("FFXIVAPP.Updater.Backup.exe", "FFXIVAPP.Updater.exe");
                    }
                }
            }
            catch (Exception ex)
            {
            }
            Func <bool> updateCheck = delegate
            {
                var current = Assembly.GetExecutingAssembly()
                              .GetName()
                              .Version.ToString();
                AppViewModel.Instance.CurrentVersion = current;
                var httpWebRequest = (HttpWebRequest)WebRequest.Create(String.Format("http://ffxiv-app.com/Json/CurrentVersion/"));
                httpWebRequest.UserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4";
                httpWebRequest.Headers.Add("Accept-Language", "en;q=0.8");
                httpWebRequest.ContentType = "application/json; charset=utf-8";
                httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                using (var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse())
                {
                    using (var response = httpResponse.GetResponseStream())
                    {
                        var responseText = "";
                        if (response != null)
                        {
                            using (var streamReader = new StreamReader(response))
                            {
                                responseText = streamReader.ReadToEnd();
                            }
                        }
                        var latestBuild  = new BuildNumber();
                        var currentBuild = new BuildNumber();
                        if (httpResponse.StatusCode != HttpStatusCode.OK || String.IsNullOrWhiteSpace(responseText))
                        {
                            AppViewModel.Instance.HasNewVersion = false;
                            AppViewModel.Instance.LatestVersion = "Unknown";
                        }
                        else
                        {
                            var jsonResult  = JObject.Parse(responseText);
                            var latest      = jsonResult["Version"].ToString();
                            var updateNotes = jsonResult["Notes"].ToList();
                            //var enabledFeatures = jsonResult["Features"];
                            //try
                            //{
                            //    foreach (var feature in enabledFeatures)
                            //    {
                            //        var key = feature["Hash"].ToString();
                            //        var enabled = (bool) feature["Enabled"];
                            //        switch (key)
                            //        {
                            //            case "E9FA3917-ACEB-47AE-88CC-58AB014058F5":
                            //                XIVDBViewModel.Instance.MonsterUploadEnabled = enabled;
                            //                break;
                            //            case "6D2DB102-B1AE-4249-9E73-4ABC7B1947BC":
                            //                XIVDBViewModel.Instance.NPCUploadEnabled = enabled;
                            //                break;
                            //            case "D95ADD76-7DA7-4692-AD00-DB12F2853908":
                            //                XIVDBViewModel.Instance.KillUploadEnabled = enabled;
                            //                break;
                            //            case "6A50A13B-BA83-45D7-862F-F110049E7E78":
                            //                XIVDBViewModel.Instance.LootUploadEnabled = enabled;
                            //                break;
                            //        }
                            //    }
                            //}
                            //catch (Exception ex)
                            //{
                            //}
                            try
                            {
                                foreach (var note in updateNotes.Select(updateNote => updateNote.Value <string>()))
                                {
                                    AppViewModel.Instance.UpdateNotes.Add(note);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBoxHelper.ShowMessage("Error", ex.Message);
                            }
                            AppViewModel.Instance.DownloadUri = jsonResult["DownloadUri"].ToString();
                            latest = (latest == "Unknown") ? "Unknown" : String.Format("3{0}", latest.Substring(1));
                            AppViewModel.Instance.LatestVersion = latest;
                            switch (latest)
                            {
                            case "Unknown":
                                AppViewModel.Instance.HasNewVersion = false;
                                break;

                            default:
                                AppViewModel.Instance.HasNewVersion = BuildUtilities.NeedsUpdate(latest, current, ref latestBuild, ref currentBuild);
                                break;
                            }

                            if (AppViewModel.Instance.HasNewVersion)
                            {
                                var title   = String.Format("{0} {1}", AppViewModel.Instance.Locale["app_DownloadNoticeHeader"], AppViewModel.Instance.Locale["app_DownloadNoticeMessage"]);
                                var message = new StringBuilder();
                                try
                                {
                                    var latestBuildDateTime  = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * latestBuild.Build + TimeSpan.TicksPerSecond * 2 * latestBuild.Revision));
                                    var currentBuildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * currentBuild.Build + TimeSpan.TicksPerSecond * 2 * currentBuild.Revision));
                                    var timeSpan             = latestBuildDateTime - currentBuildDateTime;
                                    if (timeSpan.TotalSeconds > 0)
                                    {
                                        message.AppendLine(String.Format("Missing {0} days, {1} hours and {2} seconds of updates.{3}", timeSpan.Days, timeSpan.Hours, timeSpan.Seconds));
                                    }
                                }
                                catch (Exception ex)
                                {
                                }
                                finally
                                {
                                    message.AppendLine(AppViewModel.Instance.Locale["app_AlwaysReadUpdatesMessage"]);
                                }
                                MessageBoxHelper.ShowMessageAsync(title, message.ToString(), () => ShellView.CloseApplication(true), delegate { });
                            }
                            var uri = "http://ffxiv-app.com/Analytics/Google/?eCategory=Application Launch&eAction=Version Check&eLabel=FFXIVAPP";
                            DispatcherHelper.Invoke(() => MainView.View.GoogleAnalytics.Navigate(uri));
                        }
                    }
                }
                return(true);
            };

            updateCheck.BeginInvoke(null, null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// </summary>
        public static void CheckUpdates()
        {
            try
            {
                var updaters = Process.GetProcessesByName("FFXIVAPP.Updater");
                foreach (var updater in updaters)
                {
                    updater.Kill();
                }
                if (File.Exists("FFXIVAPP.Updater.exe"))
                {
                    File.Delete("FFXIVAPP.Updater.Backup.exe");
                }
                else
                {
                    if (File.Exists("FFXIVAPP.Updater.Backup.exe"))
                    {
                        File.Move("FFXIVAPP.Updater.Backup.exe", "FFXIVAPP.Updater.exe");
                    }
                }
            }
            catch (Exception ex)
            {
            }
            Func <bool> updateCheck = delegate
            {
                var current = Assembly.GetExecutingAssembly()
                              .GetName()
                              .Version.ToString();
                AppViewModel.Instance.CurrentVersion = current;
                var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/Icehunter/ffxivapp/releases");
                httpWebRequest.UserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4";
                httpWebRequest.Headers.Add("Accept-Language", "en;q=0.8");
                httpWebRequest.ContentType = "application/json; charset=utf-8";
                httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                using (var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse())
                {
                    using (var response = httpResponse.GetResponseStream())
                    {
                        var responseText = "";
                        if (response != null)
                        {
                            using (var streamReader = new StreamReader(response))
                            {
                                responseText = streamReader.ReadToEnd();
                            }
                        }
                        var latestBuild  = new BuildNumber();
                        var currentBuild = new BuildNumber();
                        if (httpResponse.StatusCode != HttpStatusCode.OK || String.IsNullOrWhiteSpace(responseText))
                        {
                            AppViewModel.Instance.HasNewVersion = false;
                            AppViewModel.Instance.LatestVersion = "Unknown";
                        }
                        else
                        {
                            var releases = JArray.Parse(responseText);
                            var release  = releases.FirstOrDefault(r => r?["target_commitish"].ToString() == "3.0-stable");
                            var latest   = release?["name"].ToString() ?? "Unknown";
                            latest = latest.Split(' ')[0];
                            AppViewModel.Instance.LatestVersion = latest;
                            switch (latest)
                            {
                            case "Unknown":
                                AppViewModel.Instance.HasNewVersion = false;
                                break;

                            default:
                                AppViewModel.Instance.DownloadUri   = String.Format("https://github.com/Icehunter/ffxivapp/releases/download/{0}/{0}.zip", latest);
                                AppViewModel.Instance.HasNewVersion = BuildUtilities.NeedsUpdate(latest, current, ref latestBuild, ref currentBuild);
                                break;
                            }

                            if (AppViewModel.Instance.HasNewVersion)
                            {
                                var title   = String.Format("{0} {1}", AppViewModel.Instance.Locale["app_DownloadNoticeHeader"], AppViewModel.Instance.Locale["app_DownloadNoticeMessage"]);
                                var message = new StringBuilder();
                                try
                                {
                                    var latestBuildDateTime  = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * latestBuild.Build + TimeSpan.TicksPerSecond * 2 * latestBuild.Revision));
                                    var currentBuildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * currentBuild.Build + TimeSpan.TicksPerSecond * 2 * currentBuild.Revision));
                                    var timeSpan             = latestBuildDateTime - currentBuildDateTime;
                                    if (timeSpan.TotalSeconds > 0)
                                    {
                                        message.AppendLine(String.Format("Missing {0} days, {1} hours and {2} seconds of updates.{3}", timeSpan.Days, timeSpan.Hours, timeSpan.Seconds));
                                    }
                                }
                                catch (Exception ex)
                                {
                                }
                                finally
                                {
                                    message.AppendLine(AppViewModel.Instance.Locale["app_AlwaysReadUpdatesMessage"]);
                                }
                                MessageBoxHelper.ShowMessageAsync(title, message.ToString(), () => ShellView.CloseApplication(true), delegate { });
                            }
                            var uri = "http://ffxiv-app.com/Analytics/Google/?eCategory=Application Launch&eAction=Version Check&eLabel=FFXIVAPP";
                            DispatcherHelper.Invoke(() => MainView.View.GoogleAnalytics.Navigate(uri));
                        }
                    }
                }
                return(true);
            };

            updateCheck.BeginInvoke(null, null);
        }
Ejemplo n.º 5
0
        public static void LoadAvailablePlugins()
        {
            UpdateView.View.AvailableLoadingInformation.Visibility = Visibility.Visible;
            UpdateViewModel.Instance.AvailablePlugins.Clear();

            Func <bool> updateCheck = delegate
            {
                var pluginSourceList = new List <PluginSourceItem>();
                try
                {
                    var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://github.com/Icehunter/ffxivapp/raw/master/PACKAGES.json");
                    httpWebRequest.UserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4";
                    httpWebRequest.Headers.Add("Accept-Language", "en;q=0.8");
                    httpWebRequest.ContentType = "application/text; charset=utf-8";
                    httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                    using (var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse())
                    {
                        using (var response = httpResponse.GetResponseStream())
                        {
                            var responseText = "";
                            if (response != null)
                            {
                                using (var streamReader = new StreamReader(response))
                                {
                                    responseText = streamReader.ReadToEnd();
                                }
                            }
                            if (httpResponse.StatusCode == HttpStatusCode.OK || !String.IsNullOrWhiteSpace(responseText))
                            {
                                var jsonResult = JArray.Parse(responseText);
                                pluginSourceList.AddRange(from item in jsonResult
                                                          let name = item["Name"].ToString()
                                                                     let enabled = Boolean.Parse(item["Enabled"].ToString())
                                                                                   let sourceURI = item["SourceURI"].ToString()
                                                                                                   where enabled
                                                                                                   select new PluginSourceItem
                                {
                                    Enabled   = enabled,
                                    Key       = Guid.NewGuid(),
                                    SourceURI = sourceURI
                                });
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                foreach (var pluginSourceItem in UpdateViewModel.Instance.AvailableSources)
                {
                    if (pluginSourceList.Any(p => String.Equals(p.SourceURI, pluginSourceItem.SourceURI, Constants.InvariantComparer)))
                    {
                        continue;
                    }
                    pluginSourceList.Add(pluginSourceItem);
                }
                foreach (var item in pluginSourceList)
                {
                    if (item.Enabled)
                    {
                        try
                        {
                            var httpWebRequest = (HttpWebRequest)WebRequest.Create(item.SourceURI);
                            httpWebRequest.UserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4";
                            httpWebRequest.Headers.Add("Accept-Language", "en;q=0.8");
                            httpWebRequest.ContentType = "application/text; charset=utf-8";
                            httpWebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                            using (var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse())
                            {
                                using (var response = httpResponse.GetResponseStream())
                                {
                                    var responseText = "";
                                    if (response != null)
                                    {
                                        using (var streamReader = new StreamReader(response))
                                        {
                                            responseText = streamReader.ReadToEnd();
                                        }
                                    }
                                    if (httpResponse.StatusCode == HttpStatusCode.OK || !String.IsNullOrWhiteSpace(responseText))
                                    {
                                        var jsonResult     = JObject.Parse(responseText);
                                        var pluginInfo     = jsonResult["PluginInfo"];
                                        var pluginFiles    = pluginInfo["Files"].ToArray();
                                        var pluginDownload = new PluginDownloadItem
                                        {
                                            Files = new List <PluginFile>(pluginFiles.Select(pluginFile => new PluginFile
                                            {
                                                Location = pluginFile["Location"].ToString(),
                                                Name     = pluginFile["Name"].ToString()
                                            })),
                                            Name          = pluginInfo["Name"].ToString(),
                                            SourceURI     = pluginInfo["SourceURI"].ToString(),
                                            LatestVersion = pluginInfo["Version"].ToString()
                                        };
                                        var found = App.Plugins.Loaded.Find(pluginDownload.Name);
                                        if (found != null)
                                        {
                                            var latest  = pluginDownload.LatestVersion;
                                            var current = found.Instance.Version;
                                            pluginDownload.CurrentVersion = current;
                                            pluginDownload.Status         = PluginStatus.Installed;
                                            var latestBuild  = new BuildNumber();
                                            var currentBuild = new BuildNumber();
                                            if (BuildUtilities.NeedsUpdate(latest, current, ref latestBuild, ref currentBuild))
                                            {
                                                pluginDownload.Status = PluginStatus.UpdateAvailable;
                                                AppViewModel.Instance.HasNewPluginUpdate = true;
                                            }
                                        }
                                        DispatcherHelper.Invoke(() => UpdateViewModel.Instance.AvailablePlugins.Add(pluginDownload));
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        DispatcherHelper.Invoke(delegate
                        {
                            if (UpdateView.View.AvailableDG.Items.Count == UpdateViewModel.Instance.AvailablePlugins.Count)
                            {
                                UpdateView.View.AvailableLoadingInformation.Visibility = Visibility.Collapsed;
                            }
                            UpdateView.View.AvailableDG.Items.Refresh();
                            UpdateViewModel.Instance.SetupGrouping();
                        });
                    }
                }
                return(true);
            };

            updateCheck.BeginInvoke(null, null);
        }