private void NewMessageCreated(MessageModel encryptedMessage, bool isPush) { Debug.WriteLine(string.Format("{0} {1} {2}", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"), "DataSync::NewMessageCreated", "start")); (Application.Current as App).PerfTrackerString += "\nInsert to DB:" + (Application.Current as App).PerfTrackerStopWatch.ElapsedMilliseconds.ToString(); if (encryptedMessage == null) { Messenger.Default.Send<NewMessageEvent>(new NewMessageEvent() { Message = null, IsPush = isPush }); return; } MessageModel message = null; try { message = encryptedMessage.DecryptMessage(); } catch (Exception) { message = null; } if (message == null) { Messenger.Default.Send<NewMessageEvent>(new NewMessageEvent() { Message = null, IsPush = isPush }); return; } message.LastReadTime = new DateTime(1970, 1, 1); encryptedMessage.CopyNonEncryptedProperties(message); if (message.IsPollResponseMessage) { this.SavePollResponse(message); } else if (message.IsTaskMessage.Value) { this.SaveSingleTaskMessage(message, new List<UserModel>()); } else { this.SaveSingleMessage(message, new List<UserModel>()); } // Set the last sync time on the server so the tile count is correct when the // server gets a new notification. This is computed based on the last sync time on the // server. YapperServiceProxy.Instance.SetLastSyncDateTime(message.PostDateTime); (Application.Current as App).PerfTrackerString += "\nRefresh ui:" + (Application.Current as App).PerfTrackerStopWatch.ElapsedMilliseconds.ToString(); // If message send was successful, the View should clear the text box // Otherwise, the textbox should not be cleared. Messenger.Default.Send<NewMessageEvent>(new NewMessageEvent() { Message = message, IsPush = isPush }); if (isPush) { // Vibrate the phone Deployment.Current.Dispatcher.BeginInvoke( () => { this.ShowToast(message); this.VibratePhone(); }); } Debug.WriteLine(string.Format("{0} {1} {2}", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"), "DataSync::NewMessageCreated", "end")); }