예제 #1
0
        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);
        }
예제 #2
0
        //  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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
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());
        }
예제 #7
0
        /// <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());
        }
예제 #8
0
        public int importData(string resourceName, List <string> listFields, [email protected] datas, string mode)
        {
            if (checkIfBusy())
            {
                return(0);
            }

            return(importDataData(resourceName, listFields, datas, mode));
        }
예제 #9
0
        public int copy(string resourceName, int id, [email protected] valeurs)
        {
            if (checkIfBusy())
            {
                return(0);
            }

            return(copyData(resourceName, id, valeurs));
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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));
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
 public void copyAsync(string resourceName, int id, System.ComponentModel.RunWorkerCompletedEventHandler callBack, [email protected] valeurs)
 {
     copyAsync(resourceName, id, callBack, valeurs, false);
 }
예제 #16
0
 public void importDataAsync(string resourceName, List <string> listFields, [email protected] datas, System.ComponentModel.RunWorkerCompletedEventHandler callBack, bool prioritaire)
 {
     importDataAsync(resourceName, listFields, datas, callBack, "init", prioritaire);
 }
예제 #17
0
 public bool save(connectionProperties connexionOpenERP, [email protected] context)
 {
     Clients.clientOpenERP cli = new IMDEV.OpenERP.Clients.clientOpenERP(connexionOpenERP);
     return(sauveData(cli, context));
 }
예제 #18
0
 public bool save(Clients.clientOpenERP clientOpenERP, [email protected] context)
 {
     return(sauveData(clientOpenERP, context));
 }
예제 #19
0
 /// <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"));
 }
예제 #20
0
 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);
 }
예제 #21
0
        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);
        }
예제 #22
0
 public void saveAsync(Clients.clientOpenERP clientOpenERP, System.ComponentModel.RunWorkerCompletedEventHandler callBack, [email protected] context)
 {
     saveAsync(clientOpenERP, callBack, false, context);
 }
예제 #23
0
        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);
        }
예제 #24
0
        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);
        }