示例#1
0
        private void Install(string[] oPackagePathes)
        {
            Installer installer = new Installer(oPackagePathes);

            installer.SetEventInstalled((_installer) =>
            {
                Installer oInstaller = _installer as Installer;
                if (!oInstaller.IsSucess)
                {
                    if (mInstallCount < 2)
                    {
                        // 如果安装失败则重新加载,一共处理2次
                        LogMessage(MESSAGE_NORMALINFO, "资源安装出错,稍后会重新尝试!");
                        ZEvent oEvent = new ZEvent();
                        oEvent.AddListener(oEvent.GetType().Name, new DelayCaller((_delayCaller) =>
                        {
                            mInstallCount++;
                            LoadRemoteAsset();
                        }));
                        oEvent.DelayNotify(oEvent.GetType().Name, null, 10);
                    }
                    else
                    {
                        LogMessage(MESSAGE_NORMALINFO, "更新失败,请与管理员联系!");
                        CallError();
                    }
                }
                else
                {
                    LogMessage(MESSAGE_NORMALINFO, "更新成功,程序将在稍后启动!");
                    CallProgram();
                }
            });
            installer.Install();
        }
示例#2
0
        public void LoadRemoteAsset()
        {
            WebAllLoader.WebAssetDir[] oDirs = new WebAllLoader.WebAssetDir[InteralVersions.Count];
            for (int i = oDirs.Length - 1; i >= 0; i--)
            {
                VersionData oData             = InteralVersions[i];
                WebAllLoader.WebAssetDir oDir = new WebAllLoader.WebAssetDir();
                oDir.Url      = Settings.ServerPackageUri + "/" + Path.GetFileNameWithoutExtension(oData.Name) + ".zip";
                oDir.SavePath = Settings.LocalPackageUri + "/package/" + Path.GetFileNameWithoutExtension(oData.Name) + ".zip";
                oDirs[i]      = oDir;
            }
            WebAllLoader allLoader = new WebAllLoader();

            allLoader.LoadAll(oDirs);
            allLoader.SetEventAllLoading((_allLoader) =>
            {
                LogMessage(MESSAGE_ASSETPROGRESS, ((int)(_allLoader.FinalProgress * 100)).ToString());
            });
            allLoader.SetEventOnError((_allLoader) =>
            {
                _allLoader.Close();
                LogMessage(MESSAGE_NORMALINFO, "资源下载终止, 稍后将会重新尝试!");
                ZEvent oEvent = new ZEvent();
                oEvent.AddListener(oEvent.GetType().Name, new DelayCaller((_caller) =>
                {
                    LoadRemoteAsset();
                }));
                oEvent.DelayNotify(oEvent.GetType().Name, null, 10);
            });
            allLoader.SetEventAllLoaded((_allLoader) =>
            {
                _allLoader.Close();
                LogMessage(MESSAGE_NORMALINFO, "资源下载完成,等待解压");
                Install(_allLoader.SavePaths);
            });
            allLoader.Start();
        }