Exemplo n.º 1
0
        private void SerializeConnectionInfo(ConnectionInfo connectionInfo)
        {
            _currentNodeIndex++;
            var dataRow = _dataTable.NewRow();

            dataRow["ID"]         = DBNull.Value;
            dataRow["Name"]       = connectionInfo.Name;
            dataRow["Type"]       = connectionInfo.GetTreeNodeType().ToString();
            dataRow["ConstantID"] = connectionInfo.ConstantID;
            dataRow["ParentID"]   = connectionInfo.Parent?.ConstantID ?? "";
            dataRow["PositionID"] = _currentNodeIndex;
            dataRow["LastChange"] = MiscTools.DBTimeStampNow();
            dataRow["Expanded"]   =
                false; // TODO: this column can eventually be removed. we now save this property locally
            dataRow["Description"] = connectionInfo.Description;
            dataRow["Icon"]        = connectionInfo.Icon;
            dataRow["Panel"]       = connectionInfo.Panel;
            dataRow["Username"]    = _saveFilter.SaveUsername ? connectionInfo.Username : "";
            dataRow["DomainName"]  = _saveFilter.SaveDomain ? connectionInfo.Domain : "";
            dataRow["Password"]    = _saveFilter.SavePassword
                ? _cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)
                : "";
            dataRow["Hostname"]                 = connectionInfo.Hostname;
            dataRow["Protocol"]                 = connectionInfo.Protocol;
            dataRow["PuttySession"]             = connectionInfo.PuttySession;
            dataRow["Port"]                     = connectionInfo.Port;
            dataRow["ConnectToConsole"]         = connectionInfo.UseConsoleSession;
            dataRow["UseCredSsp"]               = connectionInfo.UseCredSsp;
            dataRow["RenderingEngine"]          = connectionInfo.RenderingEngine;
            dataRow["ICAEncryptionStrength"]    = connectionInfo.ICAEncryptionStrength;
            dataRow["RDPAuthenticationLevel"]   = connectionInfo.RDPAuthenticationLevel;
            dataRow["RDPMinutesToIdleTimeout"]  = connectionInfo.RDPMinutesToIdleTimeout;
            dataRow["RDPAlertIdleTimeout"]      = connectionInfo.RDPAlertIdleTimeout;
            dataRow["LoadBalanceInfo"]          = connectionInfo.LoadBalanceInfo;
            dataRow["Colors"]                   = connectionInfo.Colors;
            dataRow["Resolution"]               = connectionInfo.Resolution;
            dataRow["AutomaticResize"]          = connectionInfo.AutomaticResize;
            dataRow["DisplayWallpaper"]         = connectionInfo.DisplayWallpaper;
            dataRow["DisplayThemes"]            = connectionInfo.DisplayThemes;
            dataRow["EnableFontSmoothing"]      = connectionInfo.EnableFontSmoothing;
            dataRow["EnableDesktopComposition"] = connectionInfo.EnableDesktopComposition;
            dataRow["CacheBitmaps"]             = connectionInfo.CacheBitmaps;
            dataRow["RedirectDiskDrives"]       = connectionInfo.RedirectDiskDrives;
            dataRow["RedirectPorts"]            = connectionInfo.RedirectPorts;
            dataRow["RedirectPrinters"]         = connectionInfo.RedirectPrinters;
            dataRow["RedirectClipboard"]        = connectionInfo.RedirectClipboard;
            dataRow["RedirectSmartCards"]       = connectionInfo.RedirectSmartCards;
            dataRow["RedirectSound"]            = connectionInfo.RedirectSound;
            dataRow["SoundQuality"]             = connectionInfo.SoundQuality;
            dataRow["RedirectAudioCapture"]     = connectionInfo.RedirectAudioCapture;
            dataRow["RedirectKeys"]             = connectionInfo.RedirectKeys;
            dataRow["Connected"]                =
                false; // TODO: this column can eventually be removed. we now save this property locally
            dataRow["PreExtApp"]        = connectionInfo.PreExtApp;
            dataRow["PostExtApp"]       = connectionInfo.PostExtApp;
            dataRow["MacAddress"]       = connectionInfo.MacAddress;
            dataRow["UserField"]        = connectionInfo.UserField;
            dataRow["ExtApp"]           = connectionInfo.ExtApp;
            dataRow["VNCCompression"]   = connectionInfo.VNCCompression;
            dataRow["VNCEncoding"]      = connectionInfo.VNCEncoding;
            dataRow["VNCAuthMode"]      = connectionInfo.VNCAuthMode;
            dataRow["VNCProxyType"]     = connectionInfo.VNCProxyType;
            dataRow["VNCProxyIP"]       = connectionInfo.VNCProxyIP;
            dataRow["VNCProxyPort"]     = connectionInfo.VNCProxyPort;
            dataRow["VNCProxyUsername"] = connectionInfo.VNCProxyUsername;
            dataRow["VNCProxyPassword"] =
                _cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey);
            dataRow["VNCColors"]            = connectionInfo.VNCColors;
            dataRow["VNCSmartSizeMode"]     = connectionInfo.VNCSmartSizeMode;
            dataRow["VNCViewOnly"]          = connectionInfo.VNCViewOnly;
            dataRow["RDGatewayUsageMethod"] = connectionInfo.RDGatewayUsageMethod;
            dataRow["RDGatewayHostname"]    = connectionInfo.RDGatewayHostname;
            dataRow["RDGatewayUseConnectionCredentials"] = connectionInfo.RDGatewayUseConnectionCredentials;
            dataRow["RDGatewayUsername"] = connectionInfo.RDGatewayUsername;
            dataRow["RDGatewayPassword"] = _cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword, _encryptionKey);
            dataRow["RDGatewayDomain"]   = connectionInfo.RDGatewayDomain;
            if (_saveFilter.SaveInheritance)
            {
                dataRow["InheritCacheBitmaps"]             = connectionInfo.Inheritance.CacheBitmaps;
                dataRow["InheritColors"]                   = connectionInfo.Inheritance.Colors;
                dataRow["InheritDescription"]              = connectionInfo.Inheritance.Description;
                dataRow["InheritDisplayThemes"]            = connectionInfo.Inheritance.DisplayThemes;
                dataRow["InheritDisplayWallpaper"]         = connectionInfo.Inheritance.DisplayWallpaper;
                dataRow["InheritEnableFontSmoothing"]      = connectionInfo.Inheritance.EnableFontSmoothing;
                dataRow["InheritEnableDesktopComposition"] = connectionInfo.Inheritance.EnableDesktopComposition;
                dataRow["InheritDomain"]                   = connectionInfo.Inheritance.Domain;
                dataRow["InheritIcon"]                              = connectionInfo.Inheritance.Icon;
                dataRow["InheritPanel"]                             = connectionInfo.Inheritance.Panel;
                dataRow["InheritPassword"]                          = connectionInfo.Inheritance.Password;
                dataRow["InheritPort"]                              = connectionInfo.Inheritance.Port;
                dataRow["InheritProtocol"]                          = connectionInfo.Inheritance.Protocol;
                dataRow["InheritPuttySession"]                      = connectionInfo.Inheritance.PuttySession;
                dataRow["InheritRedirectDiskDrives"]                = connectionInfo.Inheritance.RedirectDiskDrives;
                dataRow["InheritRedirectKeys"]                      = connectionInfo.Inheritance.RedirectKeys;
                dataRow["InheritRedirectPorts"]                     = connectionInfo.Inheritance.RedirectPorts;
                dataRow["InheritRedirectPrinters"]                  = connectionInfo.Inheritance.RedirectPrinters;
                dataRow["InheritRedirectClipboard"]                 = connectionInfo.Inheritance.RedirectClipboard;
                dataRow["InheritRedirectSmartCards"]                = connectionInfo.Inheritance.RedirectSmartCards;
                dataRow["InheritRedirectSound"]                     = connectionInfo.Inheritance.RedirectSound;
                dataRow["InheritSoundQuality"]                      = connectionInfo.Inheritance.SoundQuality;
                dataRow["InheritRedirectAudioCapture"]              = connectionInfo.Inheritance.RedirectAudioCapture;
                dataRow["InheritResolution"]                        = connectionInfo.Inheritance.Resolution;
                dataRow["InheritAutomaticResize"]                   = connectionInfo.Inheritance.AutomaticResize;
                dataRow["InheritUseConsoleSession"]                 = connectionInfo.Inheritance.UseConsoleSession;
                dataRow["InheritUseCredSsp"]                        = connectionInfo.Inheritance.UseCredSsp;
                dataRow["InheritRenderingEngine"]                   = connectionInfo.Inheritance.RenderingEngine;
                dataRow["InheritUsername"]                          = connectionInfo.Inheritance.Username;
                dataRow["InheritICAEncryptionStrength"]             = connectionInfo.Inheritance.ICAEncryptionStrength;
                dataRow["InheritRDPAuthenticationLevel"]            = connectionInfo.Inheritance.RDPAuthenticationLevel;
                dataRow["InheritRDPMinutesToIdleTimeout"]           = connectionInfo.Inheritance.RDPMinutesToIdleTimeout;
                dataRow["InheritRDPAlertIdleTimeout"]               = connectionInfo.Inheritance.RDPAlertIdleTimeout;
                dataRow["InheritLoadBalanceInfo"]                   = connectionInfo.Inheritance.LoadBalanceInfo;
                dataRow["InheritPreExtApp"]                         = connectionInfo.Inheritance.PreExtApp;
                dataRow["InheritPostExtApp"]                        = connectionInfo.Inheritance.PostExtApp;
                dataRow["InheritMacAddress"]                        = connectionInfo.Inheritance.MacAddress;
                dataRow["InheritUserField"]                         = connectionInfo.Inheritance.UserField;
                dataRow["InheritExtApp"]                            = connectionInfo.Inheritance.ExtApp;
                dataRow["InheritVNCCompression"]                    = connectionInfo.Inheritance.VNCCompression;
                dataRow["InheritVNCEncoding"]                       = connectionInfo.Inheritance.VNCEncoding;
                dataRow["InheritVNCAuthMode"]                       = connectionInfo.Inheritance.VNCAuthMode;
                dataRow["InheritVNCProxyType"]                      = connectionInfo.Inheritance.VNCProxyType;
                dataRow["InheritVNCProxyIP"]                        = connectionInfo.Inheritance.VNCProxyIP;
                dataRow["InheritVNCProxyPort"]                      = connectionInfo.Inheritance.VNCProxyPort;
                dataRow["InheritVNCProxyUsername"]                  = connectionInfo.Inheritance.VNCProxyUsername;
                dataRow["InheritVNCProxyPassword"]                  = connectionInfo.Inheritance.VNCProxyPassword;
                dataRow["InheritVNCColors"]                         = connectionInfo.Inheritance.VNCColors;
                dataRow["InheritVNCSmartSizeMode"]                  = connectionInfo.Inheritance.VNCSmartSizeMode;
                dataRow["InheritVNCViewOnly"]                       = connectionInfo.Inheritance.VNCViewOnly;
                dataRow["InheritRDGatewayUsageMethod"]              = connectionInfo.Inheritance.RDGatewayUsageMethod;
                dataRow["InheritRDGatewayHostname"]                 = connectionInfo.Inheritance.RDGatewayHostname;
                dataRow["InheritRDGatewayUseConnectionCredentials"] =
                    connectionInfo.Inheritance.RDGatewayUseConnectionCredentials;
                dataRow["InheritRDGatewayUsername"] = connectionInfo.Inheritance.RDGatewayUsername;
                dataRow["InheritRDGatewayPassword"] = connectionInfo.Inheritance.RDGatewayPassword;
                dataRow["InheritRDGatewayDomain"]   = connectionInfo.Inheritance.RDGatewayDomain;
            }
            else
            {
                dataRow["InheritCacheBitmaps"]             = false;
                dataRow["InheritColors"]                   = false;
                dataRow["InheritDescription"]              = false;
                dataRow["InheritDisplayThemes"]            = false;
                dataRow["InheritDisplayWallpaper"]         = false;
                dataRow["InheritEnableFontSmoothing"]      = false;
                dataRow["InheritEnableDesktopComposition"] = false;
                dataRow["InheritDomain"]                   = false;
                dataRow["InheritIcon"]                              = false;
                dataRow["InheritPanel"]                             = false;
                dataRow["InheritPassword"]                          = false;
                dataRow["InheritPort"]                              = false;
                dataRow["InheritProtocol"]                          = false;
                dataRow["InheritPuttySession"]                      = false;
                dataRow["InheritRedirectDiskDrives"]                = false;
                dataRow["InheritRedirectKeys"]                      = false;
                dataRow["InheritRedirectPorts"]                     = false;
                dataRow["InheritRedirectPrinters"]                  = false;
                dataRow["InheritRedirectClipboard"]                 = false;
                dataRow["InheritRedirectSmartCards"]                = false;
                dataRow["InheritRedirectSound"]                     = false;
                dataRow["InheritSoundQuality"]                      = false;
                dataRow["InheritRedirectAudioCapture"]              = false;
                dataRow["InheritResolution"]                        = false;
                dataRow["InheritAutomaticResize"]                   = false;
                dataRow["InheritUseConsoleSession"]                 = false;
                dataRow["InheritUseCredSsp"]                        = false;
                dataRow["InheritRenderingEngine"]                   = false;
                dataRow["InheritUsername"]                          = false;
                dataRow["InheritICAEncryptionStrength"]             = false;
                dataRow["InheritRDPAuthenticationLevel"]            = false;
                dataRow["InheritRDPMinutesToIdleTimeout"]           = false;
                dataRow["InheritRDPAlertIdleTimeout"]               = false;
                dataRow["InheritLoadBalanceInfo"]                   = false;
                dataRow["InheritPreExtApp"]                         = false;
                dataRow["InheritPostExtApp"]                        = false;
                dataRow["InheritMacAddress"]                        = false;
                dataRow["InheritUserField"]                         = false;
                dataRow["InheritExtApp"]                            = false;
                dataRow["InheritVNCCompression"]                    = false;
                dataRow["InheritVNCEncoding"]                       = false;
                dataRow["InheritVNCAuthMode"]                       = false;
                dataRow["InheritVNCProxyType"]                      = false;
                dataRow["InheritVNCProxyIP"]                        = false;
                dataRow["InheritVNCProxyPort"]                      = false;
                dataRow["InheritVNCProxyUsername"]                  = false;
                dataRow["InheritVNCProxyPassword"]                  = false;
                dataRow["InheritVNCColors"]                         = false;
                dataRow["InheritVNCSmartSizeMode"]                  = false;
                dataRow["InheritVNCViewOnly"]                       = false;
                dataRow["InheritRDGatewayUsageMethod"]              = false;
                dataRow["InheritRDGatewayHostname"]                 = false;
                dataRow["InheritRDGatewayUseConnectionCredentials"] = false;
                dataRow["InheritRDGatewayUsername"]                 = false;
                dataRow["InheritRDGatewayPassword"]                 = false;
                dataRow["InheritRDGatewayDomain"]                   = false;
            }

            _dataTable.Rows.Add(dataRow);
        }