Beispiel #1
0
        public static async void InitializeUpdates()
        {
            string url = String.Empty;

            if (Config.GetSetting("EnableTreeHack") == "False" || string.IsNullOrEmpty(Config.GetSetting("EnableTreeHack")))
            {
                url = Ultima.IsUOP() ? Constants.UOPDownload : Constants.MULDownload;
            }
            else
            {
                url = Ultima.IsUOP() ? Constants.UOPTreeHackDownload : Constants.MULTreeHackDownload;
            }

            var doc = await GetUpdates(url);

            if (doc != null)
            {
                Instance = ((Updates)Utility.MapXmlDocToClass(typeof(Updates), doc));
            }

            foreach (var update in Instance.UpdatesCollection.ToArray())
            {
                string path = Path.Combine(update.Location, update.DisplayName);

                if (File.Exists(path))
                {
                    var localhash = Utility.Md5Checksum(path);
                    if (localhash == update.Hash.ToLower())
                    {
                        Instance.UpdatesCollection.Remove(update);
                    }
                    else
                    {
                        update.Status = AssemblyStatus.Outdated;
                    }
                }
                else
                {
                    update.Status = AssemblyStatus.Outdated;
                }
            }

            if (Instance.UpdatesCollection.Count > 0)
            {
                EventController.InvokeUpdatesRetrieved();

                if (Config.GetSetting("UpdateOnStart") == "True")
                {
                    Update_All();
                }
            }
        }