Exemple #1
0
        private async void PublishErrorHandlerButton_Click(object sender, RoutedEventArgs e)
        {
            await Task.Run(() =>
            {
                StartProcessingIcon();
                var errorOccured = false;
                foreach (var repositoryItem in mRepoItemUsages)
                {
                    try
                    {
                        if (repositoryItem.Selected && repositoryItem.RepositoryItemPublishType == RepositoryItemUsage.eRepositoryItemPublishType.PublishInstance && repositoryItem.PublishStatus != RepositoryItemUsage.ePublishStatus.Published)
                        {
                            Activity activityCopy = (Activity)mRepoItem.CreateInstance(true);
                            activityCopy.Active   = true;

                            if (repositoryItem.InsertRepositoryInsatncePosition == RepositoryItemUsage.eInsertRepositoryInsatncePosition.AtEnd)
                            {
                                repositoryItem.HostBusinessFlow.AddActivity(activityCopy, repositoryItem.HostBusinessFlow.ActivitiesGroups.Last());
                            }
                            else if (repositoryItem.InsertRepositoryInsatncePosition == RepositoryItemUsage.eInsertRepositoryInsatncePosition.Beginning)
                            {
                                repositoryItem.HostBusinessFlow.AddActivity(activityCopy, repositoryItem.HostBusinessFlow.ActivitiesGroups.FirstOrDefault(), insertIndex: 0);
                            }
                            else if (repositoryItem.InsertRepositoryInsatncePosition == RepositoryItemUsage.eInsertRepositoryInsatncePosition.AfterSpecificActivity)
                            {
                                if (repositoryItem.IndexActivityName == null)
                                {
                                    errorOccured = true;
                                }
                                else
                                {
                                    var indexToAdd = Convert.ToInt32(repositoryItem.IndexActivityName[0].ToString());
                                    repositoryItem.HostBusinessFlow.AddActivity(activityCopy, repositoryItem.HostBusinessFlow.ActivitiesGroups.FirstOrDefault(), insertIndex: indexToAdd + 1);
                                }
                            }
                            if (!errorOccured)
                            {
                                repositoryItem.PublishStatus = RepositoryItemUsage.ePublishStatus.Published;
                                WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(repositoryItem.HostBusinessFlow);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        errorOccured = true;
                        repositoryItem.PublishStatus = RepositoryItemUsage.ePublishStatus.FailedToPublish;
                        Reporter.ToLog(eLogLevel.ERROR, $"Method - {System.Reflection.MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                    }
                }
                StopProcessingIcon();
                if (errorOccured)
                {
                    Reporter.ToUser(eUserMsgKey.FailedToPublishRepositoryInfo);
                }
                else
                {
                    Reporter.ToUser(eUserMsgKey.PublishRepositoryInfo);
                }
            }
                           );
        }