/// <summary> /// Gets and bulk updates web farm servers. Called when the "Get and bulk update servers" button is pressed. /// Expects the CreateWebFarmServer method to be run first. /// </summary> 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); }
/// <summary> /// Initializes the web farm environment /// </summary> public static void InitWebFarm() { // Delete memory synchronization tasks WebSyncHelper.DeleteMemorySynchronizationTasks(); string serverDisplayName = string.Empty; string serverUrl = string.Empty; bool createServer = false; // Create web farm server if running on Azure if (AzureHelper.IsRunningOnAzure) { // Set web farm server name WebSyncHelperClass.ServerName = ValidationHelper.GetCodeName(AzureHelper.CurrentInstanceID); serverDisplayName = AzureHelper.CurrentInstanceID; serverUrl = AzureHelper.CurrentInternalEndpoint; createServer = true; } // Get dynamic name for server name else if (WebSyncHelperClass.GenerateWebFarmServers) { WebSyncHelperClass.WebFarmEnabled = true; serverUrl = HTTPHelper.UserHostAddress + SettingsKeyProvider.ApplicationPath.TrimEnd('/') + WebSyncHelperClass.WebFarmUpdaterPage; createServer = true; if (string.IsNullOrEmpty(WebSyncHelperClass.ServerName)) { serverDisplayName = WebFarmServerInfoProvider.GetAutomaticServerName(); WebSyncHelperClass.ServerName = ValidationHelper.GetCodeName(serverDisplayName); } else { serverDisplayName = WebSyncHelperClass.ServerName; } } // Create new web farm server if is needed if (createServer) { string serverName = WebSyncHelperClass.ServerName; // Create web farm server WebFarmServerInfo wfsi = WebFarmServerInfoProvider.GetWebFarmServerInfo(serverName); if (wfsi == null) { wfsi = new WebFarmServerInfo(); } wfsi.ServerName = serverName; wfsi.ServerEnabled = true; wfsi.ServerDisplayName = serverDisplayName; wfsi.ServerURL = serverUrl; WebFarmServerInfoProvider.SetWebFarmServerInfo(wfsi); } }
/// <summary> /// Deletes web farm server. Called when the "Delete server" button is pressed. /// Expects the CreateWebFarmServer method to be run first. /// </summary> private bool DeleteWebFarmServer() { // Get the web farm server WebFarmServerInfo deleteServer = WebFarmServerInfoProvider.GetWebFarmServerInfo("MyNewServer"); // Delete the web farm server WebFarmServerInfoProvider.DeleteWebFarmServerInfo(deleteServer); return(deleteServer != null); }
protected void Page_Load(object sender, EventArgs e) { this.CurrentMaster.Title.HelpTopicName = "webfarm_server_list"; // Initialize breadcrumbs string[,] pageTitleTabs = new string[2, 3]; pageTitleTabs[0, 0] = GetString("WebFarmServers_Edit.WebFarmServers"); pageTitleTabs[0, 1] = "~/CMSModules/WebFarm/Pages/WebFarm_Server_List.aspx"; pageTitleTabs[0, 2] = ""; pageTitleTabs[1, 1] = ""; pageTitleTabs[1, 2] = ""; pageTitleTabs[1, 0] = GetString("WebFarmServers_Edit.New"); btnOk.Text = GetString("general.ok"); rfvCodeName.ErrorMessage = GetString("general.requirescodename"); rfvURL.ErrorMessage = GetString("WebFarmServers_Edit.UrlEmpty"); rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname"); // Get server ID serverid = QueryHelper.GetInteger("serverid", 0); if (serverid > 0) { WebFarmServerInfo wi = WebFarmServerInfoProvider.GetWebFarmServerInfo(serverid); if (wi == null) { lblError.Visible = true; lblError.Text = GetString("WebFarmServers_Edit.InvalidServerID"); plcEditForm.Visible = false; } else { pageTitleTabs[1, 0] = HTMLHelper.HTMLEncode(wi.ServerDisplayName); if (!RequestHelper.IsPostBack()) { txtCodeName.Text = wi.ServerName; txtDisplayName.Text = wi.ServerDisplayName; txtURL.Text = wi.ServerURL; chkEnabled.Checked = wi.ServerEnabled; } } } this.CurrentMaster.Title.Breadcrumbs = pageTitleTabs; // Associate server checker control serverChecker.TextBoxControlID = txtURL.ID; if (ValidationHelper.GetString(Request.QueryString["saved"], "") != "") { lblInfo.Text = GetString("General.ChangesSaved"); lblInfo.Visible = true; } }
/// <summary> /// Creates web farm server. Called when the "Create server" button is pressed. /// </summary> private bool 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); return(true); }
/// <summary> /// Creates web farm server. Called when the "Create server" button is pressed. /// </summary> private bool 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); return true; }
/// <summary> /// Gets and updates web farm server. Called when the "Get and update server" button is pressed. /// Expects the CreateWebFarmServer method to be run first. /// </summary> private bool GetAndUpdateWebFarmServer() { // Get the web farm server WebFarmServerInfo updateServer = WebFarmServerInfoProvider.GetWebFarmServerInfo("MyNewServer"); if (updateServer != null) { // Update the properties updateServer.ServerDisplayName = updateServer.ServerDisplayName.ToLowerCSafe(); // Save the changes WebFarmServerInfoProvider.SetWebFarmServerInfo(updateServer); return(true); } return(false); }
/// <summary> /// Run task list. /// </summary> protected void btnRunTasks_Click(object sender, EventArgs e) { switch (selectedServer) { case allServers: WebSyncHelper.SynchronizeWebFarm(true); // Call synchronization method WebSyncHelper.ProcessMyTasks(); break; default: // Get the server info object WebFarmServerInfo wfsi = WebFarmServerInfoProvider.GetWebFarmServerInfo(SqlHelperClass.GetSafeQueryString(selectedServer, false)); // If server is enabled if (wfsi.ServerEnabled) { if (wfsi.ServerName.ToLower() == WebSyncHelperClass.ServerName.ToLower()) { // Call synchronization method WebSyncHelper.ProcessMyTasks(); } else { if (WebSyncHelperClass.Servers.Contains(wfsi.ServerID)) { WebFarmUpdaterAsync wfu = new WebFarmUpdaterAsync(); // Add server for sync wfu.Urls.Add(wfsi.ServerURL.TrimEnd('/') + WebSyncHelperClass.WebFarmUpdaterPage); } } } break; } UniGrid.ReloadData(); // Show info label lblInfo.Text = GetString("webfarmtasks.taskexecuted"); lblInfo.Visible = true; }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "delete") { // Delete object from database if (selectedServer == allServers) { // Delete task object WebFarmTaskInfoProvider.DeleteWebFarmTaskInfo(Convert.ToInt32(actionArgument)); } else { // Get infos for task and server WebFarmTaskInfo wfti = WebFarmTaskInfoProvider.GetWebFarmTaskInfo(Convert.ToInt32(actionArgument)); WebFarmServerInfo wfsi = WebFarmServerInfoProvider.GetWebFarmServerInfo(selectedServer); // Delete task binding to server WebFarmTaskInfoProvider.DeleteServerTask(wfsi.ServerID, wfti.TaskID); } UniGrid.ReloadData(); } }
/// <summary> /// Run task list. /// </summary> private void RunTasks() { switch (selectedServer) { case allServers: { WebSyncHelper.NotifyServers(true); WebSyncHelper.ProcessMyTasks(); } break; default: // Get the server info object WebFarmServerInfo wfsi = WebFarmServerInfoProvider.GetWebFarmServerInfo(SqlHelper.GetSafeQueryString(selectedServer, false)); // If server is enabled if (wfsi.ServerEnabled) { if (wfsi.ServerName.ToLowerCSafe() == WebSyncHelper.ServerName.ToLowerCSafe()) { // Call synchronization method WebSyncHelper.ProcessMyTasks(); } else if (WebSyncHelper.EnabledServers.Any(s => s.ServerID == wfsi.ServerID)) { WebFarmUpdaterAsync wfu = new WebFarmUpdaterAsync(); // Add server for sync wfu.Urls.Add(wfsi.ServerURL); wfu.Run(); } } break; } UniGrid.ReloadData(); // Show info label ShowInformation(GetString("webfarmtasks.taskexecuted")); }
/// <summary> /// Performs the application initialization on the first request. /// </summary> private static void FirstRequestInitialization(object sender, EventArgs e) { // Initialized properly if (mApplicationInitialized == true) { return; } // Not initialized, must install if ((mApplicationInitialized == false) && InstallerFunctions.InstallRedirect(true)) { return; } // Do not init application on request to just physical file string relativePath = URLHelper.CurrentRelativePath; ExcludedSystemEnum excludedEnum = URLHelper.IsExcludedSystemEnum(relativePath); if (excludedEnum == ExcludedSystemEnum.PhysicalFile) { return; } // Initialize application in a locked context lock (mLock) { if (ApplicationInitialized) { return; } // Remember date and time of the application start mApplicationStart = DateTime.Now; // Init run from web applicaiton - DON'T MOVE LATER SystemHelper.IsWebSite = true; mWindowsIdentity = WindowsIdentity.GetCurrent(); ViewModeOnDemand viewMode = new ViewModeOnDemand(); // Log application start if (CMSFunctions.AnyDebugEnabled) { RequestSettings settings = RequestSettings.Current; bool liveSite = (viewMode.Value == ViewModeEnum.LiveSite); settings.DebugRequest = RequestHelper.DebugRequests && liveSite; RequestHelper.LogRequestOperation("BeforeApplicationStart", null, 0); settings.DebugSQLQueries = SqlHelperClass.DebugQueries && liveSite; settings.DebugFiles = File.DebugFiles && liveSite; settings.DebugCache = CacheHelper.DebugCache && liveSite; settings.DebugSecurity = SecurityHelper.DebugSecurity && liveSite; settings.DebugOutput = OutputHelper.DebugOutput && liveSite; settings.DebugMacros = MacroResolver.DebugMacros && liveSite; settings.DebugWebFarm = WebSyncHelperClass.DebugWebFarm && liveSite; settings.DebugAnalytics = AnalyticsHelper.DebugAnalytics && liveSite; DebugHelper.SetContext("App_Start"); } // Handle the event var h = CMSApplicationEvents.Start.StartEvent(e); if (h.Continue) { //ConnectionHelper.UseContextConnection = true; //CacheHelper.CacheItemPriority = System.Web.Caching.CacheItemPriority.NotRemovable; if (SqlHelperClass.IsConnectionStringInitialized) { using (CMSConnectionScope scope = new CMSConnectionScope()) { // Use single open connection for the application start GeneralConnection conn = (GeneralConnection)scope.Connection; bool closeConnection = false; try { // Open the connection conn.Open(); closeConnection = true; // Check for the table existence if (!TableManager.TableExists("CMS_SettingsKey")) { mApplicationInitialized = false; if (InstallerFunctions.InstallRedirect(true)) { return; } } // Check the version string version = SettingsKeyProvider.GetStringValue("CMSDBVersion"); if (version != CMSContext.SYSTEM_VERSION) { // Report error about not being able to connect mConnectionErrorMessage = "The database version '" + version + "' does not match the project version '" + CMSContext.SYSTEM_VERSION + "', please check your connection string."; HttpContext.Current.Server.Transfer("~/CMSMessages/error.aspx"); } else { // Initialize the environment CMSFunctions.Init(); // Update the system !! IMPORTANT - must be first UpgradeProcedure.Update(conn); try { // Write "Application start" event to the event log EventLogProvider ev = new EventLogProvider(); ev.DeleteOlderLogs = false; ev.LogEvent(EventLogProvider.EVENT_TYPE_INFORMATION, DateTime.Now, "Application_Start", "STARTAPP", 0, null, 0, null, null, null, 0, HTTPHelper.GetAbsoluteUri()); } catch { // can't write to log, do not process any code } UserInfoProvider.OnFormattedUserName += new UserInfoProvider.FormattedUserNameEventHandler(Functions.GetFormattedUserName); // Delete memory synchronization tasks WebSyncHelper.DeleteMemorySynchronizationTasks(); // Create web farm server if running on Azure if (AzureHelper.IsRunningOnAzure) { // Set webfarm server name WebSyncHelperClass.ServerName = ValidationHelper.GetCodeName(AzureHelper.CurrentInstanceID); if (WebFarmServerInfoProvider.GetWebFarmServerInfo(WebSyncHelperClass.ServerName) == null) { // Create webfarm server WebFarmServerInfo wfsi = new WebFarmServerInfo(); wfsi.ServerName = WebSyncHelperClass.ServerName; wfsi.ServerEnabled = true; wfsi.ServerDisplayName = AzureHelper.CurrentInstanceID; wfsi.ServerURL = AzureHelper.CurrentInternalEndpoint; WebFarmServerInfoProvider.SetWebFarmServerInfo(wfsi); } } // Wait until initialization is complete CMSFunctions.WaitForInitialization(); } } catch (Exception ex) { if (closeConnection) { // Server connected succesfully but something else went wrong throw ex; } else { // Report error about not being able to connect mConnectionErrorMessage = ex.Message; HttpContext.Current.Server.Transfer("~/CMSMessages/error.aspx"); } } finally { if (closeConnection) { // Close the connection conn.Close(); } } } } else { // Register virtual path provider if (ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSUseVirtualPathProvider"], true)) { CMS.VirtualPathHelper.VirtualPathHelper.RegisterVirtualPathProvider(); } } // Register the CMS view engine CMSViewEngine.RegisterViewEngine(); } // Finalize the event h.FinishEvent(); DebugHelper.ReleaseContext(); // Log when the overall application start finished its execution mApplicationStartFinished = DateTime.Now; mApplicationInitialized = true; RequestHelper.LogRequestOperation("AfterApplicationStart", null, 0); } }
/// <summary> /// Gets and bulk updates web farm servers. Called when the "Get and bulk update servers" button is pressed. /// Expects the CreateWebFarmServer method to be run first. /// </summary> 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; }
protected void Page_Load(object sender, EventArgs e) { this.timRefresh.Interval = 1000 * ValidationHelper.GetInteger(this.drpRefresh.SelectedValue, 0); // Check permissions RaiseOnCheckPermissions("READ", this); if (StopProcessing) { return; } // Get values from counters long totalSystemRequests = RequestHelper.TotalSystemPageRequests.GetValue(null); long totalPageRequests = RequestHelper.TotalPageRequests.GetValue(null); long totalPageNotFoundRequests = RequestHelper.TotalPageNotFoundRequests.GetValue(null); long totalNonPageRequests = RequestHelper.TotalNonPageRequests.GetValue(null); long totalGetFileRequests = RequestHelper.TotalGetFileRequests.GetValue(null); // Reevaluate RPS if (mLastRPS != DateTime.MinValue) { double seconds = DateTime.Now.Subtract(mLastRPS).TotalSeconds; if ((seconds < 3) && (seconds > 0)) { mRPSSystemPageRequests = (totalSystemRequests - mLastSystemPageRequests) / seconds; mRPSPageRequests = (totalPageRequests - mLastPageRequests) / seconds; mRPSPageNotFoundRequests = (totalPageNotFoundRequests - mLastPageNotFoundRequests) / seconds; mRPSNonPageRequests = (totalNonPageRequests - mLastNonPageRequests) / seconds; mRPSGetFileRequests = (totalGetFileRequests - mLastGetFileRequests) / seconds; } else { mRPSGetFileRequests = -1; mRPSNonPageRequests = -1; mRPSPageNotFoundRequests = -1; mRPSPageRequests = -1; mRPSSystemPageRequests = -1; } } mLastRPS = DateTime.Now; // Update last values mLastGetFileRequests = totalGetFileRequests; mLastNonPageRequests = totalNonPageRequests; mLastPageNotFoundRequests = totalPageNotFoundRequests; mLastPageRequests = totalPageRequests; mLastSystemPageRequests = totalSystemRequests; // Do not count this page with async postback if (RequestHelper.IsAsyncPostback()) { RequestHelper.TotalSystemPageRequests.Decrement(null); } pnlSystemInfo.GroupingText = GetString("Administration-System.SystemInfo"); pnlSystemTime.GroupingText = GetString("Administration-System.SystemTimeInfo"); pnlDatabaseInfo.GroupingText = GetString("Administration-System.DatabaseInfo"); lblServerName.Text = GetString("Administration-System.ServerName"); lblServerVersion.Text = GetString("Administration-System.ServerVersion"); lblDBName.Text = GetString("Administration-System.DatabaseName"); lblDBSize.Text = GetString("Administration-System.DatabaseSize"); lblMachineName.Text = GetString("Administration-System.MachineName"); lblMachineNameValue.Text = HTTPHelper.MachineName; lblAspAccount.Text = GetString("Administration-System.Account"); lblValueAspAccount.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name; // Get application pool name lblPool.Text = GetString("Administration-System.Pool"); lblValuePool.Text = GetString("General.NA"); try { lblValuePool.Text = SystemHelper.GetApplicationPoolName(); } catch { } // Get application trust level lblTrustLevel.Text = GetString("Administration-System.TrustLevel"); lblValueTrustLevel.Text = GetString("General.NA"); try { lblValueTrustLevel.Text = SystemHelper.CurrentTrustLevel.ToString(); } catch { } lblAspVersion.Text = GetString("Administration-System.Version"); lblValueAspVersion.Text = System.Environment.Version.ToString(); pnlMemory.GroupingText = GetString("Administration-System.MemoryStatistics"); lblAlocatedMemory.Text = GetString("Administration-System.Memory"); lblPeakMemory.Text = GetString("Administration-System.PeakMemory"); lblVirtualMemory.Text = GetString("Administration-System.VirtualMemory"); lblPhysicalMemory.Text = GetString("Administration-System.PhysicalMemory"); lblIP.Text = GetString("Administration-System.IP"); pnlPageViews.GroupingText = GetString("Administration-System.PageViews"); lblPageViewsValues.Text = GetString("Administration-System.PageViewsValues"); lblPages.Text = GetString("Administration-System.Pages"); lblSystemPages.Text = GetString("Administration-System.SystemPages"); lblNonPages.Text = GetString("Administration-System.NonPages"); lblGetFilePages.Text = GetString("Administration-System.GetFilePages"); lblPagesNotFound.Text = GetString("Administration-System.PagesNotFound"); lblPending.Text = GetString("Administration-System.Pending"); pnlCache.GroupingText = GetString("Administration-System.CacheStatistics"); lblCacheExpired.Text = GetString("Administration-System.CacheExpired"); lblCacheRemoved.Text = GetString("Administration-System.CacheRemoved"); lblCacheUnderused.Text = GetString("Administration-System.CacheUnderused"); lblCacheItems.Text = GetString("Administration-System.CacheItems"); lblCacheDependency.Text = GetString("Administration-System.CacheDependency"); pnlGC.GroupingText = GetString("Administration-System.GC"); btnClear.Text = GetString("Administration-System.btnClear"); btnClearCache.Text = GetString("Administration-System.btnClearCache"); btnRestart.Text = GetString("Administration-System.btnRestart"); btnRestartWebfarm.Text = GetString("Administration-System.btnRestartWebfarm"); btnClearCounters.Text = GetString("Administration-System.btnClearCounters"); btnRestartServices.Text = GetString("Administration-System.btnRestartServices"); // Hide button if wefarms are not enabled or disallow restarting webfarms for Windows Azure if (!WebSyncHelperClass.WebFarmEnabled || AzureHelper.IsRunningOnAzure) { this.btnRestartWebfarm.Visible = false; } // Hide the web farm restart button if this web farm server is not enabled if (!RequestHelper.IsPostBack()) { WebFarmServerInfo webFarmServerObj = WebFarmServerInfoProvider.GetWebFarmServerInfo(WebSyncHelperClass.ServerName); if ((webFarmServerObj != null) && (!webFarmServerObj.ServerEnabled)) { this.btnRestartWebfarm.Visible = false; } } // Hide restart service button if services folder doesn't exist this.btnRestartServices.Visible = SystemHelper.IsFullTrustLevel && WinServiceHelper.ServicesAvailable(); // Hide the performance counters clear button if the health monitoring is not enabled or feature is not available this.btnClearCounters.Visible = SystemHelper.IsFullTrustLevel && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.HealthMonitoring); LoadData(); if (!RequestHelper.IsPostBack()) { switch (QueryHelper.GetString("lastaction", String.Empty).ToLower()) { case "restarted": lblInfo.Text = GetString("Administration-System.RestartSuccess"); break; case "webfarmrestarted": if (ValidationHelper.ValidateHash("WebfarmRestarted", QueryHelper.GetString("restartedhash", String.Empty))) { lblInfo.Text = GetString("Administration-System.WebframRestarted"); // Restart other servers - create webfarm task for application restart WebSyncHelperClass.CreateTask(WebFarmTaskTypeEnum.RestartApplication, "RestartApplication", "", null); } else { lblInfo.Text = GetString("general.actiondenied"); } break; case "countercleared": lblInfo.Text = GetString("Administration-System.CountersCleared"); break; case "winservicesrestarted": lblInfo.Text = GetString("Administration-System.WinServicesRestarted"); break; } } lblRunTime.Text = GetString("Administration.System.RunTime"); lblServerTime.Text = GetString("Administration.System.ServerTime"); // Remove miliseconds from the end of the time string string timeSpan = (DateTime.Now - CMSAppBase.ApplicationStart).ToString(); int index = timeSpan.LastIndexOf('.'); if (index >= 0) { timeSpan = timeSpan.Remove(index); } // Display application run time lblRunTimeValue.Text = timeSpan; lblServerTimeValue.Text = Convert.ToString(DateTime.Now) + " " + TimeZoneHelper.GetGMTStringOffset(TimeZoneHelper.ServerTimeZone); lblIPValue.Text = Request.UserHostAddress; }
protected void btnOK_Click(object sender, EventArgs e) { string result = new Validator().NotEmpty(rfvDisplayName, rfvDisplayName.ErrorMessage).NotEmpty(rfvCodeName, rfvCodeName.ErrorMessage).NotEmpty(rfvURL, rfvURL.ErrorMessage) .IsCodeName(txtCodeName.Text, GetString("general.invalidcodename")) .Result; // Get the object WebFarmServerInfo wi = WebFarmServerInfoProvider.GetWebFarmServerInfo(serverid) ?? new WebFarmServerInfo(); // Check license web farm server limit if (String.IsNullOrEmpty(result)) { LicenseKeyInfo lki = LicenseHelper.CurrentLicenseInfo; if (lki == null) { return; } // Only if server is enabled if (chkEnabled.Checked) { // Enabling or new server as action insert VersionActionEnum action = ((wi.ServerID > 0) && wi.ServerEnabled) ? VersionActionEnum.Edit : VersionActionEnum.Insert; if (!lki.CheckServerCount(WebSyncHelperClass.ServerCount, action)) { result = GetString("licenselimitation.infopagemessage"); } // Log the message if (!String.IsNullOrEmpty(result)) { EventLogProvider eventLog = new EventLogProvider(); string message = GetString("licenselimitation.serversexceeded"); eventLog.LogEvent(EventLogProvider.EVENT_TYPE_WARNING, DateTime.Now, "WebFarms", LicenseHelper.LICENSE_LIMITATION_EVENTCODE, URLHelper.CurrentURL, message); } } } if (result == "") { wi.ServerID = serverid; wi.ServerDisplayName = txtDisplayName.Text; wi.ServerName = txtCodeName.Text; wi.ServerURL = txtURL.Text; wi.ServerEnabled = chkEnabled.Checked; try { WebFarmServerInfoProvider.SetWebFarmServerInfo(wi); // Clear server list URLHelper.Redirect("WebFarm_Server_Edit.aspx?serverid=" + wi.ServerID + "&saved=1"); } catch (Exception ex) { lblError.Text = ex.Message.Replace("%%name%%", wi.ServerName); lblError.Visible = true; lblInfo.Visible = false; } } else { lblError.Text = result; lblError.Visible = true; lblInfo.Visible = false; } }