我创建的工作流是SharePoint Designer,并将其与列表相关联.工作流创建批准过程,因此SharePoint在"任务"列表中创建任务,以便用户可以批准或拒绝.
我需要做的是在不打开任务列表中的任务的情况下批准或拒绝任务.经过一些研究后,我发现我可以使用SharePoint Web Services.但是我感到迷茫,因为我不知道哪个服务,例如Lists.asmx,以及调用哪个方法,例如UpdateListItems.
有人可以指导我完成以下任务:
1-批准工作流任务SharePoint Web Services是否可行?
2-你能告诉我一个如何批准任务的例子,例如调用哪种服务和方法以及参数应该是什么?
更新
我一直在使用以下XML来设置工作流程来完成:
batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" // Also used Moderate
+ "<Field Name='ID'>115</Field>"
+ "<Field Name='Status'>Completed</Field>"
+ "<Field Name='FormData'>Completed</Field>" // Also used Approved
+ "<Field Name='WorkflowOutcome'>Approved</Field>"
+ "<Field Name='Completed'>True</Field>"
+ "<Field Name='PercentComplete'>1</Field>"
+ "<Field Name='_ModerationStatus'>0</Field>"
+ "</Method>";
Run Code Online (Sandbox Code Playgroud)
任务列表项已更新,但WorkflowOutcome仍为空,工作流不会移至下一步.
我还缺少什么?
更新#2
我怀疑任务列表项的ExtendedProperties.对于使用UI完成的项目,ExtendedProperties显示ws_TaskStatus ='已批准'.但是,对于使用代码批准的项目,ws_TaskStatus不存在.
更新#3
从MSDN帖子中,我被告知要使用Workflow.asmx而不是Lists.asmx.
我使用了以下代码:
WorkflowService.Workflow listProxy = new WorkflowService.Workflow();
listProxy.Url = "http://<server_name …Run Code Online (Sandbox Code Playgroud) 我有一个存储在文件中的PowerShell脚本.在Windows PowerShell中,我执行脚本为
.\MergeDocuments.ps1 "1.docx" "2.docx" "merge.docx"
我想从C#调用脚本.目前我使用Process.Start如下工作:
Process.Start(POWERSHELL_PATH, string.Format("-File \"{0}\" {1} {2}", SCRIPT_PATH, string.Join(" ", filesToMerge), outputFilename));
我想使用Pipeline类运行它,类似于下面的代码,但我不知道如何传递参数(请记住,我没有命名参数,我只是使用$ args)
// create Powershell runspace
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runspace);
runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
// create a pipeline and feed it the script text (AddScript method) or use the filePath (Add method)
Pipeline pipeline = runspace.CreatePipeline();
Command command = new Command(SCRIPT_PATH);
command.Parameters.Add("", ""); // I don't have named paremeters
pipeline.Commands.Add(command);
pipeline.Invoke();
runspace.Close();
Run Code Online (Sandbox Code Playgroud) 我有一个存储在文件MergeDocuments.ps1中的PowerShell脚本.当我从Windows PowerShell命令提示符运行脚本时,它运行正常
.\MergeDocuments.ps1 1.docx 2.docx merge.docx
从Windows控制台应用程序调用脚本也运行正常.
当我尝试从Asp.Net Web服务调用脚本时,我遇到了一些有关注册表访问的问题.我使用模拟并将网络服务帐户的权限授予注册表项HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell以解决此问题
接下来我遇到了关于PowerShell无法创建OpenXmlPowerTools.DocumentSource []类型对象的问题,所以我在脚本中添加了以下内容
Add-Type -Path "C:\Users\Administrator\Documents\WindowsPowerShell\Modules\OpenXmlPowerTools\OpenXmlPowerTools.dll"
Import-Module OpenXmlPowerTools
Run Code Online (Sandbox Code Playgroud)
现在的问题是我收到错误"术语'Merge-OpenXmlDocument'未被识别为cmdlet的名称,......"
我怎么解决这个问题?
PowerShell脚本
Add-Type -Path "C:\Users\Administrator\Documents\WindowsPowerShell\Modules\OpenXmlPowerTools\OpenXmlPowerTools.dll"
Import-Module OpenXmlPowerTools
# The last argument is the path of the merged document
$noOfSourceDocs = ($($args.length) - 1)
# Create an array to hold all the source documents
[OpenXmlPowerTools.DocumentSource[]] $docs = New-Object OpenXmlPowerTools.DocumentSource[] $noOfSourceDocs
for ($i = 0; $i -lt $noOfSourceDocs; $i++)
{
$docs[$i] = New-Object -TypeName OpenXmlPowerTools.DocumentSource -ArgumentList $args[$i]
$docs[$i].KeepSection = 1
}
Merge-OpenXmlDocument -OutputPath …Run Code Online (Sandbox Code Playgroud) 我注意到,通过使用log4net,在调用ISession.Update时,它会更新所有已更改的对象.
例如:
// Change 2 instances
user1.IsDeleted = true;
user2.UserName = "Xyz";
// Call session.Update to update the 2 users
using (ITransaction transaction = session.BeginTransaction())
{
Session.Update(user1); // This updates both user1 & user2
transaction.Commit();
}
using (ITransaction transaction = session.BeginTransaction())
{
Session.Update(user2); // Now there is no need for this
transaction.Commit();
}
Run Code Online (Sandbox Code Playgroud)
这是NHibernate的默认行为还是与我的映射文件有关?
我可以逐个进行NHibernate更新吗?