private void ImportFolder(vRDConfigurationFileConnectionsFolder Folder, List <string> FolderNames, Dictionary <string, vRDConfigurationFileCredentialsFolderCredentials> Credentials) { foreach (Connection conn in Folder.Connection) { ImportConnection(conn, FolderNames, Credentials); } foreach (vRDConfigurationFileConnectionsFolderFolder folder in Folder.Folder) { FolderNames.Add(folder.Name); } }
public List <FavoriteConfigurationElement> ImportFavorites(string Filename) { List <FavoriteConfigurationElement> fav = new List <FavoriteConfigurationElement>(); InputBoxResult result = InputBox.Show("Password:"******"Enter vRD Password", '*'); if (result.ReturnCode == System.Windows.Forms.DialogResult.OK) { byte[] file = File.ReadAllBytes(Filename); string xml = a(file, result.Text).Replace(" encoding=\"utf-16\"", ""); byte[] data = ASCIIEncoding.Default.GetBytes(xml); using (MemoryStream sw = new MemoryStream(data)) { if (sw.Position > 0 & sw.CanSeek) { sw.Seek(0, SeekOrigin.Begin); } XmlSerializer x = new XmlSerializer(typeof(vRDConfigurationFile)); object results = x.Deserialize(sw); List <Connection> connections = new List <Connection>(); List <vRDConfigurationFileConnectionsFolder> folders = new List <vRDConfigurationFileConnectionsFolder>(); Dictionary <string, vRDConfigurationFileCredentialsFolderCredentials> credentials = new Dictionary <string, vRDConfigurationFileCredentialsFolderCredentials>(); if (results == null) { return(fav); } vRDConfigurationFile config = (results as vRDConfigurationFile); if (config == null) { return(fav); } //scan in config item foreach (object item in config.Items) { if (item == null) { continue; } if (item is vRDConfigurationFileCredentialsFolder) { //scan in all credentials into a dictionary vRDConfigurationFileCredentialsFolder credentialFolder = (item as vRDConfigurationFileCredentialsFolder); if (credentialFolder != null && credentialFolder.Credentials != null) { foreach (vRDConfigurationFileCredentialsFolderCredentials cred in credentialFolder.Credentials) { credentials.Add(cred.Guid, cred); } } } else if (item is vRDConfigurationFileCredentialsFolderCredentials) { vRDConfigurationFileCredentialsFolderCredentials cred = (item as vRDConfigurationFileCredentialsFolderCredentials); credentials.Add(cred.Guid, cred); } else if (item is Connection) { //scan in the connections Connection connection = (item as Connection); if (connection != null) { connections.Add(connection); } } else { //scan in recurse folders vRDConfigurationFileConnectionsFolder folder = item as vRDConfigurationFileConnectionsFolder; if (folder != null) { folders.Add(folder); } } } //save credential item to local SaveCredentials(credentials); //save VRD connection to local fav = ConvertVRDConnectionCollectionToLocal(connections.ToArray(), folders.ToArray(), null, String.Empty, credentials); } } return(fav); }