SharePoint Foundation 2013 导入\导出 dbo.allDocs 文件\文件 [英] SharePoint Foundation 2013 IMPORT\EXPORT dbo.allDocs file\files

查看:24
本文介绍了SharePoint Foundation 2013 导入\导出 dbo.allDocs 文件\文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 C# 从 Sharepoint 2013 数据库导入\导出文件.你知道怎么做吗?因为 SharePoint 中的文件已加密.

I would like to import\export file from Sharepoint 2013 database via C#. Do you know how to do it? Because file in SharePoint is encrypted.

我的问题是:如何在 C# 中从 SharePoint Foundation 2013 数据库导入\导出文件?

创建脚本 [dbo].[AllDocs]

CREATE SCRIPT [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# 中导入\导出文件很简单,因为它是二进制文件 SELECT Content from [WSS_Content].[dbo].[DocStreams]

It`s simple to import\export file in C# because it's binary file SELECT Content from [WSS_Content].[dbo].[DocStreams]

这篇关于SharePoint Foundation 2013 导入\导出 dbo.allDocs 文件\文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆