Beispiel #1
0
        public async void UpdateAsync()
        {
            try
            {
                httpClient.DefaultRequestHeaders.Add("User-Agent", "Other");

                DepictInfo = string.Format(cultureInfo, "正在向wwww.github.com请求数据......");

                HttpResponseMessage response = await httpClient.GetAsync(github_cri).ConfigureAwait(false);

                DepictInfo = string.Format(cultureInfo, "正在向www.github.com响应数据......");

                if (response.ReasonPhrase == "OK")
                {
                    string _updateJson = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    if (_updateJson != null && _updateJson.Length > 450)
                    {
                        UpdateJsons = javaScriptSerializer.Deserialize <UpdateJsons>(_updateJson);

                        string UpdateVerInfoNumber = UpdateJsons.Tag_name.TrimStart('v');

                        UpdateVersionCompareTo(UpdateVerInfoNumber);
                    }
                }
            }
            catch (HttpRequestException)
            {
                DepictInfo = string.Format(cultureInfo, "GitHub服务器请求异常,更换服务器......请稍后");

                await UpdatesAsync().ConfigureAwait(false);
            }
            catch (TaskCanceledException)
            {
                DepictInfo = string.Format(cultureInfo, "GitHub服务器响应异常,更换服务器......请稍后");

                await UpdatesAsync().ConfigureAwait(false);
            }
            catch (NullReferenceException)
            {
                DepictInfo = string.Format(cultureInfo, "数据解析异常,请通过帮助菜单报告问题!");
            }
        }
Beispiel #2
0
        public async Task UpdatesAsync()
        {
            try
            {
                DepictInfo = string.Format(cultureInfo, "正在向wwww.gitee.com请求数据......");

                HttpResponseMessage response = await httpClient.GetAsync(gitee_uri).ConfigureAwait(false);

                DepictInfo = string.Format(cultureInfo, "正在向www.gitee.com响应数据......");

                if (response.ReasonPhrase == "OK")
                {
                    string _updateJson = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    if (_updateJson != null && _updateJson.Length > 45)
                    {
                        UpdateJsons = javaScriptSerializer.Deserialize <UpdateJsons>(_updateJson);

                        string UpdateVerInfoNumber = UpdateJsons.Tag_name.TrimStart('v');

                        UpdateVersionCompareTo(UpdateVerInfoNumber);
                    }
                }
            }
            catch (HttpRequestException)
            {
                DepictInfo = string.Format(cultureInfo, "服务器请求异常,请检查网络或稍后再试!");
            }
            catch (TaskCanceledException)
            {
                DepictInfo = string.Format(cultureInfo, "服务器响应异常,请检查网络或稍后再试!");
            }
            catch (NullReferenceException)
            {
                DepictInfo = string.Format(cultureInfo, "数据解析异常,请通过帮助菜单报告问题!");
            }
        }