static IDisposable Current_QueryExecuted(DynamicQueryManager.ExecuteType type, object queryName, BaseQueryRequest request)
        {
            if (request == null || !LogQuery(request, type))
                return null;

            var old = Connector.CurrentLogger;

            StringWriter sw = new StringWriter();

            Connector.CurrentLogger = old == null ? (TextWriter)sw : new DuplicateTextWriter(sw, old);

            var viewLog = new ViewLogEntity
            {
                Target = QueryLogic.GetQueryEntity(queryName).ToLite(),
                User = UserHolder.Current.ToLite(),
                ViewAction = type.ToString(),
            };

            return new Disposable(() =>
            {
                try
                {
                    viewLog.EndDate = TimeZoneManager.Now;
                    viewLog.Data = request.QueryUrl + "\r\n\r\n" + sw.ToString();
                    using (ExecutionMode.Global())
                        viewLog.Save();
                }
                finally
                {
                    Connector.CurrentLogger = old;
                }
            });
        }
예제 #2
0
        public static IDisposable LogView(Lite<IEntity> entity, string viewAction)
        {
            var viewLog = new ViewLogEntity
            {
                Target = (Lite<Entity>)entity.Clone(),
                User = UserHolder.Current.ToLite(),
                ViewAction = viewAction,
            };

            return new Disposable(() =>
            {
                viewLog.EndDate = TimeZoneManager.Now;
                using (ExecutionMode.Global())
                    viewLog.Save();
            });
        }