Imports System.IO Module Module1 '-- pARAMEER: GenCopy 346 10 '-- Korrektur '--- Dim ds As New DataSet Dim demo As Boolean = False Sub Main() Dim lArgs() As String = Environment.GetCommandLineArgs() If lArgs.Count > 0 And lArgs(1) = "Korrektur" Then korrektur Exit Sub End If If lArgs.Count > 0 And lArgs(1) = "GenCopy" Then GenCopy(lArgs(2), lArgs(3)) Exit Sub End If If lArgs.Count > 0 And lArgs(1) = "Demo" Then demo = True End If Dim subdir As Integer = 0 Dim outputpath As String outputpath = My.Settings.OutputPath + subdir.ToString + "\" System.IO.Directory.CreateDirectory(outputpath) Dim i As Integer FileOpen(1, My.Settings.InputFile, OpenMode.Input) Dim s As String Dim Filename As String ds.ReadXml(My.Settings.Strukturfile) ds.Tables(0).Rows.Clear() While Not EOF(1) Input(1, s) i = i + 1 If demo = True And i > 20 Then Exit While If i > 500 Then i = 0 ds.WriteXml(outputpath + s + ".ind") ds.Tables(0).Rows.Clear() subdir = subdir + 1 outputpath = My.Settings.OutputPath + subdir.ToString + "\" System.IO.Directory.CreateDirectory(outputpath) End If Dim dr As DataRow Filename = s + My.Settings.Filename_Ergaenzung dr = ds.Tables(0).NewRow For Each c As DataColumn In ds.Tables(0).Columns dr(c.ColumnName) = "" Next dr("Partnernr") = s dr("Funktion") = "ADD" dr("Dokumenttypnr") = My.Settings.Doktype.ToString dr("dateiname") = Filename dr("Dateiformat") = "PDF" dr("Ersteller") = My.Settings.Ersteller dr("dokumentwert2") = "" dr("ARCHIVDATUM") = My.Settings.Archivdatum ds.Tables(0).Rows.Add(dr) System.IO.File.Copy(My.Settings.AGBFile, outputpath + Filename) End While ds.WriteXml(outputpath + s + ".ind") End Sub Sub korrektur() Dim subdir As Integer = 0 Dim outputpath As String Dim pnr As String outputpath = My.Settings.Error_Path 'System.IO.Directory.CreateDirectory(outputpath) Dim files() As String = IO.Directory.GetFiles(My.Settings.Error_Path) ds.ReadXml(My.Settings.Strukturfile) ds.Tables(0).Rows.Clear() Dim I As Integer = 0 For Each file As String In files Dim fn As String = Path.GetFileName(file) pnr = Microsoft.VisualBasic.Left(fn, Len(fn) - 8) I = I + 1 If I > 500 Then I = 0 ds.WriteXml(outputpath + pnr + ".ind") ds.Tables(0).Rows.Clear() subdir = subdir + 1 outputpath = My.Settings.Error_Path 'System.IO.Directory.CreateDirectory(outputpath) End If Dim dr As DataRow dr = ds.Tables(0).NewRow For Each c As DataColumn In ds.Tables(0).Columns dr(c.ColumnName) = "" Next dr("Partnernr") = pnr dr("Funktion") = "ADD" dr("Dokumenttypnr") = My.Settings.Doktype.ToString dr("dateiname") = System.IO.Path.GetFileName(file) dr("Dateiformat") = "PDF" dr("Ersteller") = My.Settings.Ersteller dr("dokumentwert2") = "" dr("ARCHIVDATUM") = My.Settings.Archivdatum ds.Tables(0).Rows.Add(dr) 'System.IO.File.Copy(My.Settings.AGBFile, outputpath + file) Next ds.WriteXml(outputpath + pnr + ".ind") End Sub Sub GenCopy(Anzahl As Integer, Tranche As Integer) Dim p As String = My.Settings.OutputPath Dim i As Integer = 11 Dim cnt As Integer = 0 Dim fn As String Dim loopcnt As Integer loopcnt = -1 Dim file As System.IO.StreamWriter 'Anzahl = anzahl / Tranche + 1 For xx = 0 To Anzahl If i > 10 Then Try file.Close() Catch ex As Exception End Try loopcnt = loopcnt + 1 file = My.Computer.FileSystem.OpenTextFileWriter(System.AppDomain.CurrentDomain.BaseDirectory + "\copy_bat_" + loopcnt.ToString + ".bat", True) i = 1 cnt = 1 End If file.WriteLine("copy " + p + xx.ToString + "\*.* d:\edoka\edkb08") i = i + 1 cnt = cnt + 1 If cnt > 5 Then file.WriteLine("timeout /T 600") cnt = 1 End If Next file.close() End Sub End Module