public OpsiClient(string opsiServerRpcEndpoint, string username, string password, bool ignoreInvalidCert = false) { _opsiHttpClient = new OpsiHttpClient(opsiServerRpcEndpoint, username, password, ignoreInvalidCert); BackendInterface = new BackendInterface(_opsiHttpClient); DepotInterface = new DepotInterface(_opsiHttpClient); HostInterface = new HostInterface(_opsiHttpClient); ProductsInterface = new ProductsInterface(_opsiHttpClient); BackendInterface = new BackendInterface(_opsiHttpClient); }
/// <summary> /// Disconnect from the current server. /// </summary> public static void Disconnect() { if (Authenticated) { Logout(); } if (ConnectedToServer) { Client = (BackendInterface)XmlRpcProxyGen.Create(typeof(BackendInterface)); Server = ""; ConnectedToServer = false; } }
/// <summary> /// Initiate the connection to the specified server. /// </summary> /// <param name="server"></param> public static void SetServer(string server) { if (!ConnectedToServer) { Client = (BackendInterface)XmlRpcProxyGen.Create(typeof(BackendInterface)); Client.KeepAlive = false; Client.Url = server; if (Client.Ping() == "pong") { ConnectedToServer = true; Server = server; } else { throw new Exception("An Error Occured While Connecting to the Server! Please check your connection and try again."); } } else { throw new Exception("Your already connected to a server! You must disconect from that server before you can connect to a new one!"); } }