public virtual object TryGetProperty(DocumentLibraryPropertyDefinition propertyDefinition)
 {
     if (this.schema.AllProperties.ContainsKey(propertyDefinition))
     {
         return(UncDocumentLibraryItem.GetValueFromFileSystemInfo(propertyDefinition, this.fileSystemInfo));
     }
     return(new PropertyError(propertyDefinition, PropertyErrorCode.NotFound));
 }
        internal static ITableView InternalGetView(QueryFilter query, SortBy[] sortBy, DocumentLibraryQueryOptions queryOptions, PropertyDefinition[] propsToReturn, UncSession session, DirectoryInfo directoryInfo, UncObjectId id)
        {
            if (propsToReturn == null)
            {
                throw new ArgumentNullException("propsToReturn");
            }
            if (propsToReturn.Length == 0)
            {
                throw new ArgumentException("propsToReturn");
            }
            DocumentLibraryPropertyDefinition[] propertyDefinitions = new DocumentLibraryPropertyDefinition[propsToReturn.Length];
            for (int i = 0; i < propsToReturn.Length; i++)
            {
                propertyDefinitions[i] = (propsToReturn[i] as DocumentLibraryPropertyDefinition);
                if (propertyDefinitions[i] == null)
                {
                    throw new ArgumentException("propsToReturn");
                }
            }
            return(Utils.DoUncTask <ArrayTableView>(session.Identity, id, true, Utils.MethodType.GetView, delegate
            {
                FileSystemInfo[] array;
                switch (queryOptions)
                {
                case DocumentLibraryQueryOptions.Folders:
                    array = directoryInfo.GetDirectories();
                    break;

                case DocumentLibraryQueryOptions.Files:
                    array = directoryInfo.GetFiles();
                    break;

                case DocumentLibraryQueryOptions.FoldersAndFiles:
                    array = directoryInfo.GetFileSystemInfos();
                    break;

                default:
                    throw new ArgumentOutOfRangeException("queryOptions");
                }
                List <object[]> list = new List <object[]>();
                int num = 0;
                int num2 = Utils.GetViewMaxRows;
                while (num < array.Length && num2 > 0)
                {
                    object[] array2 = new object[propertyDefinitions.Length];
                    for (int j = 0; j < propertyDefinitions.Length; j++)
                    {
                        array2[j] = UncDocumentLibraryItem.GetValueFromFileSystemInfo(propertyDefinitions[j], array[num]);
                    }
                    list.Add(array2);
                    num2--;
                    num++;
                }
                return new ArrayTableView(query, sortBy, propertyDefinitions, list);
            }));
        }
예제 #3
0
        public UncDocumentLibraryItem Read(ObjectId objectId, params PropertyDefinition[] propsToReturn)
        {
            if (objectId == null)
            {
                throw new ArgumentNullException("objectId");
            }
            UncObjectId uncObjectId = objectId as UncObjectId;

            if (uncObjectId == null)
            {
                throw new ArgumentException("objectId");
            }
            if (uncObjectId.Path.Segments.Length <= 2)
            {
                throw new ArgumentException("objectId");
            }
            if (!this.id.Path.IsBaseOf(uncObjectId.Path))
            {
                throw new ArgumentException("objectId");
            }
            return(UncDocumentLibraryItem.Read(this.session, uncObjectId));
        }
예제 #4
0
        private object TryGetProperty(PropertyDefinition propertyDefinition)
        {
            DocumentLibraryPropertyId         documentLibraryPropertyId         = DocumentLibraryPropertyId.None;
            DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propertyDefinition as DocumentLibraryPropertyDefinition;

            if (documentLibraryPropertyDefinition != null)
            {
                documentLibraryPropertyId = documentLibraryPropertyDefinition.PropertyId;
            }
            DocumentLibraryPropertyId documentLibraryPropertyId2 = documentLibraryPropertyId;

            switch (documentLibraryPropertyId2)
            {
            case DocumentLibraryPropertyId.None:
                return(new PropertyError(propertyDefinition, PropertyErrorCode.NotFound));

            case DocumentLibraryPropertyId.Uri:
                return(this.id.Path);

            default:
                switch (documentLibraryPropertyId2)
                {
                case DocumentLibraryPropertyId.Id:
                    return(this.id);

                case DocumentLibraryPropertyId.Title:
                    return(this.shareName);

                default:
                    if (documentLibraryPropertyId2 != DocumentLibraryPropertyId.Description)
                    {
                        return(UncDocumentLibraryItem.GetValueFromFileSystemInfo(documentLibraryPropertyDefinition, this.directoryInfo));
                    }
                    return(this.description);
                }
                break;
            }
        }
예제 #5
0
        public ITableView GetView(QueryFilter filter, SortBy[] sortBy, params PropertyDefinition[] propsToReturn)
        {
            WindowsImpersonationContext windowsImpersonationContext = Utils.ImpersonateUser(this.identity);
            ITableView result;

            try
            {
                IntPtr zero = IntPtr.Zero;
                try
                {
                    int num = 0;
                    int num3;
                    int num4;
                    int num2 = UncSession.NetShareEnum(this.id.Path.Host, 1, out zero, -1, out num3, out num4, ref num);
                    if (num2 == 5)
                    {
                        throw new AccessDeniedException(this.Id, Strings.ExAccessDenied(this.id.Path.LocalPath));
                    }
                    if (num2 == 2250 || num2 == 53)
                    {
                        throw new ObjectMovedOrDeletedException(this.Id, Strings.ExObjectMovedOrDeleted(this.id.Path.LocalPath));
                    }
                    List <object[]> list = new List <object[]>();
                    if (num2 == 0 && num3 > 0)
                    {
                        int    num5 = Marshal.SizeOf(typeof(UncSession.SHARE_INFO_1));
                        IntPtr ptr  = zero;
                        int    num6 = 0;
                        int    num7 = Utils.GetViewMaxRows;
                        while (num6 < num3 && num7 > 0)
                        {
                            UncSession.SHARE_INFO_1 share_INFO_ = (UncSession.SHARE_INFO_1)Marshal.PtrToStructure(ptr, typeof(UncSession.SHARE_INFO_1));
                            if (share_INFO_.ShareType == UncSession.ShareType.Disk)
                            {
                                UncObjectId   uncObjectId   = new UncObjectId(new Uri(Path.Combine("\\\\" + this.id.Path.Host, share_INFO_.NetName)), UriFlags.UncDocumentLibrary);
                                object[]      array         = new object[propsToReturn.Length];
                                DirectoryInfo directoryInfo = null;
                                bool          flag          = true;
                                int           i             = 0;
                                while (i < propsToReturn.Length)
                                {
                                    DocumentLibraryPropertyId         documentLibraryPropertyId         = DocumentLibraryPropertyId.None;
                                    DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propsToReturn[i] as DocumentLibraryPropertyDefinition;
                                    if (documentLibraryPropertyDefinition != null)
                                    {
                                        documentLibraryPropertyId = documentLibraryPropertyDefinition.PropertyId;
                                    }
                                    DocumentLibraryPropertyId documentLibraryPropertyId2 = documentLibraryPropertyId;
                                    switch (documentLibraryPropertyId2)
                                    {
                                    case DocumentLibraryPropertyId.None:
                                        array[i] = new PropertyError(propsToReturn[i], PropertyErrorCode.NotFound);
                                        break;

                                    case DocumentLibraryPropertyId.Uri:
                                        array[i] = uncObjectId.Path;
                                        break;

                                    case DocumentLibraryPropertyId.ContentLength:
                                    case DocumentLibraryPropertyId.CreationTime:
                                    case DocumentLibraryPropertyId.LastModifiedTime:
                                    case DocumentLibraryPropertyId.IsFolder:
                                        goto IL_1F2;

                                    case DocumentLibraryPropertyId.IsHidden:
                                        array[i] = share_INFO_.NetName.EndsWith("$");
                                        break;

                                    case DocumentLibraryPropertyId.Id:
                                        array[i] = uncObjectId;
                                        break;

                                    case DocumentLibraryPropertyId.Title:
                                        array[i] = share_INFO_.NetName;
                                        break;

                                    default:
                                        if (documentLibraryPropertyId2 != DocumentLibraryPropertyId.Description)
                                        {
                                            goto IL_1F2;
                                        }
                                        array[i] = share_INFO_.Remark;
                                        break;
                                    }
IL_248:
                                    i++;
                                    continue;
IL_1F2:
                                    if (flag)
                                    {
                                        try
                                        {
                                            if (directoryInfo == null && flag)
                                            {
                                                directoryInfo = new DirectoryInfo(uncObjectId.Path.LocalPath);
                                                FileAttributes attributes = directoryInfo.Attributes;
                                            }
                                        }
                                        catch (UnauthorizedAccessException)
                                        {
                                            flag = false;
                                        }
                                        catch (IOException)
                                        {
                                            flag = false;
                                        }
                                    }
                                    if (flag)
                                    {
                                        array[i] = UncDocumentLibraryItem.GetValueFromFileSystemInfo(documentLibraryPropertyDefinition, directoryInfo);
                                        goto IL_248;
                                    }
                                    array[i] = new PropertyError(documentLibraryPropertyDefinition, PropertyErrorCode.NotFound);
                                    goto IL_248;
                                }
                                list.Add(array);
                                num7--;
                            }
                            num6++;
                            ptr = (IntPtr)(ptr.ToInt64() + (long)num5);
                        }
                    }
                    result = new ArrayTableView(filter, sortBy, propsToReturn, list);
                }
                finally
                {
                    if (IntPtr.Zero != zero)
                    {
                        UncSession.NetApiBufferFree(zero);
                    }
                }
            }
            catch
            {
                Utils.UndoContext(ref windowsImpersonationContext);
                throw;
            }
            finally
            {
                Utils.UndoContext(ref windowsImpersonationContext);
            }
            return(result);
        }