Exemplo n.º 1
0
 private void DownloadCoreToolsCompleted(string source, object value, Exception exception)
 {
     if (exception != null)
     {
         solutionPackagerControl.WriteErrorLog("The following error occured while downloading core tools: \r\n{0}", exception);
         MessageBox.Show(exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (value is string errorMessage)
     {
         MessageBox.Show(errorMessage, Resources.MBOX_INFORMATION, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (value is Version version)
     {
         toolViewModel.SolutionPackagerVersion = version.ToString();
     }
 }
Exemplo n.º 2
0
        private void WorkAsyncEnded(object sender, System.ComponentModel.RunWorkerCompletedEventArgs args)
        {
            if (args.Error != null)
            {
                solutionPackagerControl.WriteErrorLog("The following error occurred while checking the solution import status:\r\n{0}", args.Error);
                MessageBox.Show(args.Error.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                timer.Start();
                return;
            }

            if (!(args.Result is ImportSolutionStatus result))
            {
                timer.Start();
                return;
            }

            if (result.AsyncOperation == null)
            {
                lblJobStatus.Text      = string.Format(Resources.ASYNC_JOB_NOT_FOUND, asyncJobId);
                lblJobStatus.ForeColor = Color.Red;
                return;
            }

            var asyncOperation = result.AsyncOperation;
            var importJob      = result.ImportJob;

            lblJobStatus.Text   = asyncOperation.StatusCode?.ToString();
            lblCreatedOn.Text   = asyncOperation.CreatedOn?.ToString();
            lblStartedOn.Text   = asyncOperation.StartedOn?.ToString();
            lblCompletedOn.Text = asyncOperation.CompletedOn?.ToString();

            if (asyncOperation.ErrorCode.HasValue && Enum.IsDefined(typeof(ImportErrorCodes), asyncOperation.ErrorCode.Value))
            {
                ImportErrorCodes errorCode = (ImportErrorCodes)asyncOperation.ErrorCode.Value;
                lblErrorCode.Text = errorCode.ToString();
                toolTip.SetToolTip(lblErrorCode, DataPlatformErrorCodes.ResourceManager.GetString(errorCode.ToString(), DataPlatformErrorCodes.Culture));
            }
            else
            {
                lblErrorCode.Text = asyncOperation.ErrorCode?.ToString();
            }

            if (asyncOperation.ErrorCode.HasValue)
            {
                errorDetails            = asyncOperation.Message;
                btnCancelImport.Visible = false;
                tlpContainer.SetRow(btnCancelImport, 8);
                tlpContainer.SetRow(btnCopyMessage, 7);
                btnCopyMessage.Visible = true;
                lblJobStatus.ForeColor = Color.Red;
            }

            if (importJob != null)
            {
                progressBar.Value = importJob.Progress.HasValue ? (int)importJob.Progress : 0;
                toolTip.SetToolTip(progressBar, string.Format(Resources.PROGRESS_X_PERCENT, progressBar.Value));
                lblSolutionName.Text = importJob.SolutionName;
            }


            if (asyncOperation.StatusCode != AsyncOperation.OptionSets.StatusCode.Canceled &&
                asyncOperation.StatusCode != AsyncOperation.OptionSets.StatusCode.Failed &&
                asyncOperation.StatusCode != AsyncOperation.OptionSets.StatusCode.Succeeded)
            {
                this.timer.Start();
            }
        }