internal static PropertyErrorException GetExceptionFromError(PropertyError propertyError)
        {
            switch (propertyError.PropertyErrorCode)
            {
            case PropertyErrorCode.NotFound:
                return(new PropertyErrorNotFoundException(propertyError));

            case PropertyErrorCode.NotSupported:
                return(new PropertyErrorNotSupportedException(propertyError));

            case PropertyErrorCode.CorruptData:
                return(new PropertyErrorCorruptDataException(propertyError));
            }
            return(new PropertyErrorException(propertyError));
        }
Пример #2
0
        internal static object[] GetValuesFromCAMLView(Schema schema, XmlNode xmlNode, CultureInfo cultureInfo, IList <PropertyDefinition> propertyDefinitions)
        {
            object[] array = new object[propertyDefinitions.Count];
            string   str   = string.Empty;

            if (xmlNode.LocalName == "row")
            {
                str = "ows_";
            }
            int i = 0;

            while (i < propertyDefinitions.Count)
            {
                SharepointPropertyDefinition sharepointPropertyDefinition = SharepointPropertyDefinition.PropertyDefinitionToSharepointPropertyDefinition(schema, propertyDefinitions[i]);
                if (sharepointPropertyDefinition != null)
                {
                    string name = str + sharepointPropertyDefinition.SharepointName;
                    try
                    {
                        if (xmlNode.Attributes[name] == null || (array[i] = sharepointPropertyDefinition.FromSharepoint(xmlNode.Attributes[name].Value, cultureInfo)) == null)
                        {
                            array[i] = new PropertyError(propertyDefinitions[i], PropertyErrorCode.NotFound);
                        }
                        goto IL_DC;
                    }
                    catch (FormatException)
                    {
                        array[i] = new PropertyError(propertyDefinitions[i], PropertyErrorCode.CorruptData);
                        goto IL_DC;
                    }
                    goto IL_AC;
                }
                goto IL_AC;
IL_DC:
                i++;
                continue;
IL_AC:
                if (propertyDefinitions[i] is DocumentLibraryPropertyDefinition)
                {
                    array[i] = new PropertyError(propertyDefinitions[i], PropertyErrorCode.NotFound);
                    goto IL_DC;
                }
                array[i] = new PropertyError(propertyDefinitions[i], PropertyErrorCode.NotSupported);
                goto IL_DC;
            }
            return(array);
        }
Пример #3
0
 internal static ITableView InternalGetView(QueryFilter query, SortBy[] sortBy, DocumentLibraryQueryOptions queryOptions, PropertyDefinition[] propsToReturn, SharepointSession session, SharepointListId listId)
 {
     EnumValidator.ThrowIfInvalid <DocumentLibraryQueryOptions>(queryOptions, "queryOptions");
     if (propsToReturn == null)
     {
         throw new ArgumentNullException("propsToReturn");
     }
     if (propsToReturn.Length == 0)
     {
         throw new ArgumentException("propsToReturn");
     }
     return(Utils.DoSharepointTask <ArrayTableView>(session.Identity, new SharepointListId(listId.ListName, listId.SiteUri, listId.CultureInfo, UriFlags.SharepointList), listId, true, Utils.MethodType.GetView, delegate
     {
         XmlNode xmlNode = null;
         using (Lists lists = new Lists(listId.SiteUri.ToString()))
         {
             lists.Credentials = CredentialCache.DefaultCredentials;
             XmlNode query2 = null;
             QueryFilter queryFilter = null;
             if (queryOptions == DocumentLibraryQueryOptions.Files)
             {
                 queryFilter = new ComparisonFilter(ComparisonOperator.Equal, SharepointDocumentLibraryItemSchema.FileSystemObjectType, 0);
             }
             else if (queryOptions == DocumentLibraryQueryOptions.Folders)
             {
                 queryFilter = new ComparisonFilter(ComparisonOperator.Equal, SharepointDocumentLibraryItemSchema.FileSystemObjectType, 1);
             }
             if (query != null && queryFilter != null)
             {
                 query = new AndFilter(new QueryFilter[]
                 {
                     queryFilter,
                     query
                 });
             }
             else if (queryFilter != null)
             {
                 query = queryFilter;
             }
             if (query != null)
             {
                 query2 = SharepointHelpers.GenerateQueryCAML(query);
             }
             XmlNode viewFields = SharepointHelpers.GenerateViewFieldCAML(SharepointDocumentSchema.Instance, SharepointDocumentSchema.Instance.AllProperties.Keys);
             if (listId.CultureInfo == null)
             {
                 SharepointList sharepointList = SharepointList.Read(session, listId);
                 listId.CultureInfo = sharepointList.GetRegionalSettings();
             }
             SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = listId as SharepointDocumentLibraryItemId;
             XmlNode queryOptions2;
             if (sharepointDocumentLibraryItemId != null)
             {
                 queryOptions2 = SharepointHelpers.GenerateQueryOptionsXml(sharepointDocumentLibraryItemId.ItemHierarchy);
             }
             else
             {
                 queryOptions2 = SharepointHelpers.GenerateQueryOptionsXml(null);
             }
             xmlNode = lists.GetListItems(listId.ListName, null, query2, viewFields, Utils.GetViewMaxRows.ToString(), queryOptions2);
         }
         List <object[]> list = new List <object[]>();
         foreach (object obj in xmlNode.SelectNodes("/rs:data/z:row", SharepointHelpers.SharepointNamespaceManager))
         {
             XmlNode xmlNode2 = (XmlNode)obj;
             object[] valuesFromCAMLView = SharepointHelpers.GetValuesFromCAMLView(SharepointDocumentSchema.Instance, xmlNode2, listId.CultureInfo, new PropertyDefinition[]
             {
                 SharepointDocumentLibraryItemSchema.FileSystemObjectType,
                 SharepointDocumentLibraryItemSchema.ID,
                 SharepointDocumentLibraryItemSchema.EncodedAbsoluteUri
             });
             int num = 0;
             int num2 = num + 1;
             int num3 = num2 + 1;
             bool flag = valuesFromCAMLView[num] is bool && (bool)valuesFromCAMLView[num];
             UriFlags uriFlags = flag ? UriFlags.SharepointFolder : UriFlags.SharepointDocument;
             Uri uri = (Uri)valuesFromCAMLView[num3];
             List <string> list2 = new List <string>();
             for (int i = listId.SiteUri.Segments.Length; i < uri.Segments.Length; i++)
             {
                 list2.Add(Uri.UnescapeDataString(uri.Segments[i]));
             }
             SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId2 = new SharepointDocumentLibraryItemId((string)valuesFromCAMLView[num2], listId.ListName, listId.SiteUri, listId.CultureInfo, uriFlags, list2);
             sharepointDocumentLibraryItemId2.Cache = new KeyValuePair <string, XmlNode>?(new KeyValuePair <string, XmlNode>(session.Identity.Name, xmlNode2));
             object[] valuesFromCAMLView2 = SharepointHelpers.GetValuesFromCAMLView(SharepointDocumentSchema.Instance, xmlNode2, listId.CultureInfo, propsToReturn);
             object obj2 = null;
             for (int j = 0; j < propsToReturn.Length; j++)
             {
                 if (((DocumentLibraryPropertyDefinition)propsToReturn[j]).PropertyId == DocumentLibraryPropertyId.Id)
                 {
                     valuesFromCAMLView2[j] = sharepointDocumentLibraryItemId2;
                 }
                 else if (propsToReturn[j] == SharepointDocumentSchema.VersionControl)
                 {
                     if (obj2 == null)
                     {
                         string text = SharepointHelpers.GetValuesFromCAMLView(SharepointDocumentSchema.Instance, xmlNode2, listId.CultureInfo, new PropertyDefinition[]
                         {
                             SharepointDocumentSchema.CheckedOutUserId
                         })[0] as string;
                         object obj3 = SharepointHelpers.GetValuesFromCAMLView(SharepointDocumentSchema.Instance, xmlNode2, listId.CultureInfo, new PropertyDefinition[]
                         {
                             SharepointDocumentSchema.VersionId
                         })[0];
                         if (obj3 is int && !flag)
                         {
                             obj2 = new VersionControl(!string.IsNullOrEmpty(text), text, (int)obj3);
                         }
                         else
                         {
                             obj2 = new PropertyError(propsToReturn[j], PropertyErrorCode.NotFound);
                         }
                     }
                     valuesFromCAMLView2[j] = obj2;
                 }
             }
             list.Add(valuesFromCAMLView2);
         }
         return new ArrayTableView(null, sortBy, propsToReturn, list);
     }));
 }
Пример #4
0
 internal PropertyErrorNotSupportedException(PropertyError propertyError) : base(propertyError)
 {
 }
 internal PropertyErrorNotFoundException(PropertyError propertyError) : base(propertyError)
 {
 }
 internal PropertyErrorException(PropertyError propertyError) : this(propertyError, null)
 {
 }
 internal PropertyErrorException(PropertyError propertyError, Exception innerException) : base(propertyError.PropertyErrorDescription, innerException)
 {
     this.propertyError = propertyError;
 }
Пример #8
0
        public override bool IsMatch(object[] row)
        {
            PropertyError propertyError = row[this.Index] as PropertyError;

            return(propertyError == null || (propertyError.PropertyErrorCode != PropertyErrorCode.NotFound && propertyError.PropertyErrorCode != PropertyErrorCode.NotSupported));
        }
Пример #9
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);
        }
Пример #10
0
 internal PropertyErrorCorruptDataException(PropertyError propertyError) : base(propertyError)
 {
 }