Exemple #1
0
        public long GetValue(string name,
                             string strDate,
                             int nInc)
        {
            DailyItemCount item = GetItem(name);

            return(item.GetValue(strDate, nInc));
        }
Exemple #2
0
        // parameters:
        //      maxItemCount    最大事项数。如果为 -1 表示不限制
        public bool Add(string operation,
                        string path,
                        long size,
                        string mime,
                        string clientAddress,
                        long initial_hitcount,
                        string operator_param,
                        DateTime opertime,
                        long maxItemCount)
        {
            MongoCollection <AccessLogItem> collection = this.LogCollection;

            if (collection == null)
            {
                return(false);
            }

            // 限制最大事项数
            {
                string date     = GetToday();
                long   newValue = _itemCount.GetValue(date, 1);
                if (maxItemCount != -1 && newValue > maxItemCount)
                {
                    _itemCount.GetValue(date, -1);
                    return(false);
                }
            }

            var query = new QueryDocument("Path", path);

            query.Add("Operation", operation)
            .Add("Size", size)
            .Add("MIME", mime)
            .Add("ClientAddress", clientAddress)
            .Add("HitCount", initial_hitcount)
            .Add("Operator", operator_param)
            .Add("OperTime", opertime);
            collection.Insert(query);
            return(true);
        }