public FeedbackThreadViewModel(IFeedbackThread newFeedbackThread) { this.FeedbackThread = newFeedbackThread; this.FeedbackMessages = new ObservableCollection<FeedbackMessageViewModel>(); this.FeedbackMessages.Add(new NewFeedbackMessage(this)); }
private async Task InitializeAsync() { if (FeedbackManager.Instance.IsThreadOpen) { if (NetworkInterface.GetIsNetworkAvailable()) { try { IFeedbackThread thread = await FeedbackManager.Instance.GetActiveThreadAsync(forceReload : true); if (thread != null) { foreach (var msg in (thread.Messages)) { this.Messages.Add(new FeedbackMessageReadOnlyVM(msg, this)); } if (FeedbackManager.Instance.FeedbackPageTopTitle.IsEmpty() && !thread.Messages.First().Subject.IsEmpty()) { Deployment.Current.Dispatcher.BeginInvoke(() => this.ThreadInfo = thread.Messages.First().Subject); } SwitchToMessageList(); } else //thread has been deleted { Deployment.Current.Dispatcher.BeginInvoke(() => IsThreadActive = false); SwitchToMessageForm(); } } catch (Exception) { Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show(LocalizedStrings.LocalizedResources.FeedbackFetchError); }); LeaveFeedbackPageViaBackButton(); } } else //no internet connection { Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show(LocalizedStrings.LocalizedResources.FeedbackNoInternet); }); LeaveFeedbackPageViaBackButton(); } } else { Deployment.Current.Dispatcher.BeginInvoke(() => IsThreadActive = false); SwitchToMessageForm(); } HideOverlay(); }
internal async void SendFeedback(FeedbackViewModel viewModel) { //*********************************************************************************************************************** // Sending the Feedback about the VATRP application. //*********************************************************************************************************************** IFeedbackThread feedbackThread = HockeyClient.Current.CreateFeedbackThread(); if (feedbackThread != null) { viewModel.FeedbackResult = "Sending feedback ..."; // see note below regarding attachments. Once we have these answer and can use the data.... uncomment below. // List<IFeedbackAttachment> attachmentList = GetFileAttachmentList(); // if (attachmentList.Count == 0) // { string attachmentText = ""; if (!string.IsNullOrEmpty(AttachmentFile) && (AttachmentFile.EndsWith("txt") || AttachmentFile.EndsWith("log"))) { if (File.Exists(AttachmentFile)) { attachmentText = File.ReadAllText(AttachmentFile); } attachmentText = "\r\n\r\n" + attachmentText; } await feedbackThread.PostFeedbackMessageAsync(FeedbackMessage + attachmentText, ContactEmailAddress, Subject, ContactName); // } // else // { // await feedbackThread.PostFeedbackMessageAsync(FeedbackMessage, ContactEmailAddress, Subject, ContactName, attachmentList); // } viewModel.FeedbackResult = "Feedback sent"; } else { viewModel.FeedbackResult = "Feedback send failed"; } //******************************************************************************************* // ADDED BY MK ON DATED 24-OCT-2016 FOR DISPLAY A MESSAGE BOX WHEN MESSAGE IS SENT OR FAILED. //******************************************************************************************** MessageBox.Show(viewModel.FeedbackResult, "VATRP", MessageBoxButton.OK); }
/// <summary> /// Send a feedback message to the server /// (you should not need this if you use the provided feedback page) /// </summary> /// <param name="message">message text</param> /// <param name="email">email address of sender</param> /// <param name="subject">subject of message</param> /// <param name="name">name of sender</param> /// <param name="attachments">The attachments.</param> /// <returns></returns> public async Task <IFeedbackMessage> SendFeedback(string message, string email, string subject, string name, IEnumerable <IFeedbackAttachment> attachments) { var thread = await this.GetActiveThreadAsync() ?? FeedbackThread.CreateInstance(); foreach (var attachment in attachments) { //convert all images to jpg for filesize var bitimg = new BitmapImage(); bitimg.SetSource(new MemoryStream(attachment.DataBytes)); var wb = new WriteableBitmap(bitimg); using (var stream = new MemoryStream()) { wb.SaveJpeg(stream, bitimg.PixelWidth, bitimg.PixelHeight, 0, 70); stream.Seek(0, System.IO.SeekOrigin.Begin); var buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); attachment.DataBytes = buffer; } attachment.FileName = Path.GetFileNameWithoutExtension(attachment.FileName) + ".jpg"; attachment.ContentType = "image/jpeg"; } IFeedbackMessage msg; try { msg = await thread.PostFeedbackMessageAsync(message, email, subject, name, attachments); PersistThreadMetaInfos(thread.Token, subject, name, email); this.activeThread = thread; } catch (Exception) { this.activeThread = null; throw; } return(msg); }
/// <summary> /// Gets the active feedback thread with all messages from the HockeyApp server (cached) /// (you should not need this is you use the provided feedpage page) /// </summary> /// <param name="forceReload">[optional] force reload of thread messages</param> /// <returns>the FeedbackThread</returns> public async Task <IFeedbackThread> GetActiveThreadAsync(bool forceReload = false) { if (this.activeThread != null && !forceReload) { return(activeThread); } if (this.ThreadToken == null) { return(null); } var thread = await HockeyClient.Current.AsInternal().OpenFeedbackThreadAsync(this.ThreadToken); if (thread == null) { //thread got deleted ForgetThreadInfos(); } else { this.activeThread = thread; } return(thread); }
public async void Submit() { bool wasNewThread = this._fbThreadVM.IsNewThread; IFeedbackThread fbThread = this._fbThreadVM.FeedbackThread; IWindowManager wm = IoC.Get <IWindowManager>(); wm.ShowBusyView("Submitting..."); try { IFeedbackMessage msg = await fbThread.PostFeedbackMessageAsync(this.Message, this.EMail, this.Subject, this.Username); HockeyApp.AppLoader.Properties.Settings.Default.LastFeedbackUserName = this.Username; HockeyApp.AppLoader.Properties.Settings.Default.LastFeedbackUserEMail = this.EMail; HockeyApp.AppLoader.Properties.Settings.Default.Save(); if (msg != null) { if (wasNewThread) { FeedbackToken.AddToken(fbThread.Token); } this._fbThreadVM.FeedbackMessages.Insert(this._fbThreadVM.FeedbackMessages.Count - 1, new FeedbackMessageViewModel(msg)); this._fbThreadVM.NotifyOfPropertyChange(() => this._fbThreadVM.Subject); this.NotifyOfPropertyChange(() => this.IsNewThread); this.Message = ""; } } catch (Exception ex) { wm.ShowMetroMessageBox("An error ocurred:\n" + ex.Message); } finally { wm.HideBusyView(); } }
public FeedbackThreadVM(IFeedbackThread feedbackThread = null) { this.FeedbackThread = feedbackThread ?? HockeyApp.Model.FeedbackThread.CreateInstance(); SetCommands(); }
/// <summary> /// Gets the active feedback thread with all messages from the HockeyApp server (cached) /// (you should not need this is you use the provided feedpage page) /// </summary> /// <param name="forceReload">[optional] force reload of thread messages</param> /// <returns>the FeedbackThread</returns> public async Task<IFeedbackThread> GetActiveThreadAsync(bool forceReload = false) { if (this.activeThread != null && !forceReload) { return activeThread; } if (this.ThreadToken == null) { return null; } var thread = await HockeyClient.Current.AsInternal().OpenFeedbackThreadAsync(this.ThreadToken); if (thread == null) { //thread got deleted ForgetThreadInfos(); } else { this.activeThread = thread; } return thread; }
/// <summary> /// Send a feedback message to the server /// (you should not need this if you use the provided feedback page) /// </summary> /// <param name="message">message text</param> /// <param name="email">email address of sender</param> /// <param name="subject">subject of message</param> /// <param name="name">name of sender</param> /// <param name="attachments">The attachments.</param> /// <returns></returns> public async Task<IFeedbackMessage> SendFeedback(string message, string email, string subject, string name, IEnumerable<IFeedbackAttachment> attachments) { var thread = await this.GetActiveThreadAsync() ?? FeedbackThread.CreateInstance(); foreach (var attachment in attachments) { //convert all images to jpg for filesize var bitimg = new BitmapImage(); bitimg.SetSource(new MemoryStream(attachment.DataBytes)); var wb = new WriteableBitmap(bitimg); using (var stream = new MemoryStream()) { wb.SaveJpeg(stream, bitimg.PixelWidth, bitimg.PixelHeight, 0, 70); stream.Seek(0, System.IO.SeekOrigin.Begin); var buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); attachment.DataBytes = buffer; } attachment.FileName = Path.GetFileNameWithoutExtension(attachment.FileName) + ".jpg"; attachment.ContentType = "image/jpeg"; } IFeedbackMessage msg; try { msg = await thread.PostFeedbackMessageAsync(message, email, subject, name, attachments); PersistThreadMetaInfos(thread.Token, subject, name, email); this.activeThread = thread; } catch (Exception) { this.activeThread = null; throw; } return msg; }
// VATRP-1271: Liz E. - condense this down and use the JSON handler that we already have public static ACEConfig createConfigFromURL(string url, string userName, string password) { //ACEConfig defaultval = defaultConfig(); IFeedbackThread feedbackThread = HockeyClient.Current.CreateFeedbackThread(); string stacktrace = null; try { ACEConfig aceConfig = JsonWebRequest.MakeJsonWebRequestAuthenticated <ACEConfig>(url, userName, password); // aceConfig should never be null at this point - throwing JsonException in a failure event. If it is null, there is a problem - // but let's log it and handle it if (aceConfig == null) { aceConfig = JsonWebRequest.MakeHttpJsonWebRequest <ACEConfig>(url); // cjm-sep17 if (aceConfig == null) { aceConfig = JsonFactoryConfig.defaultConfig(ACEConfigStatusType.UNKNOWN); } } else { aceConfig.configStatus = ACEConfigStatusType.LOGIN_SUCCEESSFUL; } aceConfig.NormalizeValues(); return(aceConfig); } catch (JsonException ex) { // Once the codes that are sent back from the server are managed we can manage them here. For now, look // for unauthorized in the message string as we know that this is returned currently. if ((ex.InnerException != null) && !string.IsNullOrEmpty(ex.InnerException.Message) && ex.InnerException.Message.ToLower().Contains("unauthorized")) { ACEConfig config = JsonFactoryConfig.defaultConfig(ACEConfigStatusType.LOGIN_UNAUTHORIZED); config.NormalizeValues(); return(config); } else { ACEConfig config; switch (ex.jsonExceptionType) { case JsonExceptionType.DESERIALIZATION_FAILED: config = JsonFactoryConfig.defaultConfig(ACEConfigStatusType.UNABLE_TO_PARSE); break; case JsonExceptionType.CONNECTION_FAILED: config = JsonFactoryConfig.defaultConfig(ACEConfigStatusType.CONNECTION_FAILED); break; default: config = JsonFactoryConfig.defaultConfig(ACEConfigStatusType.UNKNOWN); break; } config.NormalizeValues(); return(config); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); stacktrace = ex.StackTrace; ACEConfig config = JsonFactoryConfig.defaultConfig(ACEConfigStatusType.UNKNOWN); config.NormalizeValues(); return(config); } if ((feedbackThread != null) && !string.IsNullOrEmpty(stacktrace)) { feedbackThread.PostFeedbackMessageAsync(url + "\n\n" + stacktrace, "*****@*****.**", "json failed to deseralized", "Ace Logcat"); } // note - this may be an invalid login - need to look for the correct unauthorized response assuming that there is one. // Otherwise the app will use null response for now to assume unauthorized ACEConfig defaultConfig = JsonFactoryConfig.defaultConfig(ACEConfigStatusType.SRV_RECORD_NOT_FOUND); defaultConfig.NormalizeValues(); return(defaultConfig); }
public FeedbackThreadViewModel(IFeedbackThread newFeedbackThread) { this.FeedbackThread = newFeedbackThread; this.FeedbackMessages = new ObservableCollection <FeedbackMessageViewModel>(); this.FeedbackMessages.Add(new NewFeedbackMessage(this)); }