Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
NRTDMS v. IManDMS in ContextItems
bfelknor
This is a refinement of a thread I posted earlier re: using Session.SearchWorkspaces function.
I am able to successfully perform SearchWorkspaces when I instantiate a new MANDMS and use its session(s).
However, when getting the DMS from the ContextItems("NRTDMS") and using its sessions, the SearchWorkspaces function fails with this error:
[NRTSession][SearchPages]An unrecognized exception has occurred.
These are the test circumstances:
VB 6 COM Addin, DeskSite 8
btSession & btiDMS declared as iManSession and MANDms.
btiDMS is set during ICommand_Update to the ContextItems("NRTDMS") object
btSession is set in the same procedure using btiDMS.Sessions.GetItemByName(n) where n matches the desired session name
If, on the other hand, I declare new MANDms & iManSession objects, login, etc...the SearchWorkSpaces succeeds.
I am able to perform the Database.SearchWorkSpaces in either case.
I have been told by Interwoven that the (documented) contextitem "IManDMS" is not supported at this time, and, in any case, I get the same results when trying to use that.
Does anyone have any insight ?
Thanks.
Bruce
Find more posts tagged with
Comments
jny
You should now be able to use IManDMS ContextItem. This was documented as unsupported probably at the time of the first release.
bfelknor
This is in reply to an unsigned request for a test scenario and code sample. I apologize if the following code is too long, but it is at least self-contained and will demonstrate the problem.
Using the test code:
1) This is a class module for COM integration. VB6 sp5.
2) I have been testing it with DeskSite 8. For the sake of discussion, I'll assume you will also test with DeskSite.
3) This can be run from VB in design mode.
Setup:
1) Create a new VB ActiveX DLL Project
2) Point the project Debug/Start Program to your copy of DeskSite.
3) Reference iManage.Dll and iManExtLib
4) Set the ICommand_Name in the Class_Initialize sub, e.g., ICommand_Name = "TestProject.TestWorkSpaceSearch" (or us the name found in the code sample)
5) Add a reference to the class in an appropriate DeskSite Menu. (This project sets an object declares as iManFolder, so, it should be a menu that will return a folder. MyMatters Popup Menu works. The regkey for this is: [HKEY_LOCAL_MACHINE\SOFTWARE\Interwoven\WorkSite\8.0\DeskSite\Commands\Popup Menus\SubscriptionFolder]
Add ",TestProject.TestSearch" (or whatever value you used for the ICommand.Name) to the end of the "Commands" value in this key.
Key Variables:
nDMS and nSession are declared as NRTDMS and NRTSession
iDMS and iSession are declared as iManDMS and iManSesison
Run:
At the top of the ICommand.Update sub is "TestMode" value. This will allow you to execute 4 different tests:
Test 1 sets nDMS = mContext("NRTDMS"); In the ICommand.Execute sub, nDMS is cast to iDMS
Test 2 sets iDMS = mContext("iManDMS") -- skips nDMS altogether
Test 3 sets iDMS = mContext("NRTDMS")
Test 4 the same as Test 2, but iDMS and iSession are re-created as new objects in ICommand.Execute. This is the only TestMode that produces results.
All modes debug.print results. A "valid" result will display a Count of Workspaces returned by the Search. Invalid results print error messages.
The only code of itnerest is in ICommand.Update and ICommand.Execute.
Thanks for your interest.
Bruce
===================================================================================================================
All the code following can be pasted directly into the class module:
Option Explicit
Implements IMANEXTLib.ICommand
Private Declare Function LoadBitmap Lib "user32" Alias "LoadBitmapA" (ByVal hInstance As Long, ByVal lpBitmapName As String) As Long
Private Const tempVirtKey = 65536
Private Const tempNoInvert = 131072
Private Const tempShift = 262144
Private Const tempControl = 524288
Private Const tempAlt = 1048576
Private mAccelerator As Long
Private mBitmap As Long
Private mContext As IMANEXTLib.IContextItems
Private mHelpFile As String
Private mHelpID As String
Private mHelpText As String
Private mMenuText As String
Private mName As String
Private mOptions As Long
Private mStatus As IMANEXTLib.CommandStatus
Private mSubCommands As ICommands
Private mTitle As String
Private mType As IMANEXTLib.CommandType
Private nDMS As NRTDMS
Private nSession As NRTSession
Private iDMS As IManDMS
Private iSession As IManSession
Private TestMode As Integer
Private Sub Class_Initialize()
On Error GoTo ClassInitializeError
ICommand_Name = "TestProject.TestSearch"
ICommand_Title = "Test"
ICommand_Accelerator = Asc("O") + tempVirtKey + tempControl
ICommand_Type = nrStandardCommand
ICommand_Status = nrGrayedCommand
ICommand_MenuText = "Test"
ICommand_HelpText = "Test WorkSpace Search"
ICommand_Bitmap = LoadBitmap(App.hInstance, "BTIMANSYNC")
Exit Sub
ClassInitializeError:
Debug.Print Err, Err.Description
End Sub
Private Sub ICommand_Update()
TestMode = 4
ICommand_MenuText = "Subscriptions Menu"
On Error Resume Next
Dim DestObject As IManObject, SelFolderObject As IManObject
Dim btFolder As IManFolder, SessName As String
mStatus = (mStatus And nrGrayedCommand)
Set DestObject = mContext("IManDestinationObject")
Set SelFolderObject = mContext("SelectedFolderObject")
If Not SelFolderObject Is Nothing Then
Set btFolder = SelFolderObject
End If
On Error GoTo UpdateError
If btFolder Is Nothing Then GoTo Exit_Update
mStatus = nrActiveCommand
SessName = btFolder.Database.Session.ServerName
If TestMode = 1 Then
'Set the nDMS here, and cast to iDMS in the Execute Sub
Set nDMS = mContext("NRTDMS")
Set nSession = nDMS.Sessions(SessName)
ElseIf TestMode = 2 Or TestMode = 4 Then
'iMan Syntax
'Set the iDMS directly here, no recasting in Execute Sub
Set iDMS = mContext("iManDMS")
Set iSession = iDMS.Sessions.ItemByName(SessName)
ElseIf TestMode = 3 Then
'Same as above, but setting the Declared iManDMS to contextitems("NRTDMS")
Set iDMS = mContext("NRTDMS")
Set iSession = iDMS.Sessions.ItemByName(SessName)
End If
Exit_Update:
Set DestObject = Nothing
Set SelFolderObject = Nothing
Exit Sub
UpdateError:
Set DestObject = Nothing
Set SelFolderObject = Nothing
Debug.Print "ICommand.Update Error: " & CStr(Err) & " - " & Err.Description
Err.Clear
GoTo Exit_Update
End Sub
Private Sub ICommand_Execute()
On Error GoTo ExecuteError
Dim wsFolders As IManFolders
Dim db As IManDatabase
Dim wssps As IManWorkspaceSearchParameters
Dim psp As IManProfileSearchParameters
Dim wsDateRange As IManDateRange
Dim strDBs As ManStrings, i As Long
Dim StartDate As Date, EndDate As Date
StartDate = "1-1-2004": EndDate = Now
Debug.Print
Debug.Print "***********", Now, "TestMode:", TestMode
If TestMode > 1 Then GoTo iManContext
NRTContext:
'When nDMS/nSession are declared as NRT objects and capture NRTDMS in context items
Set iDMS = nDMS
Set iSession = nSession
iManContext:
If TestMode = 4 Then
Dim ServerName As String
ServerName = iSession.ServerName
Set iDMS = Nothing
Set iSession = Nothing
Set iDMS = New ManDMS
Set iSession = iDMS.Sessions.Add(ServerName)
iSession.TrustedLogin
If Not iSession.Connected Then
MsgBox "Failed to login to iSession."
GoTo Exit_Sub
End If
End If
'Add all databases from session to database search parms
Set strDBs = New ManStrings
For Each db In iSession.Databases
strDBs.Add db.Name
Next db
Set wssps = iDMS.CreateWorkspaceSearchParameters
wssps.Add imFolderParentID, "NULL" 'For root level workspaces only
'Create the Profile Search Parameters
Set psp = iDMS.CreateProfileSearchParameters
Set wsDateRange = iDMS.CreateDateRange
wsDateRange.AbsoluteStartDate.Value = StartDate
wsDateRange.AbsoluteEndDate.Value = EndDate
psp.Add imProfileCreateDate, wsDateRange.Value
'Execute the Search.
On Error Resume Next
'Syntax 1:
Set wsFolders = iSession.SearchWorkspaces(strDBs, psp, wssps)
Debug.Print "SearchWorkSpaces Syntax 1"
If Err <> 0 Then
Debug.Print "WorkSpace Search Fails with this error:"
Debug.Print Err, Err.Description
Err.Clear
Else
Debug.Print "WorkSpace Search Succeeds and returned this WorkSpace Count", wsFolders.Count
End If
'Syntax 2:
Set wsFolders = Nothing
Set wsFolders = iSession.SearchWorkspaces(strDBs, iDMS.CreateProfileSearchParameters, wssps)
Debug.Print "SearchWorkSpaces Syntax 2"
If Err <> 0 Then
Debug.Print "WorkSpace Search Fails with this error:"
Debug.Print Err, Err.Description
Err.Clear
Else
Debug.Print "WorkSpace Search Succeeds and returned this WorkSpace Count", wsFolders.Count
End If
On Error GoTo ExecuteError
Exit_Sub:
Set wsFolders = Nothing
Set wsDateRange = Nothing
Set psp = Nothing
Set db = Nothing
Set wssps = Nothing
Set wsDateRange = Nothing
Set strDBs = Nothing
Exit Sub
ExecuteError:
Debug.Print "ICommand.Execute Error: " & CStr(Err) & " - " & Err.Description
Err.Clear
GoTo Exit_Sub
End Sub
Private Property Get ICommand_Accelerator() As Long
ICommand_Accelerator = mAccelerator
End Property
Private Property Let ICommand_Accelerator(ByVal newVal As Long)
mAccelerator = newVal
End Property
Private Property Get ICommand_Bitmap() As Variant
ICommand_Bitmap = mBitmap
End Property
Private Property Let ICommand_Bitmap(ByVal newVal As Variant)
mBitmap = newVal
End Property
Private Property Get ICommand_Context() As IMANEXTLib.IContextItems
Set ICommand_Context = mContext
End Property
Private Property Get ICommand_HelpFile() As String
ICommand_HelpFile = mHelpFile
End Property
Private Property Let ICommand_HelpFile(ByVal newVal As String)
mHelpFile = newVal
End Property
Private Property Get ICommand_HelpID() As Long
ICommand_HelpID = mHelpID
End Property
Private Property Let ICommand_HelpID(ByVal newVal As Long)
mHelpID = newVal
End Property
Private Property Get ICommand_HelpText() As String
ICommand_HelpText = mHelpText
End Property
Private Property Let ICommand_HelpText(ByVal newVal As String)
mHelpText = newVal
End Property
Private Property Get ICommand_MenuText() As String
ICommand_MenuText = mMenuText
End Property
Private Property Let ICommand_MenuText(ByVal newVal As String)
mMenuText = newVal
End Property
Private Property Get ICommand_Name() As String
ICommand_Name = mName
End Property
Private Property Let ICommand_Name(ByVal newVal As String)
mName = newVal
End Property
Private Property Get ICommand_Options() As Long
ICommand_Options = mOptions
End Property
Private Property Let ICommand_Options(ByVal newVal As Long)
mOptions = newVal
End Property
Private Property Get ICommand_Status() As IMANEXTLib.CommandStatus
ICommand_Status = mStatus
End Property
Private Property Let ICommand_Status(ByVal newVal As IMANEXTLib.CommandStatus)
mStatus = newVal
End Property
Private Property Get ICommand_SubCommands() As IMANEXTLib.ICommands
Set ICommand_SubCommands = mSubCommands
End Property
Private Property Let ICommand_SubCommands(ByVal newVal As IMANEXTLib.ICommands)
Set mSubCommands = newVal
End Property
Private Property Get ICommand_Title() As String
ICommand_Title = mTitle
End Property
Private Property Let ICommand_Title(ByVal newVal As String)
mTitle = newVal
End Property
Private Property Get ICommand_Type() As IMANEXTLib.CommandType
ICommand_Type = mType
End Property
Private Property Let ICommand_Type(ByVal newVal As IMANEXTLib.CommandType)
mType = newVal
End Property
Private Sub ICommand_Initialize(ByVal Context As IContextItems)
Set mContext = Context
End Sub
jny
In DeskSite 8.0 HF6, I have tested using mContext("IManDMS") in both ICommand_Execute() and ICommand_Update() successfully:
===========================
Private Sub ICommand_Execute()
Dim dms As IManDMS
Dim sess As IManSession
Dim results As IManFolders
Dim wparms As IManWorkspaceSearchParameters
Dim dblist As New ManStrings
On Error GoTo ExecuteError
Set dms = mContext("IManDMS")
Set sess = dms.Sessions.ItemByIndex(1)
With dblist
.Add sess.Databases.ItemByIndex(1).Name
.Add sess.Databases.ItemByIndex(2).Name
End With
Set wparms = dms.CreateWorkspaceSearchParameters
wparms.Add imFolderOwner, sess.UserID
Set results = sess.SearchWorkspaces(dblist, dms.CreateProfileSearchParameters, wparms)
' No error thrown.
End Sub
===========================
===========================
Private Sub ICommand_Update()
Dim dms As IManDMS
Dim sess As IManSession
Set dms = mContext("IManDMS")
Set sess = dms.Sessions.ItemByIndex(1)
...
End Sub
===========================
Also, if you were able to get a handle to the folder object by querying mContext("SelectedFolderObject"), you should be able to get to the dms object off of the folder object, like so:
===========================
Dim idms As IManDMS
Set idms = btFolder.Database.Session.DMS
===========================
It appears that if you were to do a session search for workspaces, you would only need a handle to the session object to create a searchparams, like so:
===========================
Dim wparms As IManWorkspaceSearchParameters
Set wparms = btFolder.Database.Session.DMS.CreateWorkspaceSearchParameters
===========================
bfelknor
Thanks for your time and reply.
Did you actually run my code, or the code snippets in your comment ? (By the way, thanks for the suggestion about derriving DMS / Session from the folder object.)
I have run into situations before where different criteria in code examples causes different results. For example, you used the workspace search parameter for folder owner = current user, whereas I do not use that criteria. I'm using a MANDate, you're not. I'm creating a profile searh parm object and passing it in the SearchWorkspaces call, while you're using the DMS.CreateProfileSearchParameters() in the SearchWorkSpaces call.... Know what I mean ?
I'm not sure what to make of the fact that you can run your own code successfully, while the (problem) example I supplied is untried. I don't mean to suggest that you should help me debug my code, but I would love for someone to tell me, "I ran that code and it works" or "I ran that code and it doesn't work...."
Anyway, jny, Happy Holidays and thanks for the feedback.
Bruce
jny
I used my own search criteria b|c it did not seem to matter in identifying the cause of the search method error.
If, however, you think the search criteria could be the culprit, simply run the ICommand_Update/_Execute implementation code I have included to see if the same problem occurs on your end.
The way to debug so to identify the source of the problem is simply to minimize the original code -- comment out as much as possible to still make the necessary function calls that you have suspected to be problematic.
I did not run your code but did run mine as shown. It is a simpler code to get to the source of the problem. If I could run my simplified code successfully which still had all the calls you made in your code, then the problem could be elsewhere in your code, such as the search criteria (or something elsea) but that would help eliminate your initial suspects -- and eventually moving on to the actual source of the problem in your code.
Alternatively, you may also use the dms/session object off of the folder to set up the search with the same search criteria you had to narrow down the error, and to eliminate the same initially suspected calls.
bfelknor
I ran your code in both the Update & Execute methods and each of them failed with the same error originally reported.
Any ideas ?
Thanks.
Bruce
jny
I attached the code project I used. It appears that the error occurred only if the project is run in debug mode; the error does not happen at run-time. Something is kludgy with VB in running Implement Interface code in the debugger.
bfelknor
Thanks in advance (in advance only because I haven't checked on this yet. BUT THANKS !)