Modules/Common/frmDocumentResultList.vb
2019-09-27 16:28:42 +02:00

200 lines
8.3 KiB
VB.net

Imports System.Drawing
Imports DevExpress.Utils
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.ZooFlow
Public Class frmDocumentResultList
Private _LogConfig As LogConfig
Private _Logger As Logger
Private _Environment As Environment
Private _ResultLists As List(Of DocumentResult)
Public Sub New(LogConfig As LogConfig, Environment As Environment, Params As ResultListParams)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
_LogConfig = LogConfig
_Logger = LogConfig.GetLogger()
_Environment = Environment
_ResultLists = Params.Results
End Sub
Private Sub frmDocumentResultList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oCounter = 1
For Each oList In _ResultLists
Select Case _ResultLists.Count
Case 1
CreateDocumentGrid(GridView1, oList.Datatable)
Case 2
CreateDocumentGrid(GridView2, oList.Datatable)
Case 3
CreateDocumentGrid(GridView3, oList.Datatable)
End Select
oCounter += 1
Next
End Sub
Private Sub CreateDocumentGrid(GridView As GridView, Datatable As DataTable)
Dim oMyDocDatatable As New DataTable
Try
'Die Icon Colum erstellen und konfigurieren
Dim oColIcon As New DataColumn() With {
.DataType = GetType(Image),
.ColumnName = "ICON",
.Caption = ""
}
oMyDocDatatable.Columns.Add(oColIcon)
Dim oColPath As New DataColumn() With {
.DataType = GetType(String),
.ColumnName = "FULL_FILENAME",
.Caption = "Fullpath"
}
oMyDocDatatable.Columns.Add(oColPath)
Dim oColDocID As New DataColumn() With {
.DataType = GetType(Int32),
.ColumnName = "DocID",
.Caption = "DocID"
}
oMyDocDatatable.Columns.Add(oColDocID)
Dim oColFilename As New DataColumn() With {
.DataType = GetType(String),
.ColumnName = "Filename",
.Caption = "Filename"
}
oMyDocDatatable.Columns.Add(oColFilename)
Dim oRestColArray As New List(Of String)
For Each oCol As DataColumn In Datatable.Columns
Dim onewColumn As New DataColumn()
If oCol.ColumnName <> "DocID" And oCol.ColumnName <> "FULL_FILENAME" And oCol.ColumnName <> "Filename" Then
onewColumn.DataType = GetType(String)
onewColumn.ColumnName = oCol.ColumnName
onewColumn.Caption = oCol.Caption
oMyDocDatatable.Columns.Add(onewColumn)
oRestColArray.Add(onewColumn.ColumnName)
End If
Next
For Each oRow As DataRow In Datatable.Rows
Dim oFullpath = oRow.Item("FULL_FILENAME")
Dim oDocID = oRow.Item("DocID")
'Dim Folderpath = Path.GetDirectoryName(fullpath)
Dim oFilename = IO.Path.GetFileName(oFullpath)
Dim oFileextension = IO.Path.GetExtension(oFullpath)
Dim oNewRow As DataRow
oNewRow = oMyDocDatatable.NewRow()
'Icon zuweisen
Select Case oFileextension.ToUpper
Case ".csv".ToUpper
oNewRow.Item(0) = My.Resources.xls
Case ".txt".ToUpper
oNewRow.Item(0) = My.Resources.txt
Case ".pdf".ToUpper
oNewRow.Item(0) = My.Resources.pdf
Case ".doc".ToUpper
oNewRow.Item(0) = My.Resources.doc
Case ".docx".ToUpper
oNewRow.Item(0) = My.Resources.doc
Case ".xls".ToUpper
oNewRow.Item(0) = My.Resources.xls
Case ".xlsx".ToUpper
oNewRow.Item(0) = My.Resources.xls
Case ".xlsm".ToUpper
oNewRow.Item(0) = My.Resources.xls
Case ".ppt".ToUpper
oNewRow.Item(0) = My.Resources.ppt
Case ".pptx".ToUpper
oNewRow.Item(0) = My.Resources.ppt
Case ".dwg".ToUpper
oNewRow.Item(0) = My.Resources.dwg
Case ".dxf".ToUpper
oNewRow.Item(0) = My.Resources.dxf
Case ".msg".ToUpper
oNewRow.Item(0) = My.Resources._page
Case ".msg".ToUpper
oNewRow.Item(0) = My.Resources._page
Case ".tif".ToUpper
oNewRow.Item(0) = My.Resources.tiff
Case ".tiff".ToUpper
oNewRow.Item(0) = My.Resources.tiff
Case ".jpg".ToUpper
oNewRow.Item(0) = My.Resources.jpg
Case Else
oNewRow.Item(0) = My.Resources._blank
End Select
'Den Filepath mitgeben
oNewRow.Item(1) = oFullpath
oNewRow.Item(2) = oDocID
oNewRow.Item(3) = oFilename
Dim i = 4 'Fängt bei 3 an, um die definierten Spalten zu überspringen
For Each Colname As String In oRestColArray
Dim oRowValue
oRowValue = oRow.Item(Colname)
oNewRow.Item(i) = oRowValue.ToString
i += 1
Next
oMyDocDatatable.Rows.Add(oNewRow)
Next
Dim oGridControl As GridControl = GridView.GridControl
oGridControl.DataSource = oMyDocDatatable
oGridControl.ForceInitialize()
Try
GridView.Columns.Item("DocID").Visible = False
Catch ex As Exception
End Try
Try
GridView.Columns.Item("FULL_FILENAME").Visible = False
Catch ex As Exception
End Try
Dim created, changed As String
If _Environment.User.Language <> "de-DE" Then
changed = "Changed"
created = "Created"
Else
changed = "Geändert"
created = "Erstellt"
End If
Dim createdColumn = GridView.Columns(created)
If Not IsNothing(createdColumn) Then
createdColumn.DisplayFormat.FormatType = FormatType.DateTime
createdColumn.DisplayFormat.FormatString = _Environment.User.DateFormat & " HH:MM:ss"
End If
Dim changedColumn = GridView.Columns(changed)
If Not IsNothing(changedColumn) Then
changedColumn.DisplayFormat.FormatType = FormatType.DateTime
changedColumn.DisplayFormat.FormatString = _Environment.User.DateFormat & " HH:MM:ss"
End If
' Alle Spalten aus ReadOnly setzen, danach werden alle passenden auf nicht ReadOnly gesetzt
For Each column As GridColumn In GridView.Columns
column.OptionsColumn.AllowEdit = False
Next
GridView.Columns.Item("ICON").MaxWidth = 24
GridView.Columns.Item("ICON").MinWidth = 24
GridView.OptionsView.BestFitMaxRowCount = -1
GridView.BestFitColumns(True)
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Private Sub BarToggleSwitchItem1_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarToggleSwitchItem1.CheckedChanged
SplitContainerControl1.Horizontal = BarToggleSwitchItem1.Checked
End Sub
Private Sub BarToggleSwitchItem2_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarToggleSwitchItem2.CheckedChanged
SplitContainerControl2.Horizontal = BarToggleSwitchItem2.Checked
End Sub
End Class