Kentico CMS 6.0 Developer's Guide

Managing web farm servers

Managing web farm servers

Previous topic Next topic Mail us feedback on this topic!  

Managing web farm servers

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example creates a web farm server.

 

private void CreateWebFarmServer()
{
    // Create new web farm server object
    WebFarmServerInfo newServer = new WebFarmServerInfo();
 
    // Set the properties
    newServer.ServerDisplayName = "My new server";
    newServer.ServerName = "MyNewServer";
    newServer.ServerEnabled = true;
    newServer.ServerURL = "http://localhost/KenticoCMS";
 
    // Save the web farm server
    WebFarmServerInfoProvider.SetWebFarmServerInfo(newServer);
}

 

The following example gets and updates a web farm server.

 

private bool GetAndUpdateWebFarmServer()
{

  // Get the web farm server
  WebFarmServerInfo updateServer = WebFarmServerInfoProvider.GetWebFarmServerInfo("MyNewServer");

    if (updateServer != null)
    {
        // Update the properties
        updateServer.ServerDisplayName = updateServer.ServerDisplayName.ToLower();
 
        // Save the changes
        WebFarmServerInfoProvider.SetWebFarmServerInfo(updateServer);
 
        return true;
    }
 
    return false;
}

 

The following example gets and bulk updates web farm servers.

 

private bool GetAndBulkUpdateWebFarmServers()
{
    // Get the data
    DataSet servers = WebFarmServerInfoProvider.GetAllEnabledServers();
    if (!DataHelper.DataSourceIsEmpty(servers))
    {
        // Loop through the individual items
        foreach (DataRow serverDr in servers.Tables[0].Rows)
        {
            // Create object from DataRow
            WebFarmServerInfo modifyServer = new WebFarmServerInfo(serverDr);

 
          // Update the properties
           modifyServer.ServerDisplayName = modifyServer.ServerDisplayName.ToUpper();

 
            // Save the changes
            WebFarmServerInfoProvider.SetWebFarmServerInfo(modifyServer);
        }
 
        return true;
    }
 
    return false;
}

 

The following example deletes a web farm server.

 

private bool DeleteWebFarmServer()
{

  // Get the web farm server
  WebFarmServerInfo deleteServer = WebFarmServerInfoProvider.GetWebFarmServerInfo("MyNewServer");

 
    // Delete the web farm server
    WebFarmServerInfoProvider.DeleteWebFarmServerInfo(deleteServer);
 
    return (deleteServer != null);
}