Пример #1
0
 private static List<FavoriteConfigurationElement> ImportFileContent(TestContext context, string content)
 {
     fileName = Path.Combine(context.TestDeploymentDir, FILE_NAME);
     File.WriteAllText(fileName, content);
     var importer = new ImportRDP();
     return ((IImport)importer).ImportFavorites(fileName);
 }
Пример #2
0
        List <FavoriteConfigurationElement> IImport.ImportFavorites(string Filename)
        {
            List <FavoriteConfigurationElement> coll = new List <FavoriteConfigurationElement>();

            if (File.Exists(Filename))
            {
                FavoriteConfigurationElement fav = null;
                string[] lines = File.ReadAllLines(Filename);
                foreach (string line in lines)
                {
                    if (line.StartsWith("[") && line.EndsWith("]"))
                    {
                        if (fav == null)
                        {
                            fav      = new FavoriteConfigurationElement();
                            fav.Name = line.Substring(1, line.Length - 2);
                        }
                        else
                        {
                            coll.Add(fav);
                            fav = new FavoriteConfigurationElement();
                        }
                    }
                    else
                    {
                        if (line == "")
                        {
                            coll.Add(fav);
                            fav = new FavoriteConfigurationElement();
                        }
                        else
                        {
                            string propertyName = line.Substring(0, line.IndexOf("="));
                            string pValue       = line.Substring(line.IndexOf("=") + 1);
                            switch (propertyName)
                            {
                            case "ServerName":
                                fav.ServerName = pValue;
                                break;

                            case "Port":
                                int p = 3389;
                                int.TryParse(pValue, out p);
                                fav.Port = p;
                                break;

                            case "Username":
                                fav.UserName = pValue;
                                break;

                            case "Domain":
                                fav.DomainName = pValue;
                                break;

                            case "Comment":
                                break;

                            case "Password":
                                break;

                            case "DesktopWidth":
                                fav.DesktopSize = DesktopSize.AutoScale;
                                break;

                            case "DesktopHeight":
                                fav.DesktopSize = DesktopSize.AutoScale;
                                break;

                            case "ColorDepth":
                                switch (pValue)
                                {
                                case "8":
                                    fav.Colors = Colors.Bits8;
                                    break;

                                case "16":
                                    fav.Colors = Colors.Bit16;
                                    break;

                                case "24":
                                    fav.Colors = Colors.Bits24;
                                    break;

                                case "32":
                                    fav.Colors = Colors.Bits32;
                                    break;

                                default:
                                    fav.Colors = Colors.Bit16;
                                    break;
                                }

                                break;

                            case "UseSmartSizing":
                                if (pValue == "1")
                                {
                                    fav.DesktopSize = DesktopSize.AutoScale;
                                }
                                break;

                            case "FullScreenMonitor":
                                if (pValue == "1")
                                {
                                    fav.DesktopSize = DesktopSize.FullScreen;
                                }
                                break;

                            case "ConsoleConnection":
                                fav.ConnectToConsole = false;
                                if (pValue == "1")
                                {
                                    fav.ConnectToConsole = true;
                                }
                                break;

                            case "UseCompression":
                                break;

                            case "BitmapPersistence":
                                break;

                            case "DisableWallpaper":
                                fav.DisableWallPaper = false;
                                if (pValue == "1")
                                {
                                    fav.DisableWallPaper = true;
                                }
                                break;

                            case "DisableFullWindowDrag":
                                break;

                            case "DisableMenuAnimations":
                                break;

                            case "DisableTheming":
                                break;

                            case "DisableCursorShadow":
                                break;

                            case "DisableCursorSettings":
                                break;

                            case "RedirectSmartCards":
                                fav.RedirectSmartCards = false;
                                if (pValue == "1")
                                {
                                    fav.RedirectSmartCards = true;
                                }
                                break;

                            case "RedirectPorts":
                                fav.RedirectPorts = false;
                                if (pValue == "1")
                                {
                                    fav.RedirectPorts = true;
                                }
                                break;

                            case "RedirectPrinters":
                                fav.RedirectPrinters = false;
                                if (pValue == "1")
                                {
                                    fav.RedirectPrinters = true;
                                }
                                break;

                            case "EnableWindowsKey":
                                break;

                            case "KeyboardHookMode":
                                break;

                            case "AudioRedirectionMode":
                                fav.Sounds = ImportRDP.ConvertToSounds(pValue);
                                break;

                            case "AlternateShell":
                                break;

                            case "ShellWorkingDir":
                                break;

                            case "AuthenticationLevel":
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }

            return(coll);
        }
Пример #3
0
        private FavoriteConfigurationElement ConvertVRDConnectionToLocal(Dictionary <string, vRDConfigurationFileCredentialsFolderCredentials> credentials, vRdImport.Connection con)
        {
            FavoriteConfigurationElement fav = new FavoriteConfigurationElement();
            var security = new FavoriteConfigurationSecurity(this.persistence, fav);

            fav.ServerName = con.ServerName;

            int p = 3389;

            int.TryParse(con.Port, out p);
            fav.Port = p;

            if (credentials.ContainsKey(con.Credentials))
            {
                fav.Credential    = credentials[con.Credentials].Name;
                fav.UserName      = credentials[con.Credentials].UserName;
                fav.DomainName    = credentials[con.Credentials].Domain;
                security.Password = credentials[con.Credentials].Password;
            }

            switch (con.ColorDepth)
            {
            case "8":
                fav.Colors = Colors.Bits8;
                break;

            case "16":
                fav.Colors = Colors.Bit16;
                break;

            case "24":
                fav.Colors = Colors.Bits24;
                break;

            case "32":
                fav.Colors = Colors.Bits32;
                break;

            default:
                fav.Colors = Colors.Bit16;
                break;
            }
            ;

            fav.DesktopSize = DesktopSize.AutoScale;
            if (con.SeparateWindow == "true")
            {
                fav.DesktopSize = DesktopSize.FullScreen;
            }

            fav.ConnectToConsole = false;
            if (con.Console == "true")
            {
                fav.ConnectToConsole = true;
            }

            fav.DisableWallPaper = false;
            if (con.BitmapCaching == "false")
            {
                fav.DisableWallPaper = true;
            }

            fav.RedirectSmartCards = false;
            if (con.SmartCard == "true")
            {
                fav.RedirectSmartCards = true;
            }

            fav.RedirectPorts = false;
            //if (pValue == "1") fav.RedirectPorts = true;

            fav.RedirectPrinters = false;
            if (con.Printer == "true")
            {
                fav.RedirectPrinters = true;
            }

            fav.Sounds = ImportRDP.ConvertToSounds(con.Audio);
            fav.Name   = con.Name;

            return(fav);
        }