Пример #1
0
        public async Task Execute()
        {
            try
            {
                LastReport = "";
                using (var client = new AwaredWebClient("", System.Text.Encoding.UTF8))
                {
                    LastReport = await client.GetAsync(ScriptFileUri, "text/xml");
                }
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.NameResolutionFailure)
                {
                    Core.Log("App not connected");
                }
                else
                {
                    throw ex;
                }
            }

            if (LastReport == "")
            {
                return;
            }
            LastReport = LastReport.Substring(LastReport.IndexOf("<?xml ver"));
            Core.WriteConfig(config_oa, LastReport);
            Core.WriteConfig(config_oa_time, DateTime.Now.ToString());
            Parse();
        }
Пример #2
0
 public async Task Execute()
 {
     using (var client = new AwaredWebClient("", System.Text.Encoding.UTF8))
         LastReport = await client.GetAsync(ScriptFileUri, "application/rss+xml");
     LastReport = LastReport.Trim();
     Parse();
     Core.WriteConfig(StorageFile, LastReport);
     Core.WriteConfig(StorageFile + ".time", DateTime.Now.ToString());
 }
Пример #3
0
 private async Task <string> GetUpdateString()
 {
     try
     {
         using (var wc = new AwaredWebClient(UpdateSource, Encoding.UTF8))
         {
             return(await wc.DownloadStringTaskAsync("version.txt"));
         }
     }
     catch (WebException)
     {
         return("");
     }
 }
Пример #4
0
        /// <summary>
        /// 检查更新并存储结果。
        /// </summary>
        /// <param name="force">是否强制更新。</param>
        public async void CheckUpdate(bool force = false)
        {
            await Task.Yield();

            try
            {
                using (var wc = new AwaredWebClient("", System.Text.Encoding.UTF8))
                {
                    wc.Timeout = 5000;
                    var new_meta = await wc.DownloadStringTaskAsync(UpdateSource);

                    var meta_exp   = new_meta.Split(new char[] { ';' }, 2);
                    var local_meta = Core.ReadConfig(LocalStorage + ".ver");

                    if (force)
                    {
                        force = true;
                    }
                    else if (local_meta == "")
                    {
                        force = true;
                    }
                    else if (local_meta.Split(new char[] { ';' }, 2)[0] != meta_exp[0])
                    {
                        force = true;
                    }

                    if (force)
                    {
                        Core.WriteConfig(LocalStorage + ".ver", new_meta);
                        await wc.DownloadFileTaskAsync(meta_exp[1], Path.Combine(Core.ConfigDirectory, LocalStorage));

                        Core.Log("[Hotfix] Module successfully updated - " + LocalStorage);
                    }
                }
            }
            catch (Exception ex)
            {
                Core.Log(ex);
                Core.WriteConfig(LocalStorage + ".ver", "");
            }
        }