コード例 #1
0
ファイル: MonitorData.cs プロジェクト: wisexie/WCFDemo
        /// <summary>
        /// 更新某地址的链接数
        /// </summary>
        /// <param name="ip">IP地址</param>
        /// <param name="Url">请求的url绝对地址</param>
        /// <param name="isadd">是否增加,否则就是减</param>
        public void UpdateUrlConnNums(string ip, string Url, bool isadd)
        {
            if (!this.monitorInfo.ContainsKey(ip))
            {
                lock (lockupdateconnnums)
                {
                    if (!this.monitorInfo.ContainsKey(ip))
                    {
                        LinkModel model = new LinkModel();
                        model.ClientIP    = ip;
                        model.UrlInfoList = new Dictionary <string, UrlInfo>();
                        UrlInfo url = new UrlInfo();
                        url.ConnNums           = 0;
                        url.OperateNums        = new Dictionary <string, long>();
                        model.UrlInfoList[Url] = url;

                        this.monitorInfo[ip] = model;
                    }
                }
            }

            if (this.monitorInfo.ContainsKey(ip))
            {
                lock (lockupdateconnnums)
                {
                    if (!this.monitorInfo[ip].UrlInfoList.ContainsKey(Url))
                    {
                        UrlInfo url = new UrlInfo();
                        url.ConnNums    = 0;
                        url.OperateNums = new Dictionary <string, long>();
                        this.monitorInfo[ip].UrlInfoList[Url] = url;
                    }

                    if (isadd)
                    {
                        this.monitorInfo[ip].UrlInfoList[Url].ConnNums += 1;
                    }
                    else
                    {
                        this.monitorInfo[ip].UrlInfoList[Url].ConnNums -= 1;
                    }

                    //if (this.monitorInfo[ip].UrlInfoList[Url].ConnNums < 0)
                    //    this.monitorInfo[ip].UrlInfoList[Url].ConnNums = 0;
                }
            }
        }
コード例 #2
0
ファイル: MonitorData.cs プロジェクト: wisexie/WCFDemo
        /// <summary>
        /// 更新操作次数
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="Url"></param>
        /// <param name="operateName"></param>
        public void UpdateOperateNums(string ip, string Url, string operateName)
        {
            if (!this.monitorInfo.ContainsKey(ip))
            {
                lock (lockupdateconnnums)
                {
                    if (!this.monitorInfo.ContainsKey(ip))
                    {
                        LinkModel model = new LinkModel();
                        model.ClientIP    = ip;
                        model.UrlInfoList = new Dictionary <string, UrlInfo>();
                        UrlInfo url = new UrlInfo();
                        url.ConnNums           = 0;
                        url.OperateNums        = new Dictionary <string, long>();
                        model.UrlInfoList[Url] = url;

                        this.monitorInfo[ip] = model;
                    }
                }
            }

            lock (lockupdateoperatenums)
            {
                if (!this.monitorInfo[ip].UrlInfoList.ContainsKey(Url))
                {
                    UrlInfo url = new UrlInfo();
                    url.ConnNums    = 0;
                    url.OperateNums = new Dictionary <string, long>();
                    this.monitorInfo[ip].UrlInfoList[Url] = url;
                }

                this.monitorInfo[ip].UrlInfoList[Url].OperateNums[operateName] =
                    this.monitorInfo[ip].UrlInfoList[Url].OperateNums.ContainsKey(operateName) ?
                    (this.monitorInfo[ip].UrlInfoList[Url].OperateNums[operateName] == long.MaxValue ? 1 : this.monitorInfo[ip].UrlInfoList[Url].OperateNums[operateName] + 1) : 1;
            }
        }
コード例 #3
0
ファイル: MonitorData.cs プロジェクト: wisexie/WCFDemo
        /// <summary>
        /// 更新操作次数
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="Url"></param>
        /// <param name="operateName"></param>
        public void UpdateOperateNums(string ip, string Url, string operateName)
        {
            if (!this.monitorInfo.ContainsKey(ip))
            {
                lock (lockupdateconnnums)
                {
                    if (!this.monitorInfo.ContainsKey(ip))
                    {
                        LinkModel model = new LinkModel();
                        model.ClientIP = ip;
                        model.UrlInfoList = new Dictionary<string, UrlInfo>();
                        UrlInfo url = new UrlInfo();
                        url.ConnNums = 0;
                        url.OperateNums = new Dictionary<string, long>();
                        model.UrlInfoList[Url] = url;

                        this.monitorInfo[ip] = model;
                    }
                }
            }

            lock (lockupdateoperatenums)
            {
                if (!this.monitorInfo[ip].UrlInfoList.ContainsKey(Url))
                {
                    UrlInfo url = new UrlInfo();
                    url.ConnNums = 0;
                    url.OperateNums = new Dictionary<string, long>();
                    this.monitorInfo[ip].UrlInfoList[Url] = url;
                }

                this.monitorInfo[ip].UrlInfoList[Url].OperateNums[operateName] =
                    this.monitorInfo[ip].UrlInfoList[Url].OperateNums.ContainsKey(operateName) ?
                    (this.monitorInfo[ip].UrlInfoList[Url].OperateNums[operateName] == long.MaxValue ? 1 : this.monitorInfo[ip].UrlInfoList[Url].OperateNums[operateName] + 1) : 1;
            }
        }
コード例 #4
0
ファイル: MonitorData.cs プロジェクト: wisexie/WCFDemo
        /// <summary>
        /// 更新某地址的链接数
        /// </summary>
        /// <param name="ip">IP地址</param>
        /// <param name="Url">请求的url绝对地址</param>
        /// <param name="isadd">是否增加,否则就是减</param>
        public void UpdateUrlConnNums(string ip, string Url, bool isadd)
        {
            if (!this.monitorInfo.ContainsKey(ip))
            {
                lock (lockupdateconnnums)
                {
                    if (!this.monitorInfo.ContainsKey(ip))
                    {
                        LinkModel model = new LinkModel();
                        model.ClientIP = ip;
                        model.UrlInfoList = new Dictionary<string, UrlInfo>();
                        UrlInfo url = new UrlInfo();
                        url.ConnNums = 0;
                        url.OperateNums = new Dictionary<string, long>();
                        model.UrlInfoList[Url] = url;

                        this.monitorInfo[ip] = model;
                    }
                }
            }

            if (this.monitorInfo.ContainsKey(ip))
            {
                lock (lockupdateconnnums)
                {
                    if (!this.monitorInfo[ip].UrlInfoList.ContainsKey(Url))
                    {
                        UrlInfo url = new UrlInfo();
                        url.ConnNums = 0;
                        url.OperateNums = new Dictionary<string, long>();
                        this.monitorInfo[ip].UrlInfoList[Url] = url;
                    }

                    if (isadd)
                        this.monitorInfo[ip].UrlInfoList[Url].ConnNums += 1;
                    else
                        this.monitorInfo[ip].UrlInfoList[Url].ConnNums -= 1;

                    //if (this.monitorInfo[ip].UrlInfoList[Url].ConnNums < 0)
                    //    this.monitorInfo[ip].UrlInfoList[Url].ConnNums = 0;
                }
            }
        }