예제 #1
0
 private void tmrTimeOut_Tick(object sender, EventArgs e)
 {
     if (isWait)
     {
         WaitDelay++;
         if (WaitDelay > 2)
         {
             if (WaitType == 1)
             {
                 ClientCall.软件版本请求指令(Program.MyGuid, Program.StoreID, 1);
                 isWait    = true;
                 WaitDelay = 0;
                 WaitType  = 1;
             }
             else if (WaitType == 2)
             {
                 ClientCall.载文件("update\\" + Program.CurDownload);
                 WaitType  = 3;
                 WaitDelay = 0;
                 isWait    = true;
             }
             else if (WaitType == 3)
             {
                 Console.WriteLine("下载超时");
                 //WaitType = 2;
                 ClientCall.文件下载超时();
                 WaitDelay = 0;
             }
         }
     }
 }
예제 #2
0
        void CheckUpdate()
        {
            tmrUpdate.Enabled = false;
            switch (checkFlag)
            {
            case 0:         //从磁盘检测
                if (diskID > 5)
                {
                    //lblInfo.Text = "未能从磁盘检测到更新";
                    checkFlag++;
                }
                else
                {
                    string diskName = Convert.ToChar(67 + diskID).ToString();
                    //lblInfo.Text = "正在检测" + diskName + "盘";
                    if (File.Exists(diskName + ":\\" + Program.ProcessName + ".zip"))
                    {
                        //找到相关压缩包
                        tmrUpdate.Enabled = false;
                        //lblInfo.Text = "正在解压缩...";
                        if (Directory.Exists(Application.StartupPath + "\\update\\unzip"))
                        {
                            DeletePath(Application.StartupPath + "\\update\\unzip");
                        }
                        if (UnZip(diskName + ":\\" + Program.ProcessName + ".zip", Application.StartupPath + "\\update\\unzip", "", true))
                        {
                            updateFlag++;
                            tmrCheck.Enabled = true;
                        }
                        else
                        {
                            //lblInfo.Text = "文件解压失败";

                            Application.DoEvents();
                            Thread.Sleep(2000);
                            Application.Exit();
                        }
                    }
                    diskID++;
                }
                break;

            case 1:
                //lblInfo.Text = "从网络检查更新...";

                ClientCall.软件版本请求指令(Program.MyGuid, Program.StoreID, 1);
                isWait    = true;
                WaitDelay = 0;
                WaitType  = 1;
                RequestCount++;
                //if (RequestCount > 5)
                //Application.Exit();
                break;
            }
            tmrUpdate.Enabled = true;
        }