Datenarchivarchiv

This commit is contained in:
2026-10-18 11:06:41 +02:00
parent 7d89c05b4e
commit 68bf284a8e
2 changed files with 183 additions and 53 deletions

View File

@@ -43,11 +43,15 @@ Partial Class frmDatenarchivarchiv
Me.txtUOrdner1 = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtOrdner = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.txtKategorie = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.MyComboBox1 = New VERAG_PROG_ALLGEMEIN.MyComboBox()
Me.MyTextBox1 = New VERAG_PROG_ALLGEMEIN.MyTextBox()
Me.Label11 = New System.Windows.Forms.Label()
Me.Label12 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'ProgressBar1
'
Me.ProgressBar1.Location = New System.Drawing.Point(29, 123)
Me.ProgressBar1.Location = New System.Drawing.Point(29, 147)
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.Size = New System.Drawing.Size(664, 23)
Me.ProgressBar1.TabIndex = 0
@@ -55,7 +59,7 @@ Partial Class frmDatenarchivarchiv
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(350, 153)
Me.Label1.Location = New System.Drawing.Point(350, 177)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(24, 13)
Me.Label1.TabIndex = 1
@@ -64,7 +68,7 @@ Partial Class frmDatenarchivarchiv
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(26, 19)
Me.Label2.Location = New System.Drawing.Point(26, 26)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(174, 13)
Me.Label2.TabIndex = 1
@@ -73,7 +77,7 @@ Partial Class frmDatenarchivarchiv
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(26, 56)
Me.Label3.Location = New System.Drawing.Point(26, 80)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(55, 13)
Me.Label3.TabIndex = 2
@@ -82,7 +86,7 @@ Partial Class frmDatenarchivarchiv
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(160, 56)
Me.Label4.Location = New System.Drawing.Point(160, 80)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(42, 13)
Me.Label4.TabIndex = 4
@@ -91,7 +95,7 @@ Partial Class frmDatenarchivarchiv
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(294, 56)
Me.Label5.Location = New System.Drawing.Point(294, 80)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(62, 13)
Me.Label5.TabIndex = 6
@@ -100,7 +104,7 @@ Partial Class frmDatenarchivarchiv
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(428, 56)
Me.Label6.Location = New System.Drawing.Point(428, 80)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(62, 13)
Me.Label6.TabIndex = 8
@@ -109,7 +113,7 @@ Partial Class frmDatenarchivarchiv
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Location = New System.Drawing.Point(562, 56)
Me.Label7.Location = New System.Drawing.Point(562, 80)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(62, 13)
Me.Label7.TabIndex = 10
@@ -118,7 +122,7 @@ Partial Class frmDatenarchivarchiv
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.Location = New System.Drawing.Point(562, 2)
Me.Label8.Location = New System.Drawing.Point(562, 9)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(33, 13)
Me.Label8.TabIndex = 13
@@ -127,7 +131,7 @@ Partial Class frmDatenarchivarchiv
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.Location = New System.Drawing.Point(278, 194)
Me.Button1.Location = New System.Drawing.Point(278, 198)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(165, 33)
Me.Button1.TabIndex = 14
@@ -137,7 +141,7 @@ Partial Class frmDatenarchivarchiv
'Label9
'
Me.Label9.AutoSize = True
Me.Label9.Location = New System.Drawing.Point(428, 2)
Me.Label9.Location = New System.Drawing.Point(428, 9)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(23, 13)
Me.Label9.TabIndex = 17
@@ -146,7 +150,7 @@ Partial Class frmDatenarchivarchiv
'Label10
'
Me.Label10.AutoSize = True
Me.Label10.Location = New System.Drawing.Point(294, 2)
Me.Label10.Location = New System.Drawing.Point(294, 9)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(28, 13)
Me.Label10.TabIndex = 15
@@ -167,7 +171,7 @@ Partial Class frmDatenarchivarchiv
Me.txtBis._Waehrung = False
Me.txtBis._WaehrungZeichen = True
Me.txtBis.ForeColor = System.Drawing.Color.Black
Me.txtBis.Location = New System.Drawing.Point(431, 19)
Me.txtBis.Location = New System.Drawing.Point(431, 26)
Me.txtBis.MaxLength = 10
Me.txtBis.MaxLineLength = -1
Me.txtBis.MaxLines_Warning = ""
@@ -192,7 +196,7 @@ Partial Class frmDatenarchivarchiv
Me.txtVon._Waehrung = False
Me.txtVon._WaehrungZeichen = True
Me.txtVon.ForeColor = System.Drawing.Color.Black
Me.txtVon.Location = New System.Drawing.Point(297, 19)
Me.txtVon.Location = New System.Drawing.Point(297, 26)
Me.txtVon.MaxLength = 10
Me.txtVon.MaxLineLength = -1
Me.txtVon.MaxLines_Warning = ""
@@ -217,7 +221,7 @@ Partial Class frmDatenarchivarchiv
Me.txtMax._Waehrung = False
Me.txtMax._WaehrungZeichen = True
Me.txtMax.ForeColor = System.Drawing.Color.Black
Me.txtMax.Location = New System.Drawing.Point(565, 19)
Me.txtMax.Location = New System.Drawing.Point(565, 26)
Me.txtMax.MaxLineLength = -1
Me.txtMax.MaxLines_Warning = ""
Me.txtMax.MaxLines_Warning_Label = Nothing
@@ -243,7 +247,7 @@ Partial Class frmDatenarchivarchiv
Me.txtUOrdner3._WaehrungZeichen = True
Me.txtUOrdner3.Enabled = False
Me.txtUOrdner3.ForeColor = System.Drawing.Color.Black
Me.txtUOrdner3.Location = New System.Drawing.Point(565, 73)
Me.txtUOrdner3.Location = New System.Drawing.Point(565, 97)
Me.txtUOrdner3.MaxLineLength = -1
Me.txtUOrdner3.MaxLines_Warning = ""
Me.txtUOrdner3.MaxLines_Warning_Label = Nothing
@@ -267,7 +271,7 @@ Partial Class frmDatenarchivarchiv
Me.txtUOrdner2._WaehrungZeichen = True
Me.txtUOrdner2.Enabled = False
Me.txtUOrdner2.ForeColor = System.Drawing.Color.Black
Me.txtUOrdner2.Location = New System.Drawing.Point(431, 73)
Me.txtUOrdner2.Location = New System.Drawing.Point(431, 97)
Me.txtUOrdner2.MaxLineLength = -1
Me.txtUOrdner2.MaxLines_Warning = ""
Me.txtUOrdner2.MaxLines_Warning_Label = Nothing
@@ -291,7 +295,7 @@ Partial Class frmDatenarchivarchiv
Me.txtUOrdner1._WaehrungZeichen = True
Me.txtUOrdner1.Enabled = False
Me.txtUOrdner1.ForeColor = System.Drawing.Color.Black
Me.txtUOrdner1.Location = New System.Drawing.Point(297, 73)
Me.txtUOrdner1.Location = New System.Drawing.Point(297, 97)
Me.txtUOrdner1.MaxLineLength = -1
Me.txtUOrdner1.MaxLines_Warning = ""
Me.txtUOrdner1.MaxLines_Warning_Label = Nothing
@@ -314,7 +318,7 @@ Partial Class frmDatenarchivarchiv
Me.txtOrdner._Waehrung = False
Me.txtOrdner._WaehrungZeichen = True
Me.txtOrdner.ForeColor = System.Drawing.Color.Black
Me.txtOrdner.Location = New System.Drawing.Point(163, 73)
Me.txtOrdner.Location = New System.Drawing.Point(163, 97)
Me.txtOrdner.MaxLineLength = -1
Me.txtOrdner.MaxLines_Warning = ""
Me.txtOrdner.MaxLines_Warning_Label = Nothing
@@ -338,7 +342,7 @@ Partial Class frmDatenarchivarchiv
Me.txtKategorie._Waehrung = False
Me.txtKategorie._WaehrungZeichen = True
Me.txtKategorie.ForeColor = System.Drawing.Color.Black
Me.txtKategorie.Location = New System.Drawing.Point(29, 73)
Me.txtKategorie.Location = New System.Drawing.Point(29, 97)
Me.txtKategorie.MaxLineLength = -1
Me.txtKategorie.MaxLines_Warning = ""
Me.txtKategorie.MaxLines_Warning_Label = Nothing
@@ -347,12 +351,70 @@ Partial Class frmDatenarchivarchiv
Me.txtKategorie.TabIndex = 3
Me.txtKategorie.Text = "DOKUMENTE"
'
'MyComboBox1
'
Me.MyComboBox1._allowedValuesFreiText = Nothing
Me.MyComboBox1._allowFreiText = False
Me.MyComboBox1._value = ""
Me.MyComboBox1.FormattingEnabled = True
Me.MyComboBox1.Location = New System.Drawing.Point(343, 47)
Me.MyComboBox1.Name = "MyComboBox1"
Me.MyComboBox1.Size = New System.Drawing.Size(82, 21)
Me.MyComboBox1.TabIndex = 19
'
'MyTextBox1
'
Me.MyTextBox1._DateTimeOnly = False
Me.MyTextBox1._numbersOnly = False
Me.MyTextBox1._numbersOnlyKommastellen = ""
Me.MyTextBox1._numbersOnlyTrennzeichen = True
Me.MyTextBox1._Prozent = False
Me.MyTextBox1._ShortDateNew = False
Me.MyTextBox1._ShortDateOnly = False
Me.MyTextBox1._TimeOnly = False
Me.MyTextBox1._TimeOnly_Seconds = False
Me.MyTextBox1._value = "1000"
Me.MyTextBox1._Waehrung = False
Me.MyTextBox1._WaehrungZeichen = True
Me.MyTextBox1.ForeColor = System.Drawing.Color.Black
Me.MyTextBox1.Location = New System.Drawing.Point(467, 47)
Me.MyTextBox1.MaxLineLength = -1
Me.MyTextBox1.MaxLines_Warning = ""
Me.MyTextBox1.MaxLines_Warning_Label = Nothing
Me.MyTextBox1.Name = "MyTextBox1"
Me.MyTextBox1.Size = New System.Drawing.Size(92, 20)
Me.MyTextBox1.TabIndex = 20
Me.MyTextBox1.Text = "1000"
Me.MyTextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'Label11
'
Me.Label11.AutoSize = True
Me.Label11.Location = New System.Drawing.Point(431, 50)
Me.Label11.Name = "Label11"
Me.Label11.Size = New System.Drawing.Size(30, 13)
Me.Label11.TabIndex = 22
Me.Label11.Text = "Jahr:"
'
'Label12
'
Me.Label12.AutoSize = True
Me.Label12.Location = New System.Drawing.Point(297, 50)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(40, 13)
Me.Label12.TabIndex = 21
Me.Label12.Text = "Monat:"
'
'frmDatenarchivarchiv
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(722, 239)
Me.Controls.Add(Me.Label11)
Me.Controls.Add(Me.Label12)
Me.Controls.Add(Me.MyTextBox1)
Me.Controls.Add(Me.MyComboBox1)
Me.Controls.Add(Me.txtBis)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.txtVon)
@@ -402,4 +464,8 @@ Partial Class frmDatenarchivarchiv
Friend WithEvents Label9 As Label
Friend WithEvents txtVon As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents Label10 As Label
Friend WithEvents MyComboBox1 As VERAG_PROG_ALLGEMEIN.MyComboBox
Friend WithEvents MyTextBox1 As VERAG_PROG_ALLGEMEIN.MyTextBox
Friend WithEvents Label11 As Label
Friend WithEvents Label12 As Label
End Class

View File

@@ -4,56 +4,120 @@ Public Class frmDatenarchivarchiv
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Me.Cursor = Cursors.WaitCursor
If txtMax._value = "" Then Me.Cursor = Cursors.Default : Exit Sub
If Not IsNumeric(txtMax._value) Then Me.Cursor = Cursors.Default : Exit Sub
If Not IsDate(txtVon._value) Then Me.Cursor = Cursors.Default : Exit Sub
If Not IsDate(txtBis._value) Then Me.Cursor = Cursors.Default : Exit Sub
If txtKategorie.Text Is String.Empty Then Me.Cursor = Cursors.Default : Exit Sub
If txtOrdner.Text Is String.Empty Then Me.Cursor = Cursors.Default : Exit Sub
Dim DT = SQL.loadDgvBySql(" SELECT TOP (" & txtMax._value & ") [da_id] FROM [tblDatenarchiv] inner join tblDatenarchiv_Collection on da_id=coll_daId
where da_vorlage=0 and coll_date BETWEEN '" & txtVon._value & "' and '" & txtBis._value & "' and coll_pfad NOT LIKE '%\\stor01.verag.ost.dmn\DatenArchivArchiv%' and coll_pfad NOT LIKE '\\DELETED\%'
AND da_kategorie='" & txtKategorie.Text & "' and da_ordner='" & txtOrdner.Text & "'
and da_id>=392150 group by [da_id] order by [da_id] ", "FMZOLL")
Dim maxEintraege As Integer
Dim datumVon As Date
Dim datumBis As Date
If DT Is Nothing Then Me.Cursor = Cursors.Default : Exit Sub
If DT.Rows.Count = 0 Then Me.Cursor = Cursors.Default : Exit Sub
If Not Integer.TryParse(txtMax._value, maxEintraege) OrElse maxEintraege <= 0 Then Exit Sub
If Not Date.TryParse(txtVon._value, datumVon) Then Exit Sub
If Not Date.TryParse(txtBis._value, datumBis) Then Exit Sub
If datumVon.Date > datumBis.Date Then Exit Sub
If String.IsNullOrWhiteSpace(txtKategorie.Text) Then Exit Sub
If String.IsNullOrWhiteSpace(txtOrdner.Text) Then Exit Sub
If vbYes = MsgBox("Es werden '" & DT.Rows.Count & "' Einträge verschoben - fortfahren?", vbYesNoCancel) Then
Dim sqlText As String =
"SELECT TOP (" & maxEintraege & ") da.da_id " &
"FROM tblDatenarchiv da " &
"WHERE da.da_vorlage = 0 " &
"AND da.da_kategorie = '" & txtKategorie.Text.Replace("'", "''") & "' " &
"AND da.da_ordner = '" & txtOrdner.Text.Replace("'", "''") & "' " &
"AND da.da_id >= 392150 " &
"AND EXISTS (" &
"SELECT 1 FROM tblDatenarchiv_Collection coll " &
"WHERE coll.coll_daId = da.da_id " &
"AND coll.coll_date >= '" & datumVon.ToString("yyyyMMdd") & "' " &
"AND coll.coll_date < '" & datumBis.AddDays(1).ToString("yyyyMMdd") & "' " &
"AND coll.coll_pfad NOT LIKE '%\\stor01.verag.ost.dmn\DatenArchivArchiv%' " &
"AND coll.coll_pfad NOT LIKE '\\DELETED\%' " &
") ORDER BY da.da_id"
ProgressBar1.Minimum = 1
ProgressBar1.Maximum = DT.Rows.Count
ProgressBar1.Step = 1
ProgressBar1.Value = 1
Dim DT = SQL.loadDgvBySql(sqlText, "FMZOLL")
For Each ROW In DT.Rows
'Dim DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER(txtKategorie._value, txtOrdner._value, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, txtMax._value)
If DT Is Nothing OrElse DT.Rows.Count = 0 Then Exit Sub
If MsgBox("Es werden '" & DT.Rows.Count & "' Einträge verschoben - fortfahren?", vbYesNoCancel) <> vbYes Then Exit Sub
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = DT.Rows.Count
ProgressBar1.Value = 0
Dim erfolgreich As Integer = 0
Dim fehler As Integer = 0
For Each ROW As DataRow In DT.Rows
Try
Dim DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER(ROW("da_id"))
If DS.DATA_LIST.LIST.Count > 0 Then
DS.moveTo_ARCHIVARCHIV()
End If
ProgressBar1.PerformStep()
Label1.Text = ProgressBar1.Value & "/" & DT.Rows.Count
If DT.Rows.Count < 100 Then
Me.Refresh()
Else
If ProgressBar1.Value Mod 20 = 0 Then
Me.Refresh()
If DS.moveTo_ARCHIVARCHIV() Then
erfolgreich += 1
Else
fehler += 1
End If
End If
Next
End If
Catch ex2 As Exception
fehler += 1
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex2.Message, "da_id: " & ROW("da_id").ToString() & vbNewLine & ex2.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
End Try
ProgressBar1.Value += 1
Label1.Text = ProgressBar1.Value & "/" & DT.Rows.Count & " | Fehler: " & fehler
If DT.Rows.Count < 10 OrElse ProgressBar1.Value Mod 20 = 0 Then
Me.Refresh()
End If
Next
MsgBox("Archivierung abgeschlossen." & vbNewLine &
"Erfolgreich: " & erfolgreich & vbNewLine &
"Fehler: " & fehler, vbInformation)
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
Finally
Me.Cursor = Cursors.Default
End Try
Me.Cursor = Cursors.Default
End Sub
Private Sub frmDatenarchivarchiv_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim monate As New List(Of VERAG_PROG_ALLGEMEIN.MyListItem)
For i As Integer = 1 To 12
monate.Add(New VERAG_PROG_ALLGEMEIN.MyListItem(New Date(2000, i, 1).ToString("MMMM", New System.Globalization.CultureInfo("de-AT")), i.ToString()))
Next
MyComboBox1.fillWithMyListItem(monate)
MyComboBox1._value = Date.Today.Month.ToString()
MyTextBox1._value = Date.Today.Year.ToString()
UpdateZeitraum()
End Sub
Private Sub MyComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles MyComboBox1.SelectedIndexChanged
UpdateZeitraum()
End Sub
Private Sub MyTextBox1_TextChanged(sender As Object, e As EventArgs) Handles MyTextBox1.TextChanged
UpdateZeitraum()
End Sub
Private Sub UpdateZeitraum()
Dim jahr As Integer
Dim monat As Integer
If Not Integer.TryParse(MyTextBox1._value, jahr) Then Exit Sub
If Not Integer.TryParse(MyComboBox1._value, monat) Then Exit Sub
If jahr < 1 OrElse jahr > 9999 OrElse monat < 1 OrElse monat > 12 Then Exit Sub
txtVon._value = New Date(jahr, monat, 1).ToString("dd.MM.yyyy")
txtBis._value = New Date(jahr, monat, Date.DaysInMonth(jahr, monat)).ToString("dd.MM.yyyy")
End Sub
End Class