Line-No. / Ref. | Code Line |
0001 | Public Function Backup_Prune_Scurry(DirectoryName, Directory_Timestamp, DirectoryLevel_In, Backup_Database, Directory_Only) |
0002 | Dim rst As Recordset |
0003 | Dim rst2 As Recordset |
0004 | Dim db As Database |
0005 | Dim OK As String |
0006 | Dim fso As FileSystemObject |
0007 | Dim Directory_Out As String |
0008 | Dim MainFolder |
0009 | Dim FileCollection |
0010 | Dim File |
0011 | Dim File_Name As String |
0012 | Dim DirectoryLevel As Integer |
0013 | Dim File_Timestamp As Date |
0014 | Dim File_Wanted As String |
0015 | Dim No_Backup_Now |
0016 | Dim No_Backup_Later |
0017 | Dim Response |
0018 | Dim SiteMapDirectory As String |
0019 | Dim Directory_Timestamp_Local |
0020 | 'This is a recursive Sub - ie. it calls itself |
0021 | Backup_Prune_Scurry = "OK" |
0022 | If InStr(DirectoryName, "$") > 0 Or InStr(DirectoryName, "D:\System Volume Information\") > 0 Then |
0023 | GoTo Exit_Sub |
0024 | End If |
0025 | DirectoryLevel = DirectoryLevel_In + 1 |
0026 | Directories_Logged = Directories_Logged + 1 |
0027 | Set db = CurrentDb |
0028 | 'Write out a record (to Full_Backup_Directory_Structure_Temp) for each sub-directory |
0029 | Set rst2 = db.OpenRecordset("SELECT Full_Backup_Directory_Structure_Temp.* FROM Full_Backup_Directory_Structure_Temp;") |
0030 | Directory_ID = Directory_ID + 1 |
0031 | rst2.AddNew |
0032 | rst2.Fields(0) = Directory_ID |
0033 | rst2.Fields(1) = DirectoryName |
0034 | rst2.Fields(2) = DirectoryLevel |
0035 | rst2.Fields(3) = Now() |
0036 | rst2.Fields(4) = Directory_Timestamp |
0037 | rst2.Update |
0038 | Set rst2 = Nothing |
0039 | Set fso = CreateObject("Scripting.FileSystemObject") |
0040 | If (Now() - Time_Start_Old) * 24 > 0.25 Then |
0041 | Compact_Repair (Backup_Database) |
0042 | Time_Start_Old = Now() |
0043 | Files_Logged = 0 |
0044 | Else |
0045 | If Directory_Only = False Then |
0046 | If Files_Logged > 200000 Then |
0047 | Files_Logged = 0 |
0048 | Compact_Repair (Backup_Database) |
0049 | End If |
0050 | End If |
0051 | End If |
0052 | Set MainFolder = fso.GetFolder(DirectoryName) |
0053 | If Directory_Only = False Then |
0054 | Set FileCollection = MainFolder.Files |
0055 | Set rst2 = db.OpenRecordset("SELECT Full_Backup_Site_Map_Temp.* FROM Full_Backup_Site_Map_Temp;") |
0056 | 'Main Folders |
0057 | On Error Resume Next |
0058 | For Each File In FileCollection |
0059 | File_Wanted = "Yes" |
0060 | File_Name = File.Name |
0061 | File_Timestamp = File.DateLastModified |
0062 | 'Log file stats |
0063 | SiteMapDirectory = DirectoryName |
0064 | rst2.AddNew |
0065 | rst2.Fields(0) = File_Name |
0066 | rst2.Fields(1) = File.Size |
0067 | rst2.Fields(2) = File_Timestamp |
0068 | rst2.Fields(3) = Directory_ID |
0069 | rst2.Update |
0070 | Files_Processed = Files_Processed + 1 |
0071 | Files_Logged = Files_Logged + 1 |
0072 | Next File |
0073 | Set rst2 = Nothing |
0074 | End If |
0075 | Recursion: |
0076 | Set FileCollection = MainFolder.SubFolders |
0077 | For Each File In FileCollection |
0078 | File_Name = File.Name |
0079 | Directory_Timestamp_Local = File.DateLastModified |
0080 | Directory_Out = DirectoryName & File_Name & "\" |
0081 | 'Recursion ... |
0082 | OK = Backup_Prune_Scurry(Directory_Out, Directory_Timestamp_Local, DirectoryLevel, Backup_Database, Directory_Only) |
0083 | Next File |
0084 | Exit_Sub: |
0085 | Set rst2 = Nothing |
0086 | Set rst = Nothing |
0087 | Set MainFolder = Nothing |
0088 | Set FileCollection = Nothing |
0089 | End Function |
Line-No. / Ref. | Code Line |
0001 | Public Sub Flag_For_Deletion() |
0002 | Dim rst2 As Recordset |
0003 | Dim db As Database |
0004 | Dim Start_Time As Date |
0005 | Dim Files_Processed As Long |
0006 | Dim Files_Logged As Long |
0007 | Dim File_Name As String |
0008 | Dim File_Name_Saved As String |
0009 | Dim File_Size As Long |
0010 | Dim File_Size_Saved As Long |
0011 | Dim MaxLocks As Long |
0012 | Dim LocksCount As Long |
0013 | Dim Space_Saved As Double |
0014 | Dim strMsg As String |
0015 | Dim Run_Duration As Single |
0016 | Dim Run_Duration_Text As String |
0017 | Dim File_Timestamp As Date |
0018 | Dim File_Timestamp_Saved As Date |
0019 | Set db = CurrentDb |
0020 | Start_Time = Now() |
0021 | MaxLocks = 5000 |
0022 | Files_Processed = 0 |
0023 | Files_Logged = 0 |
0024 | File_Name_Saved = "" |
0025 | File_Size_Saved = 0 |
0026 | File_Timestamp_Saved = 0 |
0027 | LocksCount = 0 |
0028 | Space_Saved = 0 |
0029 | DoCmd.RunSQL ("UPDATE Full_Backup_Site_Map_Temp SET Full_Backup_Site_Map_Temp.[Delete_Failed?] = False WHERE (((Full_Backup_Site_Map_Temp.[Delete_Failed?])=True));") |
0030 | Set rst2 = db.OpenRecordset("SELECT Full_Backup_Site_Map_Temp.File_Name, Full_Backup_Site_Map_Temp.Size, Full_Backup_Site_Map_Temp.File_Timestamp, Full_Backup_Directory_Structure_Temp.Directory_Timestamp, Full_Backup_Site_Map_Temp.Directory, Full_Backup_Site_Map_Temp.[Delete?] FROM Full_Backup_Directory_Structure_Temp INNER JOIN Full_Backup_Site_Map_Temp ON Full_Backup_Directory_Structure_Temp.Directory = Full_Backup_Site_Map_Temp.Directory WHERE Full_Backup_Site_Map_Temp.[Delete?] = False ORDER BY Full_Backup_Site_Map_Temp.File_Name, Full_Backup_Site_Map_Temp.Size, Full_Backup_Site_Map_Temp.File_Timestamp, Full_Backup_Directory_Structure_Temp.Directory_Timestamp;") |
0031 | rst2.MoveFirst |
0032 | DBEngine.BeginTrans |
0033 | Do Until rst2.EOF |
0034 | Files_Processed = Files_Processed + 1 |
0035 | File_Name = rst2.Fields(0) |
0036 | File_Size = rst2.Fields(1) |
0037 | File_Timestamp = rst2.Fields(2) |
0038 | If (File_Name_Saved = File_Name) And (File_Size_Saved = File_Size) And (File_Timestamp_Saved = File_Timestamp) Then |
0039 | Files_Logged = Files_Logged + 1 |
0040 | LocksCount = LocksCount + 1 |
0041 | Space_Saved = Space_Saved + File_Size |
0042 | rst2.Edit |
0043 | rst2.Fields(5) = True |
0044 | rst2.Update |
0045 | If LocksCount > MaxLocks Then |
0046 | DBEngine.CommitTrans |
0047 | LocksCount = 0 |
0048 | DBEngine.BeginTrans |
0049 | End If |
0050 | End If |
0051 | File_Name_Saved = File_Name |
0052 | File_Size_Saved = File_Size |
0053 | File_Timestamp_Saved = File_Timestamp |
0054 | rst2.MoveNext |
0055 | Loop |
0056 | If LocksCount > 0 Then |
0057 | DBEngine.CommitTrans |
0058 | End If |
0059 | Set rst2 = Nothing |
0060 | Run_Duration = Now() - Start_Time |
0061 | Run_Duration = Run_Duration * 24 |
0062 | If Run_Duration < 1 Then |
0063 | Run_Duration_Text = Round(Run_Duration * 60, 2) & " minutes" |
0064 | Else |
0065 | Run_Duration_Text = Round(Run_Duration, 2) & " hours" |
0066 | End If |
0067 | If automatic_processing <> "Yes" Then |
0068 | strMsg = "Deletion Flagging completed at " & Now() & " in " & Run_Duration_Text & "." |
0069 | strMsg = strMsg & Chr$(10) & "Files processed = " & Files_Processed & "." |
0070 | strMsg = strMsg & Chr$(10) & "Files Flagged for Deletion = " & Files_Logged & ". Space saved = " & Round(Space_Saved / 1000000, 1) & "Mb." |
0071 | MsgBox (strMsg) |
0072 | End If |
0073 | End Sub |
Line-No. / Ref. | Code Line |
0001 | Public Function Functor(Note_ID, Note_Title, Note_Text) |
0002 | Dim i As Long |
0003 | Dim j As Long |
0004 | Dim m As Long |
0005 | Dim n As Long |
0006 | Dim p As Long |
0007 | Dim q As Long |
0008 | Dim Note_Text_Local As String |
0009 | Dim strStart_Comment As String |
0010 | Dim strEnd_Comment As String |
0011 | Dim strFunctor_ID As String |
0012 | Dim strFunctor_ID_Plus_Parameters As String |
0013 | Dim Dud_Functor As Boolean |
0014 | Dim Functor_Insert As String |
0015 | Dim Functor_Insert_2 As String |
0016 | Dim OK_Local As String |
0017 | Dim strYear As String |
0018 | Dim strQuarter As String |
0019 | Dim strQuarter_Check As String |
0020 | Dim strQuery As String |
0021 | Dim strQuery_2 As String |
0022 | Dim rst As Recordset |
0023 | Dim str_Functor_Parameter As String |
0024 | Dim str_Functor_Parameter_2 As String |
0025 | Dim str_Functor_Parameter_3 As String |
0026 | strStart_Comment = "") |
0043 | If n = 0 Then |
0044 | 'End tag not found |
0045 | Debug.Print Now() & " - "; "Functor: End-tag for ID missing. Note="; Note_ID |
0046 | Else |
0047 | strFunctor_ID_Plus_Parameters = Trim(Mid(Note_Text_Local, i + m, n - i - m)) |
0048 | 'Check for Parameter |
0049 | p = InStr(strFunctor_ID_Plus_Parameters, ",") |
0050 | If p > 0 Then |
0051 | 'Check for Second Parameter |
0052 | strFunctor_ID = Trim(Left(strFunctor_ID_Plus_Parameters, p - 1)) |
0053 | q = InStr(p + 1, strFunctor_ID_Plus_Parameters, ",") |
0054 | If q > 0 Then |
0055 | str_Functor_Parameter = Trim(Mid(strFunctor_ID_Plus_Parameters, p + 1, q - p - 1)) |
0056 | str_Functor_Parameter_2 = Trim(Mid(strFunctor_ID_Plus_Parameters, q + 1)) |
0057 | 'Check for Third Parameter (or, currently, a helpful comment) |
0058 | q = InStr(str_Functor_Parameter_2, ",") |
0059 | If q > 0 Then |
0060 | str_Functor_Parameter_3 = Trim(Mid(str_Functor_Parameter_2, q + 1)) |
0061 | str_Functor_Parameter_2 = Trim(Left(str_Functor_Parameter_2, q - 1)) |
0062 | End If |
0063 | Else |
0064 | str_Functor_Parameter = Trim(Mid(strFunctor_ID_Plus_Parameters, p + 1)) |
0065 | End If |
0066 | Else |
0067 | str_Functor_Parameter = "1" |
0068 | strFunctor_ID = strFunctor_ID_Plus_Parameters |
0069 | End If |
0070 | If Len(strFunctor_ID) <> 2 Then |
0071 | Debug.Print Now() & " - "; "Functor: ID invalid. Note="; Note_ID; "Functor ID ="; strFunctor_ID |
0072 | Else |
0073 | j = InStr(i, Note_Text_Local, strEnd_Comment & " ID=" & strFunctor_ID) |
0074 | If j = 0 Then |
0075 | Debug.Print Now() & " - "; "Functor: End-comment missing. Note="; Note_ID; " Functor_ID = " & strFunctor_ID & ", " & str_Functor_Parameter; ": Trying for ordinary End Tag" |
0076 | j = InStr(i, Note_Text_Local, strEnd_Comment) |
0077 | If j = 0 Then |
0078 | Debug.Print Now() & " - "; "Functor: End-comment missing. Note="; Note_ID; " Functor_ID = " & strFunctor_ID & ", " & str_Functor_Parameter; ": Ordinary End Tag also missing; giving up" |
0079 | Functor = "End-comment missing" |
0080 | Exit Function |
0081 | End If |
0082 | End If |
0083 | Dud_Functor = False |
0084 | Select Case strFunctor_ID |
0085 | Case "01" |
0086 | 'Quarterly Report: Activity insert |
0087 | OK = Functor_01(Note_ID, Note_Title, Functor_Insert, "No") |
0088 | Case "02" |
0089 | 'Development Log report - Completed Items by Date |
0090 | OK = Functor_02("Development_Log_List_Complete_Date", Functor_Insert) |
0091 | Case "03" |
0092 | 'Development Log report - Outstanding Items by Priority |
0093 | OK = Functor_03("Development_Log_List_Outstanding_Own_Priority", Functor_Insert) |
0094 | OK_Local = Functor_03("Development_Log_List_Outstanding_Others_Priority", Functor_Insert_2) |
0095 | If OK_Local = "Yes" Then |
0096 | Functor_Insert = "|II||1|Own Website: " & Functor_Insert & "|1|Other Websites: " & Functor_Insert_2 & "|II|" |
0097 | End If |
0098 | Case "04" |
0099 | 'Development Log report - Outstanding Items by Category |
0100 | OK = Functor_04("Development_Log_List_Outstanding_Own_Category", Functor_Insert) |
0101 | OK_Local = Functor_04("Development_Log_List_Outstanding_Others_Category", Functor_Insert_2) |
0102 | If OK_Local = "Yes" Then |
0103 | Functor_Insert = "|II||1|Own Website: " & Functor_Insert & "|1|Other Websites: " & Functor_Insert_2 & "|II|" |
0104 | End If |
0105 | Case "05" |
0106 | 'Development Log report - Completed Items by Category |
0107 | OK = Functor_05("Development_Log_List_Complete_Own_Category", Functor_Insert) |
0108 | OK_Local = Functor_05("Development_Log_List_Complete_Others_Category", Functor_Insert_2) |
0109 | If OK_Local = "Yes" Then |
0110 | Functor_Insert = "|II||1|Own Website: " & Functor_Insert & "|1|Other Websites: " & Functor_Insert_2 & "|II|" |
0111 | End If |
0112 | Case "06" |
0113 | 'Quarterly Report: Priority 1 Outstanding Developents by Category |
0114 | OK = Functor_06("Development_Log_List_Outstanding_Own_Category_Pri1", Functor_Insert) |
0115 | OK_Local = Functor_06("Development_Log_List_Outstanding_Others_Category_Pri1", Functor_Insert_2) |
0116 | If OK_Local = "Yes" Then |
0117 | Functor_Insert = "|II||1|Own Website: " & Functor_Insert & "|1|Other Websites: " & Functor_Insert_2 & "|II|" |
0118 | End If |
0119 | Case "07" |
0120 | 'Insert Stats into Note 1247 (Website Generator Documentation - Web Links) |
0121 | OK = Functor_07(Note_ID, Note_Title, Functor_Insert) |
0122 | Case "08" |
0123 | 'Insert Stats into Quarterly Reports |
0124 | OK = Functor_08(Note_ID, Note_Title, Functor_Insert) |
0125 | Case "09" |
0126 | 'Insert Plans for Near Future into Quarterly Reports |
0127 | OK = Functor_09(Note_ID, Note_Title, Functor_Insert) |
0128 | Case "10" |
0129 | 'Insert Plans for Near Future into Summary Quarterly Report |
0130 | OK = Functor_10(Note_ID, Note_Title, Functor_Insert) |
0131 | Case "11" |
0132 | 'Web-Tools Quarterly Report: Completed Developments by Category |
0133 | 'Find the quarter |
0134 | OK = Find_Report_Period(Note_Title, strYear, strQuarter) |
0135 | strQuery = "SELECT File_Suffix FROM Next_Reporting_Month;" |
0136 | Set rst = CurrentDb.OpenRecordset(strQuery) |
0137 | rst.MoveFirst |
0138 | strQuarter_Check = rst.Fields(0) |
0139 | Set rst = Nothing |
0140 | If Right(strQuarter_Check, 2) = strQuarter Then |
0141 | strQuery = "Development_Log_List_Complete_Own_Category_Recent" |
0142 | strQuery_2 = "Development_Log_List_Complete_Others_Category_Recent" |
0143 | Else |
0144 | strQuery = "Development_Log_List_Complete_Own_Category_Recent_Previous" |
0145 | strQuery_2 = "Development_Log_List_Complete_Others_Category_Recent_Previous" |
0146 | End If |
0147 | OK = Functor_11(strQuery, Functor_Insert) |
0148 | OK_Local = Functor_11(strQuery_2, Functor_Insert_2) |
0149 | If OK_Local = "Yes" Then |
0150 | Functor_Insert = "|II||1|Own Website: " & Functor_Insert & "|1|Other Websites: " & Functor_Insert_2 & "|II|" |
0151 | Else |
0152 | Debug.Print Now() & " - "; "Functor Failed. Note ="; Note_ID; "Functor ID = "; strFunctor_ID; " (Other Websites)" |
0153 | End If |
0154 | Case "12" |
0155 | 'Quarterly Report: YTD Activity insert |
0156 | OK = Functor_01(Note_ID, Note_Title, Functor_Insert, "Yes") |
0157 | Case "13" |
0158 | 'Use Form_Documentation_Links to list Buttons referenced in Documenter |
0159 | OK = Functor_13(Note_ID, Note_Title, Functor_Insert) |
0160 | Case "14" |
0161 | 'Create an HTML table for the Blog |
0162 | OK = Functor_14(Note_ID, Note_Title, Functor_Insert) |
0163 | Case "15" |
0164 | 'Create a Timeline |
0165 | OK = Functor_15(Note_ID, Note_Title, Functor_Insert) |
0166 | Case "16" |
0167 | 'Create a Timeline |
0168 | OK = Functor_16(Note_ID, Note_Title, Functor_Insert) |
0169 | Case "17" |
0170 | 'Create an audio file list |
0171 | OK = Functor_17(Note_ID, Note_Title, Functor_Insert, str_Functor_Parameter) |
0172 | Case "18" |
0173 | 'Create the Aeon Lists list |
0174 | Functor_Insert = "" |
0175 | OK = Functor_18(Note_ID, Note_Title, Functor_Insert, 1) 'Aeon items read |
0176 | OK = Functor_18(Note_ID, Note_Title, Functor_Insert, 2) 'Aeon items un-read |
0177 | Case "19" |
0178 | 'Create the Aeon List Note 1292 jump table |
0179 | Functor_Insert = "" |
0180 | OK = Functor_19(Note_ID, Note_Title, Functor_Insert) 'Aeon items read |
0181 | Case "21" |
0182 | 'Insert table from Cross-Tab, or otherwise tabular, Query |
0183 | OK = Functor_21(str_Functor_Parameter, Functor_Insert, str_Functor_Parameter_2) |
0184 | Case "22" |
0185 | 'Insert list from Select Query |
0186 | OK = Functor_22(str_Functor_Parameter, Functor_Insert, Note_ID, str_Functor_Parameter_2, str_Functor_Parameter_3) |
0187 | Case "23" |
0188 | 'Insert value from Select Query |
0189 | If str_Functor_Parameter_2 = "" Then |
0190 | OK = Functor_23(Note_ID, str_Functor_Parameter, Functor_Insert) |
0191 | Else |
0192 | OK = Functor_23(Note_ID, str_Functor_Parameter, Functor_Insert, str_Functor_Parameter_2) |
0193 | End If |
0194 | Case "24" |
0195 | 'Insert value from Select Query |
0196 | If str_Functor_Parameter_2 = "" Then |
0197 | str_Functor_Parameter_2 = "1" |
0198 | End If |
0199 | OK = Functor_24(Note_ID, str_Functor_Parameter, Functor_Insert, str_Functor_Parameter_2) |
0200 | Case Else |
0201 | Dud_Functor = True |
0202 | Debug.Print Now() & " - "; "Functor: ID unrecognised. Note ="; Note_ID; "Functor ID = "; strFunctor_ID |
0203 | End Select |
0204 | If OK <> "Yes" Then |
0205 | Dud_Functor = True |
0206 | Debug.Print Now() & " - "; "Functor Failed. Note="; Note_ID; "Functor ID = "; strFunctor_ID |
0207 | End If |
0208 | If Dud_Functor = False Then |
0209 | Functor = "Yes" |
0210 | 'Replace old functor-stuff with new functor-stuff |
0211 | Note_Text_Local = Left(Note_Text_Local, n + 2) & Functor_Insert & Mid(Note_Text_Local, j) |
0212 | Else |
0213 | Note_Text_Local = Left(Note_Text_Local, n + 2) & Mid(Note_Text_Local, j) 'ADDED 12/08/2021 |
0214 | End If |
0215 | End If |
0216 | End If |
0217 | 'Find the next one ... |
0218 | i = InStr(i + 1, Note_Text_Local, strStart_Comment) |
0219 | Loop |
0220 | Note_Text = Note_Text_Local |
0221 | End Function |
Line-No. / Ref. | Code Line |
0001 | Public Sub Map_WebRefs() |
0002 | Dim rsObject As Recordset |
0003 | Dim strQuery As String |
0004 | Dim iUpdates As Long |
0005 | Dim iSub_Total As Long |
0006 | Dim iTotal As Long |
0007 | Dim Duration As Single |
0008 | Dim RunStartTime As Date |
0009 | Dim Message As String |
0010 | If automatic_processing = "Yes" Then |
0011 | Else |
0012 | Message = MsgBox("Map WebRefs: Re-create the WebRef_Maps Table?", vbYesNo) |
0013 | If Message = vbNo Then |
0014 | Exit Sub |
0015 | End If |
0016 | End If |
0017 | iTotal = 0 |
0018 | RunStartTime = Now() |
0019 | 'Delete Former Mappings |
0020 | strQuery = "DELETE WebRef_Maps.* FROM WebRef_Maps;" |
0021 | DoCmd.RunSQL (strQuery) |
0022 | 'Translate Authors |
0023 | iSub_Total = 0 |
0024 | strQuery = "SELECT Authors.Author_ID, Authors.Author_Narrative FROM Authors WHERE (((Authors.Author_Narrative) Like ""*+W*""));" |
0025 | Set rsObject = CurrentDb.OpenRecordset(strQuery) |
0026 | If Not rsObject.EOF Then |
0027 | rsObject.MoveFirst |
0028 | Do Until rsObject.EOF |
0029 | iUpdates = Map_WebRefs_Mapper("Author", rsObject.Fields(0), 0, rsObject.Fields(1)) |
0030 | iSub_Total = iSub_Total + iUpdates |
0031 | rsObject.MoveNext |
0032 | Loop |
0033 | End If |
0034 | Set rsObject = Nothing |
0035 | iTotal = iTotal + iSub_Total |
0036 | If automatic_processing <> "Yes" Then |
0037 | Debug.Print Now() & " - "; "Map_WebRefs: Total Author WebRefs = " & iSub_Total |
0038 | End If |
0039 | 'Translate Notes |
0040 | iSub_Total = 0 |
0041 | strQuery = "SELECT Notes.ID, Notes.Item_Text, Notes.Note_Group FROM Notes WHERE (((Notes.Item_Text) Like ""*+W*""));" |
0042 | Set rsObject = CurrentDb.OpenRecordset(strQuery) |
0043 | If Not rsObject.EOF Then |
0044 | rsObject.MoveFirst |
0045 | Do Until rsObject.EOF |
0046 | iUpdates = Map_WebRefs_Mapper("Note", rsObject.Fields(0), 0, rsObject.Fields(1), rsObject.Fields(2)) |
0047 | iSub_Total = iSub_Total + iUpdates |
0048 | rsObject.MoveNext |
0049 | Loop |
0050 | End If |
0051 | Set rsObject = Nothing |
0052 | iTotal = iTotal + iSub_Total |
0053 | If automatic_processing <> "Yes" Then |
0054 | Debug.Print Now() & " - "; "Map_WebRefs: Total Note WebRefs = " & iSub_Total |
0055 | End If |
0056 | 'Translate Notes_Archive |
0057 | iSub_Total = 0 |
0058 | strQuery = "SELECT Notes_Archive.ID, Notes_Archive.[Timestamp], Notes_Archive.Item_Text, Notes_Archive.Note_Group FROM Notes_Archive WHERE (((Notes_Archive.Item_Text) Like ""*+W*""));" |
0059 | Set rsObject = CurrentDb.OpenRecordset(strQuery) |
0060 | If Not rsObject.EOF Then |
0061 | rsObject.MoveFirst |
0062 | Do Until rsObject.EOF |
0063 | iUpdates = Map_WebRefs_Mapper("Note_Archive", rsObject.Fields(0), rsObject.Fields(1), rsObject.Fields(2), rsObject.Fields(3)) |
0064 | iSub_Total = iSub_Total + iUpdates |
0065 | rsObject.MoveNext |
0066 | Loop |
0067 | End If |
0068 | Set rsObject = Nothing |
0069 | iTotal = iTotal + iSub_Total |
0070 | If automatic_processing <> "Yes" Then |
0071 | Debug.Print Now() & " - "; "Map_WebRefs: Total Note_Archive WebRefs = " & iSub_Total |
0072 | End If |
0073 | 'Translate Book Abstracts & Comments |
0074 | iSub_Total = 0 |
0075 | strQuery = "SELECT Books.ID1, Books.Comments, Books.Abstract FROM Books WHERE (((Books.Comments) Like ""*+W*"") OR ((Books.Abstract) Like ""*+W*""));" |
0076 | Set rsObject = CurrentDb.OpenRecordset(strQuery) |
0077 | If Not rsObject.EOF Then |
0078 | rsObject.MoveFirst |
0079 | Do Until rsObject.EOF |
0080 | iUpdates = Map_WebRefs_Mapper("Book", rsObject.Fields(0), 0, rsObject.Fields(1) & rsObject.Fields(2)) |
0081 | iSub_Total = iSub_Total + iUpdates |
0082 | rsObject.MoveNext |
0083 | Loop |
0084 | End If |
0085 | Set rsObject = Nothing |
0086 | iTotal = iTotal + iSub_Total |
0087 | If automatic_processing <> "Yes" Then |
0088 | Debug.Print Now() & " - "; "Map_WebRefs: Total Book WebRefs = " & iSub_Total |
0089 | End If |
0090 | 'Translate Paper Abstracts & Comments |
0091 | iSub_Total = 0 |
0092 | strQuery = "SELECT Papers.ID, Papers.Comments, Papers.Abstract FROM Papers WHERE (((Papers.Comments) Like ""*+W*"") OR ((Papers.Abstract) Like ""*+W*""));" |
0093 | Set rsObject = CurrentDb.OpenRecordset(strQuery) |
0094 | If Not rsObject.EOF Then |
0095 | rsObject.MoveFirst |
0096 | Do Until rsObject.EOF |
0097 | iUpdates = Map_WebRefs_Mapper("Paper", rsObject.Fields(0), 0, rsObject.Fields(1) & rsObject.Fields(2)) |
0098 | iSub_Total = iSub_Total + iUpdates |
0099 | rsObject.MoveNext |
0100 | Loop |
0101 | End If |
0102 | Set rsObject = Nothing |
0103 | iTotal = iTotal + iSub_Total |
0104 | If automatic_processing <> "Yes" Then |
0105 | Debug.Print Now() & " - "; "Map_WebRefs: Total Paper WebRefs = " & iSub_Total |
0106 | Debug.Print Now() & " - "; "Map_WebRefs: Total WebRefs Mapped = " & iTotal |
0107 | End If |
0108 | If automatic_processing = "Yes" Then |
0109 | Else |
0110 | Duration = Round((Now() - RunStartTime) * 24 * 60, 1) |
0111 | If Duration < 1 Then |
0112 | Duration = Round((Now() - RunStartTime) * 24 * 60 * 60) |
0113 | MsgBox "WebRefs Mapped in " & Duration & " seconds. " & iTotal & " records added.", vbOKOnly, "Map WebRefs" |
0114 | Else |
0115 | MsgBox "WebRefs Mapped in " & Duration & " minutes. " & iTotal & " records added.", vbOKOnly, "Map WebRefs" |
0116 | End If |
0117 | End If |
0118 | End Sub |
Line-No. / Ref. | Code Line |
0001 | Public Function Map_WebRefs_Mapper(Object_Type As String, Object_ID As Long, Object_Sub_ID As Long, Object_Text As String, Optional Security As String) As Integer |
0002 | Dim iCount As Integer |
0003 | Dim Find_Start As String |
0004 | Dim Find_End As String |
0005 | Dim rsWebRef_Maps As Recordset |
0006 | Dim strQuery As String |
0007 | Dim i As Long |
0008 | Dim j As Long |
0009 | Dim strWebRef As String |
0010 | iCount = 0 |
0011 | Find_Start = "+W" |
0012 | Find_End = "W+" |
0013 | On Error Resume Next 'A bit of a fudge - to allow for duplicate key without too much of an overhead. |
0014 | 'Anything to do? |
0015 | If Len(Object_Text) = 0 Then |
0016 | GoTo The_End |
0017 | End If |
0018 | If InStr(Object_Text, Find_Start) = 0 Then |
0019 | GoTo The_End |
0020 | End If |
0021 | 'Ready for inserts |
0022 | strQuery = "SELECT * FROM WebRef_Maps WHERE Object_Type = """ & Object_Type & """ AND Object_ID = " & Object_ID & " AND Object_Sub_ID = " & Object_Sub_ID & ";" |
0023 | Set rsWebRef_Maps = CurrentDb.OpenRecordset(strQuery) |
0024 | i = InStr(Object_Text, Find_Start) |
0025 | 'Search and Add Mappings |
0026 | Do While i > 0 |
0027 | j = InStr(i, Object_Text, Find_End) |
0028 | If j > 0 Then |
0029 | strWebRef = Mid(Object_Text, i + 2, j - i - 2) |
0030 | If Len(strWebRef) > 5 Then |
0031 | 'Dud ... ignore |
0032 | If automatic_processing <> "Yes" Then |
0033 | Debug.Print Now() & " - "; "Error: Map_WebRefs_Mapper: WebRef too long. "; " "; Object_Type; " "; Object_ID; " "; Object_Sub_ID; " "; Replace(Replace(Left(strWebRef, 20), Chr(13), " "), Chr$(10), "") |
0034 | End If |
0035 | j = i + 1 |
0036 | Else |
0037 | If IsNumeric(strWebRef) Then |
0038 | rsWebRef_Maps.AddNew |
0039 | rsWebRef_Maps.Fields(0) = Object_Type |
0040 | rsWebRef_Maps.Fields(1) = Object_ID |
0041 | rsWebRef_Maps.Fields(2) = Object_Sub_ID |
0042 | rsWebRef_Maps.Fields(3) = strWebRef |
0043 | If IsMissing(Security) Then |
0044 | rsWebRef_Maps.Fields(4) = "" |
0045 | Else |
0046 | rsWebRef_Maps.Fields(4) = Security |
0047 | End If |
0048 | rsWebRef_Maps.Fields(5) = Now() |
0049 | rsWebRef_Maps.Update |
0050 | iCount = iCount + 1 |
0051 | Else |
0052 | 'Igore documentation dummies |
0053 | If (strWebRef & "" = "") Or (strWebRef = "nnn") Or (strWebRef = "mmm") Or (strWebRef = "nnnn") Or (strWebRef = "mmmm") Then |
0054 | Else |
0055 | If automatic_processing <> "Yes" Then |
0056 | Debug.Print Now() & " - "; "Error: Map_WebRefs_Mapper: WebRef not numeric. "; " "; Object_Type; " "; Object_ID; " "; Object_Sub_ID; " "; Left(strWebRef, 20) |
0057 | End If |
0058 | End If |
0059 | j = i + 1 |
0060 | End If |
0061 | End If |
0062 | i = InStr(j, Object_Text, Find_Start) |
0063 | Else |
0064 | 'Error |
0065 | If automatic_processing <> "Yes" Then |
0066 | Debug.Print Now() & " - "; "Error: Map_WebRefs_Mapper: W+ missing. "; " "; Object_Type; " "; Object_ID; " "; Object_Sub_ID; " "; Replace(Replace(Mid(Object_Text, i, 20), Chr(13), " "), Chr$(10), "") |
0067 | End If |
0068 | i = 0 |
0069 | End If |
0070 | Loop |
0071 | The_End: |
0072 | 'Return Count |
0073 | Map_WebRefs_Mapper = iCount |
0074 | Set rsWebRef_Maps = Nothing |
0075 | End Function |