internal static List <SPListItem> GetGateKeeperItems(GateKeeperType type, GateKeeperListing node) { List <SPListItem> items = new List <SPListItem>(); SPListItemCollection nodes = null; SPWeb web = SPContext.Current.Web; SPList gatekeeper = web.Lists["GateKeeper"]; SPQuery query = new SPQuery(); query.Query = "<Where><And><Eq><FieldRef Name=\"GateKeeper_Type\" /><Value Type=\"Choice\">" + type.ToString() + "</Value></Eq><IsNotNull><FieldRef Name=\"" + node.ToString() + "\" /></IsNotNull></And></Where>"; query.ViewFields = "<FieldRef Name=\"GateKeeper_Type\" /><FieldRef Name=\"GateKeeper_Date\" /><FieldRef Name=\"GateKeeper_Comment\" /><FieldRef Name=\"" + node + "\" />"; nodes = gatekeeper.GetItems(query); if (nodes.Count > 0) { foreach (SPListItem item in nodes) { items.Add(item); } } return(items); }
public bool HasListing(GateKeeperType type, GateKeeperListing node, string value) { bool listed = false; try { url = SPContext.Current.Web.Url; OpenElevatedWeb(); if (web != null) { SPListItemCollection nodes = null; string field = string.Empty; SPList gatekeeper = web.Lists["GateKeeper"]; SPQuery query = new SPQuery(); query.Query = "<Where><And><Eq><FieldRef Name=\"GateKeeper_Type\" /><Value Type=\"Choice\">" + type.ToString() + "</Value></Eq><Eq><FieldRef Name=\"" + node.ToString() + "\" /><Value Type=\"Text\">" + value + "</Value></Eq></And></Where>"; query.ViewFields = "<FieldRef Name=\"GateKeeper_Type\" />"; nodes = gatekeeper.GetItems(query); if (nodes.Count > 0) { listed = true; } } } catch (System.Exception ex) { ex.ToString(); } return(listed); }