@@ -40,25 +40,9 @@ Private Const EXTENSION_KEY As String = "AccUnitConfiguration"
4040#Const ADODB_EARLYBINDING = 0
4141'ADODB wird hier über Late binding eingesetzt, da es nur zum Erstellen der Tabelle genutzt wird
4242
43+ Private m_ACLibConfig As ACLibConfiguration
4344
44- ' Grundeinstellungen
45- Private Const ACLIB_CONFIG_ROOTFOLDERNAME As String = "AccessCodeLibrary"
46- Private Const ACLIB_CONFIG_DATABASENAME As String = "ACLib_Config"
47- Private Const ACLIB_CONFIG_TABLEDEFNAME As String = "ACLib_ConfigTable"
48-
49- Private Const SQL_CONFIG_TABLE_FIELD_PROPNAME As String = "PropName"
50- Private Const SQL_CONFIG_TABLE_FIELD_PROPVALUE As String = "PropValue"
51- Private Const SQL_SELECT_PROPERTYVALUE As String = _
52- "select " & SQL_CONFIG_TABLE_FIELD_PROPNAME & ", " & SQL_CONFIG_TABLE_FIELD_PROPVALUE & _
53- " From " & ACLIB_CONFIG_TABLEDEFNAME & " where " & SQL_CONFIG_TABLE_FIELD_PROPNAME & " = [?]"
54-
55- Private Const SQL_CREATETABLE_CONFIGTABLE As String = _
56- "CREATE TABLE " & ACLIB_CONFIG_TABLEDEFNAME & _
57- "([PropName] varchar(255) WITH COMPRESSION NOT NULL," & _
58- " [PropValue] varchar(255) WITH COMPRESSION," & _
59- " [PropRemarks] text WITH COMPRESSION," & _
60- " CONSTRAINT PK_" & ACLIB_CONFIG_TABLEDEFNAME & " PRIMARY KEY ([PropName]))"
61-
45+ ' Base config
6246Private Const PROPNAME_ACCUNITDLLPATH As String = "AccUnitDllPath"
6347
6448' Hilfsvariablen
@@ -115,9 +99,17 @@ End Sub
11599
116100
117101'---------------------------------------------------------------------------------------
118- ' Ergänzungen für Ereiterung : AccUnitConfiguration
102+ ' Ergänzungen für Erweiterung : AccUnitConfiguration
119103'---------------------------------------------------------------------------------------
120104
105+
106+ Public Property Get ACLibConfig() As ACLibConfiguration
107+ If m_ACLibConfig Is Nothing Then
108+ Set m_ACLibConfig = New ACLibConfiguration
109+ End If
110+ Set ACLibConfig = m_ACLibConfig
111+ End Property
112+
121113Private Sub GetExtensionPropertyLookup (ByVal PropertyName As String , ByRef ResumeMode As ApplicationHandlerResumeModes , ByRef ResumeMessage As Variant )
122114
123115 ResumeMode = AppResumeMode_Completed
@@ -140,15 +132,15 @@ End Property
140132Public Property Get AccUnitDllPath() As String
141133
142134 If Len(m_AccUnitDllPath) = 0 Then
143- m_AccUnitDllPath = GetACLibGlobalProperty(PROPNAME_ACCUNITDLLPATH)
135+ m_AccUnitDllPath = ACLibConfig. GetACLibGlobalProperty(PROPNAME_ACCUNITDLLPATH)
144136 If Len(m_AccUnitDllPath) > 0 Then
145137 If Not DirExists(m_AccUnitDllPath) Then
146138 Err.Raise vbObjectError, "AccUnitConfiguration.AccUnitDllPath" , "Das Verzeichnis '" & m_AccUnitDllPath & "' ist nicht vorhanden!"
147139 m_AccUnitDllPath = vbNullString
148140 End If
149141 If VBA.Right$(m_AccUnitDllPath, 1 ) <> "\" Then
150142 m_AccUnitDllPath = m_AccUnitDllPath & "\"
151- SetACLibGlobalProperty PROPNAME_ACCUNITDLLPATH, m_AccUnitDllPath
143+ ACLibConfig. SetACLibGlobalProperty PROPNAME_ACCUNITDLLPATH, m_AccUnitDllPath
152144 End If
153145 End If
154146 End If
@@ -169,180 +161,10 @@ Public Property Let AccUnitDllPath(ByVal NewPath As String)
169161 End If
170162 End If
171163 m_AccUnitDllPath = NewPath
172- SetACLibGlobalProperty PROPNAME_ACCUNITDLLPATH, m_AccUnitDllPath
164+ ACLibConfig. SetACLibGlobalProperty PROPNAME_ACCUNITDLLPATH, m_AccUnitDllPath
173165
174166End Property
175167
176168Private Property Get DefaultAccUnitDllPath() As String
177169 DefaultAccUnitDllPath = DefaultAccUnitLibFolder & "\"
178170End Property
179-
180- Private Function GetACLibGlobalProperty (ByRef PropertyName As String ) As String
181-
182- Dim rst As DAO .Recordset
183- Dim SelectSql As String
184-
185- SelectSql = Replace(SQL_SELECT_PROPERTYVALUE, "[?]" , DaoSqlTool.TextToSqlText(PropertyName))
186- Set rst = ACLibPropertyDb.OpenRecordset(SelectSql)
187- If Not rst.EOF Then
188- GetACLibGlobalProperty = Nz(rst.Fields(SQL_CONFIG_TABLE_FIELD_PROPVALUE), vbNullString)
189- Else
190- GetACLibGlobalProperty = vbNullString
191- End If
192- rst.Close
193-
194- End Function
195-
196- Private Function SetACLibGlobalProperty (ByRef PropertyName As String , ByRef NewValue As String ) As String
197-
198- Dim rst As DAO .Recordset
199- Dim SelectSql As String
200-
201- SelectSql = Replace(SQL_SELECT_PROPERTYVALUE, "[?]" , DaoSqlTool.TextToSqlText(PropertyName))
202- Set rst = ACLibPropertyDb.OpenRecordset(SelectSql)
203- If rst.EOF Then
204- rst.AddNew
205- rst.Fields(SQL_CONFIG_TABLE_FIELD_PROPNAME).Value = PropertyName
206- Else
207- rst.Edit
208- End If
209- rst.Fields(SQL_CONFIG_TABLE_FIELD_PROPVALUE).Value = NewValue
210- rst.Update
211- rst.Close
212-
213- End Function
214-
215- Private Property Get ACLibPropertyDb() As DAO .Database
216-
217- If m_ACLibPropertyDb Is Nothing Then
218- If CheckConfigTableDef Then
219- Set m_ACLibPropertyDb = CodeDb
220- End If
221- End If
222- Set ACLibPropertyDb = m_ACLibPropertyDb
223-
224- End Property
225-
226- #If ADODB_EARLYBINDING Then
227- Private Function CreateConfigTable (ByRef TargetConnection As ADODB .Connection) As Boolean
228- #Else
229- Private Function CreateConfigTable (ByRef TargetConnection As Object ) As Boolean
230- #End If
231-
232- TargetConnection.Execute SQL_CREATETABLE_CONFIGTABLE
233- CreateConfigTable = True
234-
235- End Function
236-
237-
238- Private Function CheckConfigTableDef () As Boolean
239-
240- Dim db As DAO .Database
241- Dim tdf As DAO .TableDef
242-
243- Set db = CodeDb
244-
245- If Not TableDefExists(ACLIB_CONFIG_TABLEDEFNAME, db) Then
246-
247- Set tdf = db.CreateTableDef(ACLIB_CONFIG_TABLEDEFNAME)
248- tdf.Connect = ";Database=" & ACLibConfigDatabaseFile
249- tdf.SourceTableName = ACLIB_CONFIG_TABLEDEFNAME
250- db.TableDefs.Append tdf
251-
252- ElseIf Len(VBA.Dir$(VBA.Mid$(db.TableDefs(ACLIB_CONFIG_TABLEDEFNAME).Connect, VBA.Len(";Database=" ) + 1 ))) = 0 Then
253-
254- With db.TableDefs(ACLIB_CONFIG_TABLEDEFNAME)
255- .Connect = ";Database=" & ACLibConfigDatabaseFile
256- .RefreshLink
257- End With
258-
259- End If
260-
261- Set db = Nothing
262-
263- CheckConfigTableDef = True
264-
265- End Function
266-
267- Public Property Get ACLibConfigDirectory() As String
268-
269- Dim strPath As String
270-
271- strPath = VBA.Environ("Appdata" ) & "\" & ACLIB_CONFIG_ROOTFOLDERNAME & "\"
272- If Len(VBA.Dir$(strPath, vbDirectory)) = 0 Then
273- VBA.MkDir strPath
274- End If
275-
276- ACLibConfigDirectory = strPath
277-
278- End Property
279-
280- Private Property Get ACLibConfigDatabaseFile() As String
281-
282- Dim db As DAO .Database
283- Dim strDbFile As String
284- Dim bolCreateConfigTable As Boolean
285-
286- #If ADODB_EARLYBINDING = 1 Then
287- Dim cnn As ADODB .Connection
288- #Else
289- Dim cnn As Object
290- #End If
291-
292- strDbFile = CodeDb.Name
293- strDbFile = VBA.Mid$(strDbFile, VBA.InStrRev(strDbFile, "." ))
294- If VBA.Left$(strDbFile, 5 ) = ".accd" Then
295- strDbFile = ".accdu"
296- Else
297- strDbFile = ".mdt"
298- End If
299- strDbFile = ACLibConfigDirectory & ACLIB_CONFIG_DATABASENAME & strDbFile
300-
301- If Len(VBA.Dir$(strDbFile)) = 0 Then
302-
303- 'Datenbank anlegen
304- If CodeDb.Version = "4.0" Then
305- Set db = DBEngine.CreateDatabase(strDbFile, dbLangGeneral, dbVersion40)
306- Else
307- Set db = DBEngine.CreateDatabase(strDbFile, dbLangGeneral)
308- End If
309- db.Close
310-
311- bolCreateConfigTable = True
312-
313- Else 'Prüfen ob Config-Tabelle vorhanden ist
314-
315- Set db = DBEngine.OpenDatabase(strDbFile)
316- bolCreateConfigTable = Not TableDefExists(ACLIB_CONFIG_TABLEDEFNAME, db)
317- db.Close
318-
319- End If
320-
321- If bolCreateConfigTable Then
322- 'Tabelle erstellen
323- #If ADODB_EARLYBINDING = 1 Then
324- Set cnn = New ADODB.Connection
325- #Else
326- Set cnn = CreateObject("ADODB.Connection" )
327- #End If
328- cnn.ConnectionString = VBA.Replace(CodeProject.Connection.ConnectionString, CodeDb.Name, strDbFile)
329- cnn.Open
330- CreateConfigTable cnn
331- cnn.Close
332- Set cnn = Nothing
333- End If
334-
335- ACLibConfigDatabaseFile = strDbFile
336-
337- End Property
338-
339- Private Property Get DaoSqlTool()
340- If m_DaoSqlTools Is Nothing Then
341- Set m_DaoSqlTools = SqlTools.Clone("\#yyyy-mm-dd\#" , "True" , "*" )
342- End If
343- Set DaoSqlTool = m_DaoSqlTools
344- End Property
345-
346- Private Sub Class_Terminate ()
347- Set m_DaoSqlTools = Nothing
348- End Sub
0 commit comments