public bool sauveData(Clients.clientOpenERP clientOpenERP, [email protected] context) { bool result; try { if ((!listProperties.ContainsKey("id")) || ((int)listProperties.value("id", aField.FIELD_TYPE.INTEGER) == 0)) { listProperties.setValue("id", clientOpenERP.insert(this, context)); result = ((int)listProperties.value("id") > 0); } else { result = clientOpenERP.update(this, context); } if (result) { foreach (System.Reflection.PropertyInfo prop in listeProprieteMultilangue()) { ((IMDEV.OpenERP.models.fields.texteMultilangue)(prop.GetValue(this, null))).sauveLangues(clientOpenERP); } return(true); } } catch (Exception ex) { throw new Systeme.exceptionOpenERP(IMDEV.OpenERP.Systeme.exceptionOpenERP.ERRORS.ERR_SAVE_OBJECT, ex.Message); } finally { clientOpenERP = null; } return(false); }
// TODO : Pourquoi ne pas envoyer un anOpenERPObject ? private int copyData(string resourceName, int id, [email protected] valeurs) { Interfaces.IObject conn; int retour = 0; try { conn = XmlRpcProxyGen.Create <Interfaces.IObject>(); conn.Url = url(SERVICE_XMLRPC.@object); if (valeurs == null) { retour = (int)conn.execute(_config.database, _config.userId, _config.password, resourceName, "copy", id); } else { retour = (int)conn.executeTwoParam(_config.database, _config.userId, _config.password, resourceName, "copy", id, valeurs.toArray()); } } catch (Exception ex) { if ((_config.reportXmlRpcError) && (ex.GetType() == typeof(XmlRpcFaultException))) { throw new Systeme.exceptionOpenERP(Systeme.exceptionOpenERP.ERRORS.LIB_XMLRPC, ex.Message); } } finally { conn = null; } return(retour); }
private [email protected] defaultGetData(string resourceName, List <string> listeChamps) { Interfaces.IObject conn; object retour; [email protected] ret = new [email protected](); try { conn = XmlRpcProxyGen.Create <Interfaces.IObject>(); conn.Url = url(SERVICE_XMLRPC.@object); retour = conn.execute(_config.database, _config.userId, _config.password, resourceName, "default_get", listeChamps.ToArray()); ret.copyData((XmlRpcStruct)retour); return(ret); } catch (Exception ex) { if ((_config.reportXmlRpcError) && (ex.GetType() == typeof(XmlRpcFaultException))) { throw new Systeme.exceptionOpenERP(Systeme.exceptionOpenERP.ERRORS.LIB_XMLRPC, ex.Message); } } finally { conn = null; } return(null); }
private [email protected] fieldsViewGetData(string resourceName, int viewId, string viewType, [email protected] context) { Interfaces.IObject conn; object retour; [email protected] ret = null; try { conn = XmlRpcProxyGen.Create <Interfaces.IObject>(); conn.Url = url(SERVICE_XMLRPC.@object); retour = conn.executeThreeParam(_config.database, _config.userId, _config.password, resourceName, "fields_view_get", viewId, viewType, context.toArray()); ret = new [email protected](); ret.copyData((XmlRpcStruct)retour); } catch (Exception ex) { if ((_config.reportXmlRpcError) && (ex.GetType() == typeof(XmlRpcFaultException))) { throw new Systeme.exceptionOpenERP(Systeme.exceptionOpenERP.ERRORS.LIB_XMLRPC, ex.Message); } } finally { conn = null; } return(ret); }
private int importDataData(string resourceName, List <string> listFields, [email protected] datas, string mode) { Interfaces.IObject conn; object retour; try { conn = XmlRpcProxyGen.Create <Interfaces.IObject>(); conn.Url = url(SERVICE_XMLRPC.@object); retour = conn.executeThreeParam(_config.database, _config.userId, _config.password, resourceName, "import_data", listFields.ToArray(), datas.toArray(), mode); return((int)((XmlRpcStruct)(retour))[0]); } catch (Exception ex) { if ((_config.reportXmlRpcError) && (ex.GetType() == typeof(XmlRpcFaultException))) { throw new Systeme.exceptionOpenERP(Systeme.exceptionOpenERP.ERRORS.LIB_XMLRPC, ex.Message); } } finally { conn = null; } return(0); }
/// <summary> /// Order 1 of OpenERP. Update fields of a linked object /// </summary> /// <param name="id">Id of the linked object</param> /// <param name="champs">New values of fields</param> /// <remarks></remarks> public void updateLinked(int id, [email protected] champs) { ArrayList ordre; ordre = createOrder(ORDERS.UPDATE_LINKED); ordre.Add(id); ordre.Add(champs.toArray()); }
/// <summary> /// Order 0 of OpenERP. Create the object with specified properties and link it to this object /// </summary> /// <param name="champs">List of properties to create, linked object</param> /// <remarks></remarks> public void createAndLink([email protected] champs) { ArrayList ordre; ordre = createOrder(ORDERS.CREATE_AND_LINK); ordre.Add(0); ordre.Add(champs.toArray()); }
public int importData(string resourceName, List <string> listFields, [email protected] datas, string mode) { if (checkIfBusy()) { return(0); } return(importDataData(resourceName, listFields, datas, mode)); }
public int copy(string resourceName, int id, [email protected] valeurs) { if (checkIfBusy()) { return(0); } return(copyData(resourceName, id, valeurs)); }
public void importDataAsync(string resourceName, List <string> listFields, [email protected] datas, System.ComponentModel.RunWorkerCompletedEventHandler callBack, string mode, bool prioritaire) { Hashtable param = new Hashtable(); param.Add("resourceName", resourceName); param.Add("listFields", listFields); param.Add("datas", datas); param.Add("mode", mode); _work.addTask(new System.ComponentModel.DoWorkEventHandler(this.importDataAsyncCall), callBack, param, prioritaire); }
private List <*****@*****.**> exportDataData(string resourceName, List <int> listId, List <string> listeChamps) { Interfaces.IObject conn; object retour; List <*****@*****.**> ret = new List <*****@*****.**>(); IEnumerator boucle; IEnumerator b2; [email protected] list; int i; try { conn = XmlRpcProxyGen.Create <Interfaces.IObject>(); conn.Url = url(SERVICE_XMLRPC.@object); retour = conn.executeTwoParam(_config.database, _config.userId, _config.password, resourceName, "export_data", listId.ToArray(), listeChamps.ToArray()); boucle = ((Array)(((XmlRpcStruct)(retour))["datas"])).GetEnumerator(); while (boucle.MoveNext()) { b2 = ((Array)(boucle.Current)).GetEnumerator(); list = new [email protected](); i = 0; while (b2.MoveNext()) { list.add(listeChamps[i], b2.Current); i++; } ret.Add(list); } return(ret); } catch (Exception ex) { if ((_config.reportXmlRpcError) && (ex.GetType() == typeof(XmlRpcFaultException))) { throw new Systeme.exceptionOpenERP(Systeme.exceptionOpenERP.ERRORS.LIB_XMLRPC, ex.Message); } } finally { conn = null; } return(null); }
private List <*****@*****.**> fieldsGetData(string resourceName, List <string> listFields) { Interfaces.IObject conn; object retour; List <*****@*****.**> ret = new List <*****@*****.**>(); IEnumerator boucle; IEnumerator b2; [email protected] list; try { conn = XmlRpcProxyGen.Create <Interfaces.IObject>(); conn.Url = url(SERVICE_XMLRPC.@object); retour = conn.execute(_config.database, _config.userId, _config.password, resourceName, "fields_get", listFields.ToArray()); boucle = ((Array)(retour)).GetEnumerator(); while (boucle.MoveNext()) { b2 = ((Array)(((DictionaryEntry)(boucle.Current)).Value)).GetEnumerator(); list = new [email protected](); while (b2.MoveNext()) { list.add((string)((DictionaryEntry)(b2.Current)).Key, ((DictionaryEntry)(b2.Current)).Value); } ret.Add(list); } return(ret); } catch (Exception ex) { if ((_config.reportXmlRpcError) && (ex.GetType() == typeof(XmlRpcFaultException))) { throw new Systeme.exceptionOpenERP(Systeme.exceptionOpenERP.ERRORS.LIB_XMLRPC, ex.Message); } } finally { conn = null; } return(null); }
private int addFileAttachmentData(string resourceName, int id, string filename, string libelle) { string _contentBase64; [email protected] obj = new [email protected](NOM_ATTACHMENT); [email protected] comp = new [email protected](); byte octet; if ((resourceName == "") || (id <= 0) || (filename == "")) { throw new ArgumentNullException(); } if (libelle == "") { libelle = System.IO.Path.GetFileNameWithoutExtension(filename); } System.IO.FileStream f = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); System.IO.MemoryStream donnees = new System.IO.MemoryStream((int)f.Length); while (f.Position < f.Length) { octet = (byte)f.ReadByte(); donnees.WriteByte(octet); } f.Close(); byte[] dummyArray = donnees.ToArray(); _contentBase64 = IMDEV.Cryptage.Base64.encodeBase64(dummyArray); obj.listProperties.add("datas", _contentBase64); obj.listProperties.add("datas_fname", System.IO.Path.GetFileName(filename)); obj.listProperties.add("name", libelle); obj.listProperties.add("type", "binary"); comp.add("default_res_model", resourceName); comp.add("default_res_id", id); return(insert(obj, comp)); }
private bool chargeLanguesData(IMDEV.OpenERP.Clients.clientOpenERP clientOpenERP, List <models.common.res_lang> listeLangue) { List <object> retour; List <string> listeChamps = new List <string>(); [email protected] context; listeChamps.Add(_nomChamps); _listeChaines.Clear(); _listeChaines = new Hashtable(); _changed.Clear(); _changed = new Hashtable(); try { if (listeLangue == null) { listeLangue = clientOpenERP.translatableLang(); if (listeLangue == null) { throw new Systeme.exceptionOpenERP(IMDEV.OpenERP.Systeme.exceptionOpenERP.ERRORS.NO_LANGUAGE); } } foreach (models.common.res_lang lang in listeLangue) { context = new [email protected](); context.add("lang", lang.code); retour = clientOpenERP.read(new IMDEV.OpenERP.models.query.aQuery((int)_classeParente.listProperties.value("id", [email protected]_TYPE.INTEGER)), _classeParente.resource_name(), listeChamps, context); _listeChaines.Add(lang.code, (([email protected])(retour[0])).listProperties.value(_nomChamps, [email protected]_TYPE.TEXT)); _changed.Add(lang.code, false); } _alreadyLoaded = true; return(true); } catch (Exception e) { throw new Systeme.exceptionOpenERP(Systeme.exceptionOpenERP.ERRORS.ERR_LOAD_TRANSLATE, e.Message); } }
public void copyAsync(string resourceName, int id, System.ComponentModel.RunWorkerCompletedEventHandler callBack, [email protected] valeurs) { copyAsync(resourceName, id, callBack, valeurs, false); }
public void importDataAsync(string resourceName, List <string> listFields, [email protected] datas, System.ComponentModel.RunWorkerCompletedEventHandler callBack, bool prioritaire) { importDataAsync(resourceName, listFields, datas, callBack, "init", prioritaire); }
public bool save(connectionProperties connexionOpenERP, [email protected] context) { Clients.clientOpenERP cli = new IMDEV.OpenERP.Clients.clientOpenERP(connexionOpenERP); return(sauveData(cli, context)); }
public bool save(Clients.clientOpenERP clientOpenERP, [email protected] context) { return(sauveData(clientOpenERP, context)); }
/// <summary> /// Importe des données dans un objet (une table) /// </summary> /// <param name="resourceName"></param> /// <param name="listFields"></param> /// <param name="datas"></param> /// <param name="mode"></param> /// <returns>Le nombre d'enregistrement ajouté</returns> /// <remarks></remarks> public int importData(string resourceName, List <string> listFields, [email protected] datas) { return(importData(resourceName, listFields, datas, "init")); }
public void saveAsync(connectionProperties connexionOpenERP, System.ComponentModel.RunWorkerCompletedEventHandler callBack, bool prioritaire, [email protected] context) { Clients.clientOpenERP cli = new IMDEV.OpenERP.Clients.clientOpenERP(connexionOpenERP); saveAsync(cli, callBack, prioritaire, context); }
public [email protected] getData(string resourceName, string order, string what, ArrayList comp, [email protected] context) { Interfaces.IObject conn; object retour; List <*****@*****.**> ret = new List <*****@*****.**>(); XmlRpcStruct boucle; [email protected] list; try { conn = XmlRpcProxyGen.Create <Interfaces.IObject>(); conn.Url = url(SERVICE_XMLRPC.@object); retour = conn.executeFiveParam(_config.database, _config.userId, _config.password, resourceName, "get", order, what, comp.ToArray(), false, context.toArray()); boucle = ((XmlRpcStruct)((object[])((((object[])(retour))[0])))[2]); list = new [email protected](); list.copyData(boucle); return(list); } catch (Exception ex) { if ((_config.reportXmlRpcError) && (ex.GetType() == typeof(XmlRpcFaultException))) { throw new Systeme.exceptionOpenERP(Systeme.exceptionOpenERP.ERRORS.LIB_XMLRPC, ex.Message); } } finally { conn = null; } return(null); }
public void saveAsync(Clients.clientOpenERP clientOpenERP, System.ComponentModel.RunWorkerCompletedEventHandler callBack, [email protected] context) { saveAsync(clientOpenERP, callBack, false, context); }
public void copyAsync(string resourceName, int id, System.ComponentModel.RunWorkerCompletedEventHandler callBack, [email protected] valeurs, bool prioritaire) { Hashtable param = new Hashtable(); param.Add("resourceName", resourceName); param.Add("id", id); param.Add("valeurs", valeurs); _work.addTask(new System.ComponentModel.DoWorkEventHandler(this.copyAsyncCall), callBack, param, prioritaire); }
public void saveAsync(Clients.clientOpenERP clientOpenERP, System.ComponentModel.RunWorkerCompletedEventHandler callBack, bool prioritaire, [email protected] context) { Hashtable param = new Hashtable(); param.Add("clientOpenERP", clientOpenERP); param.Add("context", context); clientOpenERP.worker.addTask(new System.ComponentModel.DoWorkEventHandler(this.sauveAsyncCallC), callBack, param, prioritaire); }