예제 #1
0
        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);
        }
        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();
            }
        }
예제 #3
0
        // 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);
        }