예제 #1
0
파일: Host.cs 프로젝트: Hunv/beRemote
        ///// <summary>
        ///// Saves a connection to the storage system (VERY BASIC; PRIVATE ONLY!!!)
        ///// </summary>
        ///// <param name="connection"></param>
        ///// <returns>The connection id in the storage</returns>
        //public static int SaveConnection(Host connection)
        //{

        //    IDbPlugin storage = StorageCore.Core;

        //    List<OSVersion> versions = storage.GetVersionlist();
        //    int osID = 11254234;
        //    foreach (OSVersion version in versions)
        //    {
        //        if (version.getFamily().ToLower() == connection._server.GetServerType().ToString().ToLower())
        //        {
        //            osID = version.getId();
        //            break;
        //        }
        //    }



        //    if (connection._inDB && connection._dbID != null)
        //    {
        //        // modify it
        //    }
        //    else
        //    {
        //        // add it
        //        connection._dbID = (int)storage.AddConnection(connection.GetServer().GetRemoteIP().ToString(), connection.GetServer().GetServerName(), "", osID, connection.GetFolderID());

        //        foreach (KeyValuePair<String, Protocol> kvp in connection.GetProtocols())
        //        {
        //            int _dbConnSettingsID = (int)storage.AddConnectionSetting(connection._dbID, kvp.Value.GetProtocolIdentifer(), kvp.Value.GetDefaultProtocolPort(), false);

        //            foreach (Session session in connection.GetSessions())
        //            {
        //                if (session.GetSessionProtocol().GetProtocolIdentifer().ToLower() == kvp.Key.ToLower())
        //                {
        //                    SortedList<String, String> settings = session.GetSessionSettings();
        //                    foreach (KeyValuePair<String, String> kvpSesSet in settings)
        //                    {
        //                        storage.ModifyConnectionOption(kvpSesSet.Value, kvpSesSet.Key, _dbConnSettingsID, false);
        //                    }
        //                }
        //            }

        //        }

        //    }


        //    //if (connection._alreadyInStorage && connection._connectionID != null)
        //    //{
        //    //    //storage.ModifyConnection(connection._connectionID, server.GetRemoteIP().ToString(), server.GetServerName(), "", osID);
        //    //    //storage.ModifyConnectionSetting(connection._connectionID, connection.GetSession().GetProtocolPort(), storage.GetUserId(), false);

        //    //    //foreach (KeyValuePair<String, String> kvp in connection.GetSession().GetSessionSettings())
        //    //    //{
        //    //    //    List<ConnectionSetting> db_settings = storage.GetConnectionSettings(connection._connectionID);
        //    //    //}
        //    //}
        //    //else
        //    //{
        //    //    connection._connectionID = (int)storage.AddConnection(server.GetRemoteIP().ToString(), server.GetServerName(), "", osID);
        //    //    int connectionSettingsID = (int)storage.AddConnectionSetting(connection._connectionID, connection.GetProtocol().GetProtocolIdentifer(), connection.GetSession().GetProtocolPort(), false);

        //    //    foreach (KeyValuePair<String, String> kvp in connection.GetSession().GetSessionSettings())
        //    //    {
        //    //        storage.ModifyConnectionOption(kvp.Value, kvp.Key, connectionSettingsID, false);
        //    //    }

        //    //}
        //    return connection._dbID;
        //    //return connection._connectionID;
        //}


        private static IServer LoadServer(long id)
        {
            IDbPlugin storage          = StorageCore.Core;
            IServer   server           = Server.NewServer(id);
            OSVersion db_connection_os = storage.GetVersion(server.GetServerTypeID());

            List <ConnectionProtocol> connectionSettings = storage.GetConnectionSettings(id);

            ServerType serverType = server.GetServerType();

            foreach (ConnectionProtocol conSet in connectionSettings)
            {
                if (Kernel.GetAvailableProtocols().Keys.Contains(conSet.Protocol))
                {
                    server.AddProtocol(Kernel.GetAvailableProtocols()[conSet.Protocol]);
                    // session settings zuweisen!
                }
            }


            return(server);
        }