Ejemplo n.º 1
0
        private void UpdateCommand(OdooCommandContext context)
        {
            _context.UserId = Login();
            var idArray = new int[1];
            //Transformamos los argumentos en XmlRpcStruct
            var fields = new XmlRpcStruct();

            foreach (var argument in context.Arguments)
            {
                if (!argument.Property.Equals("id"))
                {
                    if (argument.Value != null)
                    {
                        fields.Add(argument.Property, argument.Value);
                    }
                }
                else
                {
                    if (argument.Value != null)
                    {
                        idArray[0] = (int)argument.Value;
                    }
                }
            }

            try
            {
                _context.OdooData.Write(_context.Database, _context.UserId, _context.Password, context.EntityName, "write", idArray, fields);
            }
            catch (XmlRpcFaultException e)
            {
                throw OdooException.GetException(e);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute Add command in OpenErp with context params.
        ///
        /// Exclude id property because OpenErp will return it after creation.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private int AddCommand(OdooCommandContext context)
        {
            int res;

            _context.UserId = Login();

            XmlRpcStruct fields = new XmlRpcStruct();

            foreach (OdooCommandArgument argument in context.Arguments)
            {
                if (!argument.ReadOnly)
                {
                    if (!argument.Property.Equals("id"))
                    {
                        fields.Add(argument.Property, argument.Value);
                    }
                }
            }
            try
            {
                res = _context.OdooData.Create(_context.Database, _context.UserId, _context.Password, context.EntityName, "create", fields);
            }
            catch (XmlRpcFaultException e)
            {
                throw OdooException.GetException(e);
            }
            return(res);
        }
Ejemplo n.º 3
0
        public ResultSet GetEntityCommand(OdooCommandContext commandContext, IEnumerable <object> ids)
        {
            _context.UserId = Login();

            try
            {
                var resultset = _context.OdooData.Read(_context.Database, _context.UserId, _context.Password, commandContext.EntityName, "read", ids.ToArray(), commandContext.GetArguments());
                return(new ResultSet(resultset));
            }
            catch (XmlRpcFaultException e)
            {
                throw OdooException.GetException(e);
            }
        }
Ejemplo n.º 4
0
        private void DeleteCommand(int id, string entityName)
        {
            var idArray = new object[1];

            idArray[0] = id;
            try
            {
                _context.OdooData.Unlink(_context.Database, _context.UserId, _context.Password, entityName, "unlink", idArray);
            }
            catch (XmlRpcFaultException e)
            {
                throw OdooException.GetException(e);
            }
        }
Ejemplo n.º 5
0
 private IEnumerable <object> SearchCommand(OdooCommandContext commandContext)
 {
     _context.UserId = Login();
     try
     {
         if (commandContext.Limit != 0)
         {
             return(_context.OdooData.Search(_context.Database, _context.UserId, _context.Password, commandContext.EntityName, "search", commandContext.GetArguments(), commandContext.Offset, commandContext.Limit, commandContext.Order));
         }
         return(_context.OdooData.Search(_context.Database, _context.UserId, _context.Password, commandContext.EntityName, "search", commandContext.GetArguments()));
     }
     catch (XmlRpcFaultException e)
     {
         throw OdooException.GetException(e);
     }
 }