当前位置: 首页>>代码示例>>C#>>正文


C# IMessage.GetBody方法代码示例

本文整理汇总了C#中IMessage.GetBody方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.GetBody方法的具体用法?C# IMessage.GetBody怎么用?C# IMessage.GetBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMessage的用法示例。


在下文中一共展示了IMessage.GetBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessWebHookNotification

        private object ProcessWebHookNotification(IMessage<WebHookNotification> message) {
            WebHookNotification body = message.GetBody();
            Log.Trace().Project(body.ProjectId).Message("Process web hook call: project={0} url={1}", body.ProjectId, body.Url).Write();

            var client = new HttpClient();
            client.PostAsJsonAsync(body.Url, body.Data).ContinueWith(res => {
                if (res.Result.StatusCode == HttpStatusCode.Gone) {
                    _projectHookRepository.Delete(Query.EQ(ProjectHookRepository.FieldNames.Url, body.Url));
                    Log.Trace().Project(body.ProjectId).Message("Deleting web hook: project={0} url={1}", body.ProjectId, body.Url).Write();
                }

                Log.Trace().Project(body.ProjectId).Message("Web hook POST complete: status={0} project={1} url={2}", res.Result.StatusCode, body.ProjectId, body.Url).Write();
            }).Wait();

            return null;
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:16,代码来源:ExceptionlessMqServer.cs

示例2: CreateSerializationStrategy

        private DefaultMessageSerializationStrategy CreateSerializationStrategy(IMessage<MyMessage> message, string messageType, byte[] messageBody, string correlationId)
        {
            var typeNameSerializer = MockRepository.GenerateStub<ITypeNameSerializer>();
            typeNameSerializer.Stub(s => s.Serialize(message.MessageType)).Return(messageType);

            var serializer = MockRepository.GenerateStub<ISerializer>();
            serializer.Stub(s => s.MessageToBytes(message.GetBody())).Return(messageBody);

            return new DefaultMessageSerializationStrategy(typeNameSerializer, serializer, new StaticCorrelationIdGenerationStrategy(correlationId));
        }
开发者ID:akzhigitov,项目名称:EasyNetQ,代码行数:10,代码来源:DefaultMessageSerializationStrategyTests.cs

示例3: ExecuteAsync

 /// <summary>Executes the asynchronous operation.</summary>
 ///
 /// <param name="request">The request.</param>
 ///
 /// <returns>An object.</returns>
 public object ExecuteAsync(IMessage<UnRetryableFail> request)
 {
     return Any(request.GetBody());
 }
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:9,代码来源:UnRetryableFail.cs

示例4: ProcessSummaryNotification

        private object ProcessSummaryNotification(IMessage<SummaryNotification> message) {
            var project = _projectRepository.GetByIdCached(message.GetBody().Id);
            var organization = _organizationRepository.GetByIdCached(project.OrganizationId);
            var userIds = project.NotificationSettings.Where(n => n.Value.SendDailySummary).Select(n => n.Key).ToList();
            if (userIds.Count == 0)
                return null;

            var users = _userRepository.GetByIds(userIds).Where(u => u.IsEmailAddressVerified).ToList();
            if (users.Count == 0)
                return null;

            long count;
            List<ErrorStack> newest = _stackRepository.GetNew(project.Id, message.GetBody().UtcStartTime, message.GetBody().UtcEndTime, 0, 5, out count).ToList();

            DateTime start = _projectRepository.UtcToDefaultProjectLocalTime(project.Id, message.GetBody().UtcStartTime);
            DateTime end = _projectRepository.UtcToDefaultProjectLocalTime(project.Id, message.GetBody().UtcEndTime);
            var result = _errorStatsHelper.GetProjectErrorStats(project.Id, _projectRepository.GetDefaultTimeOffset(project.Id), start, end);
            var mostFrequent = result.MostFrequent.Results.Take(5).ToList();
            var errorStacks = _stackRepository.GetByIds(mostFrequent.Select(s => s.Id));

            foreach (var frequent in mostFrequent) {
                var stack = errorStacks.SingleOrDefault(s => s.Id == frequent.Id);
                if (stack == null) {
                    mostFrequent.RemoveAll(r => r.Id == frequent.Id);
                    continue;
                }

                // Stat's Id and Total properties are already calculated in the Results.
                frequent.Type = stack.SignatureInfo.ContainsKey("ExceptionType") ? stack.SignatureInfo["ExceptionType"] : null;
                frequent.Method = stack.SignatureInfo.ContainsKey("Method") ? stack.SignatureInfo["Method"] : null;
                frequent.Path = stack.SignatureInfo.ContainsKey("Path") ? stack.SignatureInfo["Path"] : null;
                frequent.Is404 = stack.SignatureInfo.ContainsKey("Path");

                frequent.Title = stack.Title;
                frequent.First = stack.FirstOccurrence;
                frequent.Last = stack.LastOccurrence;
            }

            var notification = new SummaryNotificationModel {
                ProjectId = project.Id,
                ProjectName = project.Name,
                StartDate = start,
                EndDate = end,
                Total = result.Total,
                PerHourAverage = result.PerHourAverage,
                NewTotal = result.NewTotal,
                New = newest,
                UniqueTotal = result.UniqueTotal,
                MostFrequent = mostFrequent,
                HasSubmittedErrors = project.TotalErrorCount > 0,
                IsFreePlan = organization.PlanId == BillingManager.FreePlan.Id
            };

            foreach (var user in users.Where(u => u.EmailNotificationsEnabled))
                _mailer.SendSummaryNotification(user.EmailAddress, notification);

            return null;
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:58,代码来源:ExceptionlessMqServer.cs

示例5: ProcessSummaryNotificationException

 private void ProcessSummaryNotificationException(IMessage<SummaryNotification> message, Exception exception) {
     exception.ToExceptionless().AddDefaultInformation().MarkAsCritical().AddObject(message.GetBody()).AddTags("ErrorMQ").Submit();
     Log.Error().Project(message.GetBody().Id).Exception(exception).Message("Error processing daily summary.").Write();
 }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:4,代码来源:ExceptionlessMqServer.cs

示例6: ProcessWebHookNotificationException

 private void ProcessWebHookNotificationException(IMessage<WebHookNotification> message, Exception exception) {
     Log.Error().Project(message.GetBody().ProjectId).Exception(exception).Message("Error calling web hook ({0}): {1}", message.GetBody().Url, exception.Message).Write();
 }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:3,代码来源:ExceptionlessMqServer.cs

示例7: ProcessNotificationException

 private void ProcessNotificationException(IMessage<ErrorNotification> message, Exception exception) {
     exception.ToExceptionless().AddDefaultInformation().MarkAsCritical().AddObject(message.GetBody()).AddTags("NotificationMQ").Submit();
     Log.Error().Project(message.GetBody().ProjectId).Exception(exception).Message("Error sending notification.").Write();
 }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:4,代码来源:ExceptionlessMqServer.cs

示例8: ProcessNotification

        private object ProcessNotification(IMessage<ErrorNotification> message) {
            int emailsSent = 0;
            ErrorNotification errorNotification = message.GetBody();
            Log.Trace().Message("Process notification: project={0} error={1} stack={2}", errorNotification.ProjectId, errorNotification.ErrorId, errorNotification.ErrorStackId).Write();

            var project = _projectRepository.GetByIdCached(errorNotification.ProjectId);
            if (project == null) {
                Log.Error().Message("Could not load project {0}.", errorNotification.ProjectId).Write();
                return null;
            }
            Log.Trace().Message("Loaded project: name={0}", project.Name).Write();

            var organization = _organizationRepository.GetByIdCached(project.OrganizationId);
            if (organization == null) {
                Log.Error().Message("Could not load organization {0}.", project.OrganizationId).Write();
                return null;
            }
            Log.Trace().Message("Loaded organization: name={0}", organization.Name).Write();

            var stack = _stackRepository.GetById(errorNotification.ErrorStackId);
            if (stack == null) {
                Log.Error().Message("Could not load stack {0}.", errorNotification.ErrorStackId).Write();
                return null;
            }

            if (!organization.HasPremiumFeatures) {
                Log.Trace().Message("Skipping because organization does not have premium features.").Write();
                return null;
            }

            if (stack.DisableNotifications || stack.IsHidden) {
                Log.Trace().Message("Skipping because stack notifications are disabled or it's hidden.").Write();
                return null;
            }

            Log.Trace().Message("Loaded stack: title={0}", stack.Title).Write();
            int totalOccurrences = stack.TotalOccurrences;

            // after the first 5 occurrences, don't send a notification for the same stack more then once every 15 minutes
            var lastTimeSent = _cacheClient.Get<DateTime>(String.Concat("NOTIFICATION_THROTTLE_", errorNotification.ErrorStackId));
            if (totalOccurrences > 5 && !errorNotification.IsRegression && lastTimeSent != DateTime.MinValue &&
                lastTimeSent > DateTime.Now.AddMinutes(-15)) {
                Log.Info().Message("Skipping message because of throttling: last sent={0} occurrences={1}", lastTimeSent, totalOccurrences).Write();
                return null;
            }

            foreach (var kv in project.NotificationSettings) {
                var settings = kv.Value;
                Log.Trace().Message("Processing notification: user={0}", kv.Key).Write();

                var user = _userRepository.GetById(kv.Key);
                if (user == null || String.IsNullOrEmpty(user.EmailAddress)) {
                    Log.Error().Message("Could not load user {0} or blank email address {1}.", kv.Key, user != null ? user.EmailAddress : "").Write();
                    continue;
                }

                if (!user.IsEmailAddressVerified) {
                    Log.Info().Message("User {0} with email address {1} has not been verified.", kv.Key, user != null ? user.EmailAddress : "").Write();
                    continue;
                }

                if (!user.EmailNotificationsEnabled) {
                    Log.Trace().Message("User {0} with email address {1} has email notifications disabled.", kv.Key, user != null ? user.EmailAddress : "").Write();
                    continue;
                }

                if (!user.OrganizationIds.Contains(project.OrganizationId)) {
                    // TODO: Should this notification setting be deleted?
                    Log.Error().Message("Unauthorized user: project={0} user={1} organization={2} error={3}", project.Id, kv.Key,
                        project.OrganizationId, errorNotification.ErrorId).Write();
                    continue;
                }

                Log.Trace().Message("Loaded user: email={0}", user.EmailAddress).Write();

                bool shouldReportOccurrence = settings.Mode != NotificationMode.None;
                bool shouldReportCriticalError = settings.ReportCriticalErrors && errorNotification.IsCritical;
                bool shouldReportRegression = settings.ReportRegressions && errorNotification.IsRegression;

                Log.Trace().Message("Settings: mode={0} critical={1} regression={2} 404={3} bots={4}",
                    settings.Mode, settings.ReportCriticalErrors,
                    settings.ReportRegressions, settings.Report404Errors,
                    settings.ReportKnownBotErrors).Write();
                Log.Trace().Message("Should process: occurrence={0} critical={1} regression={2}",
                    shouldReportOccurrence, shouldReportCriticalError,
                    shouldReportRegression).Write();

                if (settings.Mode == NotificationMode.New && !errorNotification.IsNew) {
                    shouldReportOccurrence = false;
                    Log.Trace().Message("Skipping because message is not new.").Write();
                }

                // check for 404s if the user has elected to not report them
                if (shouldReportOccurrence && settings.Report404Errors == false && errorNotification.Code == "404") {
                    shouldReportOccurrence = false;
                    Log.Trace().Message("Skipping because message is 404.").Write();
                }

                // check for known bots if the user has elected to not report them
                if (shouldReportOccurrence && settings.ReportKnownBotErrors == false &&
//.........这里部分代码省略.........
开发者ID:khoussem,项目名称:Exceptionless,代码行数:101,代码来源:ExceptionlessMqServer.cs

示例9: ProcessErrorException

 private void ProcessErrorException(IMessage<Error> message, Exception exception) {
     exception.ToExceptionless().AddDefaultInformation().MarkAsCritical().AddObject(message.GetBody()).AddTags("ErrorMQ").Submit();
     Log.Error().Project(message.GetBody().ProjectId).Exception(exception).Message("Error processing error.").Write();
     _stats.Counter(StatNames.ErrorsProcessingFailed);
 }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:5,代码来源:ExceptionlessMqServer.cs

示例10: ProcessError

        private object ProcessError(IMessage<Error> message) {
            Error value = message.GetBody();
            if (value == null)
                return null;

            _stats.Counter(StatNames.ErrorsDequeued);
            using (_stats.StartTimer(StatNames.ErrorsProcessingTime))
                _errorPipeline.Run(value);

            return null;
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:11,代码来源:ExceptionlessMqServer.cs

示例11: ProcessEventException

 private void ProcessEventException(IMessage<PersistentEvent> message, Exception exception)
 {
     exception.ToExceptionless().AddDefaultInformation().MarkAsCritical().AddObject(message.GetBody()).AddTags("ErrorMQ").Submit();
     Log.Error().Project(message.GetBody().ProjectId).Exception(exception).Message("Error processing error.").Write();
 }
开发者ID:BookSwapSteve,项目名称:Exceptionless,代码行数:5,代码来源:ExceptionlessMqServer.cs

示例12: ProcessEvent

        private object ProcessEvent(IMessage<PersistentEvent> message)
        {
            PersistentEvent value = message.GetBody();
            if (value == null)
                return null;

            using (_stats.StartTimer(StatNames.EventsProcessingTime))
                _eventPipeline.Run(value);

            return null;
        }
开发者ID:BookSwapSteve,项目名称:Exceptionless,代码行数:11,代码来源:ExceptionlessMqServer.cs

示例13: ExecuteAsync

        /// <summary>Executes the asynchronous operation.</summary>
        ///
        /// <param name="request">The request.</param>
        ///
        /// <returns>An object.</returns>
	    public object ExecuteAsync(IMessage<Greet> request)
	    {
	        return Any(request.GetBody());
	    }
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:9,代码来源:GreetService.cs

示例14: HandleSecureRequests

 public SecureResponse HandleSecureRequests(IMessage<Secure> message, SecureLogic logic)
 {
     return logic.ProcessRequest(message.GetBody());
 }
开发者ID:ryandavidhartman,项目名称:Auth303,代码行数:4,代码来源:RequestFiltersAppHostHttpListener.cs

示例15: ExecuteAsync

        /// <summary>Executes the asynchronous operation.</summary>
        ///
        /// <param name="request">The request.</param>
        ///
        /// <returns>An object.</returns>
	    public object ExecuteAsync(IMessage<AlwaysFail> request)
	    {
	        return Any(request.GetBody());
	    }
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:9,代码来源:AlwaysFailService.cs


注:本文中的IMessage.GetBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。