Beispiel #1
0
        public static IList <AuditRecord> GetAuditItems(string data, AuditRecord.AuditAction action)
        {
            ConnectionParameters parameters = ConnectionParameters.Create("DefaultDB");

            IList <AuditRecord> records;

            using (var transaction = new TransactionScope(parameters))
            {
                var store = new AuditDataStore(transaction);
                records = store.Find(data, action.ToString());
            }

            return(records);
        }
Beispiel #2
0
        public static AuditRecord GetAuditItem(string Id)
        {
            ConnectionParameters parameters = ConnectionParameters.Create("DefaultDB");

            AuditRecord record;

            using (var transaction = new TransactionScope(parameters))
            {
                var store = new AuditDataStore(transaction);

                record = store.FindByKey(Id);
            }

            return(record);
        }
Beispiel #3
0
        public static void DeleteAllAuditsAfterDate(DateTime date)
        {
            ConnectionParameters parameters = ConnectionParameters.Create("DefaultDB");

            using (var transaction = new TransactionScope(parameters))
            {
                var store = new AuditDataStore(transaction);

                IList <AuditRecord> records = store.FindAllFromDate(date);

                foreach (AuditRecord record in records)
                {
                    store.Delete(record.Id);
                }

                transaction.Commit();
            }
        }
Beispiel #4
0
        public static void Audit(string userName, string data, AuditRecord.AuditAction action)
        {
            var auditRecord = new AuditRecord();

            auditRecord.Action    = action.ToString();
            auditRecord.UserName  = userName;
            auditRecord.Data      = data;
            auditRecord.TimeStamp = DateTime.Now;

            ConnectionParameters parameters = ConnectionParameters.Create("DefaultDB");

            using (var transaction = new TransactionScope(parameters))
            {
                var store = new AuditDataStore(transaction);
                //if (!store.AuditRecordExist(username, data, action.ToString()))
                //{
                store.Insert(auditRecord);
                transaction.Commit();
                //}
            }
        }