Beispiel #1
0
        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);
        }
Beispiel #2
0
        internal static List <SPListItem> GetGateKeeperItems(GateKeeperType type, GateKeeperListing node, string value)
        {
            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><Eq><FieldRef Name=\"" + node.ToString() + "\" /><Value Type=\"Text\">" + value + "</Value></Eq></And></Where>";
             * query.ViewFields = "<FieldRef Name=\"GateKeeper_Type\" /><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);
        }
        public void GateKeeper(GateKeeperType type, GateKeeperListing node, string value)
        {
            try
            {
                url = SPContext.Current.Web.Url;
                OpenElevatedWeb();

                if (web != null)
                {
                    web.AllowUnsafeUpdates = true;
                    SPList     gatekeeper = web.Lists["GateKeeper"];
                    SPListItem http       = gatekeeper.Items.Add();
                    http["GateKeeper_Date"] = DateTime.Now;
                    if (node == GateKeeperListing.GateKeeper_IPAddress)
                    {
                        http["GateKeeper_IPAddress"] = value;
                    }
                    if (node == GateKeeperListing.GateKeeper_Url)
                    {
                        http["GateKeeper_Url"] = value;
                    }
                    if (node == GateKeeperListing.GateKeeper_Useragent)
                    {
                        http["GateKeeper_Useragent"] = value;
                    }

                    http["GateKeeper_Type"] = type;
                    SPContentType itemtype = web.AvailableContentTypes[ContentTypeId.GateKeeper_Entry];
                    http[SPBuiltInFieldId.ContentTypeId] = itemtype.Id;
                    http[SPBuiltInFieldId.ContentType]   = itemtype.Name;

                    http.Update();
                    web.AllowUnsafeUpdates = false;
                }
            }
            catch (System.Exception ex)
            {
                ex.ToString();
            }
        }