Ejemplo n.º 1
0
        static string GetXml(AccessLogItem item)
        {
            XmlDocument domOperLog = new XmlDocument();

            domOperLog.LoadXml("<root />");

            if (string.IsNullOrEmpty(item.LibraryCode) == false)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement,
                                       "libraryCode", item.LibraryCode);
            }
            DomUtil.SetElementText(domOperLog.DocumentElement,
                                   "operation", "getRes");
            DomUtil.SetElementText(domOperLog.DocumentElement,
                                   "path", item.Path);
            if (item.Size != 0)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement,
                                       "size", item.Size.ToString());
            }
            if (string.IsNullOrEmpty(item.MIME) == false)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement,
                                       "mime", item.MIME);
            }
            if (string.IsNullOrEmpty(item.ClientAddress) == false)
            {
                OperLog.WriteClientAddress(domOperLog, item.ClientAddress);
            }
            if (item.HitCount != 1)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement,
                                       "hitCount", item.HitCount.ToString());
            }

            DomUtil.SetElementText(domOperLog.DocumentElement, "operator",
                                   item.Operator);

            DomUtil.SetElementText(domOperLog.DocumentElement, "operTime",
                                   DateTimeUtil.Rfc1123DateTimeStringEx(item.OperTime.ToLocalTime()));
            return(domOperLog.OuterXml);
        }
Ejemplo n.º 2
0
        public bool Add(string operation,
                        string path,
                        long size,
                        string mime,
                        string clientAddress,
                        long initial_hitcount,
                        string operator_param,
                        DateTime opertime,
                        long maxItemCount)
        {
            AccessLogItem item = new AccessLogItem();

            item.Operation     = operation;
            item.Path          = path;
            item.Size          = size;
            item.MIME          = mime;
            item.ClientAddress = clientAddress;
            item.HitCount      = initial_hitcount;
            item.Operator      = operator_param;
            item.OperTime      = opertime;

            return(Add(item, maxItemCount));
        }
Ejemplo n.º 3
0
        // parameters:
        //      maxItemCount    最大事项数。如果为 -1 表示不限制
        public bool Add(AccessLogItem item,
                        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);
                }
            }

            collection.Insert(item);
            return(true);
        }
Ejemplo n.º 4
0
        static string GetXml(AccessLogItem item)
        {
            XmlDocument domOperLog = new XmlDocument();
            domOperLog.LoadXml("<root />");

            if (string.IsNullOrEmpty(item.LibraryCode) == false)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement,
                    "libraryCode", item.LibraryCode);
            }
            DomUtil.SetElementText(domOperLog.DocumentElement,
                "operation", "getRes");
            DomUtil.SetElementText(domOperLog.DocumentElement,
                "path", item.Path);
            if (item.Size != 0)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement,
                    "size", item.Size.ToString());
            }
            if (string.IsNullOrEmpty(item.MIME) == false)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement,
                    "mime", item.MIME);
            }
            if (string.IsNullOrEmpty(item.ClientAddress) == false)
            {
                OperLog.WriteClientAddress(domOperLog, item.ClientAddress);
            }
            if (item.HitCount != 1)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement,
                    "hitCount", item.HitCount.ToString());
            }

            DomUtil.SetElementText(domOperLog.DocumentElement, "operator",
                item.Operator);

            DomUtil.SetElementText(domOperLog.DocumentElement, "operTime",
                DateTimeUtil.Rfc1123DateTimeStringEx(item.OperTime.ToLocalTime()));
            return domOperLog.OuterXml;
        }
Ejemplo n.º 5
0
        // parameters:
        //      maxItemCount    最大事项数。如果为 -1 表示不限制
        public bool Add(AccessLogItem item,
            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;
                }
            }

            collection.Insert(item);
            return true;
        }
Ejemplo n.º 6
0
        public bool Add(string operation,
    string path,
    long size,
    string mime,
    string clientAddress,
    long initial_hitcount,
    string operator_param,
    DateTime opertime,
    long maxItemCount)
        {
            AccessLogItem item = new AccessLogItem();
            item.Operation = operation;
            item.Path = path;
            item.Size = size;
            item.MIME = mime;
            item.ClientAddress = clientAddress;
            item.HitCount = initial_hitcount;
            item.Operator = operator_param;
            item.OperTime = opertime;

            return Add(item, maxItemCount);
        }