Exemplo n.º 1
0
        protected override void OnUpdate()
        {
            lock (ProgressLockObject_)
            {
                float Value = (float)CurSize_ / (float)MaxSize_;
                Updater_.SetProgressValue(Value);
                Updater_.SetContentInfo(UnZipInfo_);

                if (IsDone_)
                {
                    UnZipThread_.Join();
                    UnZipThread_ = null;
                    Updater_.SetProgressID(StageProgressID.CopyResInfoToDocEnd);
                    Updater_.SetProgressValue(1.0f);

                    if (string.IsNullOrEmpty(ErrorInfo_))
                    {
                        StageCode_ = StageCode.Succeeded;
                    }
                    else
                    {
                        StageCode_ = StageCode.Failed;
                        Updater_.SetError(ErrorCode.CopyResInfoToDocFailed, ErrorInfo_);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnEnter()
        {
            Updater_.SetProgressID(StageProgressID.CopyResInfoToDocBegin);
            Updater_.SetProgressValue(0);
            Updater_.ClearError();

            ResPatchInfo PatchInfo = Updater_.GetCurrentResPatchInfo();

            if (PatchInfo == null)
            {
                StageCode_ = StageCode.Failed;
                Updater_.SetError(ErrorCode.GetResPatchInfoListFailed, UpdateTool.ServerVersionInfoPath_);
                return;
            }

            CurSize_            = 0;
            MaxSize_            = 1;
            IsDone_             = false;
            ErrorInfo_          = string.Empty;
            UnZipInfo_          = string.Empty;
            ProgressLockObject_ = new object();

            string PatchDataPath = UpdateTool.DataPath_ + "\\" + Path.GetFileName(PatchInfo.PatchUrl_);

            UnZipThread_ = new Thread(UnZipFunc);
            UnZipThread_.Start(PatchDataPath);
        }
Exemplo n.º 3
0
        private void OnCompletedCallback(string FileName, string ErrorInfo, bool Successed)
        {
            Updater_.SetProgressID(StageProgressID.DownloadResInfoEnd);
            Updater_.SetProgressValue(1.0f);

            if (Successed)
            {
                StageCode_ = StageCode.Succeeded;
            }
            else
            {
                StageCode_ = StageCode.Failed;
                Updater_.SetError(ErrorCode.DownloadResInfoFailed, ErrorInfo);
            }
        }
Exemplo n.º 4
0
        protected override void OnEnter()
        {
            Updater_.SetProgressID(StageProgressID.GetResVersionBegin);
            Updater_.SetProgressValue(0);
            Updater_.ClearError();

            ResVersionInfo VersionInfo = UpdateTool.GetResVersionInfo();

            if (VersionInfo == null)
            {
                StageCode_ = StageCode.Failed;
                Updater_.SetError(ErrorCode.GetResVersionInfoFailed, UpdateTool.VersionInfoPath_);
            }
            else
            {
                Updater_.SetResVersionInfo(VersionInfo);
                Updater_.SetCurrentVersionInfo(VersionInfo.Version_);
                StageCode_ = StageCode.Succeeded;
            }

            Updater_.SetProgressID(StageProgressID.GetResVersionEnd);
            Updater_.SetProgressValue(1.0f);
        }
Exemplo n.º 5
0
        protected override void OnEnter()
        {
            Updater_.SetProgressID(StageProgressID.CheckResVersionBegin);
            Updater_.SetProgressValue(0);
            Updater_.ClearError();

            ResPatchInfoList PatchInfoList = Updater_.GetResPatchInfoList();

            if (PatchInfoList == null)
            {
                PatchInfoList = UpdateTool.GetResPatchInfoList();
                if (PatchInfoList == null)
                {
                    StageCode_ = StageCode.Failed;
                    Updater_.SetError(ErrorCode.GetResPatchInfoListFailed, UpdateTool.ServerVersionInfoPath_);
                    return;
                }

                Updater_.SetResPatchInfoList(PatchInfoList);
            }

            ResPatchInfo PatchInfo = PatchInfoList.GetPatchWithVersion(Updater_.GetCurrentVersionInfo());

            if (PatchInfo != null)
            {
                Updater_.SetCurrentResPatchInfo(PatchInfo);
            }
            else
            {
                SetNextStageID(StageID.Final);
            }

            StageCode_ = StageCode.Succeeded;
            Updater_.SetProgressID(StageProgressID.CheckResVersionEnd);
            Updater_.SetProgressValue(1.0f);
        }
Exemplo n.º 6
0
        protected override void OnEnter()
        {
            Updater_.SetProgressID(StageProgressID.DownloadResBegin);
            Updater_.SetProgressValue(0);
            Updater_.ClearError();
            StageCode_ = StageCode.Continue;

            ResPatchInfo PatchInfo = Updater_.GetCurrentResPatchInfo();

            if (PatchInfo == null)
            {
                StageCode_ = StageCode.Failed;
                Updater_.SetError(ErrorCode.GetResPatchInfoListFailed, UpdateTool.ServerVersionInfoPath_);
                return;
            }

            Updater_.SetContentInfo(string.Format("{0}->{1}", PatchInfo.From_, PatchInfo.To_));

            string       PatchDataPath = Path.Combine(UpdateTool.DataPath_, Path.GetFileName(PatchInfo.PatchUrl_));
            DownloadTask Task          = Downloader.Start(PatchInfo.PatchUrl_, PatchDataPath, PatchInfo.MD5_, true);

            Task.Progress  += OnProgressCallback;
            Task.Completed += OnCompletedCallback;
        }