public IRestriction GetRestrictionForType(Type t) { if (IsEnabled) { switch (this.Type) { case RestrictionType.Equals: return(RestrictionFactory.Eq(t, property, Value)); break; case RestrictionType.Like: string search = (!string.IsNullOrEmpty(Value))? Value.Trim('%', ' '):""; search = "%" + search + "%"; return(RestrictionFactory.Like(t, property, search)); break; case RestrictionType.BetweenDates: return(RestrictionFactory.Btw(t, property, StartTime, EndTime)); break; default: break; } } return(null); }
private IRestriction fromTextRestriction(TextRestriction res) { string value = res.Value ?? ""; if (res.ExactMatch) { return(RestrictionFactory.Eq(_configuredSearch.ObjectType, res.Property, value)); } else { return(RestrictionFactory.Like(_configuredSearch.ObjectType, res.Property, string.Format("%{0}%", value.Trim('%')))); } }
public List <ListViewItem> searchIUResults(Dictionary <String, String> searchStrings, bool strategyAND) { List <ListViewItem> items = new List <ListViewItem>(); try { LogicalRestriction restrict = null; if (strategyAND) { restrict = RestrictionFactory.And(); } else { restrict = RestrictionFactory.Or(); } foreach (String key in searchStrings.Keys) { if (key != null) { IRestriction r = RestrictionFactory.Like(typeof(IdentificationUnit), key, searchStrings[key]); restrict.Add(r); } } foreach (IdentificationUnit iu in con.LoadList <IdentificationUnit>(restrict)) { if (iu != null) { ListViewItem item = new ListViewItem(); item.Text = iu.IdentificationUnitID.ToString(); item.SubItems.Add(iu.LastIdentificationCache); item.SubItems.Add(iu.TaxonomicGroup); item.SubItems.Add(iu.UnitIdentifier); item.Tag = iu.IdentificationUnitID; items.Add(item); } } } catch (Exception) { items.Clear(); } return(items); }
public IList <ListViewItem> searchEventResults(Dictionary <String, String> searchStrings, bool strategyAND) { List <ListViewItem> items = new List <ListViewItem>(); try { LogicalRestriction restrict = null; if (strategyAND) { restrict = RestrictionFactory.And(); } else { restrict = RestrictionFactory.Or(); } foreach (String key in searchStrings.Keys) { if (key != null) { IRestriction r = RestrictionFactory.Like(typeof(CollectionEvent), key, searchStrings[key]); restrict.Add(r); } } foreach (CollectionEvent ce in con.LoadList <CollectionEvent>(restrict)) { if (ce != null) { ListViewItem item = new ListViewItem(); item.Text = ce.CollectionEventID.ToString(); item.SubItems.Add(ce.CollectorsEventNumber); item.SubItems.Add(ce.CollectionDate.ToShortDateString()); item.Tag = ce.CollectionEventID; items.Add(item); } } } catch (Exception) { items.Clear(); } return(items); }
public List <ListViewItem> searchSpecimenResults(Dictionary <String, String> searchStrings, bool strategyAND) { List <ListViewItem> items = new List <ListViewItem>(); try { LogicalRestriction restrict = null; if (strategyAND) { restrict = RestrictionFactory.And(); } else { restrict = RestrictionFactory.Or(); } foreach (String key in searchStrings.Keys) { if (key != null) { IRestriction r = RestrictionFactory.Like(typeof(CollectionSpecimen), key, searchStrings[key]); restrict.Add(r); } } foreach (CollectionSpecimen cs in con.LoadList <CollectionSpecimen>(restrict)) { if (cs != null) { ListViewItem item = new ListViewItem(); item.Text = cs.CollectionSpecimenID.ToString(); item.Tag = cs.CollectionSpecimenID; items.Add(item); } } } catch (Exception) { items.Clear(); } return(items); }