Exemplo n.º 1
0
        public void httpOnResponse(WebClient client, string resp)
        {
            try
            {
                var   json  = JObject.Parse(resp);
                MyApp myApp = MyApp.getInstance();
                myApp.loadConfig(json);

                var oldVersion = myApp.getCurrentVersion();
                if (oldVersion == myApp.AppVersion)
                {
                    startMainForm();
                    return;
                }
                JArray readme = (JArray)json["appUpdateReadme"];
                string str    = "";
                foreach (var line in readme)
                {
                    str += (string)line + "\n";
                }
                lblReadme.Text = str;
                appUpdateReset = (bool)json["appUpdateReset"];
                if (appUpdateReset)
                {
                    btnCancel.Text = "退出";
                }
                llDialog.Left    = (this.Width - llDialog.Width) / 2;
                llDialog.Visible = true;;
            }
            catch (Exception e1)
            {
                lblTitle.Text    = "启动出现错误!";
                lblReadme.Text   = e1.Message;
                btnOk.Visible    = false;
                appUpdateReset   = true;
                btnCancel.Text   = "稍后再试";
                llDialog.Visible = true;
            }
        }
Exemplo n.º 2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;

            ThreadStart thread = () =>
            {
                string formCode = String.Format("install.client?appCode={0:G}&curVersion={1:G}", MyApp.AppCode, myApp.getCurrentVersion());
                string url      = MyApp.getInstance().getFormUrl(formCode);
                var    client   = new WebClient();
                client.Encoding = System.Text.Encoding.GetEncoding("utf-8");
                string resp = client.DownloadString(url);

                HttpOnResponse httpResp = httpOnResponse;
                this.Invoke(httpResp, client, resp);
            };

            new Thread(thread).Start();
        }