最近的项目中遇到了一个需求,需要向SharePointList 查询Item是否存在,找到了CamlQuery这样一个方法,但是没有找到使用这个接口的频率限制说明文档,于是就有了这篇随笔。

新接触这个方向,请大家多多指教。

	#Load SharePoint CSOM Assemblies
Add-Type -Path "F:\Microsoft.SharePoint.Client.dll"
Add-Type -Path "F:\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "F:\Microsoft.SharePoint.Client.Publishing.dll"
#Variables for Processing
$SiteUrl = "<app web url>"
$ListName="<ListTitle>"
 
$UserName="<account>"
$Password ="<password>"
  
#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
  
#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $credentials $List = $Context.web.Lists.GetByTitle('<ListTitle>') $Title="Test"
$start = Get-Date
for($i=0;$i -le 1000;$i++)
{
try
{ $Query = New-Object Microsoft.SharePoint.Client.CamlQuery;
$Query.ViewXml = "<View><Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>"+$Title+"</Value></Eq></Where></Query></View>"
$ListItems = $list.GetItems($Query);
$Context.Load($ListItems)
$Context.ExecuteQuery()
$midend = Get-Date
write-host "Test"+$i+"Do"+($midend - $start).TotalSeconds "Test"+$i+"Do"+($midend - $start).TotalSeconds | Out-File -Append d:\PsTest.txt
}
catch [System.Exception]
{
$midend = Get-Date
# write-host "Test"$i "Error" ($midend - $start).TotalSeconds
"Test"+$i+"Error"+($midend - $start).TotalSeconds | Out-File -Append d:\PsTest.txt
write-host -f red $_.Exception.ToString()
}
}
$end = Get-Date
write-host "Test"$i "Console"($end - $start).TotalSeconds
"Test"+$i+"Console"+($end - $start).TotalSeconds| Out-File -Append d:\PsTest.txt

  根据返回的结果统计来看,1000次顺序Query请求成功率为100%,曲线如下

1000次的Query查询大概用时238.46秒,曲线中纵轴为响应的返回时间,整体看来曲线还不错,回来进行一下并行测试的的情况。

最新文章

  1. ***Linux下使用git命令及github项目
  2. 关于html5不支持frameset的解决方法
  3. Excel VBA
  4. UI抑制限制(UI Suppression Limitations)
  5. Jquery的$命名冲突
  6. [转] 用管道获得shell 命令的输出
  7. node.js的ejs模版引擎
  8. 简易google地图api调用
  9. (转)C#DataTable学习心得
  10. javascript Node操作
  11. 二、ASP.NET MVC Controller 控制器(一:深入解析控制器运行原理)
  12. $PkuWc\ 2018$ 酱油记
  13. STL 小白学习(10) map
  14. vim 中文乱码怎么解决
  15. java之LinkedList详细介绍
  16. 【Python】【函数式编程】
  17. 信息安全技术PGP实验 20155205 20155218
  18. 手把手教你搭APM之Skywalking搭建指南(支持Java/C#/Node.js)
  19. 下载vc++运行库
  20. 【翻译】std::list::remove - C++ Reference

热门文章

  1. 二、计算机数据表示&amp;&amp;校验码(简单了解)
  2. MySQL密码正确却无法本地登录-1045 Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password:YES
  3. gorm操练记录
  4. 从零开始的vue学习笔记(一)
  5. 剑指offer笔记面试题5----替换空格
  6. DOMContentLoaded vs jQuery.ready vs onload, How To Decide When Your Code Should Run
  7. VC遍历访问目录下的文件
  8. 1、netty入门说明
  9. windows 下使用批处理执行 postgresql 命令行操作
  10. MySQL Error Log 中IO写入瓶颈的警告分析