public DataResponse <MqCountData> MqCount(DataRequest <string> request) { if (request == null || string.IsNullOrEmpty(request.Data)) { return(ResponseBase.InvalidInput <DataResponse <MqCountData> >("参数错误")); } MqCountData data = AppRoot.MqCountSet.GetByAppId(request.Data); return(DataResponse <MqCountData> .Ok(data)); }
public void SendMqCounts(MqCountData data) { if (data == null) { return; } _mq.BasicPublish( routingKey: MqKeyword.MqCountRoutingKey, basicProperties: CreateBasicProperties(), body: MqCountMqBodyUtil.GetMqCountMqSendBody(data)); }
protected override Dictionary <string, Action <BasicDeliverEventArgs> > GetPaths() { return(new Dictionary <string, Action <BasicDeliverEventArgs> > { [MqKeyword.MqCountRoutingKey] = ea => { string appId = ea.BasicProperties.AppId; MqCountData data = MqCountMqBodyUtil.GetMqCountMqReceiveBody(ea.Body); if (data != null) { VirtualRoot.RaiseEvent(new MqCountReceivedMqEvent(appId, data, ea.GetTimestamp())); } } }); }
public void ArrayTest() { MqCountData[] data = new MqCountData[] { new MqCountData { ReceivedCounts = new List <MqReceivedCountData> { new MqReceivedCountData() } }, new MqCountData() }; string json = VirtualRoot.JsonSerializer.Serialize(data); Console.WriteLine(json); data = VirtualRoot.JsonSerializer.Deserialize <MqCountData[]>(json); Assert.IsTrue(data[0].ReceivedCounts.Count == 1); }
public DataResponse <MqAppIds> MqAppIds() { var appIds = AppRoot.MqCountSet.GetAppIds(); var appId = appIds.FirstOrDefault(); MqCountData mqCountData = null; if (!string.IsNullOrEmpty(appId)) { mqCountData = AppRoot.MqCountSet.GetByAppId(appId); } return(DataResponse <MqAppIds> .Ok(new MqAppIds { AppIds = appIds, AppId = appId, MqCountData = mqCountData })); }
public MqCountViewModel(MqCountData data) { this.ReceivedCounts = new List <MqReceivedCountViewModel>(); this.SendCounts = new List <MqSendCountViewModel>(); foreach (var item in data.ReceivedCounts) { this.ReceivedCounts.Add(new MqReceivedCountViewModel(item)); } foreach (var item in data.SendCounts) { this.SendCounts.Add(new MqSendCountViewModel(item)); } this.ReceivedCounts.Sort((l, r) => { return((int)r.Count - (int)l.Count); }); this.SendCounts.Sort((l, r) => { return((int)r.Count - (int)l.Count); }); }
public static byte[] GetMqCountMqSendBody(MqCountData mqCount) { return(Encoding.UTF8.GetBytes(VirtualRoot.JsonSerializer.Serialize(mqCount))); }
public MqCountReceivedMqEvent(string appId, MqCountData data, DateTime timestamp) { this.AppId = appId; this.Data = data; this.Timestamp = timestamp; }