Ejemplo n.º 1
0
    //从服务器下载 version.txt 到 strGameNewVerFile
    public DownloadTaskErrorCode FetchServerVersionFile(string url, string hostName, string savedFile, int timeout, out string errMsg)
    {
        if (!FileOperate.MakeDir(savedFile))
        {
            LogString(HobaText.Format("[FetchServerVersionFile] MakeDir {0} Failed!", savedFile));
        }

        if (FileOperate.IsFileExist(savedFile))
        {
            FileOperate.DeleteFile(savedFile);
        }

        //测试
        //         int filesize2 = (int)SeasideResearch.LibCurlNet.External.CURL_GetUrlFileSize(url, timeout);
        //         LogString(HobaString.Format("c++ url FileSize: {0}, fileSize: {1}", url, filesize2));
        //
        //         int filesize = (int)UpdateUtility.GetUrlFileSizeEx(url, hostName, timeout);
        //         LogString(HobaString.Format("url FileSize: {0}, fileSize: {1}", url, filesize));

        var code = UpdateUtility.GetByUrl(
            url,
            hostName,
            savedFile,
            timeout,          //10s
            null,
            null,
            out errMsg);

        return(code);
    }
Ejemplo n.º 2
0
    public static DownloadTaskErrorCode FetchByUrl(string url, string destFile, int timeout, out string errMsg)
    {
        if (!FileOperate.MakeDir(destFile))
        {
            Common.HobaDebuger.LogWarning(HobaText.Format("[FetchByUrl] MakeDir {0} Failed!", destFile));
        }

        if (FileOperate.IsFileExist(destFile))
        {
            FileOperate.DeleteFile(destFile);
        }

        string hostName = UpdateUtility.GetHostName(url);

        var code = UpdateUtility.GetByUrl(
            url,
            hostName,
            destFile,
            timeout,          //10s
            null,
            null,
            out errMsg);

        return(code);
    }
        private void PerformUpdates(IProjectManager projectManager)
        {
            var updateUtility = new UpdateUtility(_resolver)
            {
                AllowPrereleaseVersions = IncludePrerelease.IsPresent,
                Logger = this,
                Safe   = Safe.IsPresent
            };
            var actions = Enumerable.Empty <Resolver.PackageAction>();

            if (String.IsNullOrEmpty(ProjectName))
            {
                var projectManagers = PackageManager.SolutionManager.GetProjects()
                                      .Select(p => PackageManager.GetProjectManager(p));
                actions = updateUtility.ResolveActionsForUpdate(
                    Id, Version, projectManagers, projectNameSpecified: false);
            }
            else if (projectManager != null)
            {
                actions = updateUtility.ResolveActionsForUpdate(
                    Id, Version, new[] { projectManager }, projectNameSpecified: true);
            }

            if (WhatIf)
            {
                foreach (var action in actions)
                {
                    Log(MessageLevel.Info, Resources.Log_OperationWhatIf, action);
                }

                return;
            }

            _actionExecutor.Execute(actions);
        }
Ejemplo n.º 4
0
        private void DownloadUpgrades()
        {
            try
            {
                DataSet ds = UpdateUtility.GetAvailablePatches(Config.Version);
                if (ds != null && ds.Tables.Count > 0)
                {
                    Kv   kv         = new Kv(ds.Tables[0]);
                    long patchSize  = kv.GetInt32("PatchSize");
                    long setupSize  = kv.GetInt32("SetupSize");
                    int  multiplier = 6;
                    if (patchSize >= (setupSize * multiplier))
                    {
                        if (MessageForm.Confirm(null, MsgE.ConfirmPatchSizeDownload, patchSize + " MB", setupSize + " MB") == DialogResult.No)
                        {
                            return;
                        }
                    }
                    string newVersion      = kv.Get("PatchFile1").Replace(".zip", "");
                    string currentPatchUrl = KeyValues.Instance.GetKeyValue(KeyValueE.PatchUrl).Value;
                    this.Invoke(new UpdateClient.BeginUpdateDelegateKv(UpdateClient.BeginUpdate), kv, currentPatchUrl, newVersion);
                }
            }

            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
Ejemplo n.º 5
0
        public static async Task Update(IProgress <WebDownloadProgress> progress)
        {
            progress = progress ?? new Progress <WebDownloadProgress>();
            var newVersion = await UpdateUtility.CheckNewVersion();

            var app        = AppViewModel.Instance;
            var dispatcher = app.Dispatcher;

            if (newVersion != null && await dispatcher.InvokeAsync(() => Util.MessageBox.Show("New Version available",
                                                                                              $"Do you want to download version {newVersion} now?", MessageBoxButton.YesNo)) == MessageBoxResult.Yes)
            {
                app.Messages.Add("Updating...", MessageType.Working);
                await UpdateUtility.Update(progress);
            }
        }
Ejemplo n.º 6
0
    public static DownloadTaskErrorCode FetchAccountRoleListFile(string url, string hostName, string savedFile, int timeout, out string errMsg)
    {
        if (!FileOperate.MakeDir(savedFile))
        {
            Common.HobaDebuger.LogErrorFormat("[FetchAccountRoleListFile] MakeDir {0} Failed!", savedFile);
        }

        var code = UpdateUtility.GetByUrl(
            url,
            hostName,
            savedFile,
            timeout,          //10s
            null,
            null,
            out errMsg);

        return(code);
    }
Ejemplo n.º 7
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IFileSystem sharedRepositoryFileSystem,
                                     ISharedPackageRepository sharedPackageRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(packageManager, pathResolver, project, localRepository)
                                 {
                                     ConstraintProvider = constraintProvider
                                 };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository. 
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = this;

            foreach (var package in GetPackages(localRepository))
            {
                if (localRepository.Exists(package.Id))
                {
                    using (sourceRepository.StartOperation(RepositoryOperationNames.Update, package.Id, mainPackageVersion: null))
                    {
                        try
                        {
                            // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
                            // being considered for an update.
                            bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
                            var resolver = new ActionResolver()
                            {
                                AllowPrereleaseVersions = allowPrerelease
                            };
                            var updateUtility = new UpdateUtility(resolver)
                            {
                                AllowPrereleaseVersions = allowPrerelease,
                                Safe = Safe
                            };

                            var operations = updateUtility.ResolveActionsForUpdate(package.Id, null, new[] { projectManager }, false);
                            var userOperationExecutor = new ActionExecutor();
                            userOperationExecutor.Execute(operations);
                        }
                        catch (InvalidOperationException e)
                        {
                            if (Console.Verbosity == NuGet.Verbosity.Detailed)
                            {
                                Console.WriteWarning(e.ToString());
                            }
                            else
                            {
                                Console.WriteWarning(e.Message);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IFileSystem sharedRepositoryFileSystem,
                                     ISharedPackageRepository sharedPackageRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem projectSystem)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(packageManager, pathResolver, projectSystem, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = projectSystem.Logger = this;

            foreach (var package in GetPackages(localRepository))
            {
                if (localRepository.Exists(package.Id))
                {
                    using (sourceRepository.StartOperation(RepositoryOperationNames.Update, package.Id, mainPackageVersion: null))
                    {
                        try
                        {
                            // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
                            // being considered for an update.
                            bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
                            var  resolver        = new ActionResolver()
                            {
                                AllowPrereleaseVersions = allowPrerelease
                            };
                            var updateUtility = new UpdateUtility(resolver)
                            {
                                AllowPrereleaseVersions = allowPrerelease,
                                Safe = Safe
                            };

                            var operations            = updateUtility.ResolveActionsForUpdate(package.Id, null, new[] { projectManager }, false);
                            var userOperationExecutor = new ActionExecutor();
                            userOperationExecutor.Execute(operations);
                        }
                        catch (InvalidOperationException e)
                        {
                            if (Console.Verbosity == NuGet.Verbosity.Detailed)
                            {
                                Console.WriteWarning(e.ToString());
                            }
                            else
                            {
                                Console.WriteWarning(e.Message);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
    public IEnumerable Init(string baseDir,
                            string docDir,
                            string libDir,
                            string tmpDir,
                            string updateServerDir1,
                            string updateServerDir2,
                            string updateServerDir3,
                            string clientServerDir,
                            string dynamicServerDir,
                            string dynamicAccountRoleDir)
    {
        strBaseDir = baseDir.NormalizeDir();
        strDocDir  = docDir.NormalizeDir();
        strLibDir  = libDir.NormalizeDir();
        strTmpDir  = tmpDir.NormalizeDir();

        //
        strUpdateServerDir1      = updateServerDir1.NormalizeDir();
        strUpdateServerDir2      = updateServerDir2.NormalizeDir();
        strUpdateServerDir3      = updateServerDir3.NormalizeDir();
        strClientServerDir       = clientServerDir.NormalizeDir();
        strDynamicServerDir      = dynamicServerDir.NormalizeDir();
        strDynamicAccountRoleDir = dynamicAccountRoleDir;

        strUpdateServerHostName1 = UpdateUtility.GetHostName(strUpdateServerDir1);
        strUpdateServerHostName2 = UpdateUtility.GetHostName(strUpdateServerDir2);
        strUpdateServerHostName3 = UpdateUtility.GetHostName(strUpdateServerDir3);
        strClientServerHostName  = UpdateUtility.GetHostName(strClientServerDir);
        strDynamicServerHostName = UpdateUtility.GetHostName(strDynamicServerDir);

        //
        strGameOldVerFile        = strLibDir + strGameOldVerFile;
        strGameNewVerFile        = strLibDir + strGameNewVerFile;
        strUpdateIncFile         = strLibDir + strUpdateIncFile;
        strDownloadPath          = strLibDir + strDownloadPath;
        strServerListXML         = strLibDir + strServerListXML;
        strServerListJSON        = strLibDir + strServerListJSON;
        strAccountRoleListJSON   = strLibDir + strAccountRoleListJSON;
        strErrorLog              = strDocDir + strErrorLog;
        strTempWritePackFileName = strLibDir + strTempWritePackFileName;
        //strAnnoucementFile = strLibDir + strAnnoucementFile;
        //strLibPatcherDir = strLibDir + strLibPatcherDir;
        //strLibPackageDir = strLibDir + strLibPackageDir;
        //strLibPatcherConfigDir = strLibDir + strLibPatcherConfigDir;
        strLibPatcherTmpDir = strLibDir + strLibPatcherTmpDir;
        //strLibAssetBundleDir = strLibDir + strLibAssetBundleDir;

        //create log
        FileOperate.MakeDir(strErrorLog);
        yield return(null);

        _UpdateLog.CreateLog(strErrorLog);
        yield return(null);

        LogString(HobaText.Format("skipUpdate: {0}", EntryPoint.Instance.SkipUpdate));

        LogString(HobaText.Format("baseDir: {0}", strBaseDir));
        LogString(HobaText.Format("docDir: {0}", strDocDir));
        LogString(HobaText.Format("libDir: {0}", strLibDir));
        LogString(HobaText.Format("TmpDir: {0}", strTmpDir));

        LogString(HobaText.Format("updateServerDir1: {0}, updateServerDir2: {1}, updateServerDir3: {2}",
                                  strUpdateServerDir1, strUpdateServerDir2, strUpdateServerDir3));
        LogString(HobaText.Format("clientServerDir: {0}", strClientServerDir));
        LogString(HobaText.Format("dynamicServerDir: {0}", strDynamicServerDir));
        LogString(HobaText.Format("dynamicAccountRoleDir: {0}", strDynamicAccountRoleDir));
        LogString(HobaText.Format("strUpdateServerHostName1: {0}, strUpdateServerHostName2: {1}, strUpdateServerHostName3: {2}",
                                  strUpdateServerHostName1, strUpdateServerHostName2, strUpdateServerHostName3));
        LogString(HobaText.Format("strClientServerHostName: {0}", strClientServerHostName));
        LogString(HobaText.Format("strDynamicServerHostName: {0}", strDynamicServerHostName));
        yield return(null);

        LogString(HobaText.Format("strGameOldVerFile: {0}", strGameOldVerFile));
        LogString(HobaText.Format("strGameNewVerFile: {0}", strGameNewVerFile));
        LogString(HobaText.Format("strUpdateIncFile: {0}", strUpdateIncFile));
        LogString(HobaText.Format("strDownloadPath: {0}", strDownloadPath));
        LogString(HobaText.Format("strServerListXML: {0}", strServerListXML));
        LogString(HobaText.Format("strServerListJSON: {0}", strServerListJSON));
        LogString(HobaText.Format("strAccountRoleListJSON: {0}", strAccountRoleListJSON));
    }
Ejemplo n.º 10
0
        private static void ShowUpdateWindow()
        {
            UpdateUtility window = EditorWindow.GetWindow(typeof(UpdateUtility)) as UpdateUtility;

            window.Init();
        }
Ejemplo n.º 11
0
    private static IEnumerable FetchPackByUrlCoroutine(DownloadMan downloadMan,
                                                       string urlDir, string hostName, string downloadPackName, string strMd5)
    {
        string urlFileName = urlDir + downloadPackName;
        long   dwJupSize   = -1;

        if (dwJupSize <= 0)
        {
            dwJupSize = UpdateUtility.GetUrlFileSizeEx(urlFileName, hostName, DownloadMan.reqTimeOut);
        }

        if (dwJupSize < 0)      //无法取得url文件大小,网络不通重试
        {
            yield return(new WaitForSeconds(1.0f));

            UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateState_DownloadingErrAutoRetry);
            GameUpdateMan.Instance.HotUpdateViewer.SetDownloadInfo_TextUpate(UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_DownloadingErrAutoRetry));
            yield return(null);

            Patcher.Instance.LogString(HobaText.Format("DownloadMan fail to get pack size, file: {0}, host: {1}", urlFileName, hostName));
            yield return(UpdateRetCode.net_err);
        }

        //开始下载
        downloadMan.AddTask(strMd5, urlFileName, hostName, downloadPackName, dwJupSize);
        if (!downloadMan.StartTask(strMd5))
        {
            Patcher.Instance.LogString(HobaText.Format("DownloadMan fail to start download pack, file: {0}", urlFileName));

            yield return(new WaitForSeconds(1.0f));

            UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateState_DownloadingErrAutoRetry);
            GameUpdateMan.Instance.HotUpdateViewer.SetDownloadInfo_TextUpate(UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_DownloadingErrAutoRetry));
            yield return(null);

            Patcher.Instance.LogString(HobaText.Format("DownloadMan fail to start DownloadTask, file: {0}, host: {1}", urlFileName, hostName));
            yield return(UpdateRetCode.net_err);
        }
        else
        {
            Patcher.Instance.LogString(HobaText.Format("DownloadMan StartTask, file: {0}", urlFileName));
        }

        //下载过程
        UpdateInfoUtil.bShowProgress = true;
        DownloadTaskInfo tmpInfo;
        long             taskFinishedSize = 0;
        long             lastFinishedSize = 0;
        int lastTime = System.Environment.TickCount;

        downloadMan.AddDownloadStamp(0, 0);
        int zeroDownloadTime = 0;               //下载量为0的计时,超过10秒无下载量,下载出错重试

        while (downloadMan.IsWorkerRunning())   //
        {
            //Thread.Sleep(100);
            yield return(new WaitForSeconds(0.1f));

            int now     = System.Environment.TickCount;
            int deltaMs = now - lastTime;
            lastTime = now;

            if (downloadMan.FindTask(strMd5, out tmpInfo))
            {
                if (tmpInfo.status.HasError() || tmpInfo.totalSize <= 0.0f)          //下载失败,退出,等待重试
                {
                    yield return(new WaitForSeconds(1.0f));

                    UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateState_DownloadingErrAutoRetry);
                    GameUpdateMan.Instance.HotUpdateViewer.SetDownloadInfo_TextUpate(UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_DownloadingErrAutoRetry));
                    yield return(null);

                    break;
                }

                //更新进度
                {
                    long deltaSize = tmpInfo.finishedSize - lastFinishedSize;

                    if (deltaSize < 10)
                    {
                        zeroDownloadTime += deltaMs;
                    }
                    else
                    {
                        zeroDownloadTime = 0;
                    }

                    downloadMan.AddDownloadStamp(deltaSize, deltaMs);        //下载多少
                    lastFinishedSize = tmpInfo.finishedSize;

                    //新UI
                    CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo();
                    GameUpdateMan.Instance.HotUpdateViewer.SetFileDownloadInfo(
                        updateInfo.curUpdateFileSize + tmpInfo.finishedSize,
                        updateInfo.totalUpdateFileSize,
                        downloadMan.GetDownloadSpeedKBS());

                    float progress = (float)tmpInfo.finishedSize / tmpInfo.totalSize;
                    UpdateInfoUtil.SetProgress(UPDATE_PROGRESS.File, progress);
                    //                             float totalProgress = (float)(updateInfo.curUpdateFileSize + tmpInfo.finishedSize) / updateInfo.totalUpdateFileSize;
                    //                             UpdateInfoUtil.SetProgress(UPDATE_PROGRESS.Total, totalProgress);

                    if (progress < 1.0f)
                    {
                        UpdateInfoUtil.SetDownStatusString(progress);
                        GameUpdateMan.Instance.HotUpdateViewer.SetDownloadInfo_TextUpate(UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_TextUpdate));
                    }
                    else
                    {
                        zeroDownloadTime = 0;
                        UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateStatus_CheckingExistPack);
                        GameUpdateMan.Instance.HotUpdateViewer.SetDownloadInfo_TextUpate(UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_CheckingExistPack));
                    }

                    yield return(null);
                }

                taskFinishedSize = tmpInfo.finishedSize;

                if (zeroDownloadTime >= UpdateConfig.MaxZeroDownloadTime)           //下载为0时间超时
                {
                    break;
                }
            }
            else
            {
                break;              //error
            }
        }
        downloadMan.AddDownloadStamp(0, 0);
        UpdateInfoUtil.bShowProgress = false;

        //这时下载已经完成
        UpdateRetCode ret = UpdateRetCode.success;

        if (Patcher.Instance.IsDownloadDone)
        {
            UpdateInfoUtil.SetStateString(UPDATE_STATE.UpdateStatus_CheckingExistPack);
            GameUpdateMan.Instance.HotUpdateViewer.SetDownloadInfo_TextUpate(UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_CheckingExistPack));
            yield return(null);

            if (downloadMan.FindTask(strMd5, out tmpInfo))
            {
                switch (tmpInfo.status)
                {
                case DownloadTaskStatus.Finished:
                    break;

                case DownloadTaskStatus.Failed:
                {
                    DownloadTaskErrorInfo errInfo;
                    downloadMan.GetTaskErrorInfo(strMd5, out errInfo);

                    if (errInfo.errorCode == DownloadTaskErrorCode.NetworkError && errInfo.errorMessage.Contains("CURLE_PARTIAL_FILE"))
                    {
                        ret = UpdateRetCode.net_partial_file;

                        Patcher.Instance.LogString(HobaText.Format("DownloadMan net_partial_file! file: {0}", urlFileName));
                    }
                    else if (errInfo.errorCode == DownloadTaskErrorCode.Unknown && errInfo.errorMessage.Contains("CURLE_OPERATION_TIMEOUTED"))
                    {
                        ret = UpdateRetCode.operation_timeouted;

                        Patcher.Instance.LogString(HobaText.Format("DownloadMan operation_timeouted! file: {0}", urlFileName));
                    }
                    else
                    {
                        if (errInfo.errorCode == DownloadTaskErrorCode.Md5Dismatch)
                        {
                            ret = UpdateRetCode.md5_not_match;
                        }
                        else if (errInfo.errorCode == DownloadTaskErrorCode.NetworkError)
                        {
                            ret = UpdateRetCode.net_err;
                        }
                        else if (errInfo.errorCode == DownloadTaskErrorCode.IOError)
                        {
                            ret = UpdateRetCode.io_err;
                        }
                        else if (errInfo.errorCode == DownloadTaskErrorCode.UrlArgError)
                        {
                            ret = UpdateRetCode.urlarg_error;
                        }
                        else
                        {
                            ret = UpdateRetCode.download_fail;
                        }

                        Patcher.Instance.LogString(HobaText.Format("DownloadMan fail to download pack, file: {0}, host: {1}, msg: {2}", urlFileName, hostName, errInfo.errorMessage));
                    }
                }
                break;

                default:
                    break;
                }
            }
            else
            {
                ret = UpdateRetCode.download_fail;
                Patcher.Instance.LogString(HobaText.Format("DownloadMan fail to download pack 0, file: {0}", urlFileName));
            }
        }
        else
        {
            ret = UpdateRetCode.download_fail;
            Patcher.Instance.LogString(HobaText.Format("DownloadMan fail to download pack 1, file: {0}, zeroDownloadTime: {1}", urlFileName, zeroDownloadTime));
        }

        yield return(ret);
    }
Ejemplo n.º 12
0
 public static string GetUrlContentType(string url, int timeout)
 {
     return(UpdateUtility.GetUrlContentType(url, UpdateUtility.GetHostName(url), timeout));
 }
Ejemplo n.º 13
0
        private void QueryUpgrade()
        {
            #region Check/Validate Version
            KeyValues.Reresh();
            String versionString = KeyValues.Instance.GetKeyValue(KeyValueE.CurrentVersionNo).Value;

            if (String.IsNullOrEmpty(versionString))
            {
                ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Error, ChatTypeE.OnlineClient, MsgE.InfoNoAvService, 0);
                return;
            }

            Int32 major;
            Int32 minor;
            Int32 build;
            Int32 revision;

            String[] versionParts = versionString.Split('.');

            if (versionParts.Length < 4)
            {
                ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Error, ChatTypeE.OnlineClient, MsgE.InfoNoAvService, 0);
                return;
            }

            if (!Int32.TryParse(versionParts[0], out major))
            {
                ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Error, ChatTypeE.OnlineClient, MsgE.InfoNoAvService, 0);
                return;
            }

            if (!Int32.TryParse(versionParts[1], out minor))
            {
                ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Error, ChatTypeE.OnlineClient, MsgE.InfoNoAvService, 0);
                return;
            }

            if (!Int32.TryParse(versionParts[2], out build))
            {
                ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Error, ChatTypeE.OnlineClient, MsgE.InfoNoAvService, 0);
                return;
            }

            if (!Int32.TryParse(versionParts[3], out revision))
            {
                ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Error, ChatTypeE.OnlineClient, MsgE.InfoNoAvService, 0);
                return;
            }
            #endregion

            #region Upgrade
            Version currentVersion  = new Version(Config.Version);
            Version newVersion      = new Version(major, minor, build, revision);
            Boolean upgradeRequired = false;
            upgradeRequired = UpdateUtility.IsUpgradeRequired(currentVersion, newVersion);

            if (upgradeRequired)
            {
                if (MessageForm.Confirm(null, MsgE.InfoUpgradeAvailable) == DialogResult.Yes)
                {
                    DownloadUpgrades();
                }
            }
            else
            {
                ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Info, ChatTypeE.OnlineClient, MsgE.InfoUpgradeNotRequired, 0);
            }
            #endregion
        }
        private void ReinstallOnePackage(string id, IEnumerable <IProjectManager> projectManagers)
        {
            List <Resolver.PackageAction> actions = new List <Resolver.PackageAction>();
            var projectNameSpecified = !String.IsNullOrEmpty(ProjectName);
            var oldPackage           = projectNameSpecified ?
                                       UpdateUtility.FindPackageToUpdate(
                id, version: null,
                packageManager: PackageManager,
                projectManager: projectManagers.First()) :
                                       UpdateUtility.FindPackageToUpdate(
                id, version: null,
                packageManager: PackageManager,
                projectManagers: projectManagers,
                logger: this);

            if (oldPackage.Item2 == null)
            {
                // we're reinstalling a solution level package
                Log(MessageLevel.Info, VsResources.ReinstallSolutionPackage, oldPackage.Item1);
                if (PackageManager.SourceRepository.Exists(oldPackage.Item1))
                {
                    var resolver = new ActionResolver()
                    {
                        ForceRemove = true
                    };
                    resolver.AddOperation(PackageAction.Uninstall, oldPackage.Item1, new NullProjectManager(PackageManager));

                    var packageFromSource = PackageManager.SourceRepository.FindPackage(
                        oldPackage.Item1.Id,
                        oldPackage.Item1.Version);
                    resolver.AddOperation(PackageAction.Install, packageFromSource, new NullProjectManager(PackageManager));
                    actions.AddRange(resolver.ResolveActions());
                }
                else
                {
                    Log(
                        MessageLevel.Warning,
                        VsResources.PackageRestoreSkipForSolution,
                        oldPackage.Item1.GetFullName());
                }
            }
            else
            {
                var reinstallInfo = new ReinstallInfo(Enumerable.Empty <VirtualProjectManager>());
                var resolver      = new ActionResolver()
                {
                    ForceRemove = true
                };
                foreach (var projectManager in projectManagers)
                {
                    ReinstallPackage(id, projectManager, reinstallInfo, resolver);
                }

                actions.AddRange(resolver.ResolveActions());
            }

            if (WhatIf)
            {
                foreach (var action in actions)
                {
                    Log(MessageLevel.Info, Resources.Log_OperationWhatIf, action);
                }

                return;
            }

            var executor = new ActionExecutor()
            {
                Logger = this,
                PackageOperationEventListener  = this,
                CatchProjectOperationException = true
            };

            executor.Execute(actions);
        }
Ejemplo n.º 15
0
        private void PerformUpdates(IProjectManager projectManager)
        {
            var updateUtility = new UpdateUtility(_resolver)
            {
                AllowPrereleaseVersions = IncludePrerelease.IsPresent,
                Logger = this,
                Safe = Safe.IsPresent
            };
            var actions = Enumerable.Empty<Resolver.PackageAction>();
            if (String.IsNullOrEmpty(ProjectName))
            {
                var projectManagers = PackageManager.SolutionManager.GetProjects()
                    .Select(p => PackageManager.GetProjectManager(p));
                actions = updateUtility.ResolveActionsForUpdate(
                    Id, Version, projectManagers, projectNameSpecified: false);
            }
            else if (projectManager != null)
            {
                actions = updateUtility.ResolveActionsForUpdate(
                    Id, Version, new[] { projectManager }, projectNameSpecified: true);
            }

            if (WhatIf)
            {
                foreach (var action in actions)
                {
                    Log(MessageLevel.Info, Resources.Log_OperationWhatIf, action);
                }

                return;
            }

            _actionExecutor.Execute(actions);
        }
Ejemplo n.º 16
0
    /*         
    void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.GetComponentInChildren<AI>() != null)
        {
            other.gameObject.GetComponentInChildren<AI>().SetUpdatePeriods
                (
                    thinkTime,
                    targetTime,
                    perceptionTime,
                    attackTime
                );
        }
    }

    void OnTriggerExit(Collider other)
    {
        if (other.gameObject.GetComponentInChildren<AI>() != null)
        {
            other.gameObject.GetComponentInChildren<AI>().SetUpdatePeriods
                (
                    thinkTime,
                    targetTime,
                    perceptionTime,
                    attackTime
                );
        }
    }
    */

    void Awake()
    {
        updater = new UpdateUtility(timeBetweenUpdates);
    }