Пример #1
0
        /// <summary>
        /// Audits the content edit.
        /// </summary>
        /// <param name="action">Content Editing Action</param>
        /// <param name="identifiableObject">The identifiable object.</param>
        /// <param name="comments">Optional comments.</param>
        /// <param name="xml">Optional Xml blob.</param>
        private void AuditContentEdit(String action, IdentifiableObject identifiableObject, String comments, SqlXml xml)
        {
            try
            {
                using (SqlConnection connection = Connection)
                {
                    // Register the content editing action
                    using (SqlCommand sqlAuditContentEdit = new SqlCommand()
                    {
                        CommandText = "AuditContentEdit",
                        CommandType = CommandType.StoredProcedure,
                        Connection = connection
                    })
                    {
                        sqlAuditContentEdit.AddParameter("@Action", SqlDbType.VarChar, action);
                        sqlAuditContentEdit.AddParameter("@ItemID", SqlDbType.VarChar, identifiableObject.VersionedItemId());
                        sqlAuditContentEdit.AddParameter("@ItemTitle", SqlDbType.NVarChar, identifiableObject.Title);
                        sqlAuditContentEdit.AddParameter("@Username", SqlDbType.VarChar, identifiableObject.Session.User.Title.ToUpper());
                        sqlAuditContentEdit.AddParameter("@UserDescription", SqlDbType.NVarChar, identifiableObject.Session.User.Description);

                        if (!String.IsNullOrEmpty(comments))
                        {
                            sqlAuditContentEdit.AddParameter("@Comments", SqlDbType.NVarChar, comments);
                        }
                        else
                        {
                            sqlAuditContentEdit.AddParameter("@Comments", SqlDbType.NVarChar, DBNull.Value);
                        }

                        if (xml != null)
                        {
                            sqlAuditContentEdit.AddParameter("@Xml", SqlDbType.Xml, xml);
                        }
                        else
                        {
                            sqlAuditContentEdit.AddParameter("@Xml", SqlDbType.Xml, DBNull.Value);
                        }

                        sqlAuditContentEdit.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write(ex, "TcmEvents.Audit", LoggingCategory.General, TraceEventType.Error);
            }
        }
Пример #2
0
        /// <summary>
        /// Audits the content edit.
        /// </summary>
        /// <param name="action">Content Editing Action</param>
        /// <param name="identifiableObject">The identifiable object.</param>
        /// <param name="comments">Optional comments.</param>
        /// <param name="xml">Optional Xml blob.</param>
        private void AuditContentEdit(String action, IdentifiableObject identifiableObject, String comments, SqlXml xml)
        {
            try
            {
                using (SqlConnection connection = Connection)
                {
                    // Register the content editing action
                    using (SqlCommand sqlAuditContentEdit = new SqlCommand()
                    {
                        CommandText = "AuditContentEdit",
                        CommandType = CommandType.StoredProcedure,
                        Connection = connection
                    })
                    {
                        sqlAuditContentEdit.AddParameter("@Action", SqlDbType.VarChar, action);
                        sqlAuditContentEdit.AddParameter("@ItemID", SqlDbType.VarChar, identifiableObject.VersionedItemId());
                        sqlAuditContentEdit.AddParameter("@ItemTitle", SqlDbType.NVarChar, identifiableObject.Title);
                        sqlAuditContentEdit.AddParameter("@Username", SqlDbType.VarChar, identifiableObject.Session.User.Title.ToUpper());
                        sqlAuditContentEdit.AddParameter("@UserDescription", SqlDbType.NVarChar, identifiableObject.Session.User.Description);

                        if (!String.IsNullOrEmpty(comments))
                            sqlAuditContentEdit.AddParameter("@Comments", SqlDbType.NVarChar, comments);
                        else
                            sqlAuditContentEdit.AddParameter("@Comments", SqlDbType.NVarChar, DBNull.Value);

                        if (xml != null)
                            sqlAuditContentEdit.AddParameter("@Xml", SqlDbType.Xml, xml);
                        else
                            sqlAuditContentEdit.AddParameter("@Xml", SqlDbType.Xml, DBNull.Value);

                        sqlAuditContentEdit.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write(ex, "TcmEvents.Audit", LoggingCategory.General, TraceEventType.Error);
            }
        }