public async Task <T> SearchAndRead <T>(string modelName, XMLRpcParamList <IXMLRpcParameter> filters) { List <IXMLRpcParameter> parameters = await PrepareCall(modelName, "search_read", filters); var data = await this.Send <T>(ExecuteService, "execute", parameters); return(data); }
public async void Can_Call_SearchRead() { //Arrange var filters = new XMLRpcParamList <IXMLRpcParameter>(); XMLRpcOdooClient caller = new XMLRpcOdooClient("https://corexmlrpcdemo.odoo.com", "*****@*****.**", "odoo2019", "corexmlrpcdemo"); //Act var returned = await caller.SearchAndRead <List <Contacto> >("res.partner", filters); Assert.IsType <List <Contacto> >(returned); //Assert Assert.True(returned.Count > 0); }
private async Task <List <IXMLRpcParameter> > PrepareCall(string modelName, string methodName, XMLRpcParamList <IXMLRpcParameter> filters) { var requestedId = await Login(); var parameters = new List <IXMLRpcParameter> { new XMLRpcParameter <string> { Name = "db", FilterOption = FilterOption.None, Value = Database }, new XMLRpcParameter <int> { Name = "userId", FilterOption = FilterOption.None, Value = requestedId }, new XMLRpcParameter <string> { Name = "password", FilterOption = FilterOption.None, Value = Password }, new XMLRpcParameter <string> { Name = "modelName", FilterOption = FilterOption.None, Value = modelName }, new XMLRpcParameter <string> { Name = "methodName", FilterOption = FilterOption.None, Value = methodName } }; if (filters != null) { var filter = new XMLRpcParameter <XMLRpcParamList <IXMLRpcParameter> > { Value = new XMLRpcParamList <IXMLRpcParameter>() }; foreach (var item in filters) { filter.Value.Add(item); } parameters.Add(filter); } return(parameters); }