有没有可能从sharepoint 2010服务器读取UniqueId? [英] Is there any possibility to read that UniqueId from sharepoint 2010 server?

查看:124
本文介绍了有没有可能从sharepoint 2010服务器读取UniqueId?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 sharepoint 2010服务器中读取一些文件夹和文件属性。最重要的属性是  UniqueId 。有没有可能读取该属性?
b
$ b b b我尝试使用csom(Microsoft.SharePoint.Client.dll)。对于sharepoint 2013 及更高版本,此可正常使用以下代码。它适用于sharepoint online和sharepoint服务器。问题出在我需要阅读的sharepoint 2010服务器上。
发生异常,例如"字段或属性UniqueId不可用"。 "ListItemAllFields"也不可用。我阅读了很多帖子,但我找不到解决方案。 
$


我可以发现它会有正常的3个解决方案:



1. csom  (将是最佳解决方案,适用于2013及以上版本 - >未找到2010服务器的解决方案)

2. ssom  (仅当所有内容都在同一台服务器上时才有效 - >对我来说不是解决方案,因为我需要阅读的应用程序不在像sharepoint这样的服务器上)

3. webservices  (我找不到与网络服务匹配的解决方案)



我读到的 Caml查询 并发现类似于 

I would like to read some folder- and file-properties from sharepoint 2010 server. The most important property is the UniqueId. Is there any possibility to read that property?

I tried with csom (Microsoft.SharePoint.Client.dll). This works fine with the code below for sharepoint 2013 and above. It works for sharepoint online and sharepoint server. The problem is for sharepoint 2010 server where I need to read. An exception occurs like "The Field or Property UniqueId is not available". The "ListItemAllFields" is not available either. I read many posts but I could not found a solution. 

I could figure out that there would be normaly 3 solutions for it:

1. csom (Would be the best solution and works perfect for 2013 and above -> no solution found for 2010 server)
2. ssom (Works only when everything is on the same server -> is no solution for me because the application where I need to read is not on the same server like sharepoint)
3. webservices (I could not found a matching solution with webservices)

I read about Caml query and found something like 

<FieldRef Name='UniqueId'/>


但我不知道如何使用它我不知道如果可以使用它读取UniqueId。



这里代码 适用于2013年及以上的sharepoint但不适用于sharepoint 2010服务器:



  &NBSP;

but I don't know how to use it and I don't know if reading UniqueId even is possible with it.

Here the code which works fine for sharepoint 2013 and above but did not work for sharepoint 2010 server:

   

public string GetChilds(ClientContext clientContext, string relativeUrl)    
{
  SpFolder folder=clientContext.Web.GetFolderByServerRelativeUrl(relativeUrl);      
clientContext.Load(folder,                   
  item => item.Name,                   
  item => item.UniqueId,                   
  item => item.ServerRelativeUrl                  
 );          

  clientContext.Load(folder.Folders,    
    items => items.Include(                        
    item => item.Name,                       
    item => item.UniqueId,                       
    item => item.ServerRelativeUrl,   
    item => item.TimeLastModified, 
    item => item.TimeCreated,                        
    item => item.ListItemAllFields["Author"],              
    item => item.ListItemAllFields["Editor"]));    

  clientContext.Load(folder.Files,  
    items => items.Include(    
    item => item.Name,      
    item => item.UniqueId,    
    item => item.ServerRelativeUrl,   
    item => item.TimeLastModified,  
    item => item.TimeCreated,   
    item => item.ListItemAllFields["Author"],       
    item => item.ListItemAllFields["Editor"],
    item => item.ListItemAllFields["File_x0020_Size"])); 
           
 clientContext.ExecuteQueryWithIncrementalRetry(EXECUTEQUERY_RETRYCOUNT, EXECUTEQUERY_DELAY);   

  string result = "";   
  result += "Parent Name:" + folder.Name + ","; 
  result += "Parent UniqeId:" + folder.UniqueId.ToString() + ",";  
  result += "Parent ServerRelativeUrl:" + folder.ServerRelativeUrl + ","; 

  if (folder.Folders != null)    
  {     
    foreach (SpFolder subFolder in folder.Folders)    
    {       
      result += "Name:" + subFolder.Name + ",";   
      result += "UniqueId:" + subFolder.UniqueId.ToString() + ","; 
      //...       
    }    
  }       
  
  if (folder.Files != null)  
  {    
    foreach (SpFile file in folder.Files)     
    {
      result += "Name:" + file.Name + ",";  
      result += "UniqueId:" + file.UniqueId.ToString() + ",";  
      //...   
    }   
  }    
  
  return result;  
}




预期结果 将检索UniqueId  来自sharepoint 2010服务器的ListItemAllFields。 

实际结果为:" 字段或属性UniqueId不可用"。


The expected result would be retrieving the UniqueId and ListItemAllFields from sharepoint 2010 server. 
The actual result is: "The Field or Property UniqueId is not available".

推荐答案

Hi,

对于SharePoint 2010,文件类和Folder类没有UniqueId。 File.UniqueId属性和Folder.UniqueId属性在
SharePoint 2013 CSOM及更高版本中可用。

For SharePoint 2010, the file class and Folder class do not have UniqueId. The File.UniqueId property and Folder.UniqueId property are available in SharePoint 2013 CSOM and later.

而且,Folder类没有ListItemAllFileds属性。
Folder.ListItemAllFields属性在SharePoint 2013 CSOM及更高版本中可用。

And, the Folder class does not have ListItemAllFileds property. The Folder.ListItemAllFields property is available in SharePoint 2013 CSOM and later.

有关详细信息,请参阅以下文章:

文件SharePoint 2010中的类

SharePoint 2010中的文件夹类

Best  respect,

Best regards,

Linda


这篇关于有没有可能从sharepoint 2010服务器读取UniqueId?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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