Import Lotusphere presentations into session database
Have you downloaded the Lotusphere 2010 presentation files already and are you now switching between LS agenda and your file folder to find out what session id belongs to what session?
Wouldn't it be nice to be able to browse through the sessions by day, speaker etc. and view the short descriptions together with the presentation files?
Here is how you can do this:
The guys at Genii Software offer their LS2010_SessionsDB for download with all the meta information for the Lotusphere 2010 sessions. Great job!! Download the LS2010_SessionsDB here.
Then use the Lotusscript code below to populate this database with your presentations - and voilĂ , you have all the information together.
Make sure you adjust the constants in the top section of the code to your own environment; if you have any questions, leave me a note. All presentations have to be in the same folder. I did not try it with a different OS then Windows, so I don't know if the code works for UNIX/Linux/Mac. Could though ;-) The agent writes a CSV file with the upload logs and you can choose if you want to upload only the colored, the black/white or all presentations. Have fun!
Wouldn't it be nice to be able to browse through the sessions by day, speaker etc. and view the short descriptions together with the presentation files?
Here is how you can do this:
The guys at Genii Software offer their LS2010_SessionsDB for download with all the meta information for the Lotusphere 2010 sessions. Great job!! Download the LS2010_SessionsDB here.
Then use the Lotusscript code below to populate this database with your presentations - and voilĂ , you have all the information together.
Make sure you adjust the constants in the top section of the code to your own environment; if you have any questions, leave me a note. All presentations have to be in the same folder. I did not try it with a different OS then Windows, so I don't know if the code works for UNIX/Linux/Mac. Could though ;-) The agent writes a CSV file with the upload logs and you can choose if you want to upload only the colored, the black/white or all presentations. Have fun!
Sub Initialize
On Error Goto errorhandler
Const FILEPATH_RESOURCES = "C:\ls10_sessions\" ' file path of all presentations (including terminating slash)
Const SERVER_LS_DB = "" ' server of session database
Const FILEPATH_LS_DB = "ls10/LSess10.nsf" ' file path of session database (relative path)
Const FILEPATH_LOG = "C:\ls10.csv" ' file path of log; will be created / overwritten if it exists
Const UPLOAD_MODE = "color" ' options are: "color", "bw", "all" (uploading colored presentations only, black/white presentations or all)
' check constant upload_mode
Select Case UPLOAD_MODE
Case "color", "bw", "all"
Case Else
Msgbox "Invalid option for constant UPLOAD_MODE: " & UPLOAD_MODE & "." & Chr$(13) & " Only 'color', 'bw' or 'all' allowed."
Goto e
End Select
' get session database & view
Dim dbLS As New NotesDatabase(SERVER_LS_DB, FILEPATH_LS_DB)
If Not dbLS.IsOpen Then
Msgbox "Unable to open database " & SERVER_LS_DB & "!" & FILEPATH_LS_DB
Goto e
End If
Dim vBySessionID As NotesView
Set vBySessionID = dbLS.GetView("BySessionID")
If vBySessionID Is Nothing Then
Msgbox "View BySessionID not found in database " & SERVER_LS_DB & "!" & FILEPATH_LS_DB
Goto e
End If
Open FILEPATH_LOG For Output As #1
Print #1, "SESSIONID;FILENAME;UNID;LOGSHORT;LOG"
Dim filename As String
filename = Dir$(FILEPATH_RESOURCES, 0)
Dim docSession As NotesDocument
Dim sessionID As String
Dim embObj As NotesEmbeddedObject
Dim varBody As Variant
Dim isSkip As Boolean
Do While filename <> ""
Print filename
sessionID = Trim(Strtoken(filename, ".", 1))
' check upload mode - process file?
isSkip = False
Select Case UPLOAD_MODE
Case "color"
If Lcase(Right$(sessionID, "2")) = "bw" Then
isSkip = True
End If
Case "bw"
If Lcase(Right$(sessionID, "2")) <> "bw" Then
isSkip = True
End If
End Select
If Not isSkip Then
' get session ID and session
If Lcase(Right$(sessionID, "2")) = "bw" Then
sessionID = Left$(sessionID, Len(sessionID) - 2)
End If
Set docSession = vBySessionID.GetDocumentByKey(sessionID, True)
If docSession Is Nothing Then
Print #1, sessionID & ";" & filename & ";;NO MATCH;No match found for session ID " & sessionID
Else
' check if old attachment exists with same name; do not upload again
Set embObj = docSession.GetAttachment(filename)
If Not embObj Is Nothing Then
Print #1, sessionID & ";" & filename & ";" & docSession.UniversalID & ";FILE EXISTS;Session ID " & sessionID & " already contains a file named " & filename & ". Skipped"
Else
' check if Body RT item exists / if not, create if possible
Set varBody = docSession.GetFirstItem("Body")
If varBody Is Nothing Then
Set varBody = New NotesRichTextItem(docSession, "Body")
Elseif varBody.Type <> 1 Then
If varBody.Text = "" Then
Call varBody.Remove()
Set varBody = New NotesRichTextItem(docSession, "Body")
Else
Print #1, sessionID & ";" & filename & ";" & docSession.UniversalID & ";UNABLE TO UPLOAD;Session ID " & sessionID & " contains a Body item that is not a NotesRichTextItem and that contains text. Skipped."
End If
End If
' upload file
If Not varBody Is Nothing Then
Call varBody.EmbedObject(EMBED_ATTACHMENT, "", FILEPATH_RESOURCES & filename)
Call docSession.Save(True, False, False)
Print #1, sessionID & ";" & filename & ";" & docSession.UniversalID & ";UPLOADED;Session ID " & sessionID & ": attached file " & filename & " (" & FILEPATH_RESOURCES & "/" & filename & ")"
End If
End If
End If
End If
filename = Dir$()
Loop
e:
Close
Exit Sub
errorhandler:
Msgbox "Error " & Error & " in line " & Erl
Resume e
End Sub
On Error Goto errorhandler
Const FILEPATH_RESOURCES = "C:\ls10_sessions\" ' file path of all presentations (including terminating slash)
Const SERVER_LS_DB = "" ' server of session database
Const FILEPATH_LS_DB = "ls10/LSess10.nsf" ' file path of session database (relative path)
Const FILEPATH_LOG = "C:\ls10.csv" ' file path of log; will be created / overwritten if it exists
Const UPLOAD_MODE = "color" ' options are: "color", "bw", "all" (uploading colored presentations only, black/white presentations or all)
' check constant upload_mode
Select Case UPLOAD_MODE
Case "color", "bw", "all"
Case Else
Msgbox "Invalid option for constant UPLOAD_MODE: " & UPLOAD_MODE & "." & Chr$(13) & " Only 'color', 'bw' or 'all' allowed."
Goto e
End Select
' get session database & view
Dim dbLS As New NotesDatabase(SERVER_LS_DB, FILEPATH_LS_DB)
If Not dbLS.IsOpen Then
Msgbox "Unable to open database " & SERVER_LS_DB & "!" & FILEPATH_LS_DB
Goto e
End If
Dim vBySessionID As NotesView
Set vBySessionID = dbLS.GetView("BySessionID")
If vBySessionID Is Nothing Then
Msgbox "View BySessionID not found in database " & SERVER_LS_DB & "!" & FILEPATH_LS_DB
Goto e
End If
Open FILEPATH_LOG For Output As #1
Print #1, "SESSIONID;FILENAME;UNID;LOGSHORT;LOG"
Dim filename As String
filename = Dir$(FILEPATH_RESOURCES, 0)
Dim docSession As NotesDocument
Dim sessionID As String
Dim embObj As NotesEmbeddedObject
Dim varBody As Variant
Dim isSkip As Boolean
Do While filename <> ""
Print filename
sessionID = Trim(Strtoken(filename, ".", 1))
' check upload mode - process file?
isSkip = False
Select Case UPLOAD_MODE
Case "color"
If Lcase(Right$(sessionID, "2")) = "bw" Then
isSkip = True
End If
Case "bw"
If Lcase(Right$(sessionID, "2")) <> "bw" Then
isSkip = True
End If
End Select
If Not isSkip Then
' get session ID and session
If Lcase(Right$(sessionID, "2")) = "bw" Then
sessionID = Left$(sessionID, Len(sessionID) - 2)
End If
Set docSession = vBySessionID.GetDocumentByKey(sessionID, True)
If docSession Is Nothing Then
Print #1, sessionID & ";" & filename & ";;NO MATCH;No match found for session ID " & sessionID
Else
' check if old attachment exists with same name; do not upload again
Set embObj = docSession.GetAttachment(filename)
If Not embObj Is Nothing Then
Print #1, sessionID & ";" & filename & ";" & docSession.UniversalID & ";FILE EXISTS;Session ID " & sessionID & " already contains a file named " & filename & ". Skipped"
Else
' check if Body RT item exists / if not, create if possible
Set varBody = docSession.GetFirstItem("Body")
If varBody Is Nothing Then
Set varBody = New NotesRichTextItem(docSession, "Body")
Elseif varBody.Type <> 1 Then
If varBody.Text = "" Then
Call varBody.Remove()
Set varBody = New NotesRichTextItem(docSession, "Body")
Else
Print #1, sessionID & ";" & filename & ";" & docSession.UniversalID & ";UNABLE TO UPLOAD;Session ID " & sessionID & " contains a Body item that is not a NotesRichTextItem and that contains text. Skipped."
End If
End If
' upload file
If Not varBody Is Nothing Then
Call varBody.EmbedObject(EMBED_ATTACHMENT, "", FILEPATH_RESOURCES & filename)
Call docSession.Save(True, False, False)
Print #1, sessionID & ";" & filename & ";" & docSession.UniversalID & ";UPLOADED;Session ID " & sessionID & ": attached file " & filename & " (" & FILEPATH_RESOURCES & "/" & filename & ")"
End If
End If
End If
End If
filename = Dir$()
Loop
e:
Close
Exit Sub
errorhandler:
Msgbox "Error " & Error & " in line " & Erl
Resume e
End Sub




Last seen at...
0 Comments:
Post a Comment
Thank you for your comment. It will be published shortly. Keep having a great day!
<< Home