Esempio n. 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;
             }
         }
     }
 }
Esempio n. 2
0
        void CallBackEvent_OnSoftVersionAnswer(TransmiteObject.软件版本号应答结构 soft)
        {
            if (this.InvokeRequired)
            {
                DelegVersionAnswer a = new DelegVersionAnswer(CallBackEvent_OnSoftVersionAnswer);
                this.Invoke(a, soft);
            }
            else
            {
                isWait    = false;
                WaitDelay = 0;

                Console.WriteLine("检测到版本:" + soft.软件版本号);

                string[] myver    = Program.MainVersion.Split('.');
                string[] curver   = soft.软件版本号.Split('.');
                bool     isUpdate = false;
                for (int i = 0; i < myver.Length; i++)
                {
                    if (Convert.ToInt32(myver[i]) < Convert.ToInt32(curver[i]))
                    {
                        isUpdate = true;
                        break;
                    }
                }
                if (isUpdate)
                {
                    //需要升级
                    //lblInfo.Text = "检测到新版本,正在下载...";
                    Program.CurDownload = soft.升级包名;
                    ClientCall.载文件("update\\" + Program.CurDownload);
                    Console.WriteLine("下载文件:" + soft.升级包名);
                    WaitType          = 2;
                    WaitDelay         = 0;
                    isWait            = true;
                    tmrUpdate.Enabled = false;
                }
                else
                {
                    Application.Exit();
                }
            }
        }