using System; using System.Web.UI.WebControls; using CMS.GlobalHelper; using CMS.SettingsProvider; using CMS.UIControls; using CMS.WebFarmSync; using CMS.ExtendedControls; public partial class CMSModules_WebFarm_Pages_WebFarm_Server_List : SiteManagerPage { protected void Page_Load(object sender, EventArgs e) { // New item link string[,] actions = new string[1,6]; actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = GetString("WebFarmServers_List.NewItemCaption"); actions[0, 2] = null; actions[0, 3] = ResolveUrl("WebFarm_Server_Edit.aspx"); actions[0, 4] = null; actions[0, 5] = GetImageUrl("Objects/CMS_WebFarmServer/add.png"); CurrentMaster.HeaderActions.Actions = actions; UniGrid.OnAction += new OnActionEventHandler(uniGrid_OnAction); UniGrid.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGrid_OnExternalDataBound); UniGrid.ZeroRowsText = GetString("general.nodatafound"); if (WebSyncHelperClass.WebFarmInstanceEnabled && !String.IsNullOrEmpty(WebSyncHelperClass.ServerName)) { if (AzureHelper.IsRunningOnAzure) { lblInfo.Text = String.Format(GetString("WebFarm.EnabledAzure"), WebSyncHelperClass.ServerName); } else { lblInfo.Text = String.Format(GetString("WebFarm.Enabled"), WebSyncHelperClass.ServerName); } } else { lblInfo.Text = GetString("WebFarm.Disabled"); } } /// /// Handles the UniGrid's OnExternalDataBound. /// /// Sender /// Source name /// Value private static object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "serverenabled": return UniGridFunctions.ColoredSpanYesNo(parameter); } return parameter; } /// /// Handles the UniGrid's OnAction event. /// /// Name of item (button) that throws event /// ID (value of Primary key) of corresponding data row protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { URLHelper.Redirect("WebFarm_Server_Edit.aspx?serverid=" + Convert.ToString(actionArgument)); } else if (actionName == "delete") { // delete WebFarmServerInfo object from database WebFarmServerInfoProvider.DeleteWebFarmServerInfo(Convert.ToInt32(actionArgument)); } } }