| Line-No. / Ref. | Code Line |
| 0001 | Public Sub CreateNotesWebPages(Optional NoMessages) |
| 0002 | Dim fsoTextFile As FileSystemObject |
| 0003 | Dim rsTableToRead As Recordset |
| 0004 | Dim rsTableControl As Recordset |
| 0005 | Dim rsTableToUpdate As Recordset |
| 0006 | Dim rsNotesLinks As Recordset |
| 0007 | Dim strControlQuery As String |
| 0008 | Dim StartTime As Date |
| 0009 | Dim Duration |
| 0010 | Dim Temp_Note_ID |
| 0011 | Dim strNoMessages As String |
| 0012 | Dim Note_Text_Saved As String |
| 0013 | If IsMissing(NoMessages) Then |
| 0014 | strNoMessages = "No" |
| 0015 | Else |
| 0016 | strNoMessages = NoMessages |
| 0017 | End If |
| 0018 | Find_Functors |
| 0019 | StartTime = Now() |
| 0020 | Last_Changed_Timestamp = StartTime * 1000 |
| 0021 | OK = Convert_Webrefs("Note", "Full") |
| 0022 | If Archive_Notes_Now = "Yes" Then |
| 0023 | Archive_Notes |
| 0024 | End If |
| 0025 | If Regen_Notes_Only = "No" Then |
| 0026 | 'If "Changed Notes Only", need to restrict the Notes records read ... |
| 0027 | If Changed_Notes_Only = "Yes" Then |
| 0028 | If Include_Associated_Notes = "Yes" Then |
| 0029 | strControlQuery = "SELECT Notes_List_Auto.* FROM Notes_List_Auto LEFT JOIN Active_Notes_Full ON Notes_List_Auto.ID = Active_Notes_Full.ID WHERE (((Active_Notes_Full.ID) Is Not Null));" |
| 0030 | Else |
| 0031 | If Temp_Notes_Only = "Yes" Then |
| 0032 | strControlQuery = "SELECT Notes_List_Auto.* FROM Notes_List_Auto LEFT JOIN Notes_Archive_Temp ON Notes_List_Auto.ID = Notes_Archive_Temp.ID WHERE Notes_List_Auto.Status = ""Temp"" ORDER BY Notes_List_Auto.ID;" |
| 0033 | Else |
| 0034 | strControlQuery = "SELECT Notes_List_Auto.* FROM Notes_List_Auto LEFT JOIN Notes_Archive_Temp ON Notes_List_Auto.ID = Notes_Archive_Temp.ID WHERE Notes_Archive_Temp.ID Is Not Null ORDER BY Notes_List_Auto.ID;" |
| 0035 | End If |
| 0036 | End If |
| 0037 | Else |
| 0038 | If Temp_Notes_Only = "Yes" Then |
| 0039 | strControlQuery = "SELECT Notes_List_Auto.* FROM Notes_List_Auto LEFT JOIN Notes_Archive_Temp ON Notes_List_Auto.ID = Notes_Archive_Temp.ID WHERE Notes_List_Auto.Status = ""Temp"" ORDER BY Notes_List_Auto.ID;" |
| 0040 | End If |
| 0041 | End If |
| 0042 | Else |
| 0043 | 'Specifically-chosen |
| 0044 | strControlQuery = "SELECT Notes_List_Auto.* FROM Notes_List_Auto INNER JOIN Notes_To_Regen ON Notes_List_Auto.ID = Notes_To_Regen.Note_ID ORDER BY Notes_List_Auto.ID;" |
| 0045 | End If |
| 0046 | Set rsTableToRead = CurrentDb.OpenRecordset(strControlQuery) |
| 0047 | If Regenerate_the_Links = "Yes" Then |
| 0048 | 'Regenerate the Note, Note_Archive, Note-Paper & Note-Book Links |
| 0049 | Regen_Note_Links |
| 0050 | OK = Regen_Note_Links_Archived |
| 0051 | Set rsTableToRead = CurrentDb.OpenRecordset(strControlQuery) |
| 0052 | OK = Regen_Note_Book_Links(rsTableToRead, 0, 2, 12) 'Note: uses Frozen_Timestamp (always Zero) for Timestamp |
| 0053 | Set rsTableToRead = CurrentDb.OpenRecordset(strControlQuery) |
| 0054 | OK = Regen_Note_Paper_Links(rsTableToRead, 0, 2, 12) |
| 0055 | End If |
| 0056 | Set rsTableToRead = CurrentDb.OpenRecordset(strControlQuery) |
| 0057 | If Not rsTableToRead.EOF Then |
| 0058 | rsTableToRead.MoveFirst |
| 0059 | End If |
| 0060 | 'Notes_List_Auto Fields |
| 0061 | '0 = ID |
| 0062 | '1 = Item_Title |
| 0063 | '2 = Item_Text |
| 0064 | '3 = Jump_Table? |
| 0065 | '4 = Note_Group |
| 0066 | '5 = Master Note |
| 0067 | '6 = Last_Changed |
| 0068 | '7 = Private? |
| 0069 | '8 = ReadingList? |
| 0070 | '9 = Title? |
| 0071 | '10 = Respondent? |
| 0072 | '11 = Status |
| 0073 | '12 = Frozen_Timestamp |
| 0074 | '13 = Immediate_Promotion |
| 0075 | '14 = Note_Quality |
| 0076 | '15 = Temp_Note_Timestamp |
| 0077 | 'Temp Notes: Update the timestamp and check for Functors ... |
| 0078 | If Not rsTableToRead.EOF Then |
| 0079 | rsTableToRead.MoveFirst |
| 0080 | Do While Not rsTableToRead.EOF |
| 0081 | If (rsTableToRead.Fields(11) & "" = "Temp") Then 'Temp Note |
| 0082 | If (rsTableToRead.Fields(13) = True) Then 'Immediate Promotion |
| 0083 | Set rsTableToUpdate = CurrentDb.OpenRecordset("SELECT Notes.ID, Notes.Last_Changed FROM Notes WHERE (((Notes.ID)=" & rsTableToRead.Fields(0) & "));") |
| 0084 | If Not rsTableToUpdate.EOF Then |
| 0085 | rsTableToUpdate.MoveFirst |
| 0086 | rsTableToUpdate.Edit |
| 0087 | rsTableToUpdate.Fields(1) = Last_Changed_Timestamp |
| 0088 | rsTableToUpdate.Update |
| 0089 | End If |
| 0090 | Set rsTableToUpdate = Nothing |
| 0091 | End If |
| 0092 | 'Check for Functors |
| 0093 | Note_Text_Saved = rsTableToRead.Fields(2) & "" |
| 0094 | OK = Functor(rsTableToRead.Fields(0), rsTableToRead.Fields(1), Note_Text_Saved) |
| 0095 | If OK = "Yes" Then |
| 0096 | 'Update |
| 0097 | Set rsTableToUpdate = CurrentDb.OpenRecordset("SELECT Notes.ID, Notes.Item_Text FROM Notes WHERE (((Notes.ID)=" & rsTableToRead.Fields(0) & "));") |
| 0098 | If Not rsTableToUpdate.EOF Then |
| 0099 | rsTableToUpdate.MoveFirst |
| 0100 | rsTableToUpdate.Edit |
| 0101 | rsTableToUpdate.Fields(1) = Note_Text_Saved |
| 0102 | rsTableToUpdate.Update |
| 0103 | End If |
| 0104 | Set rsTableToUpdate = Nothing |
| 0105 | End If |
| 0106 | End If |
| 0107 | rsTableToRead.MoveNext |
| 0108 | Loop |
| 0109 | rsTableToRead.MoveFirst |
| 0110 | End If |
| 0111 | strControlQuery = "SELECT Website_Control.Line_Value FROM Website_Control WHERE (((Website_Control.Web_Page) = ""Notes"") And ((Website_Control.Section) = ""Text"")) ORDER BY Website_Control.Line;" |
| 0112 | Set rsTableControl = CurrentDb.OpenRecordset(strControlQuery) |
| 0113 | If Not rsTableToRead.EOF Then |
| 0114 | rsTableToRead.MoveFirst |
| 0115 | End If |
| 0116 | 'Output the Notes |
| 0117 | Do While Not rsTableToRead.EOF |
| 0118 | OutputNotesWebPage (rsTableToRead.Fields(0)) |
| 0119 | 'Next Note |
| 0120 | rsTableToRead.MoveNext |
| 0121 | Loop |
| 0122 | Finish_Off: |
| 0123 | If automatic_processing = "Yes" Then |
| 0124 | If Done_The_Jumps = True Then |
| 0125 | GoTo Tidy_Up |
| 0126 | Else |
| 0127 | Done_The_Jumps = True |
| 0128 | End If |
| 0129 | End If |
| 0130 | 'Create the first-level notes Jump Pages (notes by Notes-Group) |
| 0131 | JumpTableTitles_Recent_Control |
| 0132 | 'Notes Jump Pages ... one for each active Notes Group |
| 0133 | strControlQuery = "SELECT Note_Groups.ID, Note_Groups.Note_Group, Note_Groups.Narrative FROM Note_Groups ORDER BY Note_Groups.ID;" |
| 0134 | Set rsTableToRead = CurrentDb.OpenRecordset(strControlQuery) |
| 0135 | rsTableToRead.MoveFirst |
| 0136 | 'Refresh the Master Notes tables |
| 0137 | Find_Master_Notes |
| 0138 | Notes_Recent = 0 'Prints all notes. If > 0, changed in last n days. |
| 0139 | Do While Notes_Recent < 29 |
| 0140 | rsTableToRead.MoveFirst |
| 0141 | Do While Not rsTableToRead.EOF |
| 0142 | Notes_Group_ID = rsTableToRead.Fields(0).Value |
| 0143 | Notes_Group = rsTableToRead.Fields(1).Value & IIf(Notes_Recent > 0, " - Updated in the last " & Notes_Recent & " days - ", "") |
| 0144 | Notes_Group_Narrative = rsTableToRead.Fields(2).Value & "" |
| 0145 | strControlTable = "Jump_Table_Titles_Notes" |
| 0146 | strOutputFileShort = "Notes_Jump_" & Notes_Group_ID & IIf(Notes_Recent > 0, "_Recent_" & Notes_Recent, "") |
| 0147 | strFileName = strOutputFileShort & ".htm" |
| 0148 | strTargetFileShort = "Notes" |
| 0149 | If Notes_Group_ID = 10 Then |
| 0150 | strOutputRoot = TheoWebsiteRoot & "\Secure_Jen\" |
| 0151 | Else |
| 0152 | strOutputRoot = TheoWebsiteRoot & "\Notes\" |
| 0153 | End If |
| 0154 | strFolder = strOutputRoot |
| 0155 | strOutputFile = strOutputRoot & strOutputFileShort |
| 0156 | strTargetFile = strOutputRoot & strTargetFileShort |
| 0157 | strDataQuery = "Notes_Jump" |
| 0158 | strSplitTable = "Yes" |
| 0159 | JumpTableTitles |
| 0160 | rsTableToRead.MoveNext |
| 0161 | Loop |
| 0162 | Notes_Recent = Notes_Recent + 7 |
| 0163 | If Notes_Recent = 21 Then 'Don't bother with 3-week |
| 0164 | Notes_Recent = Notes_Recent + 7 |
| 0165 | End If |
| 0166 | Loop |
| 0167 | Tidy_Up: |
| 0168 | 'Tidy Up |
| 0169 | Set rsNotesLinks = Nothing |
| 0170 | Set rsTableControl = Nothing |
| 0171 | Set rsTableToRead = Nothing |
| 0172 | Set fsoTextFile = Nothing |
| 0173 | Duration = Round((Now() - StartTime) * 24 * 60, 1) |
| 0174 | If automatic_processing = "Yes" Then |
| 0175 | Else |
| 0176 | Set rsTableToRead = CurrentDb.OpenRecordset("Latest_Archives") |
| 0177 | If Not rsTableToRead.EOF Then |
| 0178 | DoCmd.OpenQuery ("Latest_Archives") |
| 0179 | End If |
| 0180 | Set rsTableToRead = Nothing |
| 0181 | If strNoMessages = "No" Then |
| 0182 | If Duration < 1 Then |
| 0183 | Duration = Round((Now() - StartTime) * 24 * 60 * 60) |
| 0184 | MsgBox Now() & ": Notes Webpage Creation Complete in " & Duration & " seconds.", vbOKOnly, "Create Notes Web Pages" |
| 0185 | Else |
| 0186 | MsgBox Now() & ": Notes Webpage Creation Complete in " & Duration & " minutes.", vbOKOnly, "Create Notes Web Pages" |
| 0187 | End If |
| 0188 | End If |
| 0189 | End If |
| 0190 | End Sub |
| Line-No. / Ref. | Code Line |
| 0001 | Public Function Regen_Note_Links_Archived(Optional Note_ID, Optional Note_Timestamp) |
| 0002 | Dim strControlQuery As String |
| 0003 | Dim strLine As String |
| 0004 | Dim rsTableToRead As Recordset |
| 0005 | Dim rsNotesLinks As Recordset |
| 0006 | Dim rsLatestTimestamp As Recordset |
| 0007 | Dim x As Long |
| 0008 | Dim Y As Long |
| 0009 | Dim z As Long |
| 0010 | Dim z_Saved As Long |
| 0011 | Dim iSuperscript As Integer |
| 0012 | Dim iSection As Integer |
| 0013 | Dim iFootNoteID As Integer |
| 0014 | Dim strPrintNote As String |
| 0015 | Dim No_FN As String |
| 0016 | Dim Note_Archive_ID As Long |
| 0017 | Dim Note_Archive_Timestamp As Long |
| 0018 | Dim Time_Called As Long |
| 0019 | Dim Timestamp_Temp As Long |
| 0020 | Dim i As Long |
| 0021 | Dim TheWord As String |
| 0022 | Dim rsNoteID As Recordset |
| 0023 | Time_Called = Now() * 1000 |
| 0024 | 'Read Notes_Archive records |
| 0025 | If IsMissing(Note_ID) Then |
| 0026 | 'Select all Notes_Archive |
| 0027 | strControlQuery = "SELECT Notes_Archive.* FROM Notes_Archive ORDER BY Notes_Archive.ID, Notes_Archive.Timestamp;" |
| 0028 | Else |
| 0029 | If IsMissing(Note_Timestamp) Then |
| 0030 | 'Select all Notes_Archive for this Note |
| 0031 | strControlQuery = "SELECT Notes_Archive.* FROM Notes_Archive WHERE Notes_Archive.ID = " & Note_ID & " ORDER BY Notes_Archive.Timestamp;" |
| 0032 | Else |
| 0033 | 'Select only the Notes_Archive for this Note and Timestamp |
| 0034 | strControlQuery = "SELECT Notes_Archive.* FROM Notes_Archive WHERE Notes_Archive.ID = " & Note_ID & " AND Notes_Archive.Timestamp = " & Note_Timestamp & ";" |
| 0035 | End If |
| 0036 | End If |
| 0037 | Set rsTableToRead = CurrentDb.OpenRecordset(strControlQuery) |
| 0038 | rsTableToRead.MoveFirst |
| 0039 | 'Regenerate the Note Links |
| 0040 | Do While Not rsTableToRead.EOF |
| 0041 | Note_Archive_ID = rsTableToRead.Fields(0) |
| 0042 | Note_Archive_Timestamp = rsTableToRead.Fields(11) |
| 0043 | 'Ready the Note Links Archive |
| 0044 | DoCmd.RunSQL ("DELETE Note_Links_Archived.* FROM Note_Links_Archived WHERE Note_1 = " & Note_Archive_ID & "AND Note_1_Timestamp = " & Note_Archive_Timestamp & ";") |
| 0045 | strControlQuery = "SELECT Note_Links_Archived.* FROM Note_Links_Archived WHERE Note_1 = " & Note_Archive_ID & "AND Note_1_Timestamp = " & Note_Archive_Timestamp & ";" |
| 0046 | Set rsNotesLinks = CurrentDb.OpenRecordset(strControlQuery) |
| 0047 | strLine = rsTableToRead.Fields(2) |
| 0048 | strLine = ReplaceCode(strLine, Chr(13) & Chr(10), " ") |
| 0049 | x = 1 |
| 0050 | z = 1 |
| 0051 | iSuperscript = 1 |
| 0052 | x = InStr(x, strLine, "++") |
| 0053 | iSection = 0 |
| 0054 | Do While x > 0 |
| 0055 | 'Ignore In-sheet Footnotes |
| 0056 | No_FN = "No" |
| 0057 | Do Until No_FN = "Yes" |
| 0058 | If x > 0 Then |
| 0059 | If Mid(strLine, x + 2, 2) = "FN" Then |
| 0060 | x = x + 1 |
| 0061 | x = InStr(x, strLine, "++") |
| 0062 | If x > 0 Then |
| 0063 | x = x + 1 |
| 0064 | x = InStr(x, strLine, "++") |
| 0065 | iSuperscript = iSuperscript + 1 |
| 0066 | End If |
| 0067 | Else |
| 0068 | No_FN = "Yes" |
| 0069 | End If |
| 0070 | Else |
| 0071 | No_FN = "Yes" |
| 0072 | End If |
| 0073 | Loop |
| 0074 | If x > 0 Then |
| 0075 | Y = InStr(x + 1, strLine, "++") |
| 0076 | If Mid(strLine, x + 2, 2) = "NP" Then |
| 0077 | If InStr(Mid(strLine, x + 4, Y - x - 4), "#") > 0 Then |
| 0078 | iFootNoteID = Left(Mid(strLine, x + 4, Y - x - 4), InStr(Mid(strLine, x + 4, Y - x - 4), "#") - 1) |
| 0079 | Else |
| 0080 | If IsNumeric(Mid(strLine, x + 4, Y - x - 4)) Then |
| 0081 | iFootNoteID = Mid(strLine, x + 4, Y - x - 4) |
| 0082 | Else |
| 0083 | iFootNoteID = 0 |
| 0084 | End If |
| 0085 | End If |
| 0086 | strPrintNote = "No" |
| 0087 | Else |
| 0088 | If Y = x + 1 Then |
| 0089 | 'Check this is the "++++" case where we have to look up the reference |
| 0090 | If Mid(strLine, x, 4) = "++++" Then |
| 0091 | 'Find the key-word(s) |
| 0092 | If x > 1 Then |
| 0093 | If Mid(strLine, x - 1, 1) = " " Then |
| 0094 | i = FindWord(strLine, x - 1, "]") |
| 0095 | TheWord = Mid(strLine, i, x - 1 - i) |
| 0096 | Else |
| 0097 | i = FindWord(strLine, x, "]") |
| 0098 | TheWord = Mid(strLine, i, x - i) |
| 0099 | End If |
| 0100 | End If |
| 0101 | If Right(TheWord, 1) = "]" Then |
| 0102 | TheWord = Mid(TheWord, 2, Len(TheWord) - 2) |
| 0103 | End If |
| 0104 | 'Find the Note ID. NB uses the Note_Alternates table! |
| 0105 | Set rsNoteID = CurrentDb.OpenRecordset("SELECT Notes.ID FROM Note_Alternates INNER JOIN Notes ON Note_Alternates.Item_Title = Notes.Item_Title WHERE (((Note_Alternates.Item_Alt_Title)=""" & TheWord & """));") |
| 0106 | If rsNoteID.EOF Then |
| 0107 | strPrintNote = "1256" 'The "dud links" Note! |
| 0108 | Else |
| 0109 | rsNoteID.MoveFirst |
| 0110 | strPrintNote = rsNoteID.Fields(0) |
| 0111 | End If |
| 0112 | Set rsNoteID = Nothing |
| 0113 | strLine = Left(strLine, x + 1) & strPrintNote & Mid(strLine, x + 2) |
| 0114 | Y = Y + 1 + Len(strPrintNote) |
| 0115 | End If |
| 0116 | Else |
| 0117 | strPrintNote = Mid(strLine, x + 2, Y - x - 2) |
| 0118 | End If |
| 0119 | If InStr(strPrintNote, "#") > 0 Then |
| 0120 | iFootNoteID = Left(strPrintNote, InStr(strPrintNote, "#") - 1) |
| 0121 | Else |
| 0122 | If IsNumeric(Mid(strLine, x + 2, Y - x - 2)) Then |
| 0123 | iFootNoteID = Mid(strLine, x + 2, Y - x - 2) |
| 0124 | Else |
| 0125 | iFootNoteID = 0 |
| 0126 | End If |
| 0127 | End If |
| 0128 | strPrintNote = "Yes" |
| 0129 | End If |
| 0130 | rsNotesLinks.AddNew |
| 0131 | rsNotesLinks!Note_1 = Note_Archive_ID |
| 0132 | If x > z Then |
| 0133 | Do While z < x |
| 0134 | z_Saved = z |
| 0135 | z = InStr(z + 20, strLine, " ") |
| 0136 | If z = 0 Then |
| 0137 | z = 10000000 |
| 0138 | End If |
| 0139 | iSection = iSection + 1 |
| 0140 | Loop |
| 0141 | If z > 0 Then |
| 0142 | z = z_Saved |
| 0143 | iSection = iSection - 1 |
| 0144 | End If |
| 0145 | End If |
| 0146 | rsNotesLinks!Note_1_Timestamp = Note_Archive_Timestamp |
| 0147 | rsNotesLinks!Note_1_Ref = iSection |
| 0148 | rsNotesLinks!Note_1_FN_ID = iSuperscript |
| 0149 | rsNotesLinks!Note_2 = iFootNoteID |
| 0150 | rsNotesLinks!Update_Timestamp = Time_Called |
| 0151 | rsNotesLinks![Print_Note] = strPrintNote |
| 0152 | 'Find the Timestamp of the linked Note |
| 0153 | strControlQuery = "SELECT Max(Notes_Archive.[Timestamp]) FROM Notes_Archive WHERE Notes_Archive.ID = " & iFootNoteID & " AND Notes_Archive.[Timestamp] <=" & Note_Archive_Timestamp & ";" |
| 0154 | Set rsLatestTimestamp = CurrentDb.OpenRecordset(strControlQuery) |
| 0155 | If rsLatestTimestamp.EOF Then |
| 0156 | Timestamp_Temp = 0 |
| 0157 | Else |
| 0158 | If rsLatestTimestamp.Fields(0) & "" = "" Then |
| 0159 | Timestamp_Temp = 0 |
| 0160 | Else |
| 0161 | Timestamp_Temp = rsLatestTimestamp.Fields(0) |
| 0162 | End If |
| 0163 | End If |
| 0164 | 'Can't find ... so make the best of it ... |
| 0165 | If Timestamp_Temp = 0 Then |
| 0166 | strControlQuery = "SELECT Min(Notes_Archive.[Timestamp]) FROM Notes_Archive WHERE Notes_Archive.ID = " & iFootNoteID & " AND Notes_Archive.[Timestamp] >=" & Note_Archive_Timestamp & ";" |
| 0167 | Set rsLatestTimestamp = CurrentDb.OpenRecordset(strControlQuery) |
| 0168 | If rsLatestTimestamp.EOF Then |
| 0169 | Timestamp_Temp = 0 |
| 0170 | Else |
| 0171 | If rsLatestTimestamp.Fields(0) & "" = "" Then |
| 0172 | Timestamp_Temp = 0 |
| 0173 | Else |
| 0174 | Timestamp_Temp = rsLatestTimestamp.Fields(0) |
| 0175 | End If |
| 0176 | End If |
| 0177 | End If |
| 0178 | rsNotesLinks!Note_2_Timestamp = Timestamp_Temp |
| 0179 | rsNotesLinks.Update |
| 0180 | x = InStr(Y + 1, strLine, "++") |
| 0181 | iSuperscript = iSuperscript + 1 |
| 0182 | End If |
| 0183 | Loop |
| 0184 | rsTableToRead.MoveNext |
| 0185 | Loop |
| 0186 | Set rsTableToRead = Nothing |
| 0187 | Set rsNotesLinks = Nothing |
| 0188 | Set rsLatestTimestamp = Nothing |
| 0189 | End Function |