You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
9.0 KiB

Imports System.Data
Imports System.IO
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Color
Public Class frmAvaloqSpooler
Inherits System.Windows.Forms.Form
Dim boolActionisRunning As Boolean
Dim boolFilesInSpooler As Boolean
Dim boolStartManuell As Boolean
Dim strFileWatchDir As String
Dim boolFileCorrupted As Boolean
Public NoEdit As Integer
#Region "Load"
Public Sub New()
MyBase.New()
' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
InitializeComponent()
End Sub
Public Sub init()
End Sub
#End Region
Private Sub Spooler_Close(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
objSpooler.Visible = False
EDOKAMain.menuSpooler.Enabled = True
e.Cancel = True
End Sub
Public Sub addItem(ByVal action As String, ByVal parnr As String, ByVal ordernr As String, ByVal doctype As String, ByRef obj As DataGridView, ByVal xmlFile As String, ByVal intSort As Integer, ByVal dokPaket As String)
Dim i As Integer
Dim row0 As String()
Dim strDocType As String = ""
Dim strPartner As String = ""
Dim arrActions(0 To 5) As String
arrActions = New String() {"Anzeige Partnerdossier", "Dokument anzeige", "Dokument Erstellung", "Dokument Bearbeitung", "Statusmutation", "Host Dokument Anzeige"}
If dokPaket = "" Then
dokPaket = 0
End If
Try
' Get Dokumenttyp kurzbeschreibung
If doctype <> "" Then
Try
doctype = doctype - 900000000
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim s As String
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_GetDokumenttyp"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
scmCmdToExecute.Parameters.Add(New SqlParameter("@DokumenttypNr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, CInt(doctype)))
scmCmdToExecute.Parameters.Add(New SqlParameter("@DP", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, dokPaket))
sdaAdapter.Fill(dtToReturn)
strDocType = dtToReturn.Rows(0).Item("bezeichnung")
Catch ex As Exception
TKBLib.Errorhandling.TraceHelper.Msg("Edoka.Spooler Add Item Error DocType", ex.Message & ex.StackTrace, TraceLevel.Error)
End Try
End If
If dokPaket = "1" Then
strDocType = "Dokumentpaket"
End If
' Get Partner kurzbeschreibung
If parnr <> "" Then
Try
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
Dim s As String
Dim dtToReturn As DataTable = New DataTable()
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
scmCmdToExecute.CommandText = "dbo.sp_getPartnerInformation"
scmCmdToExecute.CommandType = CommandType.StoredProcedure
scmCmdToExecute.Connection = conn.scoDBConnection
scmCmdToExecute.Parameters.Add(New SqlParameter("@parnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, parnr))
sdaAdapter.Fill(dtToReturn)
strPartner = dtToReturn.Rows(0).Item("BKPAR00")
Catch ex As Exception
TKBLib.Errorhandling.TraceHelper.Msg("Edoka.Spooler Add Item Error parnr", ex.Message & ex.StackTrace, TraceLevel.Error)
End Try
End If
row0 = New String() {arrActions(CInt(action) - 1), strDocType, parnr, strPartner, ordernr, xmlFile, intSort}
obj.Rows.Insert(intSort, row0)
If DokList.Rows.Count > 2 Then
btnNextAction.Enabled = True
End If
Catch ex As Exception
TKBLib.Errorhandling.TraceHelper.Msg("Edoka.Spooler Add Item Error", ex.Message & ex.StackTrace, TraceLevel.Error)
End Try
End Sub
Public Sub startNextAction()
Try
Dim xmlFile As String
xmlFile = DokList.Rows(0).Cells("xml").Value
If actionIsRunning = False Then
Me.StartManuell = True
actionIsRunning = True
EDOKAMain.HandleCommand(New String() {xmlFile})
End If
Catch ex As Exception
TKBLib.Errorhandling.TraceHelper.Msg("Edoka.Spooler Start Next Action", ex.Message & ex.StackTrace, TraceLevel.Error)
End Try
End Sub
Public Property actionIsRunning() As Boolean
Get
Return boolActionisRunning
End Get
Set(ByVal value As Boolean)
boolActionisRunning = value
End Set
End Property
Public Property FilesInSpooler() As Boolean
Get
Return boolFilesInSpooler
End Get
Set(ByVal value As Boolean)
boolFilesInSpooler = value
End Set
End Property
Public Property StartManuell() As Boolean
Get
Return boolStartManuell
End Get
Set(ByVal value As Boolean)
boolStartManuell = value
End Set
End Property
Public Property FileWatchDir() As String
Get
Return strFileWatchDir
End Get
Set(ByVal value As String)
strFileWatchDir = value
End Set
End Property
Public Property fileCorrupted() As Boolean
Get
Return boolFileCorrupted
End Get
Set(ByVal value As Boolean)
boolFileCorrupted = value
End Set
End Property
Private Sub btnNextAction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextAction.Click
startNextAction()
End Sub
Public Sub refreshList()
Try
Dim arr_Folders As String()
Dim i As Integer
DokList.Rows.Clear()
Dim dir As New IO.DirectoryInfo(Globals.SpoolerDir)
If dir.Exists Then
Dim iCounter As Integer
iCounter = 0
Dim files As IO.FileInfo() = dir.GetFiles("*.*", SearchOption.AllDirectories)
Dim file As IO.FileInfo
Dim tmpAction As Action
tmpAction = New Action
For Each file In files
If UCase(file.Extension) = "." & UCase(Consts.ACTION_FILE_EXTENSION) Then
tmpAction.Load(file)
Me.btnNextAction.Enabled = True
addItem(tmpAction.ActionType, tmpAction.GetParameterByName("PartnerNr").Value, tmpAction.GetParameterByName("fanummer3").Value, tmpAction.GetParameterByName("DokumentTypNr").Value, DokList, file.DirectoryName & "\" & file.Name, iCounter, tmpAction.GetParameterByName("Dokumentpaket").Value)
iCounter = iCounter + 1
End If
Next
If iCounter = 0 Then
Me.FilesInSpooler = False
Me.btnNextAction.Enabled = False
Else
Me.FilesInSpooler = True
End If
Else
dir.Create()
refreshList()
End If
Catch ex As Exception
Dim intStart As Integer = InStr(ex.ToString, Globals.SpoolerDir) + Len(Globals.SpoolerDir)
Dim intEnd As Integer = InStr(ex.ToString, "edk") + 3
Dim intLength As Integer = intEnd - intStart
Dim fileName As String = Mid(ex.ToString, intStart + 1, intLength)
Dim fiAction As New FileInfo(Globals.SpoolerDir & "\" & fileName)
fiAction.MoveTo(Globals.SpoolerTempDir & "\" & Replace(DateTime.Now.ToShortDateString, ".", "") & Now.TimeOfDay.Hours & Now.TimeOfDay.Minutes & Now.TimeOfDay.Seconds & fileName)
'Throw New ActionException(1, "Datei " & Globals.SpoolerDir & "\" & fileName & " weist keine gültige Struktur auf.")
MsgBox("Datei " & Globals.SpoolerDir & "\" & fileName & " weist keine gültige Struktur auf." & vbNewLine & "Datei wird nach:""" & Globals.SpoolerTempDir & """ kopiert.", MsgBoxStyle.Critical)
refreshList()
TKBLib.Errorhandling.TraceHelper.Msg("Edoka.Spooler Refresh Lsit", ex.Message & ex.StackTrace, TraceLevel.Error)
'Throw ex
End Try
End Sub
Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
refreshList()
End Sub
End Class