AutoMerge.BranchesViewModel.MergeAndCheckInExecute C# (CSharp) Метод

MergeAndCheckInExecute() приватный Метод

private MergeAndCheckInExecute ( bool checkInIfSuccess ) : System.Threading.Tasks.Task
checkInIfSuccess bool
Результат System.Threading.Tasks.Task
        private async Task MergeAndCheckInExecute(bool checkInIfSuccess)
        {
            try
            {
                IsBusy = true;
                _merging = true;

                MergeCommand.RaiseCanExecuteChanged();

                var result = await Task.Run(() => MergeExecuteInternal(checkInIfSuccess));
                var notifications = new List<Notification>();
                var notCheckedIn = new List<MergeResultModel>(result.Count);
                ClearNotifications();
                foreach (var resultModel in result)
                {
                    var notification = new Notification
                    {
                        NotificationType = NotificationType.Information,
                        Message = string.Empty
                    };
                    var mergePath = string.Format("MERGE {0} -> {1}",
                        BranchHelper.GetShortBranchName(resultModel.BranchInfo.SourceBranch),
                        BranchHelper.GetShortBranchName(resultModel.BranchInfo.TargetBranch));
                    switch (resultModel.MergeResult)
                    {
                        case MergeResult.CheckInEvaluateFail:
                            notification.NotificationType = NotificationType.Error;
                            notification.Message = "Check In evaluate failed.";
                            notCheckedIn.Add(resultModel);
                            break;
                        case MergeResult.CheckInFail:
                            notification.NotificationType = NotificationType.Error;
                            notification.Message = "Check In failed.";
                            notCheckedIn.Add(resultModel);
                            break;
                        case MergeResult.NothingMerge:
                            notification.NotificationType = NotificationType.Warning;
                            notification.Message = "Nothing merged.";
                            break;
                        case MergeResult.HasConflicts:
                            notification.NotificationType = NotificationType.Error;
                            notification.Message = "Has conflicts.";
                            notCheckedIn.Add(resultModel);
                            break;
                        case MergeResult.CanNotGetLatest:
                            notification.NotificationType = NotificationType.Error;
                            notification.Message = "Can not get latest.";
                            break;
                        case MergeResult.UnexpectedFileRestored:
                            notification.NotificationType = NotificationType.Warning;
                            notification.Message = "Some unexpected files were restored.";
                            notCheckedIn.Add(resultModel);
                            break;
                        case MergeResult.Merged:
                            notification.NotificationType = NotificationType.Information;
                            notification.Message = "Files merged but not checked in.";
                            notCheckedIn.Add(resultModel);
                            break;
                        case MergeResult.CheckIn:
                            var changesetId = resultModel.TagetChangesetId.Value;
                            notification.NotificationType = NotificationType.Information;
                            notification.Message = string.Format("[Changeset {0}](Click to view the changeset details) successfully checked in.", changesetId);
                            notification.Command = new DelegateCommand(() => ViewChangesetDetailsExecute(changesetId));
                            break;
                    }
                    notification.Message = string.Format("{0}: {1}", mergePath, notification.Message);
                    if (!string.IsNullOrEmpty(notification.Message))
                        notifications.Add(notification);
                }

                if (notCheckedIn.Count > 0)
                {
                    OpenPendingChanges(notCheckedIn);
                }
                else
                {
                    _eventAggregator.GetEvent<MergeCompleteEvent>().Publish(true);
                }

                foreach (var notification in notifications)
                {
                    ShowNotification(notification.Message, notification.NotificationType, NotificationFlags.RequiresConfirmation, notification.Command, Guid.NewGuid());
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Error while merging", ex);
                ClearNotifications();
                ShowError(ex.Message);
            }
            finally
            {
                IsBusy = false;
                _merging = false;
                MergeCommand.RaiseCanExecuteChanged();
            }
        }