Пример #1
0
        public Core.File ToFile(File file)
        {
            if (file == null)
            {
                return(null);
            }

            var errorFile = file as SharePointFileErrorEntry;

            if (errorFile != null)
            {
                return new Core.File
                       {
                           ID                = MakeId(errorFile.ID),
                           FolderID          = MakeId(GetParentFolderId(errorFile.ID)),
                           CreateBy          = Owner,
                           CreateOn          = DateTime.UtcNow,
                           ModifiedBy        = Owner,
                           ModifiedOn        = DateTime.UtcNow,
                           ProviderId        = ID,
                           ProviderKey       = ProviderKey,
                           RootFolderCreator = Owner,
                           RootFolderId      = MakeId(RootFolder.ServerRelativeUrl),
                           RootFolderType    = RootFolderType,
                           Title             = MakeTitle(GetTitleById(errorFile.ID)),
                           Error             = errorFile.Error
                       }
            }
            ;

            var result = new Core.File
            {
                ID     = MakeId(file.ServerRelativeUrl),
                Access = Core.Security.FileShare.None,
                //ContentLength = file.Length,
                CreateBy          = Owner,
                CreateOn          = file.TimeCreated.Kind == DateTimeKind.Utc ? TenantUtil.DateTimeFromUtc(file.TimeCreated) : file.TimeCreated,
                FileStatus        = FileStatus.None,
                FolderID          = MakeId(GetParentFolderId(file.ServerRelativeUrl)),
                ModifiedBy        = Owner,
                ModifiedOn        = file.TimeLastModified.Kind == DateTimeKind.Utc ? TenantUtil.DateTimeFromUtc(file.TimeLastModified) : file.TimeLastModified,
                NativeAccessor    = file,
                ProviderId        = ID,
                ProviderKey       = ProviderKey,
                Title             = MakeTitle(file.Name),
                RootFolderId      = MakeId(SpRootFolderId),
                RootFolderType    = RootFolderType,
                RootFolderCreator = Owner,
                SharedByMe        = false,
                Version           = 1
            };

            if (file.IsPropertyAvailable("Length"))
            {
                result.ContentLength = file.Length;
            }
            else if (file.IsObjectPropertyInstantiated("ListItemAllFields"))
            {
                result.ContentLength = Convert.ToInt64(file.ListItemAllFields["File_x0020_Size"]);
            }

            return(result);
        }
        public Core.File ToFile(File file)
        {
            if (file == null)
                return null;

            var errorFile = file as SharePointFileErrorEntry;
            if (errorFile != null)
                return new Core.File
                {
                    ID = MakeId(errorFile.ID),
                    FolderID = MakeId(GetParentFolderId(errorFile.ID)),
                    CreateBy = Owner,
                    CreateOn = DateTime.UtcNow,
                    ModifiedBy = Owner,
                    ModifiedOn = DateTime.UtcNow,
                    ProviderId = ID,
                    ProviderKey = ProviderKey,
                    RootFolderCreator = Owner,
                    RootFolderId = MakeId(RootFolder.ServerRelativeUrl),
                    RootFolderType = RootFolderType,
                    Title = MakeTitle(GetTitleById(errorFile.ID)),
                    Error = errorFile.Error
                };

            var result = new Core.File
            {
                ID = MakeId(file.ServerRelativeUrl),
                Access = Core.Security.FileShare.None,
                //ContentLength = file.Length,
                CreateBy = Owner,
                CreateOn = file.TimeCreated.Kind == DateTimeKind.Utc ? TenantUtil.DateTimeFromUtc(file.TimeCreated) : file.TimeCreated,
                FileStatus = FileStatus.None,
                FolderID = MakeId(GetParentFolderId(file.ServerRelativeUrl)),
                ModifiedBy = Owner,
                ModifiedOn = file.TimeLastModified.Kind == DateTimeKind.Utc ? TenantUtil.DateTimeFromUtc(file.TimeLastModified) : file.TimeLastModified,
                NativeAccessor = file,
                ProviderId = ID,
                ProviderKey = ProviderKey,
                Title = MakeTitle(file.Name),
                RootFolderId = MakeId(SpRootFolderId),
                RootFolderType = RootFolderType,
                RootFolderCreator = Owner,
                SharedByMe = false,
                Version = 1
            };

            if (file.IsPropertyAvailable("Length"))
            {
                result.ContentLength = file.Length;
            }
            else if(file.IsObjectPropertyInstantiated("ListItemAllFields"))
            {
                result.ContentLength = Convert.ToInt64(file.ListItemAllFields["File_x0020_Size"]);
            }

            return result;
        }