MS_04072016
This commit is contained in:
185
app/DD-Record-Organiser/Class_DOC_SEARCH.vb
Normal file
185
app/DD-Record-Organiser/Class_DOC_SEARCH.vb
Normal file
@@ -0,0 +1,185 @@
|
||||
Imports System.IO
|
||||
|
||||
Public Class Class_DOC_SEARCH
|
||||
Private Shared DT_RESULTLIST_OPTIONS As DataTable
|
||||
Private Shared ENTITY_ID As Integer
|
||||
Private Shared RECORD_ID As Integer
|
||||
Private Shared Function GET_DOCSEARCH_DATATABLE(Type As String)
|
||||
Try
|
||||
|
||||
Dim SQL_DOC_SEARCH
|
||||
If Type = "ENTITY" Then
|
||||
SQL_DOC_SEARCH = String.Format("SELECT * FROM VWPMO_WD_DOC_SEARCH WHERE [ENTITY_ID] = {0}", ENTITY_ID)
|
||||
Else
|
||||
Dim OPTION1 = DT_RESULTLIST_OPTIONS.Rows(0).Item("OPTION1_CTRL")
|
||||
Dim OPTION2 = DT_RESULTLIST_OPTIONS.Rows(0).Item("OPTION2_CTRL")
|
||||
Dim OPTION3 = DT_RESULTLIST_OPTIONS.Rows(0).Item("OPTION3_CTRL")
|
||||
Dim OPTION4 = DT_RESULTLIST_OPTIONS.Rows(0).Item("OPTION4_CTRL")
|
||||
Dim OPTION5 = DT_RESULTLIST_OPTIONS.Rows(0).Item("OPTION5_CTRL")
|
||||
If DT_RESULTLIST_OPTIONS.Rows.Count = 0 Then
|
||||
OPTION1 = 0
|
||||
OPTION2 = 0
|
||||
OPTION3 = 0
|
||||
OPTION4 = 0
|
||||
OPTION5 = 0
|
||||
End If
|
||||
SQL_DOC_SEARCH = String.Format("SELECT * ," & _
|
||||
"(CASE (SELECT FORM_ID FROM TBPMO_RECORD WHERE GUID = {0}) " & _
|
||||
"WHEN {1} THEN " & _
|
||||
" (SELECT VALUE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {2} AND RECORD_ID = {0}) " & _
|
||||
"ELSE '' END) AS OPTION1," & _
|
||||
"CASE (SELECT FORM_ID FROM TBPMO_RECORD WHERE GUID = 3305) " & _
|
||||
"WHEN {1} THEN " & _
|
||||
" (SELECT VALUE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {3} AND RECORD_ID = {0}) " & _
|
||||
"ELSE '' END AS OPTION2," & _
|
||||
"CASE (SELECT FORM_ID FROM TBPMO_RECORD WHERE GUID = 3305) " & _
|
||||
"WHEN {1} THEN " & _
|
||||
" (SELECT VALUE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {4} AND RECORD_ID = {0}) " & _
|
||||
"ELSE '' END AS OPTION3," & _
|
||||
"CASE (SELECT FORM_ID FROM TBPMO_RECORD WHERE GUID = 3305) " & _
|
||||
"WHEN {1} THEN " & _
|
||||
" (SELECT VALUE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {5} AND RECORD_ID = {0}) " & _
|
||||
"ELSE '' END AS OPTION4 " & _
|
||||
"FROM VWPMO_WD_DOC_SEARCH WHERE RECORD_ID LIKE '%#{0}%'", RECORD_ID, ENTITY_ID, OPTION1, OPTION2, OPTION3, OPTION4)
|
||||
End If
|
||||
Return ClassDatabase.Return_Datatable_Connection(SQL_DOC_SEARCH, 1)
|
||||
Catch ex As Exception
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Shared Function Get_DOC_RESULTTABLE(vDT_RESULTLIST_OPTIONS As DataTable, DT_WINDREAM_RESULTLIST As DataTable, ENT_ID As Integer, REC_ID As Integer, vType As String)
|
||||
Dim COL_ARRAY_RESULTLIST As List(Of String)
|
||||
ENTITY_ID = ENT_ID
|
||||
DT_RESULTLIST_OPTIONS = vDT_RESULTLIST_OPTIONS
|
||||
RECORD_ID = REC_ID
|
||||
Try
|
||||
Dim sw As New Stopwatch
|
||||
sw.Start()
|
||||
Dim elapsed As Double
|
||||
|
||||
Dim DT_FILE_RESULT As DataTable = GET_DOCSEARCH_DATATABLE(vType)
|
||||
If IsNothing(DT_FILE_RESULT) Then
|
||||
ClassLogger.Add(">> ATTENTION: GET_DOCSEARCH_DATATABLE IS NOTHING!!", False)
|
||||
Return Nothing
|
||||
End If
|
||||
Dim DTGrid As New DataTable
|
||||
Dim ColArrayDEFINITION As New List(Of String)
|
||||
Try
|
||||
'Die Icon Colum erstellen und konfigurieren
|
||||
Dim colIcon As New System.Data.DataColumn()
|
||||
colIcon.DataType = GetType(Image)
|
||||
colIcon.ColumnName = "ICON"
|
||||
colIcon.Caption = ""
|
||||
DTGrid.Columns.Add(colIcon)
|
||||
'
|
||||
Dim colPath As New System.Data.DataColumn()
|
||||
colPath.DataType = GetType(String)
|
||||
colPath.ColumnName = "FULLPATH"
|
||||
colPath.Caption = "Fullpath"
|
||||
DTGrid.Columns.Add(colPath)
|
||||
|
||||
Dim colOtype As New System.Data.DataColumn()
|
||||
colOtype.DataType = GetType(String)
|
||||
colOtype.ColumnName = "OBJECTTYPE"
|
||||
colOtype.Caption = "Objecttype"
|
||||
DTGrid.Columns.Add(colOtype)
|
||||
|
||||
|
||||
If Not DT_WINDREAM_RESULTLIST Is Nothing And DT_WINDREAM_RESULTLIST.Rows.Count >= 1 Then
|
||||
Dim ColCount As Integer = 1
|
||||
For Each rw As DataRow In DT_WINDREAM_RESULTLIST.Rows
|
||||
Dim ColumnName = rw.Item("HEADER_CAPTION")
|
||||
Dim Width = rw.Item("WIDTH")
|
||||
If IsNothing(Width) Or IsDBNull(Width) Then
|
||||
Width = 200
|
||||
End If
|
||||
'Die Spalte definieren
|
||||
DTGrid.Columns.Add(ColumnName)
|
||||
ColCount += 1
|
||||
Next
|
||||
'Jetzt das Array zusammenbauen um die Spaltenwerte zu erhalten
|
||||
For Each rw As DataRow In DT_WINDREAM_RESULTLIST.Rows
|
||||
ColArrayDEFINITION.Add(rw.Item("COLUMN_VIEW"))
|
||||
Next
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in Construct Datatable for GridResult: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
COL_ARRAY_RESULTLIST = ColArrayDEFINITION
|
||||
|
||||
For Each FILE_ROW As DataRow In DT_FILE_RESULT.Rows
|
||||
|
||||
Dim fullpath = FILE_ROW.Item("FULL_FILENAME")
|
||||
Dim objecttype = FILE_ROW.Item("OBJECTTYPE")
|
||||
'Dim Folderpath = Path.GetDirectoryName(fullpath)
|
||||
Dim filename = Path.GetFileName(fullpath)
|
||||
Dim extension = Path.GetExtension(fullpath)
|
||||
' Try
|
||||
Dim NewRow As DataRow
|
||||
NewRow = DTGrid.NewRow()
|
||||
|
||||
'Icon zuweisen
|
||||
Select Case extension
|
||||
Case ".csv"
|
||||
NewRow.Item(0) = My.Resources.doc_excel_csv
|
||||
Case ".txt"
|
||||
NewRow.Item(0) = My.Resources.text
|
||||
Case ".pdf"
|
||||
NewRow.Item(0) = My.Resources.pdf
|
||||
Case ".doc"
|
||||
NewRow.Item(0) = My.Resources.doc
|
||||
Case ".docx"
|
||||
NewRow.Item(0) = My.Resources.doc
|
||||
Case ".xls"
|
||||
NewRow.Item(0) = My.Resources.xls
|
||||
Case ".xlsx"
|
||||
NewRow.Item(0) = My.Resources.xls
|
||||
Case ".ppt"
|
||||
NewRow.Item(0) = My.Resources.ppt
|
||||
Case ".pptx"
|
||||
NewRow.Item(0) = My.Resources.ppt
|
||||
Case ".dwg"
|
||||
NewRow.Item(0) = My.Resources.dwg
|
||||
Case Else
|
||||
NewRow.Item(0) = My.Resources._blank
|
||||
End Select
|
||||
'Den Filepath mitgeben
|
||||
NewRow.Item(1) = fullpath
|
||||
NewRow.Item(2) = objecttype
|
||||
Dim i = 3 'Fängt bei 2 an, um die ICON Column zu überspringen
|
||||
For Each Colname As String In ColArrayDEFINITION
|
||||
Dim rowvalue
|
||||
Try
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> now rowvalue for Colname '" & Colname & "'", False)
|
||||
rowvalue = FILE_ROW.Item(Colname)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> rowvalue : '" & rowvalue.ToString & "'", False)
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add("Unexpected Error in GetVariableValue for Column '" & Colname & "- Error: " & ex.Message)
|
||||
If Colname.ToString.StartsWith("doct") Or Colname.ToString.StartsWith("Dokum") Then
|
||||
rowvalue = ""
|
||||
Else
|
||||
rowvalue = "Error getting rowvalue"
|
||||
End If
|
||||
End Try
|
||||
NewRow.Item(i) = rowvalue.ToString
|
||||
i += 1
|
||||
Next
|
||||
DTGrid.Rows.Add(NewRow)
|
||||
' Catch ex As Exception
|
||||
' ClassLogger.Add("Unexpected Error in CreateRow for doc '" & filename & "- Error: " & ex.Message)
|
||||
' End Try
|
||||
Next
|
||||
|
||||
|
||||
Return DTGrid
|
||||
|
||||
elapsed = sw.Elapsed.TotalSeconds
|
||||
sw.Stop()
|
||||
sw.Reset()
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" >> Run Get_DOC_RESULTTABLE took " & Format(elapsed, "0.000000000") & " seconds", False)
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in Get_DOC_RESULTTABLE: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user