public async void Update() { try { var metroWindow = (Application.Current.MainWindow as MetroWindow); _manager.UpdateTopic(Instance); await metroWindow.ShowMessageAsync("Updating", "Success"); } catch (Exception e) { MessageBox.Show(e.Message, "Update failed", MessageBoxButton.OK, MessageBoxImage.Error); } }
private async Task CopyTopics(ProgressDialogController controller) { var topicsToUpdate = _fromManager.Topics.Where(a => _toManager.Topics.Select(b => b.Path).Contains(a.Path)).ToList(); foreach (var topic in topicsToUpdate) { controller.SetMessage(string.Format("Updating: {0}", topic.Path)); await Task.Run(() => { _toManager.UpdateTopic(topic); // Add missing subscription foreach (var subscription in _fromManager.GetSubscriptions(topic).Where(a => !_toManager.GetSubscriptions(topic).Select(b => b.Name).Contains(a.Name))) { _toManager.AddSubscription(subscription); } }); } var topicsToAdd = _fromManager.Topics.Except(_toManager.Topics, new LambdaComparer <TopicDescription>((a, b) => a.Path == b.Path, a => 1)).ToList(); foreach (var topic in topicsToAdd) { controller.SetMessage(string.Format("Adding: {0}", topic.Path)); await Task.Run(() => { _toManager.CreateTopic(topic); // Add missing subscription foreach (var subscription in _fromManager.GetSubscriptions(topic)) { _toManager.AddSubscription(subscription); } }); } }