通过SDK订阅用户My Matters

时间:2015-05-15 00:29:07

标签: sdk autonomy imanage

使用Autonomy WorkSite 8.5 SP2 SDK,我试图通过程序方式向其他用户添加快捷方式My Matters我被告知可以通过首先订阅其他用户My Matters,添加快捷方式然后取消订阅。

因此,我正在尝试订阅其他用户My Matters但是我遇到了如何订阅的问题,使用以下代码我可以找到用户的“我的事项”:

Dim objSFSP As IManSubscriptionFolderSearchParameters = oDms.CreateSubscriptionFolderSearchParameters
objSFSP.Add( imFolderAttributeID.imFolderOwner, sShortcutUser )
Dim objFolders As IManFolders = oMatters.FindRootSubscriptionFoldersNotSubscribedTo(oDatabaseList, objSFSP)

通过阅读COM参考指南,我应该可以使用以下代码订阅用户My Matters:

Dim objWorkArea As IManWorkArea = oSess.WorkArea
Dim oFolderShortcuts As IManSubscriptionFolderShortcuts = objWorkArea.SubscriptionFolder.SubFolders
Dim oFolderShortcut As IManFolderShortcut = oFolderShortcuts.AddNewSubscriptionFolderShortcutInheriting(objFolders)

我遇到的问题是AddNewSubscriptionFolderShortcutInheriting()期望IManSubScriptionFolder类型的对象FindRootSubscriptionFoldersNotSubscribedTo()返回IManFolders个对象。

有人能指出我需要做些什么才能将用户My Matters的实例作为IManSubscriptionFolder对象?

1 个答案:

答案 0 :(得分:2)

对我来说,我的回答可能会有点晚,但我希望它能帮助其他有同样问题的人。

回答你的问题,为了获得其他用户My Matters作为IManSubscriptionFolder对象的实例,你只需要遍历objFolders集合并将每个文件夹转换为IManSubScriptionFolder类型。

请在下面找到我的工作解决方案:

ManDMS dms = new ManDMS();
string serverName = "dms.server.com";
IManSession session = dms.Sessions.Add(serverName);
string userID = "user";
string password = "password";
session.Login(userID, password);

ManStrings dblist = new ManStrings();
dblist.Add("TargetWsDbName");

IManSubscriptionFolderSearchParameters searchParams = ndms.CreateSubscriptionFolderSearchParameters();
string folderOwner = "AnotherUser";
searchParams.Add(imFolderAttributeID.imFolderOwner, folderOwner);
IManFolders nonSubscribedRootSubscriptionFolders = session.WorkArea.SubscriptionFolder.FindRootSubscriptionFoldersNotSubscribedTo(dblist, searchParams);

foreach (var folder in nonSubscribedRootSubscriptionFolders)
{
    //another user's subscription folder
    var subscriptionFolder = folder as IManSubscriptionFolder;
    if (subscriptionFolder != null)
    {
        //Current user's subscription folder shortcuts
        var subscriptionFolderShortcuts = session.WorkArea.SubscriptionFolder.SubFolders as IManSubscriptionFolderShortcuts;
        if (subscriptionFolderShortcuts != null)
        {
            subscriptionFolderShortcuts.AddNewSubscriptionFolderShortcutInheriting(subscriptionFolder);
        }
    }

请注意,上面的代码仅供参考,并非生产代码。