예제 #1
0
        void UpdateRainfalls()
        {
            Thread.Sleep(1000);
            SetProcessBarValue(10);
            SetLableText("正在关闭雨量计...");
            if (!KillRainfallProcess())
            {
                SetLableText("雨量计没有运行,将直接执行安装程序...");
            }
            Thread.Sleep(2000);
            SetProcessBarValue(30);
            SetLableText("开始安装....");
            if (SetupNewSoft())
            {
                Thread.Sleep(2000);
                SetProcessBarValue(90);
                SetLableText("安装完成,准备重启...");
                string szRemoteAppVersion = IniHelper.IniReadValue("APP", "Version", DownloadXMLPath);
                IniHelper.IniWriteValue("基本信息", "软件版本", szRemoteAppVersion, APPBASEPATH);
                IniHelper.IniWriteValue("基本信息", "更新时间", DateTime.Now.ToString(), APPBASEPATH);
                string devid = IniHelper.IniReadValue("基本信息", "更新标识", APPBASEPATH);

                try
                {
                    SetProcessBarValue(100);
                    SetLableText("正在向服务器提交更新完成标识...");

                    string   loginUrl = "http://www.zzdawei.com/app/rainfalls.aspx";
                    Encoding encoding = Encoding.GetEncoding("gb2312");
                    IDictionary <string, string> parameters = new Dictionary <string, string>();
                    parameters.Add("id", devid);
                    parameters.Add("version", szRemoteAppVersion);
                    HttpWebResponse response = HttpWebResponseUtility.CreatePostHttpResponse(loginUrl, parameters, null, null, encoding, null);
                    Thread.Sleep(1000);
                }
                catch (Exception e)
                {
                    SetLableText("提交更新标识失败:" + e.Message);
                }
                SetButtonEnable();
                Thread.Sleep(3000);
                this.Close();
            }
            else
            {
                SetLableText("安装失败,更新程序将自动关闭...");
                SetButtonEnable();
                Thread.Sleep(3000);
            }
        }
예제 #2
0
 public frmUpdate()
 {
     m_pRarFileName = IniHelper.IniReadValue("APP", "File", DownloadXMLPath);;
     InitializeComponent();
 }