IManage WorkSite 通过 SDK 重载 WorkSpace
IManage WorkSite refile WorkSpace via SDK
使用 Web 服务的 SDK,我已经能够将用户添加到 WorkSpace 并授予他们访问权限,但是 WorkSpace 没有重新归档,因此他们实际上只能访问根文件夹而没有其他权限.
我知道有 Refile()
方法,我只是不确定如何在 WorkSpace 中执行文件夹和文档的重新归档。
目前我有一个授予用户访问 WorkSpace 的功能,我已经测试并且这个功能有效,以下是该功能的一部分,在此代码之前我已经启动了 WorkSpace 搜索方法并且下面的代码正在迭代通过搜索结果。
Dim retString As String = ""
For Each w As IManWorkspace In oDB.SearchWorkspaces(oparams, oWparams)
' Get the WorkSpace security container
Dim oSec As IManSecurity = w.Security
Dim oUACLs As IManUserACLs = oSec.UserACLs
' Grant the user the defined access
oUACLs.Add(sUserID, imAccessRight.imRightReadWrite)
' Apply the changes
w.Update()
' Refresh the Collection on the client
oUACLs.Refresh()
' TO DO: REFILE THE SUB-FOLDERS AND DOCUMENTS
retString = oUACLs.Contains(sUserID).ToString()
Next
Return retString(目前我已经硬编码了用户对WorkSpace的定义访问权限,这将在上线前更改为动态值)。
因为我已经有了 WorkSpace 对象,所以
COM Developers Reference Guide (pg 244)
说我需要获取一个 IManProfiledFolder 对象,然后获取属于配置文件夹对象的配置文件:
代码:
Dim objProfFldr as IManProfiledFolder = w
w 在我上面的代码中是一个 IManWorkSpace
Dim objProf as IManProfile = objProfFldr.Profile
然后我可以通过以下方式获取 WorkSpace 安全对象:
Dim oSecurity AS IManSecurity = w.SecurityAnd
把它们放在一起,我想这使得完整的 Refile()
方法被称为 Refile(objProf, oSecurity)
.
我只是不清楚如何将这一切应用到工作区,我是否需要遍历所有子文件夹并将 Refile() 方法应用到每个文档,或者我可以在工作区发出一个方法将为我进行迭代的级别?
遗憾的是,没有文件夹或工作区级别的重新归档方法。 Refile
方法仅在 IManDocument
对象上可用,因此您必须递归枚举每个文件夹,它是工作区中的 .Contents
并在每个文档上调用 Refile
方法。
您应该检查 Refile 方法的 return 值 (IManProfileUpdateResult
),因为如果用户锁定了他们的文档,您可能无权修改文档配置文件。
您可以在 IManWorkspace 对象的以下方法之一的帮助下实现此行为:
IManProfileUpdateResult UpdateAllWithResults(string file);
void UpdateAll(string file, ref object errors);
For more details please take a look into the "iManage WorkSite COM
Developer’s Reference Guide (p.334)"
以下辅助方法可能会有所帮助:
public void UpdateWorkspace(IManWorkspace workspace)
{
var filePath = Path.GetTempFileName();
try
{
if (workspace.HasObjectID)
workspace.GetCopy(filePath);
var results = workspace.UpdateAllWithResults(filePath);
if (!results.Succeeded)
{
// Error handling
}
}
finally
{
if (File.Exists(filePath))
File.Delete(filePath);
}
}
希望对您或其他人有所帮助。
使用 Web 服务的 SDK,我已经能够将用户添加到 WorkSpace 并授予他们访问权限,但是 WorkSpace 没有重新归档,因此他们实际上只能访问根文件夹而没有其他权限.
我知道有 Refile()
方法,我只是不确定如何在 WorkSpace 中执行文件夹和文档的重新归档。
目前我有一个授予用户访问 WorkSpace 的功能,我已经测试并且这个功能有效,以下是该功能的一部分,在此代码之前我已经启动了 WorkSpace 搜索方法并且下面的代码正在迭代通过搜索结果。
Dim retString As String = ""
For Each w As IManWorkspace In oDB.SearchWorkspaces(oparams, oWparams)
' Get the WorkSpace security container
Dim oSec As IManSecurity = w.Security
Dim oUACLs As IManUserACLs = oSec.UserACLs
' Grant the user the defined access
oUACLs.Add(sUserID, imAccessRight.imRightReadWrite)
' Apply the changes
w.Update()
' Refresh the Collection on the client
oUACLs.Refresh()
' TO DO: REFILE THE SUB-FOLDERS AND DOCUMENTS
retString = oUACLs.Contains(sUserID).ToString()
Next
Return retString(目前我已经硬编码了用户对WorkSpace的定义访问权限,这将在上线前更改为动态值)。
因为我已经有了 WorkSpace 对象,所以
COM Developers Reference Guide (pg 244)
说我需要获取一个 IManProfiledFolder 对象,然后获取属于配置文件夹对象的配置文件:
代码:
Dim objProfFldr as IManProfiledFolder = w
w 在我上面的代码中是一个 IManWorkSpace
Dim objProf as IManProfile = objProfFldr.Profile
然后我可以通过以下方式获取 WorkSpace 安全对象:
Dim oSecurity AS IManSecurity = w.SecurityAnd
把它们放在一起,我想这使得完整的 Refile()
方法被称为 Refile(objProf, oSecurity)
.
我只是不清楚如何将这一切应用到工作区,我是否需要遍历所有子文件夹并将 Refile() 方法应用到每个文档,或者我可以在工作区发出一个方法将为我进行迭代的级别?
遗憾的是,没有文件夹或工作区级别的重新归档方法。 Refile
方法仅在 IManDocument
对象上可用,因此您必须递归枚举每个文件夹,它是工作区中的 .Contents
并在每个文档上调用 Refile
方法。
您应该检查 Refile 方法的 return 值 (IManProfileUpdateResult
),因为如果用户锁定了他们的文档,您可能无权修改文档配置文件。
您可以在 IManWorkspace 对象的以下方法之一的帮助下实现此行为:
IManProfileUpdateResult UpdateAllWithResults(string file);
void UpdateAll(string file, ref object errors);
For more details please take a look into the "iManage WorkSite COM Developer’s Reference Guide (p.334)"
以下辅助方法可能会有所帮助:
public void UpdateWorkspace(IManWorkspace workspace)
{
var filePath = Path.GetTempFileName();
try
{
if (workspace.HasObjectID)
workspace.GetCopy(filePath);
var results = workspace.UpdateAllWithResults(filePath);
if (!results.Succeeded)
{
// Error handling
}
}
finally
{
if (File.Exists(filePath))
File.Delete(filePath);
}
}
希望对您或其他人有所帮助。