public static IOdoo Connect(string host, int port, bool isSsl, string database, string username, string password) { OdooConnectionInfo odooConnectionInfo = new OdooConnectionInfo() { Host = host, Port = port, IsSSL = isSsl, Database = database, Username = username, Password = password }; OdooRpcClient odooRpcClient = new OdooRpcClient(odooConnectionInfo); Task task = odooRpcClient.Authenticate(); task.Wait(); Task <OdooVersionInfo> getVersionTask = odooRpcClient.GetOdooVersion(); task.Wait(); string serverVersion = getVersionTask.Result.ServerVersion; return(new Odoo(odooRpcClient) { Version = serverVersion }); }
private static Uri GetEndpointUri(OdooConnectionInfo connectionInfo, string endpoint) { return(new Uri(string.Format("{0}://{1}:{2}{3}", GetConnectionProtocol(connectionInfo), connectionInfo.Host, connectionInfo.Port, endpoint ))); }
public HttpsEndpoint() { this.connectionInfo = new OdooConnectionInfo() { IsSSL = true, Host = "test.odoo", Port = 1234, Username = "******", Password = "******" }; }
internal OdooSessionInfo(OdooConnectionInfo connectionInfo) { this.IsSSL = connectionInfo.IsSSL; this.Host = connectionInfo.Host; this.Port = connectionInfo.Port; this.Database = connectionInfo.Database; this.Username = connectionInfo.Username; this.Password = connectionInfo.Password; this.Reset(); }
private void LoadSettings() { try { var settings = JsonConvert.DeserializeObject <JObject>(File.ReadAllText("appsettings.json")); this.OdooConnection = settings["OdooConnection"].ToObject <OdooConnectionInfo>(); } catch (Exception ex) { Console.WriteLine("Error reading app settings: {0}", ex.Message); } }
public OdooSessionInfoTests() { this.ConnectionInfo = new OdooConnectionInfo() { IsSSL = false, Host = "test.odoo", Port = 1234, Username = "******", Password = "******" }; this.SessionInfo = new OdooSessionInfo(ConnectionInfo); }
public OdooRpcClientTests() { this.ConnectionInfo = new OdooConnectionInfo() { IsSSL = false, Host = "test.odoo", Port = 1234, Database = "odoo_test", Username = "******", Password = "******" }; this.JsonRpcClient = new JsonRpcWebClientStub(); this.JsonRpcClientFactory = new JsonRpcClientFactoryStub(this.JsonRpcClient); this.RpcClient = new OdooRpcClient(this.JsonRpcClientFactory, this.ConnectionInfo); }
static async System.Threading.Tasks.Task Main(string[] args) { Console.WriteLine("Iniciando..."); //Creo objeto OdooConnectionInfo con información de conección OdooConnectionInfo ConnectionInfo = new OdooConnectionInfo() { IsSSL = false, Host = "localhost", Port = 8069, Database = "db", Username = "******", Password = "******" }; //Me conecto a Odoo IOdooRpcClient RpcClient = new OdooRpcClient(ConnectionInfo); //Obtengo la versión de Odoo y la muestro por consola var odooVersion = await RpcClient.GetOdooVersion(); Console.WriteLine("Odoo Version: {0} - {1}", odooVersion.ServerVersion, odooVersion.ProtocolVersion); //Login await RpcClient.Authenticate(); if (RpcClient.SessionInfo.IsLoggedIn) { Console.WriteLine("Login correcto => Usuario Id: {0}", RpcClient.SessionInfo.UserId); } else { Console.WriteLine("Login incorrecto"); } //Actualizo los conductores de un vehículo - many2many campo custom Object[] obj = new Object[] { new Object[] { 6, 0, new Object[] { 2, 7 } } }; try { await RpcClient.Update <dynamic>("fleet.vehicle", 4, new { x_conductor = obj }); Console.WriteLine("OK - Actualizado"); } catch (Exception ex) { Console.WriteLine("Error getting partners from Odoo: {0}", ex.Message); } //Obtengo datos de los autos try { var fieldParams = new OdooFieldParameters(); fieldParams.Add("model_id"); fieldParams.Add("display_name"); fieldParams.Add("x_conductor"); var autos = await RpcClient.GetAll <JObject[]>("fleet.vehicle", fieldParams, new OdooPaginationParameters().OrderByDescending("name")); foreach (var auto in autos) { Console.WriteLine(auto); } //Console.WriteLine(autos.FirstOrDefault()); } catch (Exception ex) { Console.WriteLine("Error recuperando los autos desde Odoo: {0}", ex.Message); } }
public static Uri GetJsonRpcUri(OdooConnectionInfo connectionInfo) { return(GetEndpointUri(connectionInfo, "/jsonrpc")); }
private static string GetConnectionProtocol(OdooConnectionInfo connectionInfo) { return(connectionInfo.IsSSL ? "https" : "http"); }
internal OdooRpcClient(IJsonRpcClientFactory rpcFactory, OdooConnectionInfo connectionInfo) { this.RpcFactory = rpcFactory; this.SessionInfo = new OdooSessionInfo(connectionInfo); }
public OdooRpcClient(OdooConnectionInfo connectionInfo) : this(new JsonRpcClientFactory(), connectionInfo) { }