public void DicForMonitorDataTest()
        {
            var m = new MonitorData()
            {
                ServiceName = "OrderDatabase",
                Ip = "database",
                BaseApiUrl = "database",
                ApiPath = "/FindBy",
                ApiUrl = "2"
            };
            var m2 = new MonitorData()
            {
                ServiceName = "OrderDatabase",
                Ip = "database",
                BaseApiUrl = "database",
                ApiPath = "/FindBy",
                ApiUrl = "1"
            };

            var dic = new Dictionary<MonitorData, string>();

            dic.Add(m, "a");
            dic.Add(m2, "b");


        }
        public void Test()
        {
            MonitorManager.RegisterSend(new FileSendCollectorData());

            var moti = new MonitorData();
            moti.ApiPath = "/test";
            moti.ApiUrl = "http://192.167.1.1:3000/test/api";
            moti.Ip = "192.167.1.1:3000";
            moti.ServiceName = "TestSerivce";

            var moti1 = new MonitorData();
            moti1.ApiPath = "/test";
            moti1.ApiUrl = "http://192.167.1.1:3000/test/api1";
            moti1.Ip = "192.167.1.1:3000";
            moti1.ServiceName = "TestSerivce";

            var moti2 = new MonitorData();
            moti2.ApiPath = "/test";
            moti2.ApiUrl = "http://192.167.1.1:3000/test/api2";
            moti2.Ip = "192.167.1.1:3000";
            moti2.ServiceName = "TestSerivce";

            var moti3 = new MonitorData();
            moti3.ApiPath = "/test";
            moti3.ApiUrl = "http://192.167.1.1:3000/test/api3";
            moti3.Ip = "192.167.1.1:3000";
            moti3.ServiceName = "TestSerivce";

            var motiList = new MonitorData[4] { moti, moti1, moti2, moti3 };

            DateTime delaydatetime = DateTime.Now.AddMinutes(3);

            while (DateTime.Now <= delaydatetime)
            {
                Thread.Sleep(new Random(Guid.NewGuid().GetHashCode()).Next(100, 1000));

                for (var i = 0; i < 50; i++)
                {
                    Task.Factory.StartNew(() =>
                    {
                        int m = new Random(Guid.NewGuid().GetHashCode()).Next(0, 4);

                        var requesttime = DateTime.Now;
                        int responseTime = new Random(Guid.NewGuid().GetHashCode()).Next(1, 1000);
                        MonitorManager.ResponseStat(requesttime, motiList[m], responseTime, true);
                    });
                }
            }

            Thread.Sleep(60 * 4 * 1000);
        }
 /// <summary>
 /// 响应统计
 /// </summary>
 /// <param name="requestTime"></param>
 /// <param name="data"></param>
 /// <param name="responseTime"></param>
 /// <param name="responseIsSuccess">请求是否成功</param>
 public static void ResponseStat(DateTime requestTime, MonitorData data, Int64 responseTime,bool responseIsSuccess)
 {
     if(t.ThreadState != ThreadState.Aborted && t.ThreadState != ThreadState.Stopped)
     {
         ActualResponseStat(requestTime, data, responseTime, responseIsSuccess);
     }
 }
        /// <summary>
        /// 响应统计
        /// </summary>
        /// <param name="requestTime"></param>
        /// <param name="data"></param>
        /// <param name="responseTime"></param>
        /// <param name="hasError"></param>
        private static void ActualResponseStat(DateTime requestTime, MonitorData data, Int64 responseTime,bool hasError)
        {
            string requestTimeMinStr = requestTime.ToString("yyyyMMddHHmm");

            ConcurrentDictionary<MonitorData, StatData> monitorData;
            if (dataContainer.TryGetValue(requestTimeMinStr, out monitorData))
            {
                StatData statData;
                if (monitorData.TryGetValue(data, out statData))
                {
                    statData.AddResponseFrequency();
                    statData.UpdateResponseTime(responseTime);
                    if (hasError)
                    {
                        statData.AddErrorResponseFrequency();
                    }
                }
                else
                {
                    statData = new StatData();
                    statData.AddResponseFrequency();
                    statData.UpdateResponseTime(responseTime);
                    if (hasError)
                    {
                        statData.AddErrorResponseFrequency();
                    }

                    monitorData.TryAdd(data, statData);
                }
            }
            else
            {
                monitorData = new ConcurrentDictionary<MonitorData, StatData>();

                var statData = new StatData();
                statData.AddResponseFrequency();
                statData.UpdateResponseTime(responseTime);
                if (hasError)
                {
                    statData.AddErrorResponseFrequency();
                }
                monitorData.TryAdd(data, statData);
                dataContainer.TryAdd(requestTimeMinStr, monitorData);
            }
        }
 /// <summary>
 /// 请求统计
 /// </summary>
 /// <param name="requestTime"></param>
 /// <param name="data"></param>
 private static void ActualRequestStat(DateTime requestTime,MonitorData data)
 {
     string requestTimeMinStr = requestTime.ToString("yyyyMMddHHmm");
     ConcurrentDictionary<MonitorData, StatData> monitorData;
     if (dataContainer.TryGetValue(requestTimeMinStr, out monitorData))
     {
         StatData statData;
         if (monitorData.TryGetValue(data, out statData))
         {
             statData.AddRequestFrequency();
         }
         else
         {
             statData = new StatData();
             statData.AddRequestFrequency();
             monitorData.TryAdd(data, statData);
         }
     }
     else
     {
         monitorData = new ConcurrentDictionary<MonitorData, StatData>();
         var statData = new StatData();
         statData.AddRequestFrequency();
         monitorData.TryAdd(data, statData);
         dataContainer.TryAdd(requestTimeMinStr, monitorData);
     }
 }
 /// <summary>
 /// 请求统计
 /// </summary>
 /// <param name="requestTime"></param>
 /// <param name="data"></param>
 public static void RequestStat(DateTime requestTime, MonitorData data)
 {
     if (t.ThreadState != ThreadState.Aborted && t.ThreadState != ThreadState.Stopped)
     {
         ActualRequestStat(requestTime, data);
     }
 }