From 6da79b70d6ac2982f6935b07c5697b4d61b9d2bb Mon Sep 17 00:00:00 2001 From: Khaja Nizamuddin Date: Mon, 3 Jul 2017 21:33:52 +0530 Subject: [PATCH] Catching mongo error in TrackEvent --- ANAConversationPlatform/Helpers/MongoHelper.cs | 15 +++++++++++---- ANAConversationSimulator/Package.appxmanifest | 2 +- .../ViewModels/MainPageViewModel.cs | 17 ++++++++++------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ANAConversationPlatform/Helpers/MongoHelper.cs b/ANAConversationPlatform/Helpers/MongoHelper.cs index d55b46c..e80e3e2 100644 --- a/ANAConversationPlatform/Helpers/MongoHelper.cs +++ b/ANAConversationPlatform/Helpers/MongoHelper.cs @@ -305,11 +305,18 @@ private static Section GetSection(BsonDocument sectionBsonDocument) public static void InsertActivityEvent(ChatActivityEvent activityEvent) { - if (activityEvent != null && string.IsNullOrWhiteSpace(activityEvent._id)) - activityEvent._id = ObjectId.GenerateNewId().ToString(); + try + { + if (activityEvent != null && string.IsNullOrWhiteSpace(activityEvent._id)) + activityEvent._id = ObjectId.GenerateNewId().ToString(); - var coll = ChatDB.GetCollection(Settings.ActivityEventLogCollectionName); - coll.InsertOne(activityEvent); + var coll = ChatDB.GetCollection(Settings.ActivityEventLogCollectionName); + coll.InsertOne(activityEvent); + } + catch (Exception ex) + { + Logger.LogError(new EventId((int)LoggerEventId.MONGO_HELPER_ERROR), ex, "InsertActivityEvent: {0}", ex.Message); + } } } } \ No newline at end of file diff --git a/ANAConversationSimulator/Package.appxmanifest b/ANAConversationSimulator/Package.appxmanifest index 7336f8b..471f56d 100644 --- a/ANAConversationSimulator/Package.appxmanifest +++ b/ANAConversationSimulator/Package.appxmanifest @@ -1,6 +1,6 @@  - + ANA Conversation Simulator diff --git a/ANAConversationSimulator/ViewModels/MainPageViewModel.cs b/ANAConversationSimulator/ViewModels/MainPageViewModel.cs index f8899c5..05487d1 100644 --- a/ANAConversationSimulator/ViewModels/MainPageViewModel.cs +++ b/ANAConversationSimulator/ViewModels/MainPageViewModel.cs @@ -233,14 +233,17 @@ public async void ProcessNode(JToken node, JToken section = null) { await Task.Run(async () => { - try + await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => { - await APIHelper.TrackEvent(Utils.GetViewEvent(parsedNode.Id, Utils.DeviceId)); - } - catch (Exception ex) - { - await Utils.ShowDialogAsync(ex.ToString()); - } + try + { + await APIHelper.TrackEvent(Utils.GetViewEvent(parsedNode.Id, Utils.DeviceId)); + } + catch (Exception ex) + { + await Utils.ShowDialogAsync(ex.ToString()); + } + }); }); } AddIncommingSection(parsedSection);