示例#1
0
        // ContentTypes separados por (;)
        public static string BuildCaml(string OriginalCamlQuery, string ContentTypes, string Order, string FilterColumnName, string FilterValue)
        {
            // CONTENT TYPE
            string queryContenType = QueryContentType(ContentTypes);

            // USER QUERY
            string queryCaml = StripQuery(OriginalCamlQuery);

            // WildCards en WebPartBase

            // FILTER
            if (!string.IsNullOrWhiteSpace(FilterColumnName) && !string.IsNullOrWhiteSpace(FilterValue))
            {
                string queryFilter = CamlHelper.NewBlock(CamlHelper.Operation.Contains, FilterColumnName, CamlHelper.ValueType.Text, FilterValue);
                queryCaml = CamlHelper.AddLogicOp(CamlHelper.Operation.And, queryFilter, queryCaml);
            }

            // <WHERE> WRAPPING
            string where = CamlHelper.AddWhere(CamlHelper.AddLogicOp(CamlHelper.Operation.And, queryContenType, queryCaml));

            // ORDER ascending by default
            string orderCaml = string.Empty;

            if (!string.IsNullOrWhiteSpace(Order))
            {
                orderCaml = BuildOrderBy(Order);
            }

            // Si no hay info en el where este no aprece
            where = where.Replace("<Where></Where>", string.Empty);

            return(where + orderCaml);
        }
示例#2
0
        QueryContentType(string ctypes)
        {
            string ret = string.Empty;

            if (!string.IsNullOrWhiteSpace(ctypes))
            {
                string[] tipos = ctypes.ExtractSeparatedValues(";");
                if (tipos != null)
                {
                    for (int i = 0; i < tipos.Length; i++)
                    {
                        ret = CamlHelper.AddLogicOp(CamlHelper.Operation.Or, ret, CamlHelper.NewBlock(CamlHelper.Operation.Eq, CamlHelper.FieldRefName.ContentType, CamlHelper.ValueType.Text, tipos[i]));
                    }
                }
            }

            return(ret);
        }