コード例 #1
0
 void IWorkspaceWindow.RefreshCheckinProgress(
     CheckinStatus checkinStatus,
     BuildProgressSpeedAndRemainingTime.ProgressData progressData)
 {
     mDeveloperProgressOperationHandler.
     RefreshCheckinProgress(checkinStatus, progressData);
 }
コード例 #2
0
ファイル: UpdateProgress.cs プロジェクト: BaseDorp/TankGame
        internal UpdateProgress(
            UpdateNotifier notifier, string wkPath, string title,
            WorkspaceWindow workspaceWindow)
        {
            mNotifier        = notifier;
            mWkPath          = wkPath;
            mWorkspaceWindow = workspaceWindow;

            mProgressData = new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

            mWorkspaceWindow.Progress.ProgressHeader    = title;
            mWorkspaceWindow.Progress.CanCancelProgress = false;
        }
コード例 #3
0
        internal UpdateProgress(
            UpdateNotifier notifier, string wkPath, string title,
            PlasticGUIClient guiClient)
        {
            mNotifier  = notifier;
            mWkPath    = wkPath;
            mGuiClient = guiClient;

            mProgressData = new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

            mGuiClient.Progress.ProgressHeader    = title;
            mGuiClient.Progress.CanCancelProgress = false;
        }
コード例 #4
0
        internal void DownloadRepositoryToPathIfNeeded(
            string cloudRepository,
            string cloudOrganization,
            string projectPath,
            string unityAccessToken)
        {
            AssetDatabase.DisallowAutoRefresh();

            try
            {
                BuildProgressSpeedAndRemainingTime.ProgressData progressData =
                    new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

                ThreadPool.QueueUserWorkItem(
                    DownloadRepository,
                    new DownloadRepositoryParameters()
                {
                    CloudOrganization = cloudOrganization,
                    CloudRepository   = cloudRepository,
                    ProjectPath       = projectPath,
                    AccessToken       = unityAccessToken
                });

                while (!mOperationFinished)
                {
                    if (mDisplayProgress)
                    {
                        DisplayProgress(
                            mUpdateNotifier.GetUpdateStatus(),
                            progressData,
                            cloudRepository);
                    }

                    Thread.Sleep(150);
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();

                AssetDatabase.AllowAutoRefresh();

                RefreshAsset.UnityAssetDatabase();

                if (!mOperationFailed)
                {
                    AssetMenuItems.Enable();
                    ShowWindow.PlasticAfterDownloadingProject();
                }
            }
        }
コード例 #5
0
        static void DisplayProgress(
            UpdateOperationStatus status,
            BuildProgressSpeedAndRemainingTime.ProgressData progressData,
            string cloudRepository)
        {
            string totalProgressMessage = UpdateProgressRender.
                                          GetProgressString(status, progressData);

            float totalProgressPercent = GetProgressBarPercent.
                                         ForTransfer(status.UpdatedSize, status.TotalSize) / 100f;

            EditorUtility.DisplayProgressBar(
                string.Format("Downloading {0}", cloudRepository),
                totalProgressMessage, totalProgressPercent);
        }
コード例 #6
0
        internal void Refresh(
            CheckinStatus checkinStatus,
            BuildProgressSpeedAndRemainingTime.ProgressData progressData)
        {
            if (checkinStatus == null)
            {
                return;
            }

            var progress = mGuiClient.Progress;

            progress.ProgressHeader = checkinStatus.StatusString;

            if (checkinStatus.Status >= EnumCheckinStatus.eciConfirming)
            {
                progress.CanCancelProgress = false;
            }

            if (checkinStatus.Status == EnumCheckinStatus.eciCancelling)
            {
                return;
            }

            int nowTicks = Environment.TickCount;

            progress.TotalProgressMessage = mProgressRender.GetUploadSize(
                checkinStatus.TransferredSize, checkinStatus.TotalSize, progressData);

            progress.TotalProgressPercent = GetProgressBarPercent.ForTransfer(
                checkinStatus.TransferredSize, checkinStatus.TotalSize) / 100f;

            progress.ShowCurrentBlock = mProgressRender.
                                        NeedShowCurrentBlockForCheckinStatus(checkinStatus, nowTicks);

            string currentFileInfo = mProgressRender.GetCurrentFileInfo(
                checkinStatus.CurrentCheckinBlock, mWkInfo.ClientPath);

            progress.ProgressHeader = currentFileInfo;

            float fileProgressBarValue = GetProgressBarPercent.ForTransfer(
                checkinStatus.CurrentCheckinBlock.UploadedSize,
                checkinStatus.CurrentCheckinBlock.BlockSize) / 100f;

            progress.CurrentBlockProgressPercent = fileProgressBarValue;

            progress.CurrentBlockProgressMessage = mProgressRender.GetCurrentBlockUploadSize(
                checkinStatus.CurrentCheckinBlock, nowTicks);
        }
コード例 #7
0
        internal static string GetProgressString(
            CreateWorkspaceFromCollab.Progress status,
            BuildProgressSpeedAndRemainingTime.ProgressData progressData,
            DateTime now,
            double smoothingFactor,
            string updateProgressCalculatingMessage,
            string updateProgressSingularMessage,
            string updateProgressPluralMessage,
            string remainingMessage)
        {
            if (status.CurrentStatus == CreateWorkspaceFromCollab.Progress.Status.Starting)
            {
                return(updateProgressCalculatingMessage);
            }

            progressData.StartTimerIfNotStarted(now);

            string updatedSize;
            string totalSize;

            GetFormattedSizes.ForTransfer(
                status.ProcessedSize,
                status.TotalSize,
                out updatedSize,
                out totalSize);

            string details = string.Format(
                status.TotalFiles == 1 ?
                updateProgressSingularMessage :
                updateProgressPluralMessage,
                updatedSize,
                totalSize,
                status.ProcessedFiles,
                status.TotalFiles,
                BuildProgressSpeedAndRemainingTime.ForTransfer(
                    progressData,
                    now,
                    status.TotalSize,
                    status.ProcessedSize,
                    smoothingFactor,
                    remainingMessage));

            return(details);
        }
コード例 #8
0
        static void UpdateProgress(string wkPath,
                                   CreateWorkspaceFromCollab.Progress progress,
                                   ProgressControlsForMigration progressControls,
                                   BuildProgressSpeedAndRemainingTime.ProgressData progressData)
        {
            string header = MigrationProgressRender.FixNotificationPath(
                wkPath, progress.CurrentFile);

            string message = MigrationProgressRender.GetProgressString(
                progress,
                progressData,
                DateTime.Now,
                0.05,
                "Calculating...",
                "Converted {0} of {1}bytes ({2} of 1 file){4}",
                "Converted {0} of {1}bytes ({2} of {3} files {4})",
                "remaining");

            float percent = GetProgressBarPercent.ForTransfer(
                progress.ProcessedSize, progress.TotalSize) / 100f;

            progressControls.ShowProgress(header, message, percent);
        }
コード例 #9
0
        internal void DownloadRepositoryToPathIfNeeded(
            string cloudRepository,
            string cloudOrganization,
            string projectPath)
        {
            var allowAutoRefreshFeature = new AssetDatabase().GetType().GetMethod("DisallowAutoRefresh") != null;

            #if allowAutoRefreshFeature
            AssetDatabase.DisallowAutoRefresh();
            #endif

            try
            {
                BuildProgressSpeedAndRemainingTime.ProgressData progressData =
                    new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

                ThreadPool.QueueUserWorkItem(
                    DownloadRepository,
                    new DownloadRepositoryParameters()
                {
                    CloudOrganization = cloudOrganization,
                    CloudRepository   = cloudRepository,
                    ProjectPath       = projectPath,
                    AccessToken       = CloudProjectSettings.accessToken
                });

                while (!mOperationFinished)
                {
                    if (mDisplayProgress)
                    {
                        DisplayProgress(
                            mUpdateNotifier.GetUpdateStatus(),
                            progressData,
                            cloudRepository);
                    }

                    Thread.Sleep(150);
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();

                #if allowAutoRefreshFeature
                AssetDatabase.AllowAutoRefresh();
                #endif

                DisableCollabIfEnabled(projectPath);

                RefreshAsset.UnityAssetDatabase();

                if (!mOperationFailed)
                {
                    // we just download a cloud project,
                    // so let's assume we're going to use Cloud Edition
                    SetupUnityEditionToken.ToCloud();

                    ShowWindow.Plastic();
                }
            }
        }
コード例 #10
0
 internal void RefreshCheckinProgress(
     CheckinStatus checkinStatus,
     BuildProgressSpeedAndRemainingTime.ProgressData progressData)
 {
     mCheckinProgress.Refresh(checkinStatus, progressData);
 }
コード例 #11
0
        void PartialUpdateWorkspace()
        {
            mProgressControls.ShowProgress(PlasticLocalization.GetString(
                                               PlasticLocalization.Name.UpdatingWorkspace));

            ((IUpdateProgress)mGluonProgressOperationHandler).ShowCancelableProgress();

            OutOfDateUpdater outOfDateUpdater = new OutOfDateUpdater(mWkInfo);

            BuildProgressSpeedAndRemainingTime.ProgressData progressData =
                new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

            IThreadWaiter waiter = ThreadWaiter.GetWaiter();

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                outOfDateUpdater.Execute();
            },
                /*afterOperationDelegate*/ delegate
            {
                mProgressControls.HideProgress();

                ((IUpdateProgress)mGluonProgressOperationHandler).EndProgress();

                mViewHost.RefreshView(ViewType.CheckinView);
                mViewHost.RefreshView(ViewType.IncomingChangesView);

                RefreshAsset.UnityAssetDatabase();

                if (waiter.Exception != null)
                {
                    ExceptionsHandler.DisplayException(waiter.Exception);
                    return;
                }

                ShowUpdateReportDialog(
                    mWkInfo, mViewHost, outOfDateUpdater.Progress, mProgressControls,
                    mGuiMessage, mGluonProgressOperationHandler, this);
            },
                /*timerTickDelegate*/ delegate
            {
                UpdateProgress progress = outOfDateUpdater.Progress;

                if (progress == null)
                {
                    return;
                }

                if (progress.IsCanceled)
                {
                    mProgressControls.ShowNotification(
                        PlasticLocalization.GetString(PlasticLocalization.Name.Canceling));
                }

                ((IUpdateProgress)mGluonProgressOperationHandler).RefreshProgress(
                    progress,
                    UpdateProgressDataCalculator.CalculateProgressForWorkspaceUpdate(
                        mWkInfo.ClientPath, progress, progressData));
            });
        }
コード例 #12
0
        void LaunchMigration(
            string unityAccessToken,
            string projectPath,
            string organizationName,
            RepId repId,
            long changesetId,
            long branchId,
            Action afterWorkspaceMigratedAction,
            ProgressControlsForMigration progressControls)
        {
            string serverName = string.Format(
                "{0}@cloud", organizationName);

            TokenExchangeResponse tokenExchangeResponse = null;

            mWorkspaceInfo = null;

            CreateWorkspaceFromCollab.Progress progress = new CreateWorkspaceFromCollab.Progress();

            BuildProgressSpeedAndRemainingTime.ProgressData progressData =
                new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

            waiter.Execute(
                /*threadOperationDelegate*/
                delegate
            {
                tokenExchangeResponse = AutoConfig.PlasticCredentials(
                    unityAccessToken,
                    serverName,
                    projectPath);

                if (tokenExchangeResponse.Error != null)
                {
                    return;
                }

                RepositoryInfo repInfo = new BaseCommandsImpl().
                                         GetRepositoryInfo(repId, serverName);

                if (repInfo == null)
                {
                    return;
                }

                repInfo.SetExplicitServer(serverName);

                mWorkspaceInfo = CreateWorkspaceFromCollab.Create(
                    projectPath, repInfo.Name, repInfo,
                    changesetId, branchId,
                    progress);
            },
                /*afterOperationDelegate*/
                delegate
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    DisplayException(progressControls, waiter.Exception);
                    TrackWorkspaceMigrationFinishedFailureEvent(mWorkspaceInfo);
                    return;
                }

                if (tokenExchangeResponse.Error != null)
                {
                    mLog.ErrorFormat(
                        "Unable to get TokenExchangeResponse: {0} [code {1}]",
                        tokenExchangeResponse.Error.Message,
                        tokenExchangeResponse.Error.ErrorCode);
                }

                if (tokenExchangeResponse.Error != null ||
                    mWorkspaceInfo == null)
                {
                    progressControls.ShowError(
                        "Failed to convert your workspace to Plastic SCM");
                    TrackWorkspaceMigrationFinishedFailureEvent(mWorkspaceInfo);
                    return;
                }

                progressControls.ShowSuccess(
                    "Your workspace has been successfully converted to Plastic SCM");

                mIsMigrationCompleted = true;

                TrackFeatureUseEvent.For(
                    PlasticGui.Plastic.API.GetRepositorySpec(mWorkspaceInfo),
                    TrackFeatureUseEvent.Features.WorkspaceMigrationFinishedSuccess);

                afterWorkspaceMigratedAction();
            },
                /*timerTickDelegate*/
                delegate
            {
                UpdateProgress(projectPath, progress, progressControls, progressData);
            });
        }
コード例 #13
0
        void LaunchMigration(
            string unityAccessToken,
            string projectPath,
            string organizationName,
            RepId repId,
            long changesetId,
            long branchId,
            Action afterWorkspaceMigratedAction,
            ProgressControlsForMigration progressControls)
        {
            string serverName = string.Format(
                "{0}@cloud", organizationName);

            TokenExchangeResponse tokenExchangeResponse = null;

            mWorkspaceInfo = null;

            CreateWorkspaceFromCollab.Progress progress = new CreateWorkspaceFromCollab.Progress();

            BuildProgressSpeedAndRemainingTime.ProgressData progressData =
                new BuildProgressSpeedAndRemainingTime.ProgressData(DateTime.Now);

            IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);

            waiter.Execute(
                /*threadOperationDelegate*/
                delegate
            {
                // we just migrate a cloud project,
                // so let's assume we're going to use Cloud Edition
                SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded();

                if (!ClientConfig.IsConfigured())
                {
                    AutoConfigClientConf.FromUnityAccessToken(
                        unityAccessToken, serverName, projectPath);
                }

                tokenExchangeResponse = WebRestApiClient.
                                        PlasticScm.TokenExchange(unityAccessToken);

                if (tokenExchangeResponse.Error != null)
                {
                    return;
                }

                CloudEditionWelcomeWindow.JoinCloudServer(
                    serverName,
                    tokenExchangeResponse.User,
                    tokenExchangeResponse.AccessToken);

                RepositoryInfo repInfo = new BaseCommandsImpl().
                                         GetRepositoryInfo(repId, serverName);

                if (repInfo == null)
                {
                    return;
                }

                repInfo.SetExplicitServer(serverName);

                mWorkspaceInfo = CreateWorkspaceFromCollab.Create(
                    projectPath, repInfo.Name, repInfo,
                    changesetId, branchId,
                    progress);
            },
                /*afterOperationDelegate*/
                delegate
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    DisplayException(progressControls, waiter.Exception);
                    return;
                }

                if (tokenExchangeResponse.Error != null)
                {
                    mLog.ErrorFormat(
                        "Unable to get TokenExchangeResponse: {0} [code {1}]",
                        tokenExchangeResponse.Error.Message,
                        tokenExchangeResponse.Error.ErrorCode);
                }

                if (tokenExchangeResponse.Error != null ||
                    mWorkspaceInfo == null)
                {
                    progressControls.ShowError(
                        "Failed to convert your workspace to Plastic SCM");
                    return;
                }

                progressControls.ShowSuccess(
                    "Your workspace has been successfully converted to Plastic SCM");

                mIsMigrationCompleted = true;

                afterWorkspaceMigratedAction();
            },
                /*timerTickDelegate*/
                delegate
            {
                UpdateProgress(projectPath, progress, progressControls, progressData);
            });
        }