예제 #1
0
        public int SavePermissions(int groupId, int forumId, Permission permission)
        {
            string[] fieldNames = { "GroupID", "ForumID" };
            string[] fieldValues = { groupId.ToString(), forumId.ToString() };
            SharePointListItem listItem = Provider.GetListItemByField(ForumConstants.Lists_ForumAccess, fieldNames, fieldValues);

            int rc = 0;
            if (listItem == null)
            {
                string[] values = {
									  "Title", permission.ToString(),
									  "GroupID", groupId.ToString(),
									  "ForumID", forumId.ToString(),
				};

                listItem = new SharePointListItem(0, values);
                rc = Provider.AddListItem(ForumConstants.Lists_ForumAccess, listItem);
            }
            else
            {
                listItem["Title"] = permission.ToString();
                rc = Provider.UpdateListItem(ForumConstants.Lists_ForumAccess, listItem);
            }

            return rc;
        }
예제 #2
0
        public int SavePermissions(int groupId, int forumId, Permission permission)
        {
            string[]           fieldNames  = { "GroupID", "ForumID" };
            string[]           fieldValues = { groupId.ToString(), forumId.ToString() };
            SharePointListItem listItem    = Provider.GetListItemByField(ForumConstants.Lists_ForumAccess, fieldNames, fieldValues);

            int rc = 0;

            if (listItem == null)
            {
                string[] values =
                {
                    "Title",   permission.ToString(),
                    "GroupID", groupId.ToString(),
                    "ForumID", forumId.ToString(),
                };

                listItem = new SharePointListItem(0, values);
                rc       = Provider.AddListItem(ForumConstants.Lists_ForumAccess, listItem);
            }
            else
            {
                listItem["Title"] = permission.ToString();
                rc = Provider.UpdateListItem(ForumConstants.Lists_ForumAccess, listItem);
            }

            return(rc);
        }
예제 #3
0
        /// <summary>
        /// Creates the domain object.
        /// </summary>
        /// <param name="listItem">The list item.</param>
        /// <returns></returns>
        public static Category CreateDomainObject(SharePointListItem listItem)
        {
            Category category = new Category(listItem.Id, listItem["Title"]);

            category.SortOrder = Convert.ToInt32(listItem["SortOrder"]);

            return category;
        }
예제 #4
0
        /// <summary>
        /// Creates the domain object.
        /// </summary>
        /// <param name="listItem">The list item.</param>
        /// <returns></returns>
        public static Category CreateDomainObject(SharePointListItem listItem)
        {
            Category category = new Category(listItem.Id, listItem["Title"]);

            category.SortOrder = Convert.ToInt32(listItem["SortOrder"]);

            return(category);
        }
예제 #5
0
        public ForumUser GetLast()
        {
            SharePointListProvider   provider   = new SharePointListProvider(ForumApplication.Instance.SpWeb);
            SharePointListDescriptor descriptor = provider.GetAllListItems(ForumConstants.Lists_Users);
            SharePointListItem       item       = descriptor.SharePointListItems[descriptor.SharePointListItems.Length - 1];

            return(UserMapper.CreateDomainObject(item));
        }
예제 #6
0
        public Group FindById(int id)
        {
            SharePointListProvider provider = new SharePointListProvider(ForumApplication.Instance.SpWeb);
            SharePointListItem     listItem = provider.GetListItembyID(ForumConstants.Lists_Groups, id);
            Group group = new Group();

            group.Id   = listItem.Id;
            group.Name = listItem["Title"];
            return(group);
        }
예제 #7
0
        public Forum GetById(int id)
        {
            SharePointListItem currentItem = Provider.GetListItemByField(ForumConstants.Lists_Forums, "ID", id.ToString());

            if (currentItem == null)
            {
                return(new Forum(id, 1, "Default Forum"));
            }

            return(ForumMapper.CreateDomainObject(currentItem));
        }
예제 #8
0
        public int Save(Group group)
        {
            SharePointListProvider provider = new SharePointListProvider(ForumApplication.Instance.SpWeb);
            string[] values = {
				"Title", group.Name,
			};
            SharePointListItem listItem = new SharePointListItem(group.Id, values);
            if (group.Id == 0)
                return provider.AddListItem(ForumConstants.Lists_Groups, listItem);
            else
                return provider.UpdateListItem(ForumConstants.Lists_Groups, listItem);
        }
예제 #9
0
 public int UpdateListItem(string listName, SharePointListItem updateItem)
 {
     using (Identity.ImpersonateAppPool())
     {
         SPList list = this.GetList(listName);
         list.ParentWeb.AllowUnsafeUpdates = true;
         SPListItem itemById = list.Items.GetItemById(updateItem.Id);
         this.UpdateSPListItem(itemById, updateItem);
         itemById.Update();
         return(itemById.ID);
     }
 }
예제 #10
0
 public int AddListItem(string listName, SharePointListItem newItem)
 {
     using (Identity.ImpersonateAppPool())
     {
         SPList list = this.GetList(listName);
         list.ParentWeb.AllowUnsafeUpdates = true;
         SPListItem spListItem = list.Items.Add();
         this.UpdateSPListItem(spListItem, newItem);
         spListItem.Update();
         return(spListItem.ID);
     }
 }
예제 #11
0
        public Topic GetById(int id)
        {
            SharePointListItem currentItem = Provider.GetListItemByField(ForumConstants.Lists_Topics, "ID", id.ToString());

            // FIXME bit of a hack
            if (currentItem == null)
            {
                return(new Topic(id, 1, "Unknown Topic"));
            }

            return(TopicMapper.CreateDomainObject(currentItem));
        }
예제 #12
0
 public int AddListItem(string listName, SharePointListItem newItem)
 {
     using (Identity.ImpersonateAppPool())
     {
         SPList list = this.GetList(listName);
         list.ParentWeb.AllowUnsafeUpdates = true;
         SPListItem spListItem = list.Items.Add();
         this.UpdateSPListItem(spListItem, newItem);
         spListItem.Update();
         return spListItem.ID;
     }
 }
예제 #13
0
        public ForumUser GetBySharePointId(int id)
        {
            SharePointListProvider provider = new SharePointListProvider(ForumApplication.Instance.SpWeb);
            SharePointListItem     listItem = provider.GetListItemByField(ForumConstants.Lists_Users, "UserID", id.ToString());

            if (null == listItem)
            {
                CreateUserFromSharePointId(id);
                listItem = provider.GetListItemByField(ForumConstants.Lists_Users, "UserID", id.ToString());
            }

            return(UserMapper.CreateDomainObject(listItem));
        }
예제 #14
0
 private static void LoadGroupsForUser(SharePointListItem listItem, ForumUser user)
 {
     string groupIds = listItem["Groups"];
     string delim = ";";
     char[] delimArray = delim.ToCharArray();
     string[] groupArray = groupIds.Split(delimArray);
     foreach (string s in groupArray)
     {
         int groupId = Convert.ToInt32(s);
         Group group = RepositoryRegistry.GroupRepository.FindById(groupId);
         user.Groups.Add(group);
     }
 }
예제 #15
0
        /// <summary>
        /// Loads the specified list item.
        /// </summary>
        /// <param name="listItem">The list item.</param>
        /// <returns></returns>
        public static Forum CreateDomainObject(SharePointListItem listItem)
        {
            int   categoryId = Convert.ToInt32(listItem["CategoryID"]);
            Forum forum      = new Forum(listItem.Id, categoryId, listItem["Title"]);

            forum.Description = listItem["Description"];

            // TODO I think this is wrong. The last post should be set when
            // a topic is added, not modified
            forum.LastPost = Convert.ToDateTime(listItem["Modified"]);

            return(forum);
        }
예제 #16
0
        /// <summary>
        /// Loads the specified list item.
        /// </summary>
        /// <param name="listItem">The list item.</param>
        /// <returns></returns>
        public static Forum CreateDomainObject(SharePointListItem listItem)
        {
            int categoryId = Convert.ToInt32(listItem["CategoryID"]);
            Forum forum = new Forum(listItem.Id, categoryId, listItem["Title"]);

            forum.Description = listItem["Description"];

            // TODO I think this is wrong. The last post should be set when
            // a topic is added, not modified
            forum.LastPost = Convert.ToDateTime(listItem["Modified"]);

            return forum;
        }
예제 #17
0
        public static Message CreateDomainObject(SharePointListItem listItem)
        {
            Message message = new Message(Convert.ToInt32(listItem["TopicID"]));

            message.Name = listItem["Title"];
            message.UserId = Convert.ToInt32(listItem["UserID"]);
            message.Author = RepositoryRegistry.ForumUserRepository.GetBySharePointId(message.UserId);
            message.Created = Convert.ToDateTime(listItem["Created"]);
            message.Body = listItem["Body"];
            message.Id = listItem.Id;

            return message;
        }
예제 #18
0
        public static Message CreateDomainObject(SharePointListItem listItem)
        {
            Message message = new Message(Convert.ToInt32(listItem["TopicID"]));

            message.Name    = listItem["Title"];
            message.UserId  = Convert.ToInt32(listItem["UserID"]);
            message.Author  = RepositoryRegistry.ForumUserRepository.GetBySharePointId(message.UserId);
            message.Created = Convert.ToDateTime(listItem["Created"]);
            message.Body    = listItem["Body"];
            message.Id      = listItem.Id;

            return(message);
        }
예제 #19
0
        private static void LoadGroupsForUser(SharePointListItem listItem, ForumUser user)
        {
            string groupIds = listItem["Groups"];
            string delim    = ";";

            char[]   delimArray = delim.ToCharArray();
            string[] groupArray = groupIds.Split(delimArray);
            foreach (string s in groupArray)
            {
                int   groupId = Convert.ToInt32(s);
                Group group   = RepositoryRegistry.GroupRepository.FindById(groupId);
                user.Groups.Add(group);
            }
        }
예제 #20
0
        public void Save(Message message)
        {
            SharePointListItem listItem = MessageMapper.CreateDto(message);

            if (message.Id == 0)
            {
                Provider.AddListItem(ForumConstants.Lists_Posts, listItem);
                //				TopicRepository.IncreasePostCount(message.TopicId);
            }
            else
            {
                Provider.UpdateListItem(ForumConstants.Lists_Posts, listItem);
            }
        }
예제 #21
0
        public static Topic CreateDomainObject(SharePointListItem item)
        {
            Topic topic = new Topic(item.Id, Convert.ToInt32(item["ForumID"]), item["Title"]);

            topic.Views          = Convert.ToInt32(item["Views"]);
            topic.TopicStarterId = Convert.ToInt32(item["TopicStarterID"]);
            topic.Author         = RepositoryRegistry.ForumUserRepository.GetBySharePointId(topic.TopicStarterId);

            // Built in values from SharePoint list
            // TODO might be the wrong value
            topic.LastPost = Convert.ToDateTime(item["Modified"]);

            return(topic);
        }
예제 #22
0
        public static Topic CreateDomainObject(SharePointListItem item)
        {
            Topic topic = new Topic(item.Id, Convert.ToInt32(item["ForumID"]), item["Title"]);

            topic.Views = Convert.ToInt32(item["Views"]);
            topic.TopicStarterId = Convert.ToInt32(item["TopicStarterID"]);
            topic.Author = RepositoryRegistry.ForumUserRepository.GetBySharePointId(topic.TopicStarterId);

            // Built in values from SharePoint list
            // TODO might be the wrong value
            topic.LastPost = Convert.ToDateTime(item["Modified"]);

            return topic;
        }
예제 #23
0
        public static ForumUser CreateDomainObject(SharePointListItem listItem)
        {
            ForumUser user = new ForumUser();

            user.Id = Convert.ToInt32(listItem.Id);
            user.LastVisit = Convert.ToDateTime(listItem["LastVisit"]);
            user.UserId = Convert.ToInt32(listItem["UserID"]);
            user.NumPosts = Convert.ToInt32(listItem["NumPosts"]);
            user.Joined = Convert.ToDateTime(listItem["Created"]);
            user.IsAdmin = Convert.ToBoolean(listItem["IsAdmin"]);

            LoadGroupsForUser(listItem, user);
            LoadSharePointInfoForUser(user);

            return user;
        }
예제 #24
0
        public static ForumUser CreateDomainObject(SharePointListItem listItem)
        {
            ForumUser user = new ForumUser();

            user.Id        = Convert.ToInt32(listItem.Id);
            user.LastVisit = Convert.ToDateTime(listItem["LastVisit"]);
            user.UserId    = Convert.ToInt32(listItem["UserID"]);
            user.NumPosts  = Convert.ToInt32(listItem["NumPosts"]);
            user.Joined    = Convert.ToDateTime(listItem["Created"]);
            user.IsAdmin   = Convert.ToBoolean(listItem["IsAdmin"]);

            LoadGroupsForUser(listItem, user);
            LoadSharePointInfoForUser(user);

            return(user);
        }
예제 #25
0
        /// <summary>
        /// Saves the specified category.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        public int Save(Category category)
        {
            SharePointListItem listItem = CategoryMapper.CreateDto(category);
            int categoryId;

            if (listItem.Id == 0)
            {
                categoryId = Provider.AddListItem(ForumConstants.Lists_Category, listItem);
            }
            else
            {
                categoryId = Provider.UpdateListItem(ForumConstants.Lists_Category, listItem);
            }

            return(categoryId);
        }
예제 #26
0
        public int Save(Forum forum)
        {
            SharePointListItem listItem = ForumMapper.CreateDto(forum);
            int newId = 0;

            if (forum.Id == 0)
            {
                newId = Provider.AddListItem(ForumConstants.Lists_Forums, listItem);
                SetupDefaultPermissions(newId);
            }
            else
            {
                newId = Provider.UpdateListItem(ForumConstants.Lists_Forums, listItem);
            }

            return(newId);
        }
예제 #27
0
        public int Save(Topic topic)
        {
            SharePointListItem listItem = TopicMapper.CreateDto(topic);
            int newTopicId = 0;

            if (topic.Id == 0)
            {
                newTopicId = Provider.AddListItem(ForumConstants.Lists_Topics, listItem);
                RepositoryRegistry.ForumRepository.IncreaseCount(topic.ForumId);
            }
            else
            {
                newTopicId = Provider.UpdateListItem(ForumConstants.Lists_Topics, listItem);
            }

            return(newTopicId);
        }
예제 #28
0
        public int Save(ForumUser user)
        {
            int userId;

            SharePointListProvider provider = new SharePointListProvider(ForumApplication.Instance.SpWeb);
            SharePointListItem     listItem = UserMapper.CreateDto(user);

            if (user.Id == 0)
            {
                userId = provider.AddListItem(ForumConstants.Lists_Users, listItem);
            }
            else
            {
                userId = provider.UpdateListItem(ForumConstants.Lists_Users, listItem);
            }

            return(userId);
        }
예제 #29
0
        public int Save(Group group)
        {
            SharePointListProvider provider = new SharePointListProvider(ForumApplication.Instance.SpWeb);

            string[] values =
            {
                "Title", group.Name,
            };
            SharePointListItem listItem = new SharePointListItem(group.Id, values);

            if (group.Id == 0)
            {
                return(provider.AddListItem(ForumConstants.Lists_Groups, listItem));
            }
            else
            {
                return(provider.UpdateListItem(ForumConstants.Lists_Groups, listItem));
            }
        }
예제 #30
0
        private SharePointListItem SPListItemtoDescriptor(SPListItem spListItem)
        {
            SharePointListItem item = new SharePointListItem();

            for (int i = 0; i < spListItem.Fields.Count; i++)
            {
                if (!spListItem.Fields[i].Hidden)
                {
                    try
                    {
                        item.Id = spListItem.ID;
                        string internalName = spListItem.Fields[i].InternalName;
                        string fieldValue   = (spListItem[internalName] != null) ? spListItem[spListItem.Fields[i].InternalName].ToString() : "";
                        item.Add(internalName, fieldValue, spListItem.Fields[i].ReadOnlyField);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            return(item);
        }
예제 #31
0
 private void UpdateSPListItem(SPListItem spListItem, SharePointListItem sharePointListItem)
 {
     foreach (SharePointListField field in sharePointListItem.SharePointListFields)
     {
         try
         {
             SPField field2 = spListItem.Fields.GetField(field.Name);
             if (!field2.ReadOnlyField)
             {
                 if (field2.Type == SPFieldType.DateTime)
                 {
                     spListItem[field.Name] = DateTime.Parse(field.Value);
                 }
                 else
                 {
                     spListItem[field.Name] = field.Value;
                 }
             }
         }
         catch (Exception)
         {
         }
     }
 }
예제 #32
0
        /// <summary>
        /// Gets a category by its identity.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public Category GetById(int id)
        {
            SharePointListItem currentItem = Provider.GetListItembyID(ForumConstants.Lists_Category, id);

            return(CategoryMapper.CreateDomainObject(currentItem));
        }
예제 #33
0
 /// <summary>
 /// Adds the list values.
 /// </summary>
 /// <param name="values">The values.</param>
 protected void AddListValues(string[] values)
 {
     SharePointListItem listItem = new SharePointListItem(0, values);
     SharePointListProvider provider = new SharePointListProvider(ForumApplication.Instance.SpWeb);
     provider.AddListItem(listName, listItem);
 }
예제 #34
0
 private SharePointListItem SPListItemtoDescriptor(SPListItem spListItem)
 {
     SharePointListItem item = new SharePointListItem();
     for (int i = 0; i < spListItem.Fields.Count; i++)
     {
         if (!spListItem.Fields[i].Hidden)
         {
             try
             {
                 item.Id = spListItem.ID;
                 string internalName = spListItem.Fields[i].InternalName;
                 string fieldValue = (spListItem[internalName] != null) ? spListItem[spListItem.Fields[i].InternalName].ToString() : "";
                 item.Add(internalName, fieldValue, spListItem.Fields[i].ReadOnlyField);
             }
             catch (Exception)
             {
             }
         }
     }
     return item;
 }
예제 #35
0
 public int UpdateListItem(string listName, SharePointListItem updateItem)
 {
     using (Identity.ImpersonateAppPool())
     {
         SPList list = this.GetList(listName);
         list.ParentWeb.AllowUnsafeUpdates = true;
         SPListItem itemById = list.Items.GetItemById(updateItem.Id);
         this.UpdateSPListItem(itemById, updateItem);
         itemById.Update();
         return itemById.ID;
     }
 }
예제 #36
0
 private void UpdateSPListItem(SPListItem spListItem, SharePointListItem sharePointListItem)
 {
     foreach (SharePointListField field in sharePointListItem.SharePointListFields)
     {
         try
         {
             SPField field2 = spListItem.Fields.GetField(field.Name);
             if (!field2.ReadOnlyField)
             {
                 if (field2.Type == SPFieldType.DateTime)
                 {
                     spListItem[field.Name] = DateTime.Parse(field.Value);
                 }
                 else
                 {
                     spListItem[field.Name] = field.Value;
                 }
             }
         }
         catch (Exception)
         {
         }
     }
 }
예제 #37
0
        public Message GetById(int id)
        {
            SharePointListItem postItem = Provider.GetListItemByField(ForumConstants.Lists_Posts, "ID", id.ToString());

            return(MessageMapper.CreateDomainObject(postItem));
        }