Exemple #1
0
        protected override void MapEntityToCustomProperties(IENTBaseEntity entity)
        {
            var eNTAudit = (ENTAudit)entity;

            ID           = eNTAudit.ENTAuditId;
            ObjectName   = eNTAudit.ObjectName;
            RecordId     = eNTAudit.RecordId;
            PropertyName = eNTAudit.PropertyName;
            OldValue     = eNTAudit.OldValue;
            NewValue     = eNTAudit.NewValue;
            AuditType    = (AuditTypeEnum)eNTAudit.AuditType;
        }
        private string GetLocationClassCodesSelectStatement(AuditTypeEnum auditType)
        {
            return($@"
                    SELECT 
	                    LocationID,
	                    ClassCodeState,
	                    ClassCode,
	                    ClassCodeDesc,
	                    ClassCodeId = CASE WHEN (ClassCodeLookUpId IS NULL OR ClassCodeLookupId = 0)
                            THEN dbo.fnGetClassCodeId({(int)auditType}, ClassCodeState, ClassCode, ClassCodeDesc) 
                            ELSE ClassCodeLookupId END
                    FROM dbo.ClassCodes2Audit
                    ");
        }
Exemple #3
0
        /// <summary>
        /// Log audit/messages
        /// </summary>
        /// <param name="type">type of event</param>
        /// <param name="server">server name</param>
        /// <param name="username">username</param>
        /// <param name="clientips">connected ip</param>
        /// <param name="text">log text</param>
        public static void Log(AuditTypeEnum type, string server, string username, string clientips, string text, string zoneName, string recordName)
        {
            if (!AuditTypes.HasFlag(type))
            {
                return;
            }

            if (AuditMedia.HasFlag(AuditMediaEnum.DB))
            {
                if (auditrecords.Count > 100)
                {
                    throw new Exception("Audit records are not being save quick enough to the database, check server load or check if the database is locked");
                }

                auditrecords.Enqueue(new AuditRecord
                {
                    Id           = Guid.NewGuid(),
                    Server       = (server != null) ? server.ToLower() : string.Empty,
                    TimestampUTC = DateTime.UtcNow,
                    Type         = type.ToString(),
                    Username     = username.ToLower(),
                    ClientIP     = clientips,
                    Text         = text,
                    Zone         = zoneName,
                    RecordName   = recordName
                });

                //first execution always access the database, easy to see startup errors
                if (tDatabaseHandler == null)
                {
                    DatabaseHandler(false);

                    tDatabaseHandler = new Thread(new ThreadStart(DatabaseHandler));
                    tDatabaseHandler.Start();
                }
            }

            if (AuditMedia.HasFlag(AuditMediaEnum.File))
            {
                var log = log4net.LogManager.GetLogger("MSDNSAdmin");
                log.InfoFormat(LogLineFormat, type.ToString(), (server != null) ? server.ToLower() : string.Empty, username.ToLower(), clientips, text, zoneName, recordName);
            }
        }
Exemple #4
0
        /// <summary>
        /// Log audit/messages
        /// </summary>
        /// <param name="type">type of event</param>
        /// <param name="server">server name</param>
        /// <param name="username">username</param>
        /// <param name="clientips">connected ip</param>
        /// <param name="text">log text</param>
        public static void Log(AuditTypeEnum type, string server, string username, string clientips, string text, string zoneName, string recordName)
        {
            if (!AuditTypes.HasFlag(type))
                return;

            if (AuditMedia.HasFlag(AuditMediaEnum.DB))
            {
                if (auditrecords.Count > 100)
                    throw new Exception("Audit records are not being save quick enough to the database, check server load or check if the database is locked");

                auditrecords.Enqueue(new AuditRecord
                {
                    Id = Guid.NewGuid(),
                    Server = (server != null ) ? server.ToLower() : string.Empty,
                    TimestampUTC = DateTime.UtcNow,
                    Type = type.ToString(),
                    Username = username.ToLower(),
                    ClientIP = clientips,
                    Text = text,
                    Zone = zoneName,
                    RecordName = recordName
                });

                //first execution always access the database, easy to see startup errors
                if (tDatabaseHandler == null)
                {
                    DatabaseHandler(false);

                    tDatabaseHandler = new Thread(new ThreadStart(DatabaseHandler));
                    tDatabaseHandler.Start();
                }

            }

            if (AuditMedia.HasFlag(AuditMediaEnum.File))
            {
                var log = log4net.LogManager.GetLogger("MSDNSAdmin");
                log.InfoFormat(LogLineFormat, type.ToString(), (server != null) ? server.ToLower() : string.Empty, username.ToLower(), clientips, text, zoneName, recordName);
            }
        }
        public async Task <GetResponse <IReadOnlyList <IClassCode> > > GetAllByAuditType(AuditTypeEnum auditType)
        {
            var getResponse = new GetResponse <IReadOnlyList <IClassCode> >();

            try
            {
                getResponse = await _classCodeRepository.GetAllByAuditType(auditType);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                getResponse.AddError(ex);
                _logManager.LogError(ex, "Error retrieving classCodes");
            }

            return(getResponse);
        }
Exemple #6
0
        public async Task <GetResponse <IReadOnlyList <IClassCode> > > GetAllByAuditType(AuditTypeEnum auditType)
        {
            {
                var response = new GetResponse <IReadOnlyList <IClassCode> >();

                try
                {
                    using (var connection = ConnectionFactory.GetConnection())
                    {
                        var results = await connection.QueryAsync <ClassCodeDto>("spsClassCodesForAuditType", new { AuditTypeId = auditType }, commandType : CommandType.StoredProcedure);

                        response.Content = results
                                           .Select(dto => dto.ToModel())
                                           .AsList();
                    }
                }
                catch (Exception e)
                {
                    var messaage = $@"Unable to retrieve class codes for audit type {auditType}.";
                    response.AddError(e);
                    LogManager.LogError(e, messaage);
                    Console.WriteLine(e);
                }

                return(response);
            }
        }