Beispiel #1
0
        private static AuditOperation BuildOperation(AuditOperationEntry operationEntry)
        {
            AuditOperation operation = operationEntry.MapTo <AuditOperation>();

            if (operationEntry.UserAgent != null)
            {
                UserAgent userAgent = new UserAgent(operationEntry.UserAgent);
                operation.OperationSystem = userAgent.GetSystem();
                operation.Browser         = userAgent.GetBrowser();
            }
            operation.Elapsed = (int)operationEntry.EndedTime.Subtract(operationEntry.CreatedTime).TotalMilliseconds;
            if (operation.ResultType == AjaxResultType.Success)
            {
                foreach (AuditEntityEntry entityEntry in operationEntry.EntityEntries)
                {
                    AuditEntity entity = entityEntry.MapTo <AuditEntity>();
                    operation.AuditEntities.Add(entity);
                    foreach (AuditPropertyEntry propertyEntry in entityEntry.PropertyEntries)
                    {
                        AuditProperty property = propertyEntry.MapTo <AuditProperty>();
                        entity.Properties.Add(property);
                    }
                }
            }
            return(operation);
        }
Beispiel #2
0
        /// <summary>
        /// 插入访问日志或分享日志
        /// </summary>
        /// <param name="rData"></param>
        /// <param name="shareUrl"></param>
        /// <param name="preTableName"></param>
        /// <returns></returns>
        private int VisitLog_Insert(NewsContentInfo_RD rData, string shareUrl, string preTableName = "VisitLog_")
        {
            WebOperationContext context = WebOperationContext.Current;

            context.OutgoingResponse.ContentType = "application/json; charset=utf-8";
            VisitLogInfo vlog = new VisitLogInfo();
            IncomingWebRequestContext inContext = context.IncomingRequest;
            UserAgent ua = UserAgentCache.CreateOrGetCacheItem(inContext.UserAgent);

            vlog.vl_browser    = ua.GetBrowser();
            vlog.vl_cookieId   = string.Empty;
            vlog.vl_createTime = DateTime.Now;
            vlog.vl_gid        = rData.n_gid;
            vlog.vl_id         = 0;
            vlog.vl_ip         = Util.Get_RemoteIp();
            vlog.vl_remoteAddr = vlog.vl_ip;
            vlog.vl_osName     = ua.GetPlatform();  // todo 操作系统的获取可能需要重新实现
            //UserAgent.KeyItem ki = ua.Spider();
            vlog.vl_spiderName = rData.vl_spiderName != null?ShareFlatform(rData.vl_spiderName) : string.Empty;

            vlog.vl_referrer = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.OriginalString + "/" + rData.n_gid;
            vlog.vl_url      = shareUrl;// 拼接成PC端地址
            vlog.vl_cateId   = rData.vl_cateId;
            //vlog.vl_screenSize = string.Empty;
            vlog.vl_totalTime = 0;
            vlog.vl_type      = rData.vl_type;
            string userName = rData.vl_userId;

            vlog.vl_userName   = (userName == "|") ? "" : userName;
            vlog.vl_screenSize = rData.vl_screenSize;
            vlog.vl_host       = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.Host; // 主域名
            string tblName = preTableName + vlog.vl_createTime.ToString("yyyyMMdd");                           // 插入表的表名
            // 插入浏览记录
            int logIndex = DataAccess_News.VisitLog_Insert(vlog, tblName);

            return(logIndex);
        }