Exemple #1
0
        public void RollBack(Guid VersionId, User u)
        {
            var e = new RollBackEventArgs();
            FireBeforeRollBack(e);

            if (!e.Cancel)
            {
                Content = ApplicationContext.Current.Services.ContentService.Rollback(Id, VersionId, u.Id);

                FireAfterRollBack(e);
            }
        }
Exemple #2
0
 /// <summary>
 /// Raises the <see cref="E:BeforeRollBack"/> event.
 /// </summary>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected virtual void FireBeforeRollBack(RollBackEventArgs e)
 {
     if (BeforeRollBack != null)
         BeforeRollBack(this, e);
 }
Exemple #3
0
 /// <summary>
 /// Raises the <see cref="E:AfterRollBack"/> event.
 /// </summary>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected virtual void FireAfterRollBack(RollBackEventArgs e)
 {
     if (AfterRollBack != null)
         AfterRollBack(this, e);
 }
Exemple #4
0
        /// <summary>
        /// Rollbacks a document to a previous version, this will create a new version of the document and copy
        /// all of the old documents data.
        /// </summary>
        /// <param name="u">The usercontext under which the action are performed</param>
        /// <param name="VersionId">The unique Id of the version to roll back to</param>
        public void RollBack(Guid VersionId, User u)
        {
            RollBackEventArgs e = new RollBackEventArgs();
            FireBeforeRollBack(e);

            if (!e.Cancel)
            {
                Guid newVersion = createNewVersion();
                SqlHelper.ExecuteNonQuery("insert into cmsDocument (nodeId, published, documentUser, versionId, Text, TemplateId) values (" +
                                          Id +
                                          ", 0, " + u.Id + ", @versionId, @text, " +
                                          _template + ")",
                                          SqlHelper.CreateParameter("@versionId", newVersion),
                                          SqlHelper.CreateParameter("@text", Text));

                // Get new version
                Document dNew = new Document(Id, newVersion);

                // Old version
                Document dOld = new Document(Id, VersionId);

                // Revert title
                dNew.Text = dOld.Text;

                // Revert all properties
                var props = dOld.getProperties;
                foreach (Property p in props)
                    try
                    {
                        dNew.getProperty(p.PropertyType).Value = p.Value;
                    }
                    catch
                    {
                        // property doesn't exists
                    }

                FireAfterRollBack(e);
            }
        }