Пример #1
0
        private void GetGitHubInfo()
        {
            string strCode = HttpHelper.Send(JsonGitHub.URL);

            JsonGitHub jsonGitHub = new JsonGitHub(strCode);

            StringWriter swInfo = new StringWriter();

            swInfo.WriteLine("项目名:" + jsonGitHub.versionInfo.Name);
            swInfo.WriteLine("版本号:" + jsonGitHub.versionInfo.Version.ToString());
            swInfo.WriteLine("强制性:" + jsonGitHub.versionInfo.Prerelease.ToString());
            swInfo.WriteLine("日期:" + jsonGitHub.versionInfo.Published_at.ToString());

            foreach (Assets item in jsonGitHub.versionInfo.ArrAssets)
            {
                if (item.Name == "updata.zip")
                {
                    swInfo.WriteLine("文件名:" + item.Name);
                    swInfo.WriteLine("下载数:" + item.Download_count);
                    swInfo.WriteLine("大小:" + item.Size);
                    //下载
                    AddDownloadFile(item.Name, item.Browser_download_url);
                }
            }
            swInfo.WriteLine("更新记录:\r\n" + jsonGitHub.versionInfo.Body);

            this.Invoke((MethodInvoker) delegate()
            {
                txtUpdataInfo.Text = swInfo.ToString();
                labelInfo.Text     = "获取更新完成";
                btnUpdata.Enabled  = true;
            });
        }
Пример #2
0
        /// <summary>
        /// 获取GitHub信息
        /// </summary>
        /// <param name="fileName">需要更新的文件名</param>
        private void GetGitHubInfo(string fileName = "updata.zip")
        {
            string strCode = HttpHelper.Send(GetUrl());

            JsonGitHub jsonGitHub = new JsonGitHub(strCode);

            StringWriter swInfo = new StringWriter();

            try
            {
                swInfo.WriteLine("项目名:" + jsonGitHub.versionInfo.Name);
                swInfo.WriteLine("版本号:" + jsonGitHub.versionInfo.Version.ToString());
                swInfo.WriteLine("强制性:" + jsonGitHub.versionInfo.Prerelease.ToString());
                swInfo.WriteLine("日期:" + jsonGitHub.versionInfo.Published_at.ToString());
            }
            catch (Exception err)
            {
                ActiveUpdataInfo(EnumUpdataStatus.Error, "获取更新信息错误");
            }

            foreach (Assets item in jsonGitHub.versionInfo.ArrAssets)
            {
                if (item.Name == fileName)
                {
                    swInfo.WriteLine("文件名:" + item.Name);
                    swInfo.WriteLine("下载数:" + item.Download_count);
                    swInfo.WriteLine("大小:" + item.Size);
                    //下载
                    AddDownloadFile(item.Name, item.Browser_download_url);
                }
            }
            swInfo.WriteLine("更新记录:\r\n" + jsonGitHub.versionInfo.Body);

            ActiveUpdataInfo(EnumUpdataStatus.GetJson, swInfo.ToString());

            isRunGet = false;
        }