Web farms


List of examples:

Creating a web farm server




// Creates a new web farm server object
WebFarmServerInfo newServer = new WebFarmServerInfo();

// Sets the properties for the server
newServer.ServerDisplayName = "New server";
newServer.ServerName = "NewServer";
newServer.ServerEnabled = true;

// Saves the web farm server to the database
WebFarmServerInfoProvider.SetWebFarmServerInfo(newServer);


> Back to list of examples

Updating a web farm server




// Gets the web farm server
WebFarmServerInfo updateServer = WebFarmServerInfoProvider.GetWebFarmServerInfo("NewServer");

if (updateServer != null)
{
    // Updates the properties of the server
    updateServer.ServerDisplayName = updateServer.ServerDisplayName.ToLowerCSafe();

    // Saves the changed server to the database
    WebFarmServerInfoProvider.SetWebFarmServerInfo(updateServer);
}


> Back to list of examples

Updating multiple web farm servers




// Gets all enabled web farm servers
var servers = WebFarmServerInfoProvider.GetWebFarmServers().WhereTrue("ServerEnabled");

// Loops through individual servers
foreach (WebFarmServerInfo server in servers)
{
    // Disables the server
    server.ServerEnabled = false;

    // Saves the changed server to the database
    WebFarmServerInfoProvider.SetWebFarmServerInfo(server);
}


> Back to list of examples

Deleting a web farm server




// Gets the web farm server
WebFarmServerInfo deleteServer = WebFarmServerInfoProvider.GetWebFarmServerInfo("NewServer");

if (deleteServer != null)
{
    // Deletes the web farm server
    WebFarmServerInfoProvider.DeleteWebFarmServerInfo(deleteServer);
}


> Back to list of examples

Creating a web farm synchronization task




// Sets the properties for the task
string taskTarget = "";
string taskTextData = "WebFarmTask";

// Creates the web farm task
WebFarmHelper.CreateTask(DataTaskType.ClearHashtables, taskTarget, taskTextData);


> Back to list of examples