Example #1
0
 public ITableView GetView(QueryFilter query, SortBy[] sortBy, DocumentLibraryQueryOptions queryOptions, params PropertyDefinition[] propsToReturn)
 {
     return(SharepointDocumentLibraryFolder.InternalGetView(query, sortBy, queryOptions, propsToReturn, this.Session, (SharepointListId)base.Id));
 }
Example #2
0
        private static ClassifyResult ClassifySharepointLink(Uri uri, WindowsIdentity authenticatedUser)
        {
            WindowsImpersonationContext windowsImpersonationContext = null;
            ClassifyResult classifyResult = null;
            ClassifyResult result;

            try
            {
                windowsImpersonationContext = Utils.ImpersonateUser(authenticatedUser);
                Uri siteAddress = LinkClassifier.GetSiteAddress(uri, out classifyResult);
                if (classifyResult != null)
                {
                    result = classifyResult;
                }
                else
                {
                    SharepointSession session       = SharepointSession.Open(new SharepointSiteId(siteAddress, UriFlags.Sharepoint), new WindowsPrincipal(authenticatedUser));
                    SharepointList    listSpecifics = LinkClassifier.GetListSpecifics(uri, session, out classifyResult);
                    if (classifyResult != null)
                    {
                        result = classifyResult;
                    }
                    else
                    {
                        IList <string> itemHierarchy = LinkClassifier.GetItemHierarchy(uri, listSpecifics);
                        if (itemHierarchy.Count < 2)
                        {
                            Uri  uri2 = listSpecifics.Uri;
                            bool flag = false;
                            if (itemHierarchy.Count == 0 || string.Compare(itemHierarchy[0].TrimEnd(new char[]
                            {
                                '/',
                                '\\'
                            }), Uri.UnescapeDataString(uri2.Segments[siteAddress.Segments.Length].TrimEnd(new char[]
                            {
                                '/',
                                '\\'
                            })), StringComparison.OrdinalIgnoreCase) != 0)
                            {
                                flag = true;
                            }
                            if (!flag)
                            {
                                result = new ClassifyResult(listSpecifics.Id, uri, UriFlags.SharepointDocumentLibrary);
                            }
                            else
                            {
                                result = new ClassifyResult(uri, ClassificationError.ObjectNotFound);
                            }
                        }
                        else
                        {
                            string propertyValue = itemHierarchy[itemHierarchy.Count - 1];
                            itemHierarchy.RemoveAt(itemHierarchy.Count - 1);
                            SharepointListId sharepointListId      = (SharepointListId)listSpecifics.Id;
                            SharepointDocumentLibraryItemId listId = new SharepointDocumentLibraryItemId("-1", sharepointListId.ListName, sharepointListId.SiteUri, listSpecifics.GetRegionalSettings(), UriFlags.SharepointFolder, itemHierarchy);
                            ComparisonFilter     query             = new ComparisonFilter(ComparisonOperator.Equal, SharepointDocumentLibraryItemSchema.Name, propertyValue);
                            PropertyDefinition[] propsToReturn     = new PropertyDefinition[]
                            {
                                SharepointDocumentLibraryItemSchema.ID,
                                SharepointDocumentLibraryItemSchema.FileSystemObjectType
                            };
                            object[][] rows = SharepointDocumentLibraryFolder.InternalGetView(query, null, DocumentLibraryQueryOptions.FoldersAndFiles, propsToReturn, session, listId).GetRows(2);
                            if (rows.Length == 1)
                            {
                                result = new ClassifyResult((DocumentLibraryObjectId)rows[0][0], uri, ((DocumentLibraryObjectId)rows[0][0]).UriFlags);
                            }
                            else
                            {
                                result = new ClassifyResult(uri, ClassificationError.ObjectNotFound);
                            }
                        }
                    }
                }
            }
            catch (SoapException)
            {
                result = new ClassifyResult(uri, ClassificationError.ConnectionFailed);
            }
            catch (ObjectNotFoundException)
            {
                result = new ClassifyResult(uri, ClassificationError.ObjectNotFound);
            }
            catch (AccessDeniedException)
            {
                result = new ClassifyResult(uri, ClassificationError.AccessDenied);
            }
            catch (WebException ex)
            {
                result = LinkClassifier.GetClassificationResultFromWebException(uri, ex);
            }
            catch
            {
                Utils.UndoContext(ref windowsImpersonationContext);
                throw;
            }
            finally
            {
                Utils.UndoContext(ref windowsImpersonationContext);
            }
            return(result);
        }