コード例 #1
0
        protected void PersistThreadMetaInfos(FeedbackResponseSingle fbResponse, string user, string email)
        {
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

            settings.SetValue(Constants.FeedbackThreadKey, fbResponse.token);
            settings.SetValue(Constants.FeedbackThreadSubjectKey, fbResponse.feedback.messages.First().subject);
            settings.SetValue(Constants.FeedbackEmailKey, email);
            settings.SetValue(Constants.FeedbackUsernameKey, user);
            settings.Save();
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>FeedbackThread or null if the thread got deleted</returns>
        /// <exception cref="ApplicationException"></exception>
        public async Task <FeedbackThread> GetActiveThreadAsync()
        {
            var request = WebRequest.CreateHttp(new Uri(Constants.ApiBase + "apps/" + this.AppIdentitfier + "/feedback/" + this.ThreadToken + ".json", UriKind.Absolute));

            request.Method = HttpMethod.Get;
            request.Headers[HttpRequestHeader.UserAgent] = Constants.UserAgentString;

            try
            {
                var response = await request.GetResponseTaskAsync();

                var fbResp = await TaskEx.Run <FeedbackResponseSingle>(() => FeedbackResponseSingle.FromJson(response.GetResponseStream()));

                if (fbResp.status.Equals("success"))
                {
                    return(fbResp.feedback);
                }
                else
                {
                    throw new Exception("Server error. Server returned status " + fbResp.status);
                }
            }
            catch (Exception e)
            {
                var webex = e.InnerException as WebException;
                if (webex != null)
                {
                    if (webex.Response.ContentType.IsEmpty())
                    {
                        //Connection error during call
                        throw webex;
                    }
                    else
                    {
                        //404 Response from server => thread got deleted
                        ForgetThreadInfos();
                        return(null);
                    }
                }
                else
                {
                    throw;
                }
            }
        }
コード例 #3
0
        protected async Task <FeedbackResponseSingle> StartThreadAsync(FeedbackMessage message)
        {
            var request = WebRequest.CreateHttp(new Uri(Constants.ApiBase + "apps/" + this.AppIdentitfier + "/feedback", UriKind.Absolute));

            request.Method = HttpMethod.Post;
            request.Headers[HttpRequestHeader.UserAgent] = Constants.UserAgentString;
            await request.SetPostDataAsync(message.SerializeToWwwForm());

            var response = await request.GetResponseTaskAsync();

            var fbResp = await TaskEx.Run <FeedbackResponseSingle>(() => FeedbackResponseSingle.FromJson(response.GetResponseStream()));

            if (fbResp.status.Equals("success"))
            {
                return(fbResp);
            }
            else
            {
                throw new Exception("Server error. Server returned status " + fbResp.status);
            }
        }