Ejemplo n.º 1
0
        public static ObjectChangeHistoryData CreateFromScript(string username, SqlConnection conn, string script)
        {
            if (ConfigHelper.Current == null || !ConfigHelper.Current.PragmaSql_ObjectChangeHistoryLogEnabled)
            {
                return(null);
            }

            if (conn == null)
            {
                return(null);
            }

            int    ObjectType = DBObjectType.None;
            bool   isAlter    = false;
            string objectName = String.Empty;

            objectName = ScriptingHelper.GetObjectNameFromScript(script, ref ObjectType, ref isAlter);
            if (String.IsNullOrEmpty(objectName) || ObjectType == DBObjectType.None)
            {
                return(null);
            }

            ObjectChangeHistoryData result = new ObjectChangeHistoryData();

            result.ServerName   = conn.DataSource;
            result.DatabaseName = conn.Database;
            result.ObjectName   = objectName;
            result.ObjectScript = script;
            result.ObjectType   = DBConstants.GetObjectTypeAbb(ObjectType);
            result.Comment      = String.Empty;
            result.CreatedBy    = username;

            return(result);
        }