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; }
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); }
/// <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; }
/// <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); }
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)); }
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); }
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)); }
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); }
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); } }
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); } }
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)); }
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; } }
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)); }
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); } }
/// <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); }
/// <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; }
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; }
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); }
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); } }
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); }
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; }
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; }
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); }
/// <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); }
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); }
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); }
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); }
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)); } }
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); }
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) { } } }
/// <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)); }
/// <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); }
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; }
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; } }
public Message GetById(int id) { SharePointListItem postItem = Provider.GetListItemByField(ForumConstants.Lists_Posts, "ID", id.ToString()); return(MessageMapper.CreateDomainObject(postItem)); }