protected void SetAuthenticationModeControls(ServerAuthenticationEnum authentication)
 {
     txtServerX509ClientKeyID.Enabled = (authentication == ServerAuthenticationEnum.X509);
     txtServerX509ServerKeyID.Enabled = (authentication == ServerAuthenticationEnum.X509);
     txtServerUsername.Enabled        = (authentication != ServerAuthenticationEnum.X509);
     encryptedPassword.Enabled        = (authentication != ServerAuthenticationEnum.X509);
 }
Beispiel #2
0
        /// <summary>
        /// Creates a new <see cref="IServer"/> in the CMS System.
        /// </summary>
        /// <param name="displayName">The Display Name for the new Server.</param>
        /// <param name="serverName">The Server Name for the new Server.</param>
        /// <param name="serverUrl">The Url for the new Server.</param>
        /// <param name="authentication">The authentication for the new Server.</param>
        /// <param name="enabled">The enabled status for the new Server.</param>
        /// <param name="userName">The user name for the new Server.</param>
        /// <param name="password">The password for the new Server.</param>
        /// <param name="siteID">The site id associated with the new Server.</param>
        /// <returns>The newly created <see cref="IServer"/>.</returns>
        public IServer CreateServer(
            string displayName,
            string serverName,
            string serverUrl,
            ServerAuthenticationEnum authentication,
            bool?enabled,
            string userName,
            string password,
            int siteID)
        {
            // default authentication is UserName
            authentication = authentication == ServerAuthenticationEnum.X509 ? authentication : ServerAuthenticationEnum.UserName;

            // default is Enabled
            enabled = enabled == false ? false : true;

            // default user name and password value cannot be null
            userName = string.IsNullOrEmpty(userName) ? string.Empty : userName;
            password = string.IsNullOrEmpty(password) ? string.Empty : password;

            // default server name
            TextInfo txtInfo       = new CultureInfo("en-us", false).TextInfo;
            var      newServerName = string.IsNullOrEmpty(serverName) ? txtInfo.ToTitleCase(displayName).Replace(" ", string.Empty) : serverName;

            var data = new
            {
                ServerDisplayName    = displayName,
                ServerName           = newServerName,
                ServerURL            = serverUrl,
                ServerAuthentication = authentication,
                ServerEnabled        = enabled,
                ServerUsername       = userName,
                ServerPassword       = password,
                ServerSiteID         = siteID,
            };

            return(this.StagingService.Create(data.ActLike <IServer>()));
        }
        /// <summary>
        /// Sets the <see cref="IServer"/> in the CMS System.
        /// </summary>
        /// <param name="serverName">The server name to look for the server.</param>
        /// <param name="serverSiteId">The server site id to look for the server.</param>
        /// <param name="displayName">The Display Name for server to update.</param>
        /// <param name="serverUrl">The Server Url for server to update.</param>
        /// <param name="authentication">The authentication for server to update.</param>
        /// <param name="enabled">The enabled status for server to update.</param>
        /// <param name="userName">The user name for server to update.</param>
        /// <param name="password">The password for server to update.</param>
        /// <returns>The updated server.</returns>
        public IServer Set(
            string serverName,
            int serverSiteId,
            string displayName,
            string serverUrl,
            ServerAuthenticationEnum authentication,
            bool?enabled,
            string userName,
            string password)
        {
            var data = new
            {
                ServerName           = serverName,
                ServerSiteID         = serverSiteId,
                ServerDisplayName    = displayName,
                ServerURL            = serverUrl,
                ServerAuthentication = authentication,
                ServerEnabled        = enabled,
                ServerUsername       = userName,
                ServerPassword       = password,
            };

            return(this.StagingService.Update(data.ActLike <IServer>(), false));
        }
 protected void SetAuthenticationModeControls(ServerAuthenticationEnum authentication)
 {
     txtServerX509ClientKeyID.Enabled = (authentication == ServerAuthenticationEnum.X509);
     txtServerX509ServerKeyID.Enabled = (authentication == ServerAuthenticationEnum.X509);
     txtServerUsername.Enabled = (authentication != ServerAuthenticationEnum.X509);
     encryptedPassword.Enabled = (authentication != ServerAuthenticationEnum.X509);
 }