/// <summary>
        /// Returns the profile associated with the key, or null if no such profile exists.
        /// </summary>
        /// <param name="key">The name of the registry key to define the profile under.</param>
        /// <returns></returns>
        public DestinationProfile loadProfile(String key)
        {
            SettingsPersisterHelper settings = getProfileSettings(key);

            if (settings.GetNames().Length == 0)
            {
                return(null);
            }
            DestinationProfile profile = new DestinationProfile();

            profile.Id               = key;
            profile.Name             = settings.GetString(PROFILE_NAME_KEY, "");
            profile.WebsiteURL       = settings.GetString(PROFILE_WEBSITE_URL_KEY, "");
            profile.FtpServer        = settings.GetString(PROFILE_FTP_SERVER_KEY, "");
            profile.UserName         = settings.GetString(PROFILE_FTP_USER_KEY, "");
            profile.FtpPublishPath   = settings.GetString(PROFILE_FTP_PUBLISH_DIR_KEY, "");
            profile.LocalPublishPath = settings.GetString(PROFILE_PUBLISH_DIR_KEY, "");
            profile.Type             = (DestinationProfile.DestType)settings.GetInt32(PROFILE_DESTINATION_TYPE_KEY, 0);

            //load the decrypted password
            try
            {
                profile.Password = settings.GetEncryptedString(PROFILE_FTP_PASSWORD_KEY);
            }
            catch (Exception e)
            {
                Trace.Fail("Failed to decrypt password: " + e);
            }

            return(profile);
        }
        /// <summary>
        /// Returns the profile associated with the key, or null if no such profile exists.
        /// </summary>
        /// <param name="key">The name of the registry key to define the profile under.</param>
        /// <returns></returns>
        public DestinationProfile loadProfile(String key)
        {
            SettingsPersisterHelper settings = getProfileSettings(key);

            if (settings.GetNames().Length == 0)
            {
                return null;
            }
            DestinationProfile profile = new DestinationProfile();
            profile.Id = key;
            profile.Name = settings.GetString(PROFILE_NAME_KEY, "");
            profile.WebsiteURL = settings.GetString(PROFILE_WEBSITE_URL_KEY, "");
            profile.FtpServer = settings.GetString(PROFILE_FTP_SERVER_KEY, "");
            profile.UserName = settings.GetString(PROFILE_FTP_USER_KEY, "");
            profile.FtpPublishPath = settings.GetString(PROFILE_FTP_PUBLISH_DIR_KEY, "");
            profile.LocalPublishPath = settings.GetString(PROFILE_PUBLISH_DIR_KEY, "");
            profile.Type = (DestinationProfile.DestType)settings.GetInt32(PROFILE_DESTINATION_TYPE_KEY, 0);

            //load the decrypted password
            try
            {
                profile.Password = settings.GetEncryptedString(PROFILE_FTP_PASSWORD_KEY);
            }
            catch (Exception e)
            {
                Trace.Fail("Failed to decrypt password: " + e);
            }

            return profile;
        }
Esempio n. 3
0
        /// <summary>
        /// Create the appropriate file destination for the specified settings profile and initial path
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="initialPath"></param>
        /// <returns></returns>
        public static FileDestination CreateFileDestination(WebPublishSettings settings, string initialPath)
        {
            DestinationProfile destProfile = settings.Destination.Profile;

            if (destProfile.Type == DestinationProfile.DestType.WINDOWS)
            {
                return(new LocalFileSystemDestination(initialPath));
            }
            else
            {
                return(new WinInetFTPFileDestination(destProfile.FtpServer, initialPath, destProfile.UserName, destProfile.Password));
            }
        }
        /// <summary>
        /// Saves a destination profile into the registry.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="profile"></param>
        public void saveProfile(String key, DestinationProfile profile)
        {
            SettingsPersisterHelper settings = getProfileSettings(key);
            profile.Id = key;
            settings.SetString(PROFILE_NAME_KEY, profile.Name);
            settings.SetString(PROFILE_WEBSITE_URL_KEY, profile.WebsiteURL);
            settings.SetString(PROFILE_FTP_SERVER_KEY, profile.FtpServer);
            settings.SetString(PROFILE_FTP_PUBLISH_DIR_KEY, profile.FtpPublishPath);
            settings.SetString(PROFILE_FTP_USER_KEY, profile.UserName);
            settings.SetString(PROFILE_PUBLISH_DIR_KEY, profile.LocalPublishPath);
            settings.SetInt32(PROFILE_DESTINATION_TYPE_KEY, (short)profile.Type);

            //save an encrypted password
            try
            {
                settings.SetEncryptedString(PROFILE_FTP_PASSWORD_KEY, profile.Password);
            }
            catch (Exception e)
            {
                //if an exception occurs, just leave the password empty
                Trace.Fail("Failed to encrypt password: " + e.Message, e.StackTrace);
            }
        }
        /// <summary>
        /// Saves a destination profile into the registry.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="profile"></param>
        public void saveProfile(String key, DestinationProfile profile)
        {
            SettingsPersisterHelper settings = getProfileSettings(key);

            profile.Id = key;
            settings.SetString(PROFILE_NAME_KEY, profile.Name);
            settings.SetString(PROFILE_WEBSITE_URL_KEY, profile.WebsiteURL);
            settings.SetString(PROFILE_FTP_SERVER_KEY, profile.FtpServer);
            settings.SetString(PROFILE_FTP_PUBLISH_DIR_KEY, profile.FtpPublishPath);
            settings.SetString(PROFILE_FTP_USER_KEY, profile.UserName);
            settings.SetString(PROFILE_PUBLISH_DIR_KEY, profile.LocalPublishPath);
            settings.SetInt32(PROFILE_DESTINATION_TYPE_KEY, (short)profile.Type);

            //save an encrypted password
            try
            {
                settings.SetEncryptedString(PROFILE_FTP_PASSWORD_KEY, profile.Password);
            }
            catch (Exception e)
            {
                //if an exception occurs, just leave the password empty
                Trace.Fail("Failed to encrypt password: " + e.Message, e.StackTrace);
            }
        }