public static void Apply(roxority_FilterWebPart filterWebPart, DataFormWebPart bdcListWebPart)
        {
            BdcDataSource dataSource = bdcListWebPart.DataSource as BdcDataSource;
            List <roxority_FilterZen.FilterBase> filters = filterWebPart.GetFilters();
            List <KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > > list2 = new List <KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > >();
            Dictionary <string, roxority_FilterZen.FilterBase> dictionary = new Dictionary <string, roxority_FilterZen.FilterBase>();

            foreach (roxority_FilterZen.FilterBase base3 in filters)
            {
                dictionary[base3.Name] = base3;
            }
            using (List <KeyValuePair <string, roxority_FilterWebPart.FilterPair> > .Enumerator enumerator2 = filterWebPart.PartFilters.GetEnumerator())
            {
                Predicate <KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > > match = null;
                KeyValuePair <string, roxority_FilterWebPart.FilterPair> kvp;
                while (enumerator2.MoveNext())
                {
                    kvp = enumerator2.Current;
                    KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > item = new KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> >(kvp.Key, new List <roxority_FilterWebPart.FilterPair>());
                    if (list2.Count > 0)
                    {
                        if (match == null)
                        {
                            match = test => test.Key.Equals(kvp.Key);
                        }
                        item = list2.Find(match);
                    }
                    if (string.IsNullOrEmpty(item.Key) || (kvp.Value == null))
                    {
                        item = new KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> >(kvp.Key, new List <roxority_FilterWebPart.FilterPair>());
                    }
                    list2.Remove(item);
                    item.Value.Add(kvp.Value);
                    list2.Add(item);
                }
            }
            foreach (KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > pair2 in list2)
            {
                foreach (roxority_FilterWebPart.FilterPair pair3 in pair2.Value)
                {
                    roxority_FilterZen.FilterBase base2;
                    Microsoft.SharePoint.WebControls.BusinessDataParameter parameter = new Microsoft.SharePoint.WebControls.BusinessDataParameter();
                    if (dictionary.TryGetValue(pair3.Key, out base2))
                    {
                        parameter.ConvertEmptyStringToNull = !base2.SendEmpty;
                    }
                    parameter.Name         = pair3.Key;
                    parameter.DefaultValue = pair3.Value;
                    parameter.Direction    = ParameterDirection.Input;
                    parameter.Operator     = ConvertCamlOperator(pair3.CamlOperator);
                    dataSource.FilterParameters.Add(parameter);
                }
            }
        }
Ejemplo n.º 2
0
        public static void Apply(roxority_FilterWebPart filterWebPart, DataFormWebPart bdcListWebPart)
        {
            BdcDataSource         dataSource = bdcListWebPart.DataSource as BdcDataSource;
            BusinessDataParameter param;
            FilterBase            filter;
            List <FilterBase>     filters = filterWebPart.GetFilters();
            List <KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > > filterValues = new List <KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > > ();
            Dictionary <string, FilterBase> allFilters = new Dictionary <string, FilterBase> ();
            KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > tmp;

            foreach (FilterBase fb in filters)
            {
                allFilters [fb.Name] = fb;
            }
            foreach (KeyValuePair <string, roxority_FilterWebPart.FilterPair> kvp in filterWebPart.PartFilters)
            {
                tmp = new KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > (kvp.Key, new List <roxority_FilterWebPart.FilterPair> ());
                if (filterValues.Count > 0)
                {
                    tmp = filterValues.Find(delegate(KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > test) {
                        return(test.Key.Equals(kvp.Key));
                    });
                }
                if (string.IsNullOrEmpty(tmp.Key) || (kvp.Value == null))
                {
                    tmp = new KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > (kvp.Key, new List <roxority_FilterWebPart.FilterPair> ());
                }
                filterValues.Remove(tmp);
                tmp.Value.Add(kvp.Value);
                filterValues.Add(tmp);
            }
            foreach (KeyValuePair <string, List <roxority_FilterWebPart.FilterPair> > kvp in filterValues)
            {
                foreach (roxority_FilterWebPart.FilterPair pair in kvp.Value)
                {
                    param = new BusinessDataParameter();
                    if (allFilters.TryGetValue(pair.Key, out filter))
                    {
                        param.ConvertEmptyStringToNull = !filter.SendEmpty;
                    }
                    param.Name         = pair.Key;
                    param.DefaultValue = pair.Value;
                    param.Direction    = ParameterDirection.Input;
                    param.Operator     = ConvertCamlOperator(pair.CamlOperator);
                    dataSource.FilterParameters.Add(param);
                }
            }
        }