Exemplo n.º 1
0
        public static IDisposable?LogView(Lite <IEntity> entity, string viewAction)
        {
            if (!IsStarted)
            {
                return(null);
            }

            if (entity == null || !LogType(entity.EntityType) || UserHolder.Current == null)
            {
                return(null);
            }


            var viewLog = new ViewLogEntity
            {
                Target     = (Lite <Entity>)entity.Clone(),
                User       = UserHolder.Current.ToLite(),
                ViewAction = viewAction,
                Data       = new BigStringEmbedded(),
            };

            return(new Disposable(() =>
            {
                viewLog.EndDate = TimeZoneManager.Now;
                using (ExecutionMode.Global())
                    viewLog.Save();
            }));
        }
Exemplo n.º 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();
            }));
        }
Exemplo n.º 3
0
        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
                {
                    using (Transaction tr = Transaction.ForceNew())
                    {
                        viewLog.EndDate = TimeZoneManager.Now;
                        viewLog.Data = GetData(request, sw);
                        using (ExecutionMode.Global())
                            viewLog.Save();
                        tr.Commit();
                    }
                }
                finally
                {
                    Connector.CurrentLogger = old;
                }
            }));
        }