Ejemplo n.º 1
0
        public static unsafe void CalculateImageDiff(
            IImageDiffView diffView, IProgressControls progressControls,
            byte *leftBitmapData, byte *rightBitmapData, int leftLen, int rightLen)
        {
            if (leftLen != rightLen)
            {
                progressControls.ShowInformation(DIFF_SIZE_INFO_MESSSAGE);
                return;
            }

            byte[] resultDiffImage = null;

            progressControls.ShowProgress();

            IThreadWaiter waiter = ThreadWaiter.GetWaiter();

            waiter.Execute(
                /*threadOperationDelegate*/ delegate
            {
                resultDiffImage = PixelDiff(leftBitmapData, rightBitmapData, leftLen);
            },
                /*afterOperationDelegate*/ delegate
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    progressControls.ShowError(waiter.Exception.Message);
                    return;
                }

                diffView.SetDiffImageBytes(resultDiffImage);
            });
        }
Ejemplo n.º 2
0
        static void DisplayException(
            IProgressControls progressControls,
            Exception ex)
        {
            ExceptionsHandler.LogException(
                "CreateWorkspaceView", ex);

            progressControls.ShowError(
                ExceptionsHandler.GetCorrectExceptionMessage(ex));
        }
Ejemplo n.º 3
0
        static void DisplayException(
            IProgressControls progressControls,
            Exception ex)
        {
            ExceptionsHandler.LogException(
                "MigrationDialog", ex);

            progressControls.ShowError(
                ExceptionsHandler.GetCorrectExceptionMessage(ex));
        }
Ejemplo n.º 4
0
        public void AddElement(
            string element,
            IApplicationWindow window,
            IProgressControls progressControls)
        {
            if (string.IsNullOrEmpty(element))
            {
                progressControls.ShowError(
                    Localization.GetText(
                        Localization.Name.ElementCantBeEmptyErrorMessage));
                return;
            }

            progressControls.ShowProgress(
                Localization.GetText(
                    Localization.Name.AddingElementProgressText,
                    element));

            IThreadWaiter waiter = ThreadWaiter.GetWaiter();

            waiter.Execute(
                threadOperationDelegate: () =>
            {
                DoHeavyWork();

                if (mModel.Contains(element))
                {
                    throw new Exception(
                        Localization.GetText(
                            Localization.Name.ElementInTheListErrorMessage, element));
                }

                mModel.Add(element);
                mModel.Sort(StringComparer.Ordinal);
            },
                afterOperationDelegate: () =>
            {
                progressControls.HideProgress();

                if (waiter.Exception != null)
                {
                    GuiMessage.ShowError(
                        Localization.GetText(Localization.Name.ErrorTitle),
                        waiter.Exception.Message);
                    return;
                }

                window.UpdateItems(mModel);
                window.ClearInput();
            });
        }
Ejemplo n.º 5
0
        void LaunchMigration(
            string unityAccessToken,
            string projectPath,
            string organizationName,
            RepId repId,
            long changesetId,
            long branchId,
            Action afterWorkspaceMigratedAction,
            IProgressControls progressControls)
        {
            string serverName = string.Format(
                "{0}@cloud", organizationName);

            progressControls.ShowProgress(
                "Migrating project to Plastic SCM...");

            TokenExchangeResponse tokenExchangeResponse = null;
            WorkspaceInfo         workspaceInfo         = null;

            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);

                workspaceInfo = CreateWorkspaceFromCollab.Create(
                    projectPath, repInfo.Name, repInfo,
                    changesetId, branchId,
                    new CreateWorkspaceFromCollab.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 ||
                    workspaceInfo == null)
                {
                    progressControls.ShowError(
                        "Failed to migrate the project to Plastic SCM");
                    return;
                }

                progressControls.ShowSuccess(
                    "The project migration to Plastic SCM is completed successfully");

                mIsMigrationCompleted = true;

                afterWorkspaceMigratedAction();
            });
        }