public static Guid ParseLibraryId(PageContext pageContext) { Guid applicationId = Guid.Empty; var tokenValue = pageContext.GetTokenValue("libraryId"); if (tokenValue != null) { var applicationKey = tokenValue.ToString(); if (!string.IsNullOrEmpty(applicationKey)) { var groupId = int.Parse(pageContext.ContextItems.GetItemByContentType(Extensibility.Api.Version1.PublicApi.Groups.ContentTypeId).Id); var list = listDataService.Get(applicationKey, groupId); if (list != null && list.Id != Guid.Empty) { applicationId = list.Id; } else { Guid libraryId; if (Guid.TryParse(applicationKey, out libraryId) && listDataService.Get(libraryId) != null) { applicationId = libraryId; } } } } return(applicationId); }
public string EditLibrary(Guid libraryId) { var library = listDataService.Get(libraryId); if (library != null && library.GroupId > 0) { return(libraryUrls.EditLibrary(library)); } return(null); }
private void Initialize(SPList list) { Created = list.Created; Description = list.Description; GroupId = list.GroupId; Id = list.Id; IsEnabled = true; ItemCount = list.ItemCount; Modified = list.Modified; Name = list.Title; Root = list.RootFolder; SPViewUrl = list.SPViewUrl; SPWebUrl = list.SPWebUrl; var listBase = listDataService.Get(Id); Url = listBase != null?documentUrls.BrowseDocuments(listBase) : SPWebUrl; VersioningEnabled = list.EnableVersioning; ViewId = list.ViewId; foreach (var error in list.Errors) { Errors.Add(error); } foreach (var warning in list.Warnings) { Warnings.Add(warning); } }
private string GetUrl(Guid listId) { var list = listDataService.Get(listId); if (list != null) { return(list.SPWebUrl); } return(null); }
private string GetUrlByListId(Guid listId) { var list = listDataService.Get(listId); if (list != null) { list.Validate(); return(list.SPWebUrl); } return(null); }
public string Edit(Guid contentId, [Documentation(Name = "ApplicationId", Type = typeof(Guid)), Documentation(Name = "ItemId", Type = typeof(int))] IDictionary options = null) { var url = PublicApi.SharePointUrls.EditListItem(contentId); if (string.IsNullOrEmpty(url) && options != null) { var applicationId = (Guid)options["ApplicationId"]; var itemId = (int)options["ItemId"]; ListBase listBase; if (applicationId != Guid.Empty && (listBase = listDataService.Get(applicationId)) != null) { url = listItemUrls.EditListItem(listBase, new ItemUrlQuery(itemId, contentId)); } } return(url); }
public Microsoft.SharePoint.Client.Field Get(Guid listId, Guid fieldId) { var cacheId = string.Concat("SPFields:", listId.ToString("N"), fieldId.ToString("N")); var field = (Microsoft.SharePoint.Client.Field)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process); if (field == null) { var listBase = lists.Get(listId); if (listBase != null) { field = fields.Get(listBase.SPWebUrl, listBase.Id, fieldId); cacheService.Put(cacheId, field, CacheScope.Context | CacheScope.Process, new[] { string.Empty }, CacheTimeOut); } } return(field); }
public int[] GetViewSecurityRoles(Guid contentId) { var itemBase = listItemDataService.Get(contentId); if (itemBase != null) { var listBase = listDataService.Get(itemBase.ApplicationId); if (listBase != null) { var group = TEApi.Groups.Get(new GroupsGetOptions { Id = listBase.GroupId }); var roles = TEApi.Roles.List(group.ApplicationId, SharePointPermissionIds.ViewLibrary); return(roles.Any() ? roles.Select(r => r.Id.GetValueOrDefault()).ToArray() : new int[0]); } } return(new int[] { }); }
public void Update(ListUpdateQuery options) { if (options.Id == Guid.Empty) { return; } ListBase listBase = null; string spwebUrl = options.SPWebUrl; if (string.IsNullOrEmpty(spwebUrl)) { listBase = listDataService.Get(options.Id); if (listBase == null) { return; } Validate(listBase); spwebUrl = listBase.SPWebUrl; } try { var hasSharePointUpdates = options.Title != null || options.Description != null; if (hasSharePointUpdates) { using (var clientContext = new SPContext(spwebUrl, credentials.Get(spwebUrl))) { var splist = clientContext.Web.Lists.GetById(options.Id); if (!string.IsNullOrEmpty(options.Title)) { splist.Title = options.Title; } if (options.Description != null) { splist.Description = options.Description; } splist.Update(); clientContext.ExecuteQuery(); if (listBase != null) { listBase.ApplicationKey = splist.Title; } } } if (listBase != null) { listBase.ViewId = options.DefaultViewId ?? Guid.Empty; listDataService.AddUpdate(listBase); } } catch (Exception ex) { string message = string.Format("An exception of type {0} occurred in the InternalApi.SPListService.Update() method. The exception message is: {1}", ex.GetType(), ex.Message); SPLog.RoleOperationUnavailable(ex, message); throw new SPInternalException(message, ex); } }