Пример #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);
        }
Пример #2
0
        public ObjectChangeHistoryData CreateCopy()
        {
            ObjectChangeHistoryData result = new ObjectChangeHistoryData();

            result.ServerName   = ServerName;
            result.DatabaseName = DatabaseName;
            result.ObjectName   = ObjectName;
            result.ObjectScript = ObjectScript;
            result.ObjectType   = ObjectType;
            result.CreatedBy    = CreatedBy;
            result.Comment      = Comment;

            return(result);
        }
Пример #3
0
        public void CopyFrom(ObjectChangeHistoryData source)
        {
            if (source == null)
            {
                throw new NullParameterException("Source is null!");
            }

            ServerName   = source.ServerName;
            DatabaseName = source.DatabaseName;
            ObjectName   = source.ObjectName;
            ObjectScript = source.ObjectScript;
            ObjectType   = source.ObjectType;
            CreatedBy    = source.CreatedBy;
            Comment      = source.Comment;
        }
Пример #4
0
        public static void InsertObjectChangeHistoryRecord(ObjectChangeHistoryData data)
        {
#if PERSONAL_EDITION
            return;
#else
            if (ConfigHelper.Current == null || !ConfigHelper.Current.PragmaSql_ObjectChangeHistoryLogEnabled)
            {
                return;
            }

            if (data == null)
            {
                return;
            }

            ConnectionParams cp = ConfigHelper.Current.PragmaSqlDbConn;
            if (cp == null)
            {
                return;
            }

            using (SqlConnection conn = cp.CreateSqlConnection(true, false))
            {
                string     cmdText = "exec spPragmaSQL_ObjectChangeHist_Insert @ServerName, @DatabaseName, @ObjectName, @ObjectScript, @ObjectType, @CreatedBy, @Comment";
                SqlCommand cmd     = new SqlCommand(cmdText, conn);
                cmd.CommandTimeout = 0;
                AddParam(cmd, "@ServerName", SqlDbType.VarChar, data.ServerName);
                AddParam(cmd, "@DatabaseName", SqlDbType.VarChar, data.DatabaseName);
                AddParam(cmd, "@ObjectName", SqlDbType.VarChar, data.ObjectName);
                AddParam(cmd, "@ObjectScript", SqlDbType.Text, data.ObjectScript);
                AddParam(cmd, "@ObjectType", SqlDbType.VarChar, data.ObjectType);
                AddParam(cmd, "@CreatedBy", SqlDbType.VarChar, data.CreatedBy);
                AddParam(cmd, "@Comment", SqlDbType.VarChar, data.Comment);
                cmd.ExecuteNonQuery();
            }
#endif
        }