public void Log(IAuditInfo info)
        {
            try
            {
                if (info is IPagePreRenderCompleteEvent)
                {
                    return;
                }

                if (info == null)
                {
                    return;
                }

                var request = new IndexRequest <IDictionary <string, object> >(this.IndexName, new Id(Guid.NewGuid().ToString()));
                request.Document = info.Fields;
                this.client.Index(request);
            }
            catch (Exception e)
            {
                var exceptionMessage = new StringBuilder()
                                       .AppendLine("Error sending the audit information to Elasticsearch.")
                                       .AppendLine("Error details:")
                                       .Append(e.ToString())
                                       .ToString();
                Telerik.Sitefinity.Abstractions.Log.Write(exceptionMessage);
            }
        }
예제 #2
0
 /// <summary>
 ///     设置审核人信息
 /// </summary>
 /// <param name="auditInfo">被赋值的实体</param>
 /// <param name="auditID">创建人ID</param>
 /// <param name="auditName">创建人名称</param>
 public static void SetAuditInfo(this IAuditInfo auditInfo, int?auditID = 0, string auditName = "")
 {
     auditInfo.AuditIP   = Req.GetIP();
     auditInfo.AuditAt   = DateTime.Now;
     auditInfo.AuditID   = auditID;
     auditInfo.AuditName = auditName;
 }
예제 #3
0
        public void Log(IAuditInfo info)
        {
            try
            {
                if (info is IPagePreRenderCompleteEvent)
                {
                    return;
                }

                if (info == null)
                {
                    return;
                }

                this.client.Raw.Index(this.IndexName, AuditTypeFriendlyName, info.Fields);
            }
            catch (Exception e)
            {
                var exceptionMessage = new StringBuilder()
                                       .AppendLine("Error sending the audit information to Elasticsearch.")
                                       .AppendLine("Error details:")
                                       .Append(e.ToString())
                                       .ToString();
                Telerik.Sitefinity.Abstractions.Log.Write(exceptionMessage);
            }
        }
예제 #4
0
        public static AuditAutoDetectData[] AutoDetectDataAuditing(ConnectionData connData)
        {
            List <AuditAutoDetectData> lst = new List <AuditAutoDetectData>();

            string[]    auditTables = SqlSync.DbInformation.InfoHelper.GetDatabaseTableList(connData, String.Format(auditTableNameFormat, "%"));
            TableSize[] allTable    = SqlSync.DbInformation.InfoHelper.GetDatabaseTableListWithRowCount(connData);
            string      baseName;
            int         rowCount;

            for (int i = 0; i < auditTables.Length; i++)
            {
                baseName = auditTables[i].Replace(String.Format(auditTableNameFormat, ""), "");

                rowCount = SqlSync.DbInformation.InfoHelper.DbContainsTableWithRowcount(baseName, allTable);
                if (rowCount > -1)
                {
                    AuditAutoDetectData dat = new AuditAutoDetectData();
                    dat.TableName     = baseName;
                    dat.RowCount      = rowCount;
                    dat.HasAuditTable = true;
                    lst.Add(dat);
                }
            }
            string[] allTriggers = SqlSync.DbInformation.InfoHelper.GetTriggers(connData);
            for (int i = 0; i < lst.Count; i++)
            {
                IAuditInfo item = lst[i];
                CheckForStandardAuditTriggers(ref item, allTriggers);
            }

            AuditAutoDetectData[] data = new AuditAutoDetectData[lst.Count];
            lst.CopyTo(data);
            return(data);
        }
예제 #5
0
 private void ApplyRules()
 {
     foreach (var entry in this.ChangeTracker.Entries().Where(e => e.Entity is IAuditInfo && (e.State == EntityState.Added) || (e.State == EntityState.Modified)))
     {
         IAuditInfo e = (IAuditInfo)entry.Entity;
         if (entry.State == EntityState.Added)
         {
             e.CreatedOn = DateTime.Now;
         }
         e.ModifiedOn = DateTime.Now;
     }
 }
예제 #6
0
        /// <summary>
        /// Método para auditar la modificación de la entidad.
        /// </summary>
        /// <remarks>
        /// Sin comentarios especiales.
        /// </remarks>
        /// <param name="updatedBy">
        /// Parámetro que indica el identificador único del usuario
        /// que modifica la entidad.
        /// </param>
        public virtual void AuditUpdate(string updatedBy)
        {
            // Creamos el objeto-valor AuditInfo.
            IAuditInfo auditInfoObject = AuditInfoFactory.Create(
                System.Convert.ToString(this.AuditInfo.CreatedBy),
                updatedBy,
                this.auditInfo.CreatedTimestamp,
                System.DateTime.UtcNow);

            // Establecemos los datos de auditoría.
            this.AuditInfo = auditInfoObject;
        }
예제 #7
0
        /// <summary>
        /// Método para auditar la creación de la entidad.
        /// </summary>
        /// <remarks>
        /// Sin comentarios especiales.
        /// </remarks>
        /// <param name="createdBy">
        /// Parámetro que indica el identificador único del usuario
        /// que modifica la entidad.
        /// </param>
        public virtual void AuditInsert(string createdBy)
        {
            // Creamos el objeto-valor AuditInfo.
            IAuditInfo auditInfoObject = AuditInfoFactory.Create(
                createdBy,
                null,
                System.DateTime.UtcNow,
                null);

            // Establecemos los datos de auditoría.
            this.AuditInfo = auditInfoObject;
        }
예제 #8
0
        public void ApplyRules()
        {
            //Approach via @julielerman: http://bit.ly/123661P
            foreach (var entry in ChangeTracker.Entries().Where(e => e.Entity is IAuditInfo && (e.State == EntityState.Added) || (e.State == EntityState.Modified)))
            {
                IAuditInfo e = (IAuditInfo)entry.Entity;

                if (entry.State == EntityState.Added)
                {
                    e.Created = DateTime.Now;
                }

                e.Modified = DateTime.Now;
            }
        }
예제 #9
0
 public static void CheckForStandardAuditTriggers(ref IAuditInfo tableInf, string[] allTriggers)
 {
     for (int j = 0; j < allTriggers.Length; j++)
     {
         if (allTriggers[j].IndexOf(String.Format(triggerNameFormat, tableInf.TableName, "INSERT")) > -1)
         {
             tableInf.HasAuditInsertTrigger = true;
         }
         else if (allTriggers[j].IndexOf(String.Format(triggerNameFormat, tableInf.TableName, "UPDATE")) > -1)
         {
             tableInf.HasAuditUpdateTrigger = true;
         }
         else if (allTriggers[j].IndexOf(String.Format(triggerNameFormat, tableInf.TableName, "DELETE")) > -1)
         {
             tableInf.HasAuditDeleteTrigger = true;
         }
     }
 }
예제 #10
0
        private void AplicarReglas()
        {
            foreach (var entrada in this.ChangeTracker.Entries()
                     .Where(
                         e => e.Entity is IAuditInfo &&
                         ((e.State == EntityState.Added) ||
                          (e.State == EntityState.Modified))))
            {
                IAuditInfo e = (IAuditInfo)entrada.Entity;

                if (entrada.State == EntityState.Added)
                {
                    e.CreadoEn = DateTime.Now;
                    e.Activo   = true;
                }

                e.ModificadoEn = DateTime.Now;
            }
        }
예제 #11
0
 public static void CheckForStandardAuditTriggers(ref IAuditInfo tableInf, ConnectionData connData)
 {
     string[] allTriggers = SqlSync.DbInformation.InfoHelper.GetTriggers(connData);
     CheckForStandardAuditTriggers(ref tableInf, allTriggers);
 }