Exemple #1
0
 private void OnUpdaterUnZip(bool isDone, float progress)
 {
     if (isDone)
     {
         _stateArg.StateInfo = "...解压更新程序完成...";
         EventService.GetInstance().SendEvent((uint)EventId.UpdateStateChange, _stateArg);
         _unzipper.Stop();
         _unzipper = null;
         //清理掉老的AutoUpdate.exe
         string oldp = FileUtil.CombinePath(FileUtil.GetExeRootPath(), "AutoUpdate.exe");
         FileUtil.DeleteFile(oldp);
         //
         string oldp2 = FileUtil.CombinePath(FileUtil.GetExeRootPath(), "AutoUpdate.exe.manifest");
         FileUtil.DeleteFile(oldp2);
         //---开始网络检查
         DoNetworkCheck();
     }
     else
     {
         _stateArg.Progress  = progress;
         _stateArg.StateInfo = "...正在解压更新程序...";
         EventService.GetInstance().SendEvent((uint)EventId.UpdateStateChange, _stateArg);
     }
 }
Exemple #2
0
    /// <summary>
    /// 更新程序EXE 检查
    /// </summary>
    private void DoUpdaterCheck()
    {
        _stateArg.Progress  = 0f;
        _stateArg.StateInfo = "...检查更新程序...";
        EventService.GetInstance().SendEvent((uint)EventId.UpdateStateChange, _stateArg);
        //建立更新程序文件夹
        string updaterDir = FileUtil.CombinePath(FileUtil.GetExeRootPath(), "ArcadeUpdater");

        if (!FileUtil.IsDirectoryExist(updaterDir))
        {
            FileUtil.CreateDirectory(updaterDir);
        }
        //验证更新器是否存在
        string updaterExePath     = FileUtil.CombinePath(updaterDir, "ArcadeUpdater.exe");
        string updaterVersionPath = FileUtil.CombinePath(updaterDir, "ArcadeUpdaterVersion.bytes");
        //
        string updaterCurVersion = "000";

        //不存在一个 就清理目录
        if (!FileUtil.IsFileExist(updaterExePath) || !FileUtil.IsFileExist(updaterVersionPath))
        {
            FileUtil.ClearDirectory(updaterDir);
            //
            updaterCurVersion = "000";
        }
        else
        {
            string rr = System.Text.Encoding.UTF8.GetString(FileUtil.ReadFile(updaterVersionPath));
            if (string.IsNullOrEmpty(rr))
            {
                rr = "000";
            }
            updaterCurVersion = rr.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");
        }
        //
        string newVerisonPath = FileUtil.GetStreamingAssetsPath("ArcadeUpdaterVersion.bytes");
        string newVersion     = System.Text.Encoding.UTF8.GetString(FileUtil.ReadFile(newVerisonPath));

        if (string.IsNullOrEmpty(newVersion))
        {
            newVersion = "f**k";
        }
        newVersion = newVersion.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");
        //
        if (string.Equals(newVersion, updaterCurVersion))
        {
            //不需要更新更新程序
            DoNetworkCheck();
        }
        else
        {
            //需要更新更新程序
            string newArcadeZip = FileUtil.GetStreamingAssetsPath("ArcadeUpdater.zip");
            if (!FileUtil.IsFileExist(newArcadeZip))
            {
                Log.LogE("F**k No ArcadeUpdater.zip");
                //
                DoNetworkCheck();
                return;
            }
            //
            _stateArg.Progress  = 0f;
            _stateArg.StateInfo = "...解压更新程序...";
            EventService.GetInstance().SendEvent((uint)EventId.UpdateStateChange, _stateArg);
            //
            _unzipper = UnZipperMono.GetUnZipper(newArcadeZip, updaterDir, this.OnUpdaterUnZip);
            _unzipper.Begin();
        }
    }