| Line-No. / Ref. | Code Line |
| 0001 | Private Sub cmdRegenerateArchivedNoteRanges_Click() |
| 0002 | Dim rsTableControl As Recordset |
| 0003 | Dim rsTableToRead As Recordset |
| 0004 | Dim i As Integer |
| 0005 | Dim Temp_Note_ID |
| 0006 | Dim strMessage As String |
| 0007 | Dim StartTime As Date |
| 0008 | Dim RunStartTime As Date |
| 0009 | Dim Duration As Double |
| 0010 | Dim Response As String |
| 0011 | Dim Total_Run As Single |
| 0012 | Dim RunDate As Date |
| 0013 | Dim NumberOfRows As Integer |
| 0014 | Dim RowCount As Integer |
| 0015 | Dim StopRows As Boolean |
| 0016 | Dim Etc_Message As String |
| 0017 | Dim ID_Start As Integer |
| 0018 | Dim ID_End As Integer |
| 0019 | i = 0 |
| 0020 | If MsgBox("Do you want to regenerate ranges of Archived Notes based on the Note_Archive_Regen_Ranges table?", vbYesNo) = vbYes Then |
| 0021 | Etc_Message = " ... Etc. " & Chr(10) |
| 0022 | Set rsTableToRead = CurrentDb.OpenRecordset("SELECT * FROM Note_Archive_Regen_Ranges WHERE [Select?] = True ORDER BY ID_Start;") |
| 0023 | If Not rsTableToRead.EOF Then |
| 0024 | rsTableToRead.MoveFirst |
| 0025 | NumberOfRows = rsTableToRead.RecordCount |
| 0026 | RowCount = 0 |
| 0027 | StopRows = False |
| 0028 | strMessage = "Run for the following range" & IIf(rsTableToRead.RecordCount > 1, "s", "") & "?" & Chr(10) & Chr(10) |
| 0029 | Do While Not rsTableToRead.EOF |
| 0030 | RowCount = RowCount + 1 |
| 0031 | If RowCount < 15 Then |
| 0032 | strMessage = strMessage & rsTableToRead.Fields(0) & ": " & rsTableToRead.Fields(1) & "-" & rsTableToRead.Fields(2) & ": " & Round(rsTableToRead.Fields(5), 0) & " mins (" & Round(rsTableToRead.Fields(4), 0) & ", " & Round((Now() - Round(rsTableToRead.Fields(4))), 0) & " days)" & Chr(10) |
| 0033 | Else |
| 0034 | If StopRows = False Then |
| 0035 | If NumberOfRows > 20 Then |
| 0036 | StopRows = True |
| 0037 | strMessage = strMessage & Etc_Message |
| 0038 | Else |
| 0039 | strMessage = strMessage & rsTableToRead.Fields(0) & ": " & rsTableToRead.Fields(1) & "-" & rsTableToRead.Fields(2) & ": " & Round(rsTableToRead.Fields(5), 0) & " mins (" & Round(rsTableToRead.Fields(4), 0) & ", " & Round((Now() - Round(rsTableToRead.Fields(4))), 0) & " days)" & Chr(10) |
| 0040 | End If |
| 0041 | End If |
| 0042 | End If |
| 0043 | Total_Run = Total_Run + rsTableToRead.Fields(5) |
| 0044 | rsTableToRead.MoveNext |
| 0045 | Loop |
| 0046 | strMessage = strMessage & "Total time = " & Round(Total_Run, 0) & " mins." & Chr(10) & Chr(10) |
| 0047 | Else |
| 0048 | DoCmd.OpenTable ("Note_Archive_Regen_Ranges") |
| 0049 | MsgBox ("No Ranges selected. Update the Note_Archive_Regen_Ranges Table.") |
| 0050 | End |
| 0051 | End If |
| 0052 | Total_Run = 0 |
| 0053 | Set rsTableToRead = CurrentDb.OpenRecordset("SELECT * FROM Note_Archive_Regen_Ranges WHERE [Select?] = False ORDER BY ID_Start;") |
| 0054 | If Not rsTableToRead.EOF Then |
| 0055 | NumberOfRows = NumberOfRows + rsTableToRead.RecordCount |
| 0056 | strMessage = strMessage & "Not selected:- " & Chr(10) & Chr(10) |
| 0057 | rsTableToRead.MoveFirst |
| 0058 | Do While Not rsTableToRead.EOF |
| 0059 | RowCount = RowCount + 1 |
| 0060 | If StopRows = False Then |
| 0061 | strMessage = strMessage & rsTableToRead.Fields(0) & ": " & rsTableToRead.Fields(1) & "-" & rsTableToRead.Fields(2) & ": " & Round(rsTableToRead.Fields(5), 0) & " mins (" & Round(rsTableToRead.Fields(4), 0) & ", " & Round((Now() - Round(rsTableToRead.Fields(4))), 0) & " days)" & Chr(10) |
| 0062 | End If |
| 0063 | If RowCount > 18 Then |
| 0064 | If NumberOfRows > 20 Then |
| 0065 | StopRows = True |
| 0066 | strMessage = strMessage & Etc_Message |
| 0067 | Etc_Message = "" |
| 0068 | End If |
| 0069 | End If |
| 0070 | Total_Run = Total_Run + rsTableToRead.Fields(5) |
| 0071 | rsTableToRead.MoveNext |
| 0072 | Loop |
| 0073 | strMessage = strMessage & "Total time outstanding = " & Round(Total_Run, 0) & " mins." & Chr(10) & Chr(10) |
| 0074 | End If |
| 0075 | Response = MsgBox(strMessage, vbYesNo) |
| 0076 | If Response = vbNo Then |
| 0077 | DoCmd.OpenTable ("Note_Archive_Regen_Ranges") |
| 0078 | MsgBox ("Update the Note_Archive_Regen_Ranges Table.") |
| 0079 | End |
| 0080 | Else |
| 0081 | RunStartTime = Now() |
| 0082 | Set rsTableToRead = CurrentDb.OpenRecordset("SELECT * FROM Note_Archive_Regen_Ranges WHERE [Select?] = True ORDER BY ID_Start;") |
| 0083 | If Not rsTableToRead.EOF Then |
| 0084 | rsTableToRead.MoveFirst |
| 0085 | Do While Not rsTableToRead.EOF |
| 0086 | StartTime = Now() |
| 0087 | ID_Start = rsTableToRead.Fields(1) |
| 0088 | ID_End = rsTableToRead.Fields(2) |
| 0089 | strQuery = "SELECT [ID], [Timestamp] FROM Notes_Archive WHERE [ID] >= " & ID_Start & " AND [ID] <= " & ID_End & " ORDER BY [ID], [Timestamp]; " |
| 0090 | Set rsTableControl = CurrentDb.OpenRecordset(strQuery) |
| 0091 | If Not rsTableControl.EOF Then |
| 0092 | rsTableControl.MoveFirst |
| 0093 | Do While Not rsTableControl.EOF |
| 0094 | Note_ID = rsTableControl.Fields(0) |
| 0095 | Note_Timestamp = rsTableControl.Fields(1) |
| 0096 | OK = OutputNotesWebPage_Archived(Note_ID, Note_Timestamp) |
| 0097 | i = i + 1 |
| 0098 | rsTableControl.MoveNext |
| 0099 | Loop |
| 0100 | End If |
| 0101 | 'Update the control table |
| 0102 | Duration = Now() - StartTime |
| 0103 | Duration = Duration * 24 * 60 |
| 0104 | Duration = Round(Duration, 1) |
| 0105 | RunDate = Now() |
| 0106 | rsTableToRead.Edit |
| 0107 | rsTableToRead.Fields(4) = RunDate |
| 0108 | rsTableToRead.Fields(5) = Duration |
| 0109 | rsTableToRead.Update |
| 0110 | StartTime = Now() |
| 0111 | rsTableToRead.MoveNext |
| 0112 | Loop |
| 0113 | End If |
| 0114 | End If |
| 0115 | End If |
| 0116 | Duration = (Now() - RunStartTime) * 24 * 60 |
| 0117 | If Duration < 1 Then |
| 0118 | Duration = Round(Duration * 60) |
| 0119 | MsgBox Now() & ": Notes Archive Webpage Creation Complete in " & Duration & " seconds. " & i & " Pages output. ", vbOKOnly, "Create Notes Archive Web Pages" |
| 0120 | Else |
| 0121 | Duration = Round(Duration, 2) |
| 0122 | MsgBox Now() & ": Notes Archive Webpage Creation Complete in " & Duration & " minutes. " & i & " Pages output. ", vbOKOnly, "Create Notes Archive Web Pages" |
| 0123 | End If |
| 0124 | End Sub |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Convert_Webrefs(RunType, Optional RunType2) |
| 0002 | Dim start As Double |
| 0003 | Dim Duration As Double |
| 0004 | Dim rsTableToRead As Recordset |
| 0005 | Dim rsMaintenance As Recordset |
| 0006 | Dim strLine As String |
| 0007 | Dim strLine_New As String |
| 0008 | Dim i As Long |
| 0009 | Dim j As Long |
| 0010 | Dim All_Done As String |
| 0011 | Dim strQuery As String |
| 0012 | Dim Use_Maintainable_Objects As Boolean |
| 0013 | i = 0 |
| 0014 | j = 0 |
| 0015 | If IsMissing(RunType2) Then |
| 0016 | Use_Maintainable_Objects = True |
| 0017 | Else |
| 0018 | Use_Maintainable_Objects = False |
| 0019 | End If |
| 0020 | Err.Clear |
| 0021 | On Error GoTo End_Of |
| 0022 | start = Now() |
| 0023 | If Use_Maintainable_Objects = True Then |
| 0024 | If RunType = "Note_Archive" Then |
| 0025 | DoCmd.RunSQL ("DELETE * FROM Maintainable_Archived_Objects;") |
| 0026 | DoCmd.OpenQuery ("Maintainable_Archived_Objects_GEN") |
| 0027 | Else |
| 0028 | DoCmd.RunSQL ("DELETE * FROM Maintainable_Objects;") |
| 0029 | DoCmd.OpenQuery ("Maintainable_Objects_GEN") |
| 0030 | End If |
| 0031 | End If |
| 0032 | Select Case RunType |
| 0033 | Case "Author" |
| 0034 | If Use_Maintainable_Objects = True Then |
| 0035 | strQuery = "SELECT Authors.Author_ID, Authors.Author_Narrative FROM Maintainable_Objects INNER JOIN Authors ON Maintainable_Objects.Object_ID = Authors.Author_ID WHERE (((Authors.Author_Narrative) Is Not Null) And ((Maintainable_Objects.Object_Type) = ""A"") And ((Maintainable_Objects.Other_Type) = ""W"")) ORDER BY Authors.Author_ID;" |
| 0036 | Else |
| 0037 | strQuery = "SELECT Authors.Author_ID, Authors.Author_Narrative FROM Authors WHERE (((Authors.Author_Narrative) Like ""*http*"")) OR (((Authors.Author_Narrative) Like ""*www*""));" |
| 0038 | End If |
| 0039 | Set rsTableToRead = CurrentDb.OpenRecordset(strQuery) |
| 0040 | Case "Book" |
| 0041 | If Use_Maintainable_Objects = True Then |
| 0042 | strQuery = "SELECT Books.ID1, Books.Comments FROM Books INNER JOIN Maintainable_Objects ON Books.ID1 = Maintainable_Objects.Object_ID WHERE (((Books.Comments) Is Not Null) AND ((Maintainable_Objects.Object_Type) = ""B"") And ((Maintainable_Objects.Other_Type) = ""W"")) ORDER BY Books.ID1;" |
| 0043 | Else |
| 0044 | strQuery = "SELECT Books.ID1, Books.Comments FROM Books WHERE (((Books.Comments) Like ""*http*"")) OR (((Books.Comments) Like ""*www*""));" |
| 0045 | End If |
| 0046 | Set rsTableToRead = CurrentDb.OpenRecordset(strQuery) |
| 0047 | 'The above doesn't seem to work for Notes, so additionally select all "Temp" Notes |
| 0048 | Case "Note" |
| 0049 | If Use_Maintainable_Objects = True Then |
| 0050 | strQuery = "SELECT Notes.ID, Notes.Item_Text FROM Notes LEFT JOIN Maintainable_Objects ON Notes.ID = Maintainable_Objects.Object_ID WHERE (((Notes.Item_Text) Is Not Null) And ((Maintainable_Objects.Object_Type) = ""N"") And ((Maintainable_Objects.Other_Type) = ""W"")) Or (((Notes.Status) = ""Temp"")) ORDER BY Notes.ID;" |
| 0051 | Else |
| 0052 | strQuery = "SELECT Notes.ID, Notes.Item_Text FROM Notes WHERE (((Notes.Item_Text) Like ""*http*"")) OR (((Notes.Item_Text) Like ""*www*""));" |
| 0053 | End If |
| 0054 | Set rsTableToRead = CurrentDb.OpenRecordset(strQuery) |
| 0055 | Case "Note_Archive" |
| 0056 | If Use_Maintainable_Objects = True Then |
| 0057 | strQuery = "SELECT Notes_Archive.ID, Notes_Archive.Item_Text FROM Notes_Archive INNER JOIN Maintainable_Archived_Objects ON (Maintainable_Archived_Objects.Object_Timestamp = Notes_Archive.Timestamp) AND (Notes_Archive.ID = Maintainable_Archived_Objects.Object_ID) WHERE (((Notes_Archive.Item_Text) Is Not Null) And ((Maintainable_Archived_Objects.Object_Type) = ""N"") And ((Maintainable_Archived_Objects.Other_Type) = ""W"")) ORDER BY Notes_Archive.ID;" |
| 0058 | Else |
| 0059 | strQuery = "SELECT Notes_Archive.ID, Notes_Archive.Item_Text FROM Notes_Archive WHERE (((Notes_Archive.Item_Text) Like ""*http*"")) OR (((Notes_Archive.Item_Text) Like ""*www*""));" |
| 0060 | End If |
| 0061 | Set rsTableToRead = CurrentDb.OpenRecordset(strQuery) |
| 0062 | Case "Paper" |
| 0063 | If Use_Maintainable_Objects = True Then |
| 0064 | strQuery = "SELECT Papers.ID, Papers.Comments FROM Papers INNER JOIN Maintainable_Objects ON Papers.ID = Maintainable_Objects.Object_ID WHERE (((Papers.Comments) Is Not Null) AND ((Maintainable_Objects.Object_Type) = ""P"") And ((Maintainable_Objects.Other_Type) = ""W"")) ORDER BY Papers.ID;" |
| 0065 | Else |
| 0066 | strQuery = "SELECT Papers.ID, Papers.Comments FROM Papers WHERE (((Papers.Comments) Like ""*http*"")) OR (((Papers.Comments) Like ""*www*""));" |
| 0067 | End If |
| 0068 | Set rsTableToRead = CurrentDb.OpenRecordset(strQuery) |
| 0069 | Case Else |
| 0070 | MsgBox ("Dud type " & RunType & " in Convert_Webrefs") |
| 0071 | End Select |
| 0072 | If Not rsTableToRead.EOF Then |
| 0073 | rsTableToRead.MoveFirst |
| 0074 | End If |
| 0075 | All_Done = "No" |
| 0076 | Do Until All_Done = "Yes" |
| 0077 | Do Until rsTableToRead.EOF |
| 0078 | i = i + 1 |
| 0079 | strLine = rsTableToRead.Fields(1) |
| 0080 | strLine_New = WebEncode(strLine) |
| 0081 | If strLine_New <> strLine Then |
| 0082 | j = j + 1 |
| 0083 | rsTableToRead.Edit |
| 0084 | rsTableToRead.Fields(1) = strLine_New |
| 0085 | rsTableToRead.Update |
| 0086 | End If |
| 0087 | rsTableToRead.MoveNext |
| 0088 | Loop |
| 0089 | If All_Done = "No" Then |
| 0090 | All_Done = "Half" |
| 0091 | Select Case RunType |
| 0092 | Case "Book" |
| 0093 | If Use_Maintainable_Objects = True Then |
| 0094 | strQuery = "SELECT Books.ID1, Books.Abstract FROM Books INNER JOIN Maintainable_Objects ON Books.ID1 = Maintainable_Objects.Object_ID WHERE (((Books.Abstract) Is Not Null) AND ((Maintainable_Objects.Object_Type) = ""B"") And ((Maintainable_Objects.Other_Type) = ""W"")) ORDER BY Books.ID1;" |
| 0095 | Else |
| 0096 | strQuery = "SELECT Books.ID1, Books.Abstract FROM Books WHERE (((Books.Abstract) Like ""*http*"")) OR (((Books.Abstract) Like ""*www*""));" |
| 0097 | End If |
| 0098 | Set rsTableToRead = CurrentDb.OpenRecordset(strQuery) |
| 0099 | Case "Paper" |
| 0100 | If Use_Maintainable_Objects = True Then |
| 0101 | strQuery = "SELECT Papers.ID, Papers.Abstract FROM Papers INNER JOIN Maintainable_Objects ON Papers.ID = Maintainable_Objects.Object_ID WHERE (((Papers.Abstract) Is Not Null) AND ((Maintainable_Objects.Object_Type) = ""P"") And ((Maintainable_Objects.Other_Type) = ""W"")) ORDER BY Papers.ID;" |
| 0102 | Else |
| 0103 | strQuery = "SELECT Papers.ID, Papers.Abstract FROM Papers WHERE (((Papers.Abstract) Like ""*http*"")) OR (((Papers.Abstract) Like ""*www*""));" |
| 0104 | End If |
| 0105 | Set rsTableToRead = CurrentDb.OpenRecordset(strQuery) |
| 0106 | Case Else |
| 0107 | All_Done = "Yes" |
| 0108 | End Select |
| 0109 | Else |
| 0110 | All_Done = "Yes" |
| 0111 | End If |
| 0112 | Loop |
| 0113 | If Use_Maintainable_Objects = True Then |
| 0114 | Set rsMaintenance = CurrentDb.OpenRecordset("SELECT Maintenance_Dates.Webref_Date FROM Maintenance_Dates WHERE (((Maintenance_Dates.Object)=""" & RunType & """));") |
| 0115 | If Not rsMaintenance.EOF Then |
| 0116 | rsMaintenance.MoveFirst |
| 0117 | rsMaintenance.Edit |
| 0118 | rsMaintenance.Fields(0) = start |
| 0119 | rsMaintenance.Update |
| 0120 | End If |
| 0121 | End If |
| 0122 | End_Of: |
| 0123 | Set rsTableToRead = Nothing |
| 0124 | Set rsMaintenance = Nothing |
| 0125 | If Err.Number > 0 Then |
| 0126 | strLine = "Convert_Webrefs: " & RunType & " error. Number: " & Err.Number & ". Name: " & Err.Description |
| 0127 | Debug.Print Now() & " - "; strLine |
| 0128 | Else |
| 0129 | Duration = Round((Now() - start) * 24 * 60 * 60, 2) |
| 0130 | If automatic_processing <> "Yes" Then |
| 0131 | strLine = "Convert_Webrefs: " & RunType & " (" & Duration & " seconds; " & j & " updates of " & i & " records)" |
| 0132 | Debug.Print Now() & " - "; strLine |
| 0133 | End If |
| 0134 | End If |
| 0135 | End Function |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Reference_Webrefs(strText, Calling_Type, Calling_ID, Calling_Timestamp, Optional ShowLink) |
| 0002 | Dim x As Long |
| 0003 | Dim Y As Long |
| 0004 | Dim Weblink As Long |
| 0005 | Dim strWebRef As String |
| 0006 | Dim strText_Local As String |
| 0007 | Dim strText_End As String |
| 0008 | Dim qryString As String |
| 0009 | Dim rsTableToRead As Recordset |
| 0010 | Dim rsMissingWebrefs As Recordset |
| 0011 | Dim WebRef_Missing_IDs_Open As Boolean |
| 0012 | Dim Web_Reference As String |
| 0013 | Dim Visible_Reference As String |
| 0014 | Dim Display_Text As String |
| 0015 | Dim Defunct_Reference As Boolean |
| 0016 | Dim WebID As Integer |
| 0017 | Dim Private_Area As String |
| 0018 | Dim FairUse As String |
| 0019 | Private_Area = "http://www.theotodman.com/PDFs/" |
| 0020 | FairUse = "This document was found on the Web at a URL that no longer exists. I've added the document to my own site on a 'fair use' basis. If you are the author and wish me to remove it please let me know. " |
| 0021 | FairUse = "Fair Use" |
| 0022 | If Len(strText) = 0 Then |
| 0023 | Reference_Webrefs = "Not Found" |
| 0024 | Exit Function |
| 0025 | End If |
| 0026 | strText_Local = strText |
| 0027 | WebRef_Missing_IDs_Open = False |
| 0028 | x = 1 |
| 0029 | x = InStr(x, strText_Local, "+W") |
| 0030 | Reference_Webrefs = "Not Found" |
| 0031 | Do While x > 0 |
| 0032 | Reference_Webrefs = "Found" |
| 0033 | Y = InStr(x + 1, strText_Local, "W+") |
| 0034 | 'Watch out for false positives in finding +W |
| 0035 | If Y = 0 Then |
| 0036 | x = x + 1 |
| 0037 | Else |
| 0038 | If Y - x > 7 Then |
| 0039 | x = x + 1 |
| 0040 | Else |
| 0041 | strWebRef = Mid(strText_Local, x + 2, Y - x - 2) |
| 0042 | If Not IsNumeric(strWebRef) Then |
| 0043 | x = x + 1 |
| 0044 | Else |
| 0045 | Weblink = Trim(strWebRef) |
| 0046 | If Y > Len(strText_Local) - 2 Then |
| 0047 | strText_End = "" |
| 0048 | Else |
| 0049 | strText_End = Mid(strText_Local, Y + 2, Len(strText_Local)) |
| 0050 | End If |
| 0051 | 'Determine Web Link |
| 0052 | Web_Reference = "" |
| 0053 | qryString = "SELECT Webrefs_Table.ID, Webrefs_Table.Webref, Webrefs_Table.Display_Text, Webrefs_Table.[Defunct?] FROM Webrefs_Table WHERE (((Webrefs_Table.ID)=" & Weblink & "));" |
| 0054 | Set rsTableToRead = CurrentDb.OpenRecordset(qryString) |
| 0055 | If Not rsTableToRead.EOF Then |
| 0056 | rsTableToRead.MoveFirst |
| 0057 | WebID = rsTableToRead.Fields(0).Value |
| 0058 | Web_Reference = rsTableToRead.Fields(1).Value |
| 0059 | Display_Text = rsTableToRead.Fields(2).Value & "" |
| 0060 | Defunct_Reference = rsTableToRead.Fields(3).Value |
| 0061 | If Display_Text = "" Then |
| 0062 | Display_Text = "Link" |
| 0063 | End If |
| 0064 | If IsMissing(ShowLink) Then |
| 0065 | Visible_Reference = "" |
| 0066 | Else |
| 0067 | Visible_Reference = " (" & Web_Reference & ")" |
| 0068 | End If |
| 0069 | If Defunct_Reference = True Then |
| 0070 | If Visible_Reference = "" Then |
| 0071 | Visible_Reference = " (Defunct)" |
| 0072 | Else |
| 0073 | Visible_Reference = " - Defunct" |
| 0074 | End If |
| 0075 | End If |
| 0076 | 'Check if in my private area ... add "fair use" |
| 0077 | If Left(Web_Reference, Len(Private_Area)) = Private_Area Then |
| 0078 | If Visible_Reference = "" Then |
| 0079 | Visible_Reference = " (" & FairUse & ")" |
| 0080 | Else |
| 0081 | Visible_Reference = " - " & FairUse |
| 0082 | End If |
| 0083 | End If |
| 0084 | Web_Reference = "" & Display_Text & "" & Visible_Reference |
| 0085 | 'strText_Local = Left(strText_Local, x - 1) & IIf(Calling_Type <> "X", "", "") & Web_Reference & strText_End |
| 0086 | strText_Local = Left(strText_Local, x - 1) & "" & Web_Reference & strText_End |
| 0087 | x = x + Len(Web_Reference) |
| 0088 | Else |
| 0089 | WebID = 0 |
| 0090 | Web_Reference = """Unknown Web Reference""" |
| 0091 | Debug.Print Now() & " - "; "Unknown WebRef", Weblink, Calling_Type, Calling_ID |
| 0092 | If WebRef_Missing_IDs_Open = False Then |
| 0093 | Set rsMissingWebrefs = CurrentDb.OpenRecordset("SELECT * FROM WebRef_Missing_IDs WHERE WebRef_Missing_IDs.ID = 0;") |
| 0094 | WebRef_Missing_IDs_Open = True |
| 0095 | End If |
| 0096 | rsMissingWebrefs.AddNew |
| 0097 | rsMissingWebrefs.Fields(1) = Weblink |
| 0098 | rsMissingWebrefs.Fields(2) = Calling_Type |
| 0099 | rsMissingWebrefs.Fields(3) = Calling_ID |
| 0100 | rsMissingWebrefs.Fields(4) = Calling_Timestamp / 1000 |
| 0101 | rsMissingWebrefs.Fields(5) = Now() |
| 0102 | rsMissingWebrefs.Update |
| 0103 | 'strText_Local = Left(strText_Local, x - 1) & IIf(Calling_Type <> "X", "", "") & Web_Reference & strText_End |
| 0104 | strText_Local = Left(strText_Local, x - 1) & "" & Web_Reference & strText_End |
| 0105 | End If |
| 0106 | If Calling_Type <> "X" Then |
| 0107 | OK = Cross_Reference_Add(Calling_Type, Calling_ID, Calling_Timestamp, "W", WebID, 0) |
| 0108 | End If |
| 0109 | Set rsTableToRead = Nothing |
| 0110 | End If |
| 0111 | End If |
| 0112 | End If |
| 0113 | x = InStr(x, strText_Local, "+W") |
| 0114 | Loop |
| 0115 | Set rsMissingWebrefs = Nothing |
| 0116 | strText = strText_Local |
| 0117 | End Function |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Spider_WebLinks_Tester_Page_Gen(Optional Map, Optional Defunct) |
| 0002 | Dim strOutputFolder As String |
| 0003 | Dim strOutputFile As String |
| 0004 | Dim strLine As String |
| 0005 | Dim rsTableControl2 As Recordset |
| 0006 | Dim i As Integer |
| 0007 | Dim j As Integer |
| 0008 | Dim k As Integer |
| 0009 | Dim m As Integer |
| 0010 | Dim FileName As String |
| 0011 | Dim FileName_Root As String |
| 0012 | Dim ifields As Integer |
| 0013 | Dim strControlQuery As String |
| 0014 | Dim rs As Recordset |
| 0015 | Dim rsFooterControl As Recordset |
| 0016 | Dim rsWebRef_Maps As Recordset |
| 0017 | Dim rsWebLinkCheck_Map As Recordset |
| 0018 | Dim x As String |
| 0019 | Dim Link_Saved As String |
| 0020 | Dim Link_Returned_Saved As String |
| 0021 | Dim Link_Narr As String |
| 0022 | Dim File_Sub As Integer |
| 0023 | Dim strFile_Sub As String |
| 0024 | Dim strJump_Table As String |
| 0025 | Dim Issue_Saved As String |
| 0026 | Dim strQuery As String |
| 0027 | Dim Last_Regen As Date |
| 0028 | Dim strLast_Regen As String |
| 0029 | Dim Last_Regen_Day As Integer |
| 0030 | Dim Last_Regen_Month As String |
| 0031 | Dim Last_Regen_Year As Integer |
| 0032 | Dim strLink_Called As String |
| 0033 | Dim strObject As String |
| 0034 | Dim Date_Webrefs_Table_Max As Date |
| 0035 | Dim Date_WebRef_Maps_Max As Date |
| 0036 | Dim strJump_Page_Title As String |
| 0037 | Dim Missing_Page As Boolean |
| 0038 | Dim Repeat_Line As Boolean |
| 0039 | Dim Same_Line As Boolean |
| 0040 | Dim ID_Saved As String |
| 0041 | Dim strQuery2 As String |
| 0042 | Dim strDefunct As String |
| 0043 | If IsMissing(Map) Then 'Use Links from the Spider |
| 0044 | DoCmd.RunSQL ("DELETE * FROM WebLinkCheck;") |
| 0045 | DoCmd.OpenQuery ("Spider_Weblinks_Add") |
| 0046 | 'Prune - The Raw_Links table contains ancient stuff no longer relevant to current pages |
| 0047 | strQuery = "SELECT Min(Last_Run) AS MinOfLast_Run FROM Website_Regen_Control;" |
| 0048 | Set rs = CurrentDb.OpenRecordset(strQuery) |
| 0049 | rs.MoveFirst |
| 0050 | Last_Regen = rs.Fields(0) - 1 |
| 0051 | Last_Regen_Day = Day(Last_Regen) |
| 0052 | Last_Regen_Month = Month(Last_Regen) |
| 0053 | Last_Regen_Month = MonthName(Last_Regen_Month) |
| 0054 | Last_Regen_Year = Year(Last_Regen) |
| 0055 | strLast_Regen = Last_Regen_Day & " " & Last_Regen_Month & " " & Last_Regen_Year |
| 0056 | strLast_Regen = "31 December 2016" 'Bodge ... as if the Spider has not been run since the last regen, everything gets deleted! |
| 0057 | 'Correction to allow for standard MS Date muddle - the above query was deleting everything in February! |
| 0058 | strQuery = "DELETE WebLinkCheck.*, WebLinkCheck.Timestamp_Logged FROM WebLinkCheck WHERE (((WebLinkCheck.Timestamp_Logged)<#" & strLast_Regen & "#));" |
| 0059 | DoCmd.RunSQL (strQuery) |
| 0060 | FileName_Root = "WebLinks_Tester" |
| 0061 | Set rs = Nothing |
| 0062 | Else |
| 0063 | 'Use Links from WebRef_Maps |
| 0064 | 'First check if need to re-generate the WebRef_Maps table |
| 0065 | Set rs = CurrentDb.OpenRecordset("SELECT Max(Webrefs_Table.Date_Created) AS MaxOfDate_Created FROM Webrefs_Table;") |
| 0066 | rs.MoveFirst |
| 0067 | Date_Webrefs_Table_Max = rs.Fields(0) |
| 0068 | Set rs = Nothing |
| 0069 | Set rs = CurrentDb.OpenRecordset("SELECT Max(WebRef_Maps.Timestamp) AS MaxOfTimestamp FROM WebRef_Maps;") |
| 0070 | rs.MoveFirst |
| 0071 | Date_WebRef_Maps_Max = rs.Fields(0) |
| 0072 | Set rs = Nothing |
| 0073 | If Date_WebRef_Maps_Max < Date_Webrefs_Table_Max Then |
| 0074 | Map_WebRefs |
| 0075 | End If |
| 0076 | 'Now create the WebLinkCheck_Map table |
| 0077 | DoCmd.RunSQL ("DELETE * FROM WebLinkCheck_Map;") |
| 0078 | Set rsWebRef_Maps = CurrentDb.OpenRecordset("SELECT WebRef_Maps.WebRef_ID, WebRef_Maps.Object_Type, WebRef_Maps.Object_ID, WebRef_Maps.Object_Sub_ID, Webrefs_Table.Webref, Webrefs_Table.Alt_Ref, Webrefs_Table.Issue, Webrefs_Table.[Defunct?], Webrefs_Table.Display_Text, Webrefs_Table.Date_Last_Checked, Webrefs_Table.Check_Time, WebRef_Maps.Object_Security, Webrefs_Table.Defunct_Explanation FROM WebRef_Maps INNER JOIN Webrefs_Table ON WebRef_Maps.WebRef_ID = Webrefs_Table.ID;") |
| 0079 | Set rsWebLinkCheck_Map = CurrentDb.OpenRecordset("SELECT * FROM WebLinkCheck_Map;") |
| 0080 | rsWebRef_Maps.MoveFirst |
| 0081 | Do While Not rsWebRef_Maps.EOF |
| 0082 | rsWebLinkCheck_Map.AddNew |
| 0083 | rsWebLinkCheck_Map.Fields(0) = rsWebRef_Maps.Fields(0) 'WebRef ID |
| 0084 | rsWebLinkCheck_Map.Fields(1) = rsWebRef_Maps.Fields(4) 'Link Called |
| 0085 | strObject = rsWebRef_Maps.Fields(1) |
| 0086 | Select Case strObject |
| 0087 | Case "Author" |
| 0088 | Set rs = CurrentDb.OpenRecordset("SELECT * FROM Authors WHERE Authors.Author_ID = " & rsWebRef_Maps.Fields(2) & ";") |
| 0089 | If Not rs.EOF Then |
| 0090 | rs.MoveFirst |
| 0091 | strLink_Called = "Authors/" & Left(rs.Fields(0), 1) & "/Author_" & rs.Fields(0) |
| 0092 | Else |
| 0093 | strLink_Called = "" |
| 0094 | End If |
| 0095 | Set rs = Nothing |
| 0096 | Case "Book" |
| 0097 | strLink_Called = "BookSummaries/BookSummary_" & Mid(rsWebRef_Maps.Fields(2) + 1000000, 3, 2) & "/BookPaperAbstracts/BookPaperAbstracts_" & rsWebRef_Maps.Fields(2) |
| 0098 | 'Need a check for the Note Group for Secure_Jen here! |
| 0099 | Case "Note" |
| 0100 | If rsWebRef_Maps.Fields(11) & "" = "10" Then |
| 0101 | strLink_Called = "Secure_Jen/Notes_" & Val(Mid(rsWebRef_Maps.Fields(2) + 1000000, 4, 2)) & "/Notes_" & rsWebRef_Maps.Fields(2) |
| 0102 | Else |
| 0103 | strLink_Called = "Notes/Notes_" & Val(Mid(rsWebRef_Maps.Fields(2) + 1000000, 4, 2)) & "/Notes_" & rsWebRef_Maps.Fields(2) |
| 0104 | End If |
| 0105 | 'And here! |
| 0106 | Case "Note_Archive" |
| 0107 | If rsWebRef_Maps.Fields(11) & "" = "10" Then |
| 0108 | strLink_Called = "Secure_Jen/Notes_" & Val(Mid(rsWebRef_Maps.Fields(2) + 1000000, 4, 2)) & "/Notes_" & rsWebRef_Maps.Fields(2) & "_" & rsWebRef_Maps.Fields(3) |
| 0109 | Else |
| 0110 | strLink_Called = "Notes/Notes_" & Val(Mid(rsWebRef_Maps.Fields(2) + 1000000, 4, 2)) & "/Notes_" & rsWebRef_Maps.Fields(2) & "_" & rsWebRef_Maps.Fields(3) |
| 0111 | End If |
| 0112 | Case "Paper" |
| 0113 | strLink_Called = "Abstracts/Abstract_" & Mid(rsWebRef_Maps.Fields(2) + 1000000, 3, 2) & "/Abstract_" & rsWebRef_Maps.Fields(2) |
| 0114 | Case Else |
| 0115 | Stop |
| 0116 | End Select |
| 0117 | strLink_Called = "Link" |
| 0118 | rsWebLinkCheck_Map.Fields(2) = strLink_Called 'Called From |
| 0119 | rsWebLinkCheck_Map.Fields(3) = rsWebRef_Maps.Fields(5) 'Link Returned |
| 0120 | rsWebLinkCheck_Map.Fields(4) = rsWebRef_Maps.Fields(6) 'Issue |
| 0121 | rsWebLinkCheck_Map.Fields(5) = IIf(rsWebRef_Maps.Fields(7) = True, "Yes", "") 'Defunct? |
| 0122 | rsWebLinkCheck_Map.Fields(6) = rsWebRef_Maps.Fields(8) 'Display Text |
| 0123 | rsWebLinkCheck_Map.Fields(7) = rsWebRef_Maps.Fields(9) 'Date Last Checked |
| 0124 | rsWebLinkCheck_Map.Fields(8) = rsWebRef_Maps.Fields(10) 'Seconds |
| 0125 | rsWebLinkCheck_Map.Fields(9) = rsWebRef_Maps.Fields(12) 'Explanation |
| 0126 | rsWebLinkCheck_Map.Update |
| 0127 | rsWebRef_Maps.MoveNext |
| 0128 | Loop |
| 0129 | FileName_Root = "WebLinks_Tester_Map" |
| 0130 | Set rsWebRef_Maps = Nothing |
| 0131 | Set rsWebLinkCheck_Map = Nothing |
| 0132 | End If |
| 0133 | If Not IsMissing(Defunct) Then |
| 0134 | FileName_Root = FileName_Root & "_NotDefunct" |
| 0135 | End If |
| 0136 | Issue_Saved = "" |
| 0137 | If IsMissing(Defunct) Then |
| 0138 | strDefunct = "" |
| 0139 | Else |
| 0140 | strDefunct = " (Not yet investigated and set as Defunct)" |
| 0141 | End If |
| 0142 | If IsMissing(Map) Then 'Use Links from the Spider |
| 0143 | If IsMissing(Defunct) Then |
| 0144 | strQuery2 = "Spider_Weblink_Fix_Check_Counts" |
| 0145 | Else |
| 0146 | strQuery2 = "Spider_Weblink_Fix_Check_Counts_NotDefunct" |
| 0147 | End If |
| 0148 | Set rsTableControl2 = CurrentDb.OpenRecordset(strQuery2) |
| 0149 | If rsTableControl2.EOF Then |
| 0150 | MsgBox ("No records in " & strQuery2) |
| 0151 | Exit Function |
| 0152 | Else |
| 0153 | DoEvents |
| 0154 | rsTableControl2.MoveLast |
| 0155 | DoEvents |
| 0156 | End If |
| 0157 | Else |
| 0158 | If IsMissing(Defunct) Then |
| 0159 | strQuery2 = "Weblink_Fix_Check_Counts" |
| 0160 | Else |
| 0161 | strQuery2 = "Weblink_Fix_Check_Counts_NotDefunct" |
| 0162 | End If |
| 0163 | Set rsTableControl2 = CurrentDb.OpenRecordset(strQuery2) |
| 0164 | If rsTableControl2.EOF Then |
| 0165 | MsgBox ("No records in " & strQuery2) |
| 0166 | Exit Function |
| 0167 | Else |
| 0168 | DoEvents |
| 0169 | rsTableControl2.MoveLast |
| 0170 | DoEvents |
| 0171 | End If |
| 0172 | End If |
| 0173 | 'Create the jump table ... |
| 0174 | ifields = rsTableControl2.RecordCount |
| 0175 | rsTableControl2.MoveFirst |
| 0176 | strJump_Table = ""
| 0177 | strJump_Table = strJump_Table & ""
| 0178 | For i = 1 To ifields |
| 0179 | If i = 1 Then |
| 0180 | strFile_Sub = "" |
| 0181 | Else |
| 0182 | strFile_Sub = "_" & i - 1 |
| 0183 | End If |
| 0184 | strJump_Page_Title = rsTableControl2.Fields(0) |
| 0185 | strJump_Page_Title = Replace(strJump_Page_Title, "zMissing", "WebRef Missing") |
| 0186 | strJump_Page_Title = Replace(strJump_Page_Title, "URL ", "URL ") & " (" & rsTableControl2.Fields(1) & ")" |
| 0187 | strJump_Table = strJump_Table & "| " & strJump_Page_Title & " | " |
| 0188 | rsTableControl2.MoveNext |
| 0189 | Next i |
| 0190 | strJump_Table = strJump_Table & " | | " |
| 0191 | If IsMissing(Map) Then 'Use Links from the Spider |
| 0192 | strQuery2 = "Spider_Weblink_Fix_Check" |
| 0193 | Else |
| 0194 | strQuery2 = "Weblink_Fix_Check_Map" |
| 0195 | End If |
| 0196 | If Not IsMissing(Defunct) Then |
| 0197 | strQuery2 = strQuery2 & "_NotDefunct" |
| 0198 | End If |
| 0199 | Set rsTableControl2 = CurrentDb.OpenRecordset(strQuery2) |
| 0200 | rsTableControl2.MoveFirst |
| 0201 | ifields = rsTableControl2.Fields.Count |
| 0202 | rsTableControl2.MoveFirst |
| 0203 | strOutputFolder = TheoWebsiteRoot & "\Test\" |
| 0204 | Set fsoTextFile2 = New FileSystemObject |
| 0205 | File_Sub = 0 |
| 0206 | Link_Returned_Saved = "" |
| 0207 | Link_Saved = "" |
| 0208 | ID_Saved = "" |
| 0209 | Same_Line = False |
| 0210 | 'Rows |
| 0211 | Do While Not rsTableControl2.EOF |
| 0212 | If rsTableControl2.Fields(4) <> Issue_Saved Then |
| 0213 | Issue_Saved = rsTableControl2.Fields(4) |
| 0214 | ID_Saved = "" |
| 0215 | 'Close off previous file ... |
| 0216 | If File_Sub > 0 Then |
| 0217 | If Same_Line = True Then |
| 0218 | tsTextFile.WriteLine strLine & " |
"
| 0219 | Same_Line = False |
| 0220 | End If |
| 0221 | 'Footer |
| 0222 | strLine = " |
| 0300 | strLine = ""
| 0301 | tsTextFile.WriteLine strLine |
| 0302 | End If |
| 0303 | strLine = ""
| 0304 | tsTextFile.WriteLine strLine |
| 0305 | 'Headers |
| 0306 | j = 0 |
| 0307 | Do While j < ifields - 1 |
| 0308 | If j <> 4 Then 'Ignore "Issue" column, as it's always the same & is in the heading |
| 0309 | strLine = "| " | |
| 0310 | strLine = strLine & rsTableControl2.Fields(j).Name & "" |
| 0311 | tsTextFile.WriteLine strLine |
| 0312 | End If |
| 0313 | j = j + 1 |
| 0314 | Loop |
| 0315 | strLine = " | " |
| 0316 | tsTextFile.WriteLine strLine |
| 0317 | End If |
| 0318 | j = 0 |
| 0319 | Do While j < ifields - 1 |
| 0320 | If j <> 4 Then 'Ignore "Issue" column, as it's always the same & is in the heading |
| 0321 | x = rsTableControl2.Fields(j) & "" |
| 0322 | Select Case j |
| 0323 | Case 0 |
| 0324 | If Missing_Page = True Then |
| 0325 | x = "Missing" |
| 0326 | End If |
| 0327 | If x <> ID_Saved Then |
| 0328 | If Same_Line = True Then |
| 0329 | tsTextFile.WriteLine strLine & " | "
| 0330 | Same_Line = False |
| 0331 | End If |
| 0332 | ID_Saved = x |
| 0333 | Repeat_Line = False |
| 0334 | End If |
| 0335 | If Same_Line = False Then |
| 0336 | strLine = ""
| 0337 | tsTextFile.WriteLine strLine |
| 0338 | strLine = "| " | |
| 0339 | Else |
| 0340 | x = "" |
| 0341 | End If |
| 0342 | Case 1 |
| 0343 | If x = Link_Saved Then |
| 0344 | Repeat_Line = True |
| 0345 | If Same_Line = False Then |
| 0346 | strLine = "| " | |
| 0347 | x = "As above ↑: Further links to the right → " |
| 0348 | strLine = strLine & x & " | "
| 0349 | tsTextFile.WriteLine strLine |
| 0350 | Else |
| 0351 | x = "" |
| 0352 | End If |
| 0353 | Else |
| 0354 | strLine = "| " | |
| 0355 | Link_Saved = x |
| 0356 | Repeat_Line = False |
| 0357 | Same_Line = False |
| 0358 | Link_Narr = x |
| 0359 | If Len(Link_Narr) > 50 Then |
| 0360 | Link_Narr = Left(x, 40) & " ..." |
| 0361 | End If |
| 0362 | x = "" & Link_Narr & "" |
| 0363 | End If |
| 0364 | Link_Saved = rsTableControl2.Fields(j) |
| 0365 | Case 2 |
| 0366 | If Repeat_Line = False Then |
| 0367 | strLine = "| " | |
| 0368 | Else |
| 0369 | If Same_Line = False Then |
| 0370 | strLine = "| " | |
| 0371 | Same_Line = True |
| 0372 | End If |
| 0373 | End If |
| 0374 | x = Replace(x, """>Link", "#Off-Page_Link_W" & rsTableControl2.Fields(0) & "W"">Link") |
| 0375 | If InStr(x, "/Abstract_") > 0 Then |
| 0376 | x = Replace(x, "Link", "Paper Abstract") |
| 0377 | End If |
| 0378 | k = InStr(x, "/Notes_") |
| 0379 | If k > 0 Then |
| 0380 | x = Replace(x, "Link", "Note") |
| 0381 | If InStr(x, "Print") > 0 Then |
| 0382 | x = Replace(x, "Note", "Note Print") |
| 0383 | Else |
| 0384 | k = InStr(k + 1, x, "/Notes_") |
| 0385 | m = InStr(k + Len("/Notes_") + 1, x, "_") |
| 0386 | If m > 0 And InStr(k + Len("/Notes_") + 1, x, ".") > m Then |
| 0387 | x = Replace(x, "Note", "Note Archive") |
| 0388 | End If |
| 0389 | End If |
| 0390 | End If |
| 0391 | If InStr(x, "BookPaperAbstract") > 0 Then |
| 0392 | x = Replace(x, "Link", "Book Abstract") |
| 0393 | End If |
| 0394 | If InStr(x, "/BookSummary_") > 0 Then |
| 0395 | x = Replace(x, "Link", "Book") |
| 0396 | End If |
| 0397 | If InStr(x, "/PaperSummary_") > 0 Then |
| 0398 | x = Replace(x, "Link", "Paper") |
| 0399 | End If |
| 0400 | If InStr(x, "ConcatenatedNotes") > 0 Then |
| 0401 | x = Replace(x, "Link", "Concatenated") |
| 0402 | End If |
| 0403 | If InStr(x, "/Authors/") > 0 Then |
| 0404 | x = Replace(x, "Link", "Author") |
| 0405 | End If |
| 0406 | If Same_Line = True Then |
| 0407 | x = x & "; " |
| 0408 | End If |
| 0409 | Case 3 |
| 0410 | If Repeat_Line = False Then |
| 0411 | strLine = "| " | |
| 0412 | Link_Narr = x & "" |
| 0413 | If Link_Narr <> "" Then |
| 0414 | Link_Returned_Saved = Link_Narr |
| 0415 | If Len(Link_Narr) > 50 Then |
| 0416 | Link_Narr = Left(x, 40) & " ..." |
| 0417 | End If |
| 0418 | x = "" & Link_Narr & "" |
| 0419 | Else |
| 0420 | x = " " |
| 0421 | Link_Returned_Saved = "" |
| 0422 | End If |
| 0423 | Else |
| 0424 | x = "" |
| 0425 | End If |
| 0426 | Case 6 |
| 0427 | If Repeat_Line = False Then |
| 0428 | strLine = "| " | |
| 0429 | If x = "" Then |
| 0430 | x = " " |
| 0431 | End If |
| 0432 | Else |
| 0433 | x = "" |
| 0434 | End If |
| 0435 | Case 7 'Date Last Checked |
| 0436 | If Repeat_Line = False Then |
| 0437 | strLine = "| " | |
| 0438 | x = Left(x, 10) |
| 0439 | Else |
| 0440 | x = "" |
| 0441 | End If |
| 0442 | Case 9 |
| 0443 | If Repeat_Line = False Then |
| 0444 | strLine = "| " | |
| 0445 | If x = "" Then |
| 0446 | x = " " |
| 0447 | End If |
| 0448 | Else |
| 0449 | x = "" |
| 0450 | End If |
| 0451 | Case Else |
| 0452 | If Repeat_Line = False Then |
| 0453 | strLine = "| " | |
| 0454 | If x = "" Then |
| 0455 | x = " " |
| 0456 | End If |
| 0457 | Else |
| 0458 | x = "" |
| 0459 | End If |
| 0460 | End Select |
| 0461 | strLine = strLine & x |
| 0462 | If Repeat_Line = False Then |
| 0463 | strLine = strLine & " | "
| 0464 | tsTextFile.WriteLine strLine |
| 0465 | End If |
| 0466 | End If |
| 0467 | j = j + 1 |
| 0468 | Loop |
| 0469 | If Repeat_Line = False Then |
| 0470 | strLine = " | " |
| 0471 | End If |
| 0472 | rsTableControl2.MoveNext |
| 0473 | Loop |
| 0474 | 'Final Footer |
| 0475 | strLine = " | " |