簡體   English   中英

SharePoint Foundation 2013 IMPORT \\ EXPORT dbo.allDocs文件\\文件

[英]SharePoint Foundation 2013 IMPORT\EXPORT dbo.allDocs file\files

我想通過C#從Sharepoint 2013數據庫導入\\導出文件。 你知道怎么做嗎? 因為SharePoint中的文件是加密的。

我的問題是: 如何從SharePoint Foundation 2013數據庫導入C#文件?

在此處輸入圖片說明

創建腳本[dbo]。[AllDocs]

CREATE TABLE [dbo].[AllDocs](
    [Id] [uniqueidentifier] NOT NULL,
    [SiteId] [uniqueidentifier] NOT NULL,
    [DirName] [nvarchar](256) NOT NULL,
    [LeafName] [nvarchar](128) NOT NULL,
    [Level] [tinyint] NOT NULL,
    [ParentId] [uniqueidentifier] NOT NULL,
    [DeleteTransactionId] [varbinary](16) NOT NULL,
    [WebId] [uniqueidentifier] NOT NULL,
    [ListId] [uniqueidentifier] NULL,
    [DoclibRowId] [int] NULL,
    [Type] [tinyint] NOT NULL,
    [SortBehavior] [tinyint] NOT NULL,
    [Size] [int] NULL,
    [ETagVersion]  AS (case when [InternalVersion] IS NULL then NULL else ([InternalVersion]+[BumpVersion]*(256))/(256) end),
    [EffectiveVersion]  AS (case when [InternalVersion] IS NULL then NULL else [InternalVersion]+[BumpVersion]*(256) end),
    [InternalVersion] [int] NULL,
    [ContentVersion] [int] NOT NULL,
    [NextBSN] [bigint] NULL,
    [MetadataNextBSN] [bigint] NULL,
    [StreamSchema] [tinyint] NULL,
    [HasStream]  AS (case when [Type]=(0) AND ([DocFlags]&(256))=(256) AND [SetupPath] IS NULL OR [SetupPath] IS NOT NULL AND ([DocFlags]&(64))=(64) then (1) else (0) end),
    [BumpVersion] [tinyint] NOT NULL,
    [UIVersion] [int] NOT NULL,
    [Dirty]  AS (case when [BumpVersion]<>(0) then CONVERT([bit],(1)) else CONVERT([bit],(0)) end),
    [ListDataDirty] [bit] NOT NULL,
    [DocFlags] [int] NULL,
    [ThicketFlag] [bit] NULL,
    [CharSet] [int] NULL,
    [ProgId] [nvarchar](255) NULL,
    [TimeCreated] [datetime] NOT NULL,
    [TimeLastModified] [datetime] NOT NULL,
    [NextToLastTimeModified] [datetime] NULL,
    [MetaInfoTimeLastModified] [datetime] NULL,
    [TimeLastWritten] [datetime] NULL,
    [SetupPathVersion] [tinyint] NOT NULL,
    [SetupPath] [nvarchar](255) NULL,
    [SetupPathUser] [nvarchar](255) NULL,
    [CheckoutUserId] [int] NULL,
    [DraftOwnerId] [int] NULL,
    [CheckoutDate] [datetime] NULL,
    [CheckoutExpires] [datetime] NULL,
    [VersionCreatedSinceSTCheckout] [bit] NOT NULL,
    [LTCheckoutUserId]  AS (case when ([DocFlags]&(32))=(32) then [CheckoutUserId]  end),
    [CheckinComment] [nvarchar](1023) NULL,
    [IsCheckoutToLocal]  AS (case when ([DocFlags]&(512))=(512) then (1) else (0) end),
    [VirusVendorID] [int] NULL,
    [VirusStatus] [tinyint] NULL,
    [VirusInfo] [nvarchar](255) SPARSE  NULL,
    [VirusInfoEx] [varbinary](max) NULL,
    [MetaInfo] [dbo].[tCompressedBinary] NULL,
    [MetaInfoSize] [int] NULL,
    [MetaInfoVersion] [int] NOT NULL,
    [UnVersionedMetaInfo] [dbo].[tCompressedBinary] NULL,
    [UnVersionedMetaInfoSize] [int] NULL,
    [UnVersionedMetaInfoVersion] [int] NULL,
    [WelcomePageUrl] [nvarchar](260) NULL,
    [WelcomePageParameters] [nvarchar](max) NULL,
    [IsCurrentVersion] [bit] NOT NULL,
    [AuditFlags] [int] NULL,
    [InheritAuditFlags] [int] NULL,
    [UIVersionString]  AS ((CONVERT([nvarchar],[UIVersion]/(512))+'.')+CONVERT([nvarchar],[UIVersion]%(512))),
    [ScopeId] [uniqueidentifier] NOT NULL,
    [BuildDependencySet] [varbinary](max) NULL,
    [ParentVersion] [int] NULL,
    [ParentVersionString]  AS ((CONVERT([nvarchar],[ParentVersion]/(512))+'.')+CONVERT([nvarchar],[ParentVersion]%(512))),
    [TransformerId] [uniqueidentifier] NULL,
    [ParentLeafName] [nvarchar](128) NULL,
    [CtoOffset] [smallint] NULL,
    [Extension]  AS (case when charindex(N'.',[LeafName] collate Latin1_General_BIN)>(0) then right([LeafName],charindex(N'.',reverse([LeafName]) collate Latin1_General_BIN)-(1)) else N'' end),
    [ExtensionForFile]  AS (case when [Type]=(0) AND charindex(N'.',[LeafName] collate Latin1_General_BIN)>(0) then right([LeafName],charindex(N'.',reverse([LeafName]) collate Latin1_General_BIN)-(1)) else N'' end),
    [ItemChildCount] [int] NOT NULL,
    [FolderChildCount] [int] NOT NULL,
    [FileFormatMetaInfo] [varbinary](max) NULL,
    [FileFormatMetaInfoSize] [int] NOT NULL,
    [FFMConsistent] [bit] NULL,
    [ListSchemaVersion] [int] NULL,
    [ClientId] [varbinary](16) NULL,
 CONSTRAINT [AllDocs_ParentId] PRIMARY KEY CLUSTERED 
(
    [SiteId] ASC,
    [DeleteTransactionId] ASC,
    [ParentId] ASC,
    [Id] ASC,
    [Level] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 95) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

我嘗試使用此:

1個代碼:

-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

2碼

DECLARE  @Command       VARCHAR(4000),
         @FileID       VARCHAR(128),
         @MyFilename nvarchar(max)

DECLARE curFile CURSOR  FOR             -- Cursor for each image in table
SELECT DocId FROM [WSS_Content].[dbo].[DocStreams]

OPEN curFile

FETCH NEXT FROM curFile
INTO @FileID

WHILE (@@FETCH_STATUS = 0) -- Cursor loop
  BEGIN
-- Keep the bcp command on ONE LINE - SINGLE LINE!!! - broken up for presentation

SELECT @MyFilename = LeafName from [WSS_Content].[dbo].[AllDocs] WHERE Id = @FileID

    SET @Command = 'bcp "SELECT Content from [WSS_Content].[dbo].[DocStreams] WHERE DocId = ''' +
    @FileID + '''" queryout "C:\' +
    @MyFilename+'" -T -n -Slocalhost -fC:\bcp.fmt'

    PRINT @Command -- debugging

    EXEC xp_cmdshell @Command     -- Carry out image export to file from db table

    FETCH NEXT FROM curFile
    INTO @FileID
  END  -- cursor loop

CLOSE curFile

DEALLOCATE curFile

但是我得到了錯誤:

在此處輸入圖片說明

使用C#導入\\導出文件很簡單,因為它是[WSS_Content]。[dbo]。[DocStreams]中的二進制文件SELECT Content。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM