AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. Configuration
  3. Staging

Staging


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

List of examples:

  • Staging servers
    • Creating a staging server
    • Updating a staging server
    • Updating multiple staging servers
    • Deleting a staging server
  • Staging tasks
    • Synchronizing staging tasks
    • Deleting all staging tasks that target a server
    • Running code without logging staging tasks
    • Logging staging tasks under specific task groups

Staging servers

Creating a staging server

C#
// Creates a new staging server object
ServerInfo newServer = new ServerInfo();

// Sets the server properties
newServer.ServerDisplayName = "New target server";
newServer.ServerName = "NewTargetServer";
newServer.ServerEnabled = true;
newServer.ServerSiteID = SiteContext.CurrentSiteID;
newServer.ServerURL = "http://localhost/Kentico/";
newServer.ServerAuthentication = ServerAuthenticationEnum.UserName;
newServer.ServerUsername = "admin";
newServer.ServerPassword = "pass";

// Saves the staging server to the database
ServerInfo.Provider.Set(newServer);
> Back to list of examples

Updating a staging server

C#
// Gets the staging server
ServerInfo updateServer = ServerInfo.Provider.Get("NewTargetServer", SiteContext.CurrentSiteID);
if (updateServer != null)
{
    // Updates the server properties
    updateServer.ServerDisplayName = updateServer.ServerDisplayName.ToLowerCSafe();

    // Saves the updated server to the database
    ServerInfo.Provider.Set(updateServer);
}
> Back to list of examples

Updating multiple staging servers

C#
// Gets all staging servers defined on the current site whose code name starts with 'New'
var servers = ServerInfo.Provider.Get()
                                    .WhereStartsWith("ServerName", "New")
                                    .WhereEquals("ServerSiteID", SiteContext.CurrentSiteID);

// Loops through individual servers
foreach (ServerInfo server in servers)
{
    // Updates the server properties
    server.ServerDisplayName = server.ServerDisplayName.ToUpper();

    // Saves the updated server to the database
    ServerInfo.Provider.Set(server);
}
> Back to list of examples

Deleting a staging server

C#
// Gets the staging server
ServerInfo deleteServer = ServerInfo.Provider.Get("NewTargetServer", SiteContext.CurrentSiteID);

if (deleteServer != null)
{
    // Deletes the staging server
    ServerInfo.Provider.Delete(deleteServer);
}
> Back to list of examples

Staging tasks

Synchronizing staging tasks

C#
// Gets a staging server
ServerInfo server = ServerInfo.Provider.Get("NewTargetServer", SiteContext.CurrentSiteID);

if (server != null)
{
    // Gets all staging tasks that target the given server
    var tasks = StagingTaskInfoProvider.SelectTaskList(SiteContext.CurrentSiteID, server.ServerID, null, null);

    // Loops through individual staging tasks
    foreach (StagingTaskInfo task in tasks)
    {
        // Synchronizes the staging task
        string result = new StagingTaskRunner(server.ServerID).RunSynchronization(task.TaskID);

        if (string.IsNullOrEmpty(result))
        {
            // The task synchronization was successful
        }
        else 
        {
            // The task synchronization failed
            // The 'result' string returned by the RunSynchronization method contains the error message for the given task
        }
    }         
}
> Back to list of examples

Deleting all staging tasks that target a server

C#
// Gets the staging server
ServerInfo server = ServerInfo.Provider.Get("NewTargetServer", SiteContext.CurrentSiteID);

if (server != null)
{
    // Gets all staging tasks that target the given server
    var tasks = StagingTaskInfoProvider.SelectTaskList(SiteContext.CurrentSiteID, server.ServerID, null, null);
    
    // Loops through individual staging tasks
    foreach (StagingTaskInfo task in tasks)
    {                       
        // Deletes the staging task
        StagingTaskInfo.Provider.Delete(task);
    }
}
> Back to list of examples

Running code without logging staging tasks

C#
// Prepares an action context for running code without logging of staging tasks
using (new CMSActionContext() { LogSynchronization = false })
{
    // Creates a new role without logging any staging tasks
    RoleInfo newRole = new RoleInfo();
    newRole.RoleDisplayName = "New role";
    newRole.RoleName = "NewRole";
    newRole.SiteID = SiteContext.CurrentSiteID;
    
    RoleInfo.Provider.Set(newRole);
}
> Back to list of examples

Logging staging tasks under specific task groups

C#
// Gets a "collection" of task groups (in this case one group whose code name is equal to "Group_Name")
var taskGroups = TaskGroupInfo.Provider.Get().WhereEquals("TaskGroupCodeName", "Group_Name");

// Prepares a synchronization action context
// The context ensures that any staging tasks logged by the wrapped code are included in the specified task groups
using (new SynchronizationActionContext() { TaskGroups = taskGroups })
{
    // Creates a new role object
    RoleInfo newRole = new RoleInfo();

    // Sets the role properties
    newRole.RoleDisplayName = "New role";
    newRole.RoleName = "NewRole";
    newRole.SiteID = SiteContext.CurrentSiteID;

    // Saves the role to the database
    RoleInfo.Provider.Set(newRole);
}
> Back to list of examples