Ejemplo n.º 1
0
 public void Add(AuditType type, string comment, int userId, int objectId)
 {
     using (var uow = UowProvider.GetUnitOfWork())
     {
         var repo = RepositoryFactory.CreateAuditRepository(uow);
         repo.AddOrUpdate(new AuditItem(objectId, comment, type, userId));
         uow.Commit();
     }
 }
Ejemplo n.º 2
0
 private void Audit(AuditType type, string message, int userId, int objectId)
 {
     var uow = _dataUowProvider.GetUnitOfWork();
     using (var auditRepo = _repositoryFactory.CreateAuditRepository(uow))
     {
         auditRepo.AddOrUpdate(new AuditItem(objectId, message, type, userId));
         uow.Commit();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns paged items in the audit trail for a given user
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecords"></param>
        /// <param name="orderDirection">
        /// By default this will always be ordered descending (newest first)
        /// </param>
        /// <param name="auditTypeFilter">
        /// Since we currently do not have enum support with our expression parser, we cannot query on AuditType in the query or the custom filter
        /// so we need to do that here
        /// </param>
        /// <param name="customFilter">
        /// Optional filter to be applied
        /// </param>
        /// <returns></returns>
        public IEnumerable <IAuditItem> GetPagedItemsByUser(int userId, long pageIndex, int pageSize, out long totalRecords, Direction orderDirection = Direction.Descending, AuditType[] auditTypeFilter = null, IQuery <IAuditItem> customFilter = null)
        {
            Mandate.ParameterCondition(pageIndex >= 0, "pageIndex");
            Mandate.ParameterCondition(pageSize > 0, "pageSize");

            if (userId < 0)
            {
                totalRecords = 0;
                return(Enumerable.Empty <IAuditItem>());
            }

            using (var uow = UowProvider.GetUnitOfWork(readOnly: true))
            {
                var repository = RepositoryFactory.CreateAuditRepository(uow);

                var query = Query <IAuditItem> .Builder.Where(x => x.UserId == userId);

                return(repository.GetPagedResultsByQuery(query, pageIndex, pageSize, out totalRecords, orderDirection, auditTypeFilter, customFilter));
            }
        }
        ///// <summary>
        ///// Gets a list all available <see cref="IMacroPropertyType"/> plugins
        ///// </summary>
        ///// <returns>An enumerable list of <see cref="IMacroPropertyType"/> objects</returns>
        //public IEnumerable<IMacroPropertyType> GetMacroPropertyTypes()
        //{
        //    return MacroPropertyTypeResolver.Current.MacroPropertyTypes;
        //}

        ///// <summary>
        ///// Gets an <see cref="IMacroPropertyType"/> by its alias
        ///// </summary>
        ///// <param name="alias">Alias to retrieve an <see cref="IMacroPropertyType"/> for</param>
        ///// <returns>An <see cref="IMacroPropertyType"/> object</returns>
        //public IMacroPropertyType GetMacroPropertyTypeByAlias(string alias)
        //{
        //    return MacroPropertyTypeResolver.Current.MacroPropertyTypes.FirstOrDefault(x => x.Alias == alias);
        //}

        private void Audit(IScopeUnitOfWork uow, AuditType type, string message, int userId, int objectId)
        {
            var repository = RepositoryFactory.CreateAuditRepository(uow);

            repository.AddOrUpdate(new AuditItem(objectId, message, type, userId));
        }