Exemplo n.º 1
0
        public override List <AmplaRecordChanges> DetectChanges()
        {
            DateTime createdDate  = amplaRecord.GetValueOrDefault("CreatedDateTime", DateTime.MinValue);
            string   user         = amplaRecord.GetValueOrDefault("CreatedBy", "System");
            DateTime samplePeriod = amplaRecord.GetValueOrDefault("Sample Period", DateTime.MinValue);
            DateTime startTime    = amplaRecord.GetValueOrDefault("Start Time", DateTime.MinValue);

            if (user.StartsWith(systemConfigurationUsers))
            {
                user = user.Substring(systemConfigurationUsers.Length);
            }

            List <AmplaRecordChanges> recordChanges = new List <AmplaRecordChanges>();

            DateTime recordTime = createdDate != DateTime.MinValue ? createdDate
                                      : samplePeriod != DateTime.MinValue ? samplePeriod
                                      : startTime != DateTime.MinValue ? startTime
                                      : DateTime.Now;

            recordChanges.Add(new AmplaRecordChanges
            {
                Operation       = Operation,
                User            = user,
                VersionDateTime = recordTime,
                Changes         = new AmplaAuditField[0],
                Display         = string.Format("{0} created record", user)
            });

            return(recordChanges);
        }
        public override List <AmplaRecordChanges> DetectChanges()
        {
            List <AmplaRecordChanges> recordChanges = new List <AmplaRecordChanges>();

            if (amplaRecord.GetValueOrDefault(deletedDisplayName, false))
            {
                if (amplaAuditRecord.Changes != null)
                {
                    foreach (AmplaAuditSession session in amplaAuditRecord.Changes)
                    {
                        AmplaAuditField isDeleted = session.Fields.FirstOrDefault(f => f.Name == deletedName);
                        if (isDeleted != null)
                        {
                            AmplaRecordChanges changes = new AmplaRecordChanges
                            {
                                VersionDateTime = session.EditedTime,
                                User            = session.User,
                                Operation       = Operation,
                                Changes         = new [] { new AmplaAuditField()
                                                           {
                                                               Name          = deletedName,
                                                               OriginalValue = "False",
                                                               EditedValue   = "True"
                                                           } },
                                Display = string.Format("{0} deleted record", session.User)
                            };
                            recordChanges.Add(changes);
                        }
                    }
                }
            }
            return(recordChanges);
        }