簡體   English   中英

DotCMIS連接到SharePoint Foundation 2013

[英]DotCMIS connect to SharePoint Foundation 2013

我想將DotCMIS.dll連接到我的SharePoint,但是不能正常工作。

我在SharePoint 2013命令行管理程序中打開腳本。

我使用我的用戶權限(這不是Farm用戶)

給出正確的鏈接可能是問題所在。 org.apache.chemistry.dotcmis.binding.atompub.url =?

您知道共享點中的鏈接必須去哪里嗎?

示例網站:

http://chemistry.apache.org/dotnet/powershell-example.html

錯誤

You cannot call a method on a null-valued expression.
At line:6 char:7
+       $b = $contentStream.Stream.Read($buffer, 0, 4096)
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

我腳本的重要部分

$sp["org.apache.chemistry.dotcmis.binding.atompub.url"] = "http://localhost/_layouts/15/start.aspx#/SitePages/WebSite.aspx"
    $sp["org.apache.chemistry.dotcmis.user"] = "mylogin"
    $sp["org.apache.chemistry.dotcmis.password"] = "mypassword"

所有腳本

# load DotCMIS DLL
[Reflection.Assembly]::LoadFile("C:\dotCmisServer\DotCMIS.dll")


# -----------------------------------------------------------------

# helper functions
function New-GenericDictionary([type] $keyType, [type] $valueType) {  
   $base = [System.Collections.Generic.Dictionary``2]  
   $ct = $base.MakeGenericType(($keyType, $valueType))  
   New-Object $ct
}

function New-ContentStream([string] $file, [string] $mimetype) {
   $fileinfo = ([System.IO.FileInfo]$file)

   $contentStream = New-Object "DotCMIS.Data.Impl.ContentStream"
   $contentStream.Filename = $fileinfo.Name
   $contentStream.Length = $fileinfo.Length
   $contentStream.MimeType = $mimetype
   $contentStream.Stream = $fileinfo.OpenRead()

   $contentStream
}

function Download-ContentStream([DotCMIS.Client.IDocument] $document, [string] $file) {
   $contentStream = $document.GetContentStream()   
   $fileStream = [System.IO.File]::OpenWrite($file)

   $buffer = New-Object byte[] 4096  
   do {  
      $b = $contentStream.Stream.Read($buffer, 0, 4096)  
      $fileStream.Write($buffer, 0, $b)  
   }  
   while ($b -ne 0)

   $fileStream.Close()
   $contentStream.Stream.Close()
}


# -----------------------------------------------------------------

# create session
$sp = New-GenericDictionary string string
$sp["org.apache.chemistry.dotcmis.binding.spi.type"] = "atompub"
$sp["org.apache.chemistry.dotcmis.binding.atompub.url"] = "http://localhost/_layouts/15/start.aspx#/SitePages/WebSite.aspx"
$sp["org.apache.chemistry.dotcmis.user"] = "mylogin"
$sp["org.apache.chemistry.dotcmis.password"] = "mypassword"

$factory = [DotCMIS.Client.Impl.SessionFactory]::NewInstance()
$session = $factory.GetRepositories($sp)[0].CreateSession()


# print the repository infos
$session.RepositoryInfo.Id
$session.RepositoryInfo.Name
$session.RepositoryInfo.Vendor
$session.RepositoryInfo.ProductName
$session.RepositoryInfo.ProductVersion


# get root folder
$root = $session.GetRootFolder()


# print root folder children
$children = $root.GetChildren()
foreach ($object in $children) {
   $object.Name + "     (" + $object.ObjectType.Id + ")" 
}


# run a quick query
$queryresult = $session.Query("SELECT * FROM cmis:document", $false)
foreach ($object in $queryresult) {
   foreach ($item in $object.Properties) {
      $item.QueryName + ": " + $item.FirstValue
   }
   "----------------------------------"
}


# create a folder
$folderProperties = New-GenericDictionary string object
$folderProperties["cmis:name"] = "myNewFolder"
$folderProperties["cmis:objectTypeId"] = "cmis:folder"

$folder = $root.CreateFolder($folderProperties)


# create a document 
$documentProperties = New-GenericDictionary string object
$documentProperties["cmis:name"] = "myNewDocument"
$documentProperties["cmis:objectTypeId"] = "cmis:document"

$source = $home + "\source.txt"
$mimetype = "text/plain"
$contentStream = New-ContentStream $source $mimetype

$doc = $folder.CreateDocument($documentProperties, $contentStream, $null)


# download a document
$target = $home + "\target.txt"
Download-ContentStream $doc $target


# clean up
$doc.Delete($true)
$folder.Delete($true)

不幸的是,在SharePoint Foundation 2013中,我必須編寫自己的C#軟件。

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

暫無
暫無

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

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