private void bindLayout() { set("notificationUrl", to(new NotificationController().List)); // 是否有阅读网站通知的权限? String lnkSiteNf = ""; if (ctx.viewer.obj.RoleId == SiteRole.Administrator.Id) { String siteNfUrl = t2(new SiteNfController().List); lnkSiteNf = string.Format("<li id=\"tabSite\"><a href=\"{0}\">网站通知</a><span></span></li>", siteNfUrl); } set("lnkSiteNotification", lnkSiteNf); set("msg.UrlNew", to(New, -1)); set("msg.UrlUnread", to(Unread)); set("msg.UrlAll", to(Index)); set("msg.UrlSend", to(Sent)); set("msg.UrlTrash", to(Deleted)); User user = ctx.owner.obj as User; MessageStats stats = msgService.GetStats(user); set("msg.NewCount", getCountString(stats.New)); set("msg.AllCount", getCountString(stats.All)); set("msg.SendCount", getCountString(stats.Sended)); set("msg.TrashCount", getCountString(stats.Trash)); }
private StatisticsRecord GetStatisticsByQueue(SubscriptionQueueEntry e, MessageStats prevStats) { var record = new StatisticsRecord(); var setting = _statisticsSettings.GetSetting(e.Subscription); if (setting == null) { setting = _statisticsSettings.CreateSetting(e.Subscription); } record.StatisticsSetting = setting; record.Since = DateTime.Now; record.To = record.Since.AddMilliseconds(StatisticsIntervalToMilliseconds(Interval)); record.StatisticsInterval = Interval; var stats = e.Queue.MessageStats; var sumSentFunc = new Func <MessageStats, long> (x => x != null ? x.DeliverGet : 0); var sumPublishFunc = new Func <MessageStats, long> (x => x != null ? x.Publish : 0); if (stats != null) { record.SentCount = GetStatisticValue((int)sumSentFunc(stats), (int)sumSentFunc(prevStats)); record.ReceivedCount = GetStatisticValue((int)sumPublishFunc(stats), (int)sumPublishFunc(prevStats)); record.QueueLength = e.Queue.Messages; } return(record); }
public virtual MessageStats GetStats(User owner) { MessageStats stats = new MessageStats(); stats.New = owner.MsgNewCount; stats.All = owner.MsgCount; stats.Sended = db.find <MessageData>("IsDelete=0 and Sender.Id=" + owner.Id).count(); stats.Trash = db.find <Message>("IsDelete=1 and Receiver.Id=" + owner.Id).count(); return(stats); }
public BrokerQueueChurnMetricsImpl(MessageStats messageStats, QueueStats queueStats) { Incoming = new QueueDepthImpl(messageStats.TotalMessagesPublished, messageStats.MessagesPublishedDetails?.Value ?? 0); NotRouted = new QueueDepthImpl(messageStats.TotalUnroutableMessages, messageStats.UnroutableMessagesDetails?.Value ?? 0); Gets = new QueueDepthImpl(messageStats.TotalMessageGets, messageStats.MessageGetDetails?.Value ?? 0); GetsWithoutAck = new QueueDepthImpl(messageStats.TotalMessageGetsWithoutAck, messageStats.MessageGetsWithoutAckDetails?.Value ?? 0); DeliveredGets = new QueueDepthImpl(messageStats.TotalMessageDeliveryGets, messageStats.MessageDeliveryGetDetails?.Value ?? 0); Delivered = new QueueDepthImpl(messageStats.TotalMessagesDelivered, messageStats.MessageDeliveryDetails?.Value ?? 0); DeliveredWithoutAck = new QueueDepthImpl(messageStats.TotalMessageDeliveredWithoutAck, messageStats.MessagesDeliveredWithoutAckDetails?.Value ?? 0); Redelivered = new QueueDepthImpl(messageStats.TotalMessagesRedelivered, messageStats.MessagesRedeliveredDetails?.Value ?? 0); Acknowledged = new QueueDepthImpl(messageStats.TotalMessagesAcknowledged, messageStats.MessagesAcknowledgedDetails?.Value ?? 0); Broker = new QueueDepthImpl(queueStats.TotalMessages, queueStats.MessageDetails?.Value ?? 0); Ready = new QueueDepthImpl(queueStats.TotalMessagesReadyForDelivery, queueStats.MessagesReadyForDeliveryDetails?.Value ?? 0); Unacknowledged = new QueueDepthImpl(queueStats.TotalUnacknowledgedDeliveredMessages, queueStats.UnacknowledgedDeliveredMessagesDetails?.Value ?? 0); }
public GraphManager(IDatabase database, DiscordShardedClient client, LogHandler logger) { Database = database; Client = client; var config = GetConfig(); if (config.GraphiteUrl == null) { logger.Log("Graphite URL not set, you can set it using the SetGraphiteUrl command.", Discord.LogSeverity.Warning); } GraphiteService = new GraphiteService(config.GraphiteUrl); Client.UserJoined += UserCountChanged; Client.JoinedGuild += GuildCountChanged; Client.LeftGuild += GuildCountChanged; Client.UserLeft += UserCountChanged; Client.MessageReceived += MessageReceived; MessageStatistics = new MessageStats(); Timer = new Timer(TimerEvent, null, TimeSpan.Zero, TimeSpan.FromMinutes(1)); }