privatevoid CreateWebFarmServer() { // Create new web farm server object WebFarmServerInfo newServer = newWebFarmServerInfo(); // 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.
privatebool 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); returntrue; } returnfalse; }
The following example gets and bulk updates web farm servers.
privatebool 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 = newWebFarmServerInfo(serverDr);
// Update the properties modifyServer.ServerDisplayName = modifyServer.ServerDisplayName.ToUpper();
// Save the changes WebFarmServerInfoProvider.SetWebFarmServerInfo(modifyServer); } returntrue; } returnfalse; }
The following example deletes a web farm server.
privatebool DeleteWebFarmServer() {
// Get the web farm server WebFarmServerInfo deleteServer = WebFarmServerInfoProvider.GetWebFarmServerInfo("MyNewServer");
// Delete the web farm server WebFarmServerInfoProvider.DeleteWebFarmServerInfo(deleteServer); return (deleteServer != null); }