Sub AttachLogFile(doc_setup As NotesDocument, doc_user As NotesDocument, duration As Long) Dim result As Integer Dim setup_duration As Long Dim log_file_path As String Dim log_file_path_zip As String Dim item As NotesItem Dim item_task As NotesItem Dim item_profile As NotesItem Dim rtitem As NotesRichTextItem Dim object As NotesEmbeddedObject Dim temp_directory As String Dim fd_previous As Integer Dim fd_current As Integer Dim previous_log_file_path As String Dim previous_file_date As String Dim previous_file_line As String Dim current_file_line As String Dim previous_line_length As Integer Dim current_line_length As Integer Dim is_task As Integer Dim is_profile As Integer Dim is_audit As Integer ' ################################ ' ######## DskMgrLog.txt file ######## ' # Last Line Call dmDskMgrLogLine ("") ' ## Build Temp Path temp_directory = Environ("Temp") If temp_directory = "" Then Exit Sub If Right$(temp_directory,1) <> "/" And Right$(temp_directory,1) <> "\" Then temp_directory = temp_directory + "\" temp_directory = temp_directory + "DskMgr\" ' # Compute delay between lines Call dmDskMgrLogLine("EndFile") ' ## Remove previous Log file Set item = doc_user.GetFirstItem("Body") If Not (item Is Nothing) Then If ( item.Type = RICHTEXT ) Then Set rtitem = doc_user.GetFirstItem("Body") Set object = rtitem.GetEmbeddedObject("DskMgrLog.txt") If Not( object Is Nothing) Then Call object.Remove Else Set object = rtitem.GetEmbeddedObject("DskMgrLog.zip") If Not( object Is Nothing) Then Call object.Remove End If End If End If End If Call doc_user.RemoveItem("Body") ' ## Insert the new one If Not (doc_setup Is Nothing) Then If Cstr(doc_setup.SETUP_ExecTime(0)) = "" Then setup_duration = 0 Else setup_duration = Clng(doc_setup.SETUP_ExecTime(0)) If doc_setup.SETUP_ExecLog(0) = "1" And (duration > setup_duration Or setup_duration = 0) Then log_file_path = temp_directory + "DskMgrLog.txt" log_file_path_zip = temp_directory + "DskMgrLog.zip" If IsFileExist(log_file_path) = 1 Then Set rtitem = New NotesRichTextItem(doc_user,"Body") ' # Zip File first result = dmZipFile(log_file_path, "DskMgrLog.txt", log_file_path_zip) If result = 0 Then Set object = rtitem.EmbedObject (EMBED_ATTACHMENT,"",log_file_path_zip) Call DeleteFileFromDisk(log_file_path_zip) Else Set object = rtitem.EmbedObject (EMBED_ATTACHMENT,"",log_file_path) End If End If End If End If ' ## Extract TASK and PROFILE parts from Log File Call doc_user.RemoveItem("DM_LogTask") Call doc_user.RemoveItem("DM_LogProfile") log_file_path = temp_directory + "DskMgrLog.txt" If IsFileExist(log_file_path) Then ' # Open Log File fd_current = Freefile() Open log_file_path For Input As fd_current ' ## Read file content Do Until Eof(fd_current) Line Input #fd_current, current_file_line current_line_length = Len(current_file_line) If current_line_length < 5 Then Goto NEXT_LINE If previous_line_length = 25 And current_line_length = 25 Then Goto NEXT_LINE ' # Detect TASK or PROFILE If Right$(current_file_line,Len("########## Processing Tasks")) = "########## Processing Tasks" Then is_task = 1 If Right$(current_file_line,Len("########## Processing Profiles")) = "########## Processing Profiles" Then is_profile = 1 If Right$(current_file_line,Len("########## Processing Audit")) = "########## Processing Audit" Then is_audit = 1 ' ## Store Log Lines into Text List fields If is_audit = 1 Then ' Nothing Elseif is_profile = 1 Then If item_profile Is Nothing Then Call doc_user.ReplaceItemValue("DM_LogProfile",current_file_line) Set item_profile = doc_user.GetFirstItem("DM_LogProfile") item_profile.IsSummary = False Else If item_profile.Valuelength < 64000 Then Call item_profile.AppendToTextList(current_file_line) End If Elseif is_task = 1 Then If item_task Is Nothing Then Call doc_user.ReplaceItemValue("DM_LogTask",current_file_line) Set item_task = doc_user.GetFirstItem("DM_LogTask") item_task.IsSummary = False Else If item_task.Valuelength < 64000 Then Call item_task.AppendToTextList(current_file_line) End If End If NEXT_LINE: previous_line_length = current_line_length Loop ' # Close file Close fd_current ' # Build Empty fields (if needed) If item_task Is Nothing Then Call doc_user.ReplaceItemValue("DM_LogTask","") Set item_task = doc_user.GetFirstItem("DM_LogTask") End If If item_profile Is Nothing Then Call doc_user.ReplaceItemValue("DM_LogProfile","") Set item_profile = doc_user.GetFirstItem("DM_LogProfile") End If ' # Remove Summary flags item_task.IsSummary = False item_profile.IsSummary = False End If ' ################################### ' ######## DskMgrExeLog.txt file ######## ' # Remove previous Log file Set item = doc_user.GetFirstItem( "BodyExe" ) If Not (item Is Nothing) Then If ( item.Type = RICHTEXT ) Then Set rtitem = doc_user.GetFirstItem( "BodyExe" ) Set object = rtitem.GetEmbeddedObject("DskMgrExeLog.txt") If Not( object Is Nothing) Then Call object.Remove Else Set object = rtitem.GetEmbeddedObject("DskMgrExeLog.zip") If Not( object Is Nothing) Then Call object.Remove End If End If End If End If Call doc_user.RemoveItem("BodyExe") ' ### Insert the new one log_file_path = temp_directory + "DskMgrExeLog.txt" log_file_path_zip = temp_directory + "DskMgrExeLog.zip" If Not (doc_setup Is Nothing) Then If Cstr(doc_setup.SETUP_ExecTime(0)) = "" Then setup_duration = 0 Else setup_duration = Clng(doc_setup.SETUP_ExecTime(0)) If doc_setup.SETUP_ExecLog(0) = "1" And (duration > setup_duration Or setup_duration = 0) Then If IsFileExist(log_file_path) = 1 Then ' ## Attach the new one Set rtitem = New NotesRichTextItem(doc_user,"BodyExe") ' # Zip File first result = dmZipFile(log_file_path, "DskMgrExeLog.txt", log_file_path_zip) If result = 0 Then Set object = rtitem.EmbedObject (EMBED_ATTACHMENT,"",log_file_path_zip) Else Set object = rtitem.EmbedObject (EMBED_ATTACHMENT,"",log_file_path) End If End If End If End If ' ## Rename previous DskMgrExeLog.txt file ' # Get File date If IsFileExist(log_file_path) Then ' # Get First Line fd_previous = Freefile() Open log_file_path For Input As fd_previous Line Input #fd_previous, previous_file_line Close fd_previous ' # Set new name to previous file If Len(previous_file_line) > Len("2008/12/15 10:36:12") Then previous_file_date = Mid$(previous_file_line,1,4) + Mid$(previous_file_line,6,2) + Mid$(previous_file_line,9,2) + "_" + Mid$(previous_file_line,12,2) + Mid$(previous_file_line,15,2) + Mid$(previous_file_line,18,2) previous_log_file_path = temp_directory + "DskMgrExeLog_" + previous_file_date + ".txt" ' # Rename File Name log_file_path As previous_log_file_path End If End If ' # Remove the Log file from disk Call DeleteFileFromDisk(log_file_path) If IsFileExist(log_file_path_zip) = 1 Then Call DeleteFileFromDisk(log_file_path_zip) End Sub