Compare commits
6 Commits
4eae3d6e80
...
2f4b8afd67
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f4b8afd67 | ||
|
|
4a081ed65e | ||
|
|
f8ea2c755b | ||
|
|
7e05938ba8 | ||
|
|
99e5675d51 | ||
|
|
ebf53ea108 |
@@ -62,8 +62,6 @@ Public Class LookupControl2
|
||||
|
||||
Friend WithEvents GridView1 As DevExpress.XtraGrid.Views.Grid.GridView
|
||||
Friend WithEvents GridView2 As DevExpress.XtraGrid.Views.Grid.GridView
|
||||
Friend WithEvents fProperties As RepositoryItemGridLookUpEdit
|
||||
Friend WithEvents fPropertiesView As DevExpress.XtraGrid.Views.Grid.GridView
|
||||
Private _ReadOnly As Boolean = False
|
||||
|
||||
Shared Sub New()
|
||||
@@ -76,8 +74,9 @@ Public Class LookupControl2
|
||||
|
||||
Public Sub New(MultiSelect As Boolean)
|
||||
_LookupFormButton = New EditorButton() With {
|
||||
.Kind = ButtonPredefines.Ellipsis,
|
||||
.Tag = TAG_BUTTON_LOOKUP_FORM
|
||||
.Kind = ButtonPredefines.Search,
|
||||
.Tag = TAG_BUTTON_LOOKUP_FORM,
|
||||
.Width = 20
|
||||
}
|
||||
|
||||
Properties.Buttons.Item(0).Tag = TAG_DROPDOWN
|
||||
@@ -199,31 +198,6 @@ Public Class LookupControl2
|
||||
Return RepositoryItemLookupControl2.CustomEditName
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Sub InitializeComponent()
|
||||
Me.fProperties = New DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit()
|
||||
Me.fPropertiesView = New DevExpress.XtraGrid.Views.Grid.GridView()
|
||||
CType(Me.fProperties, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
CType(Me.fPropertiesView, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'fProperties
|
||||
'
|
||||
Me.fProperties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
|
||||
Me.fProperties.Name = "fProperties"
|
||||
Me.fProperties.PopupView = Me.fPropertiesView
|
||||
'
|
||||
'fPropertiesView
|
||||
'
|
||||
Me.fPropertiesView.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus
|
||||
Me.fPropertiesView.Name = "fPropertiesView"
|
||||
Me.fPropertiesView.OptionsSelection.EnableAppearanceFocusedCell = False
|
||||
Me.fPropertiesView.OptionsView.ShowGroupPanel = False
|
||||
CType(Me.fProperties, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
CType(Me.fPropertiesView, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
<UserRepositoryItem("RegisterLookupControl2")>
|
||||
@@ -244,7 +218,18 @@ Public Class RepositoryItemLookupControl2
|
||||
|
||||
Public Shared Sub RegisterLookupControl2()
|
||||
Dim img As Image = Nothing
|
||||
EditorRegistrationInfo.Default.Editors.Add(New EditorClassInfo(CustomEditName, GetType(LookupControl2), GetType(RepositoryItemLookupControl2), GetType(GridLookUpEditBaseViewInfo), New ButtonEditPainter(), True, img, GetType(ButtonEditAccessible)))
|
||||
EditorRegistrationInfo.Default.Editors.Add(
|
||||
New EditorClassInfo(
|
||||
CustomEditName,
|
||||
GetType(LookupControl2),
|
||||
GetType(RepositoryItemLookupControl2),
|
||||
GetType(GridLookUpEditBaseViewInfo),
|
||||
New ButtonEditPainter(),
|
||||
True,
|
||||
img,
|
||||
GetType(ButtonEditAccessible)
|
||||
)
|
||||
)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Assign(item As RepositoryItem)
|
||||
|
||||
@@ -99,8 +99,13 @@ Public Class DocumentPropertyMenu
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oDirectory = IO.Path.GetDirectoryName(_FilePath)
|
||||
Process.Start(oDirectory)
|
||||
Dim oArgs As String = $"/e, /select, ""{_FilePath}"""
|
||||
Dim oInfo As New ProcessStartInfo() With {
|
||||
.Arguments = oArgs,
|
||||
.FileName = "explorer"
|
||||
}
|
||||
|
||||
Process.Start(oInfo)
|
||||
End Sub
|
||||
|
||||
Private Function TestPathExists(Title As String) As Boolean
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
<Compile Include="ConfigAttributes.vb" />
|
||||
<Compile Include="ConfigManager.vb" />
|
||||
<Compile Include="ConfigSample.vb" />
|
||||
<Compile Include="ConfigUtils.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
Public Class ConnectionStringTestAttribute
|
||||
Inherits Attribute
|
||||
End Class
|
||||
Public Class ConnectionStringAppServer
|
||||
Inherits Attribute
|
||||
End Class
|
||||
Public Class AppServerConfig
|
||||
|
||||
''' <summary>
|
||||
''' The app server connection string. Will not be saved to userconfig.
|
||||
''' </summary>
|
||||
Public Class ConnectionStringAppServerAttribute
|
||||
Inherits Attribute
|
||||
End Class
|
||||
''' <summary>
|
||||
|
||||
@@ -20,7 +20,6 @@ Public Class ConfigManager(Of T)
|
||||
Private ReadOnly _AppConfigDirectory As String
|
||||
Private ReadOnly _AppConfigPath As String
|
||||
|
||||
|
||||
Private ReadOnly _TestMode As Boolean = False
|
||||
|
||||
Private ReadOnly _Blueprint As T
|
||||
@@ -29,7 +28,7 @@ Public Class ConfigManager(Of T)
|
||||
|
||||
Private ReadOnly _ExcludedAttributes = New List(Of Type) From {
|
||||
GetType(ConnectionStringAttribute),
|
||||
GetType(ConnectionStringAppServer),
|
||||
GetType(ConnectionStringAppServerAttribute),
|
||||
GetType(ConnectionStringTestAttribute),
|
||||
GetType(GlobalSettingAttribute)
|
||||
}
|
||||
@@ -66,7 +65,7 @@ Public Class ConfigManager(Of T)
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Path to the current computer config. Maybe the same as `UserConfigPath`
|
||||
''' Path to the current computer config.
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public ReadOnly Property ComputerConfigPath As String
|
||||
@@ -74,6 +73,11 @@ Public Class ConfigManager(Of T)
|
||||
Return _ComputerConfigPath
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Path to the current Application config.
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public ReadOnly Property AppConfigPath As String
|
||||
Get
|
||||
Return _AppConfigPath
|
||||
|
||||
@@ -7,6 +7,7 @@ Public Class ConfigSample
|
||||
|
||||
<ConnectionStringTest>
|
||||
Public Property ConnectionStringTest As String
|
||||
|
||||
<ConnectionStringAppServer>
|
||||
Public Property ConnectionStringAppServer As String
|
||||
|
||||
|
||||
92
Modules.Config/ConfigUtils.vb
Normal file
92
Modules.Config/ConfigUtils.vb
Normal file
@@ -0,0 +1,92 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ConfigUtils
|
||||
Private _Logger As Logger
|
||||
Private _File As Filesystem.File
|
||||
|
||||
Private Const MIGRATE_DIRECTORY As String = "Migrate"
|
||||
|
||||
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_File = New Filesystem.File(LogConfig)
|
||||
End Sub
|
||||
|
||||
Public Sub MigrateConfig(SourceDirectory As String, TargetDirectory As String, Optional FilePattern As String = "*.*")
|
||||
If IO.Directory.Exists(TargetDirectory) Then
|
||||
_Logger.Warn("Config Migration aborted because new config directory [{0}] already exists!", TargetDirectory)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
' Create target directory
|
||||
Try
|
||||
IO.Directory.CreateDirectory(TargetDirectory)
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Config Migration aborted because new config directory [{0}] could not be created!", TargetDirectory)
|
||||
_Logger.Error(ex)
|
||||
Exit Sub
|
||||
End Try
|
||||
|
||||
' Create Migration directory
|
||||
Dim oMigrationDirectory = IO.Path.Combine(SourceDirectory, MIGRATE_DIRECTORY)
|
||||
Try
|
||||
IO.Directory.CreateDirectory(oMigrationDirectory)
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Config Migration aborted because migration directory [{0}] could not be created!", oMigrationDirectory)
|
||||
_Logger.Error(ex)
|
||||
Exit Sub
|
||||
End Try
|
||||
|
||||
For Each oPath In IO.Directory.EnumerateFiles(SourceDirectory, FilePattern)
|
||||
Dim oFileInfo = New IO.FileInfo(oPath)
|
||||
Try
|
||||
IO.File.Copy(oPath, IO.Path.Combine(TargetDirectory, oFileInfo.Name))
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Could not move old config file {0} to new config location {1}", oFileInfo.Name, TargetDirectory)
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
For Each oPath In IO.Directory.EnumerateFiles(SourceDirectory, FilePattern)
|
||||
Dim oFileInfo = New IO.FileInfo(oPath)
|
||||
Try
|
||||
IO.File.Move(oPath, IO.Path.Combine(oMigrationDirectory, oFileInfo.Name))
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Could not move old config file {0} to migration directory {1}", oFileInfo.Name, oMigrationDirectory)
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
For Each oDirectoryPath In IO.Directory.EnumerateDirectories(SourceDirectory, "*", IO.SearchOption.TopDirectoryOnly)
|
||||
Dim oDirInfo As New IO.DirectoryInfo(oDirectoryPath)
|
||||
|
||||
If oDirInfo.FullName = TargetDirectory Or oDirInfo.FullName = oMigrationDirectory Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oNewDirectoryPath = IO.Path.Combine(TargetDirectory, oDirInfo.Name)
|
||||
Try
|
||||
_File.CopyDirectory(oDirInfo.FullName, oNewDirectoryPath, True)
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Could not move directory [{0}] to new path [{1}]", oDirInfo.FullName, oNewDirectoryPath)
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
For Each oDirectoryPath In IO.Directory.EnumerateDirectories(SourceDirectory, "*", IO.SearchOption.TopDirectoryOnly)
|
||||
Dim oDirInfo As New IO.DirectoryInfo(oDirectoryPath)
|
||||
|
||||
If oDirInfo.FullName = TargetDirectory Or oDirInfo.FullName = oMigrationDirectory Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oNewDirectoryPath = IO.Path.Combine(oMigrationDirectory, oDirInfo.Name)
|
||||
Try
|
||||
_File.CopyDirectory(oDirInfo.FullName, oNewDirectoryPath, True)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Could not move directory [{0}] to migration directory [{1}]", oDirInfo.FullName, oNewDirectoryPath)
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
@@ -206,6 +206,36 @@ Public Class File
|
||||
IO.File.Move(FilePath, Path.Combine(Directory, NewFileName))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Copied from https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-copy-directories
|
||||
''' </summary>
|
||||
''' <param name="SourceDirName"></param>
|
||||
''' <param name="DestDirName"></param>
|
||||
''' <param name="CopySubDirs"></param>
|
||||
Public Sub CopyDirectory(ByVal SourceDirName As String, ByVal DestDirName As String, ByVal CopySubDirs As Boolean)
|
||||
Dim oDirectory As DirectoryInfo = New DirectoryInfo(SourceDirName)
|
||||
|
||||
If Not oDirectory.Exists Then
|
||||
Throw New DirectoryNotFoundException("Source directory does not exist or could not be found: " & SourceDirName)
|
||||
End If
|
||||
|
||||
Dim oDirectories As DirectoryInfo() = oDirectory.GetDirectories()
|
||||
Directory.CreateDirectory(DestDirName)
|
||||
Dim oFiles As FileInfo() = oDirectory.GetFiles()
|
||||
|
||||
For Each oFile As FileInfo In oFiles
|
||||
Dim tempPath As String = Path.Combine(DestDirName, oFile.Name)
|
||||
oFile.CopyTo(tempPath, False)
|
||||
Next
|
||||
|
||||
If CopySubDirs Then
|
||||
For Each oSubDirectory As DirectoryInfo In oDirectories
|
||||
Dim oTempPath As String = Path.Combine(DestDirName, oSubDirectory.Name)
|
||||
CopyDirectory(oSubDirectory.FullName, oTempPath, CopySubDirs)
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Tries to create a directory and returns its path.
|
||||
''' Returns a temp path if `DirectoryPath` can not be created or written to.
|
||||
|
||||
@@ -75,16 +75,16 @@
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Compression.vb" />
|
||||
<Compile Include="DocumentObject.vb" />
|
||||
<Compile Include="EncryptionLegacy.vb" />
|
||||
<Compile Include="FileContainer.vb" />
|
||||
<Compile Include="Encryption.vb" />
|
||||
<Compile Include="Encryption\Compression.vb" />
|
||||
<Compile Include="FileContainer\DocumentObject.vb" />
|
||||
<Compile Include="Encryption\EncryptionLegacy.vb" />
|
||||
<Compile Include="FileContainer\FileContainer.vb" />
|
||||
<Compile Include="Encryption\Encryption.vb" />
|
||||
<Compile Include="File.vb" />
|
||||
<Compile Include="FileContainerInner.vb" />
|
||||
<Compile Include="FileWatcher.vb" />
|
||||
<Compile Include="FileWatcherFilters.vb" />
|
||||
<Compile Include="FileWatcherProperties.vb" />
|
||||
<Compile Include="FileContainer\FileContainerInner.vb" />
|
||||
<Compile Include="FileWatcher\FileWatcher.vb" />
|
||||
<Compile Include="FileWatcher\FileWatcherFilters.vb" />
|
||||
<Compile Include="FileWatcher\FileWatcherProperties.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
Reference in New Issue
Block a user