コード例 #1
0
        public IDirectoryCollection GetChildren(bool includeDeleted, bool applySecurityTrimming = true)
        {
            string viewFields = string.Concat(
                "<FieldRef Name='" + Constants.List_ID_Field + "' />",
                "<FieldRef Name='" + Constants.GAD_ID_Field + "' />",
                "<FieldRef Name='" + Constants.Notification_InheritParentNotification_Field + "' />",
                "<FieldRef Name='" + Constants.Field_InheritParentFields_Field + "' />",
                "<FieldRef Name='" + Constants.Notification_IsNotificationActive_Field + "' />",
                "<FieldRef Name='" + Constants.Parent_Brand_Name_Field + "' />",
                "<FieldRef Name='" + Constants.IsDeleted_Field + "' />"
                );

            string query = string.Empty;

            if (!includeDeleted)
            {
                query = "<Where><Eq><FieldRef Name='" + Constants.IsDeleted_Field + "' /><Value Type='Boolean'>0</Value></Eq></Where>";
            }

            SPListItemCollection spItems = GetItemByQuery(Constants.Parent_Brand_Url, viewFields, query);

            IDirectoryCollection parentBrands = new IDirectoryCollection();

            foreach (SPListItem item in spItems)
            {
                int    id    = Convert.ToInt32(item[Constants.List_ID_Field]);
                int    gadID = Convert.ToInt32(item[Constants.GAD_ID_Field]);
                string name  = Convert.ToString(item[Constants.Parent_Brand_Name_Field]);
                bool   inheritParentField   = Convert.ToBoolean(item[Constants.Field_InheritParentFields_Field] ?? "false");
                bool   inheritParentNoti    = Convert.ToBoolean(item[Constants.Notification_InheritParentNotification_Field] ?? "false");
                bool   isaAtiveNotification = Convert.ToBoolean(item[Constants.Notification_IsNotificationActive_Field] ?? "false");
                bool   isDeleted            = Convert.ToBoolean(item[Constants.IsDeleted_Field] ?? "false");
                parentBrands.Add(new ParentBrand(id, name, gadID, this)
                {
                    InheritParentFields = inheritParentField, InheritParentNotification = inheritParentNoti, IsNotificationActive = isaAtiveNotification, IsDeleted = isDeleted
                });
            }

            if (applySecurityTrimming)
            {
                IDirectoryCollection parentBrandsSecured = new IDirectoryCollection();
                parentBrandsSecured.AddRange(parentBrands.FindAll(pb => pb.DoesUserHasPermission));
                return(parentBrandsSecured);
            }
            else
            {
                return(parentBrands);
            }
        }
コード例 #2
0
        public IDirectoryCollection GetChildren(bool includeDeleted, bool applySecurityTrimming = true)
        {
            string viewFields = string.Concat(
                                   "<FieldRef Name='" + Constants.List_ID_Field + "' />",
                                   "<FieldRef Name='" + Constants.GAD_ID_Field + "' />",
                                   "<FieldRef Name='" + Constants.Notification_InheritParentNotification_Field + "' />",
                                   "<FieldRef Name='" + Constants.Field_InheritParentFields_Field + "' />",
                                   "<FieldRef Name='" + Constants.Notification_IsNotificationActive_Field + "' />",
                                   "<FieldRef Name='" + Constants.Parent_Brand_Name_Field + "' />",
                                   "<FieldRef Name='" + Constants.IsDeleted_Field + "' />"
                                   );

            string query=string.Empty;

            if (!includeDeleted)
                query = "<Where><Eq><FieldRef Name='" + Constants.IsDeleted_Field + "' /><Value Type='Boolean'>0</Value></Eq></Where>";

            SPListItemCollection spItems = GetItemByQuery(Constants.Parent_Brand_Url, viewFields, query);

            IDirectoryCollection parentBrands = new IDirectoryCollection();

            foreach (SPListItem item in spItems)
            {
                int id = Convert.ToInt32(item[Constants.List_ID_Field]);
                int gadID = Convert.ToInt32(item[Constants.GAD_ID_Field]);
                string name = Convert.ToString(item[Constants.Parent_Brand_Name_Field]);
                bool inheritParentField = Convert.ToBoolean(item[Constants.Field_InheritParentFields_Field] ?? "false");
                bool inheritParentNoti = Convert.ToBoolean(item[Constants.Notification_InheritParentNotification_Field] ?? "false");
                bool isaAtiveNotification = Convert.ToBoolean(item[Constants.Notification_IsNotificationActive_Field] ?? "false");
                bool isDeleted = Convert.ToBoolean(item[Constants.IsDeleted_Field] ?? "false");
                parentBrands.Add(new ParentBrand(id, name, gadID,this) { InheritParentFields = inheritParentField, InheritParentNotification = inheritParentNoti, IsNotificationActive = isaAtiveNotification,IsDeleted=isDeleted });
            }

            if (applySecurityTrimming)
            {
                IDirectoryCollection parentBrandsSecured = new IDirectoryCollection();
                parentBrandsSecured.AddRange(parentBrands.FindAll(pb => pb.DoesUserHasPermission));
                return parentBrandsSecured;
            }
            else
            {
                return parentBrands;
            }
        }