public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer) {
            if (!config.IsValid)
                return new SubmissionResponse(500, message: "Invalid client configuration settings.");

            string data = serializer.Serialize(description);
            string url = String.Format("{0}/events/by-ref/{1}/user-description", GetServiceEndPoint(config), referenceId);

            HttpResponseMessage response;
            try {
                HttpContent content = new StringContent(data, Encoding.UTF8, "application/json");

                // don't compress data smaller than 4kb
                if (data.Length > 1024 * 4)
                    content = new GzipContent(content);

                _client.Value.AddAuthorizationHeader(config.ApiKey);
                response = _client.Value.PostAsync(url, content).ConfigureAwait(false).GetAwaiter().GetResult();
            } catch (Exception ex) {
                return new SubmissionResponse(500, message: ex.Message);
            }

            int settingsVersion;
            if (Int32.TryParse(GetSettingsVersionHeader(response.Headers), out settingsVersion))
                SettingsManager.CheckVersion(settingsVersion, config);

            return new SubmissionResponse((int)response.StatusCode, GetResponseMessage(response));
        }
        public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer) {
            var ev = Events.FirstOrDefault(e => e.ReferenceId == referenceId);
            if (ev == null)
                return new SubmissionResponse(404, "Not Found");

            ev.Data[Event.KnownDataKeys.UserDescription] = description;

            return new SubmissionResponse(200, "OK");
        }
        public void PostUserDescription() {
            var container = AppBuilder.CreateContainer();
            using (WebApp.Start(Settings.Current.BaseURL, app => AppBuilder.BuildWithContainer(app, container, false))) {
                var repository = container.GetInstance<IEventRepository>();
                repository.RemoveAll();

                const string referenceId = "fda94ff32921425ebb08b73df1d1d34c";
                const string badReferenceId = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";

                var statsCounter = container.GetInstance<IAppStatsClient>() as InMemoryAppStatsClient;
                Assert.NotNull(statsCounter);

                EnsureSampleData(container);

                var events = new List<Event> { new Event { Message = "Testing", ReferenceId = referenceId } };
                var configuration = GetClient().Configuration;
                var serializer = new DefaultJsonSerializer();

                var client = new DefaultSubmissionClient();
                var description = new UserDescription { EmailAddress = "*****@*****.**", Description = "Some description." };
                statsCounter.WaitForCounter(StatNames.EventsUserDescriptionErrors, work: () => {
                    var response = client.PostUserDescription(referenceId, description, configuration, serializer);
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                });

                statsCounter.WaitForCounter(StatNames.EventsUserDescriptionProcessed, work: () => {
                    var response = client.PostEvents(events, configuration, serializer);
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                });

                container.GetInstance<IElasticClient>().Refresh();
                var ev = repository.GetByReferenceId("537650f3b77efe23a47914f4", referenceId).FirstOrDefault();
                Assert.NotNull(ev);
                Assert.NotNull(ev.GetUserDescription());
                Assert.Equal(description.ToJson(), ev.GetUserDescription().ToJson());

                Assert.Equal(2, statsCounter.GetCount(StatNames.EventsUserDescriptionErrors));
                statsCounter.WaitForCounter(StatNames.EventsUserDescriptionErrors, work: () => {
                    var response = client.PostUserDescription(badReferenceId, description, configuration, serializer);
                    Assert.True(response.Success, response.Message);
                    Assert.Null(response.Message);
                });

                Assert.Equal(2, statsCounter.GetCount(StatNames.EventsUserDescriptionErrors));
            }
        }
        private void ProcessUserDescription(EventUserDescription description) {
            var ev = _eventRepository.GetByReferenceId(description.ProjectId, description.ReferenceId).FirstOrDefault();
            if (ev == null)
                throw new DocumentNotFoundException(description.ReferenceId);

            var ud = new UserDescription {
                EmailAddress = description.EmailAddress,
                Description = description.Description
            };

            if (description.Data.Count > 0)
                ev.Data.AddRange(description.Data);

            ev.SetUserDescription(ud);

            _eventRepository.Save(ev);
        }
        public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer) {
            var data = serializer.Serialize(description);

            HttpWebResponse response;
            try {
                var request = CreateHttpWebRequest(config, String.Format("events/by-ref/{0}/user-description", referenceId));
                response = request.PostJsonAsyncWithCompression(data).Result as HttpWebResponse;
            } catch (AggregateException aex) {
                var ex = aex.GetInnermostException() as WebException;
                if (ex != null)
                    response = (HttpWebResponse)ex.Response;
                else
                    return new SubmissionResponse(500, message: aex.GetMessage());
            } catch (Exception ex) {
                return new SubmissionResponse(500, message: ex.Message);
            }

            return new SubmissionResponse((int)response.StatusCode, response.IsSuccessful() ? null : response.GetResponseText());
        }
        public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer) {
            var data = serializer.Serialize(description);

            HttpWebResponse response;
            try {
                var request = CreateHttpWebRequest(config, String.Format("events/by-ref/{0}/user-description", referenceId));
                response = request.PostJsonAsyncWithCompression(data).Result as HttpWebResponse;
            } catch (AggregateException aex) {
                var ex = aex.GetInnermostException() as WebException;
                if (ex != null)
                    response = (HttpWebResponse)ex.Response;
                else
                    return new SubmissionResponse(500, message: aex.GetMessage());
            } catch (Exception ex) {
                return new SubmissionResponse(500, message: ex.Message);
            }

            int settingsVersion;
            if (Int32.TryParse(response.Headers[ExceptionlessHeaders.ConfigurationVersion], out settingsVersion))
                SettingsManager.CheckVersion(settingsVersion, config);

            return new SubmissionResponse((int)response.StatusCode, GetResponseMessage(response));
        }
 public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer) {
     return new SubmissionResponse(202);
 }
 public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer) {
     throw new NotImplementedException();
 }
 protected bool Equals(UserDescription other) {
     return string.Equals(EmailAddress, other.EmailAddress) && string.Equals(Description, other.Description) && Equals(Data, other.Data);
 }
Пример #10
0
        /// <summary>
        /// Sets the user's description of the event.
        /// </summary>
        /// <param name="ev">The event.</param>
        /// <param name="description">The user's description.</param>
        public static void SetUserDescription(this Event ev, UserDescription description) {
            if (description == null || (String.IsNullOrWhiteSpace(description.EmailAddress) && String.IsNullOrWhiteSpace(description.Description)))
                return;

            ev.Data[Event.KnownDataKeys.UserDescription] = description;
        }
 public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer) {
     string data = serializer.Serialize(description);
     _userDescriptionContainer[referenceId] = data;
     return new SubmissionResponse(200);
 }
Пример #12
0
 protected bool Equals(UserDescription other)
 {
     return(string.Equals(EmailAddress, other.EmailAddress) && string.Equals(Description, other.Description) && Equals(Data, other.Data));
 }
Пример #13
0
        /// <summary>
        /// Sets the user's description of the event.
        /// </summary>
        /// <param name="ev">The event.</param>
        /// <param name="description">The user's description.</param>
        public static void SetUserDescription(this Event ev, UserDescription description)
        {
            if (description == null || (String.IsNullOrWhiteSpace(description.EmailAddress) && String.IsNullOrWhiteSpace(description.Description)))
                return;

            // TODO: Should we be merging existing user descriptions?

            ev.Data[Event.KnownDataKeys.UserDescription] = description;
        }