private async void UpdateAllButton_Click(object sender, RoutedEventArgs e) { await Task.Run(() => { //update status to pending foreach (RepositoryItemUsage usage in RepoItemUsages) { if (usage.Selected && usage.Status == RepositoryItemUsage.eStatus.NotUpdated || usage.Status == RepositoryItemUsage.eStatus.UpdateFailed) { usage.Status = RepositoryItemUsage.eStatus.Pending; } } //do the update foreach (RepositoryItemUsage usage in RepoItemUsages) { try { if (usage.Status == RepositoryItemUsage.eStatus.Pending) { if (usage.HostActivity != null) { this.Dispatcher.Invoke(() => mRepoItem.UpdateInstance(usage.UsageItem, usage.SelectedItemPart, usage.HostActivity)); //mRepoItem.UpdateInstance(usage.UsageItem, usage.SelectedItemPart, usage.HostActivity); } else { this.Dispatcher.Invoke(() => mRepoItem.UpdateInstance(usage.UsageItem, usage.SelectedItemPart, usage.HostBusinessFlow, extraDetails)); //mRepoItem.UpdateInstance(usage.UsageItem, usage.SelectedItemPart, usage.HostBusinessFlow); } usage.Status = RepositoryItemUsage.eStatus.Updated; } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to update the repository item usage", ex); usage.Status = RepositoryItemUsage.eStatus.UpdateFailed; } } Reporter.ToUser(eUserMsgKey.UpdateRepositoryItemUsagesSuccess); }); }
private async void UpdateAllButton_Click(object sender, RoutedEventArgs e) { await Task.Run(() => { StartProcessingIcon(); Parallel.ForEach(RepoItemUsages, usage => { try { if (usage.Selected && (usage.Status == RepositoryItemUsage.eStatus.NotUpdated || usage.Status == RepositoryItemUsage.eStatus.UpdateFailed || usage.Status == RepositoryItemUsage.eStatus.Pending)) { if (usage.HostActivity != null) { SetStatus("Updating: " + usage.HostActivity.ActivityName); mRepoItem.UpdateInstance(usage.UsageItem, usage.SelectedItemPart, usage.HostActivity); } else { SetStatus("Updating: " + usage.HostBusinessFlow.Name); mRepoItem.UpdateInstance(usage.UsageItem, usage.SelectedItemPart, usage.HostBusinessFlow); } usage.Status = RepositoryItemUsage.eStatus.Updated; } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to update the repository item usage", ex); usage.Status = RepositoryItemUsage.eStatus.UpdateFailed; } }); StopProcessingIcon(); SetStatus(""); Reporter.ToUser(eUserMsgKey.UpdateRepositoryItemUsagesSuccess); }); }