コード例 #1
0
        protected static Dictionary <string, object> MapQuery(OdooContext context, OdooQuery query = null)
        {
            if (query == null && (context == null || !context.Any()))
            {
                return(null);
            }

            var result = new Dictionary <string, object>();

            if (context != null && context.Any())
            {
                result["context"] = context;
            }

            if (query == null)
            {
                return(result);
            }

            if (query.Limit.HasValue)
            {
                result["limit"] = query.Limit;
            }

            if (!string.IsNullOrWhiteSpace(query.Order))
            {
                result["order"] = query.Order;
            }

            if (query.Offset.HasValue)
            {
                result["offset"] = query.Offset;
            }

            if (query.ReturnFields.Any())
            {
                result["fields"] = query.ReturnFields.ToArray();
            }

            if (!result.Any())
            {
                return(null);
            }

            return(result);
        }
コード例 #2
0
 internal OdooQueryBuilder(OdooClient odooClient) : base()
 {
     _odooClient = odooClient;
     _query      = new OdooQuery <T>();
 }
コード例 #3
0
        public static OdooRequestModel SearchCount(OdooConfig config, int uid, string tableName, OdooQuery query = null, OdooContext context = null)
        {
            var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute_kw", config.DbName, uid, config.Password, tableName, OdooOperation.SearchCount, GetRequestFilters(query), MapQuery(context, query));

            return(new OdooRequestModel(param));
        }
コード例 #4
0
        public static OdooRequestModel Read(OdooConfig config, int uid, string tableName, long[] ids, OdooQuery query = null, OdooContext context = null)
        {
            var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute_kw", config.DbName, uid, config.Password, tableName, OdooOperation.Read, ids, MapQuery(context, query));

            return(new OdooRequestModel(param));
        }
コード例 #5
0
 protected static object[] GetRequestFilters(OdooQuery query = null)
 {
     return(query != null && query.Filters.Count > 0 ? new object[] { query.Filters.ToArray() } : new object[] { new object[] { } });
 }
        public static OdooRequestModel SearchRead(OdooConfig config, int uid, string tableName, OdooQuery query = null)
        {
            var param = new OdooRequestParams(config.ApiUrlJson, "object", "execute", config.DbName, uid, config.Password, tableName, OdooOperation.SearchRead, query?.GetRequestFilters(), query?.GetRequestFields(), query?.Offset, query?.Limit, query?.Order);

            return(new OdooRequestModel(param));
        }