Public Class cListe

    Public Shared DBConnectionString As String = ""

    Public Shared PDFUploadPath As String = ""

    Public Shared HighwayFTPUser As String = "u78672691"
    Public Shared HighwayFTPPwd As String = "verag#2"
    Public Shared HighwayFTPSrv As String = "ftp://home546285429.1and1-data.host"


    Public Shared Debug As Boolean = False

    Public Shared Hintergrund As New List(Of String())

    Public Shared Function selectDBConnection(connection As String)

        Select Case connection
            Case "Debug"
                DBConnectionString = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Initial Catalog=Gastro;User ID=sa;Password=+ibidTsu2303!;Connection Timeout=5;"
                Debug = True
            Case "Highway"
                DBConnectionString = "Server=YM5T001348;Initial Catalog=Gastro;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
            Case "SQLGuide01"
                DBConnectionString = "Server=SQLGUIDE01.verag.ost.dmn;Initial Catalog=AVISO;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
        End Select

    End Function
End Class

Public Class cFTP

    Public Shared Function Upload2FTP(server As String, user As String, pwd As String, file As String)
        Dim clsRequest As System.Net.FtpWebRequest =
    DirectCast(System.Net.WebRequest.Create(server), System.Net.FtpWebRequest)
        clsRequest.Credentials = New System.Net.NetworkCredential(user, pwd)
        clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

        ' read in file...
        Dim bFile() As Byte = System.IO.File.ReadAllBytes(file)

        ' upload file...
        Dim clsStream As System.IO.Stream =
            clsRequest.GetRequestStream()
        clsStream.Write(bFile, 0, bFile.Length)
        clsStream.Close()
        clsStream.Dispose()
    End Function


End Class

Public Class cTools
    Public Shared Function ReturnKW(ByVal Datum As Date)
        Dim KW As Integer = DatePart(DateInterval.WeekOfYear, Datum, FirstDayOfWeek.Monday, FirstWeekOfYear.FirstFourDays)
        If KW = 53 Then
            Return 1
        Else
            Return KW
        End If
    End Function
    Public Shared Function DateToWeek(ByVal dDate As Date) As String
        ' Startdatum der ersten Kalenderwoche des Jahres und Folgejahres berechnen
        Dim dThisYear As Date = CalendarWeek(1, dDate.Year)
        Dim dNextYear As Date = CalendarWeek(1, dDate.Year + 1)

        ' Prüfen, ob Datum zur ersten Woche des Folgejahres gehört
        If dDate >= dNextYear Then
            ' Rückgabe: KW 1 des Folgejahres
            Return "1"
        ElseIf dDate < dThisYear Then
            ' Falls das Datum noch zu einer KW aus dem letzten Jahr zählt
            Return DatePart(DateInterval.WeekOfYear, New Date(dDate.Year - 1, 12, 28), FirstDayOfWeek.Monday, FirstWeekOfYear.FirstFourDays)
        Else
            ' KW = Differenz zum ersten Tag der ersten Woche
            Return Format$(dDate.Subtract(dThisYear).Days \ 7 + 1, "00")
        End If
    End Function
    Public Shared Function CalendarWeek(ByVal nWeek As Integer, ByVal nYear As Integer) As Date

        ' Wochentag des 4. Januar des Jahres ermitteln
        Dim dStart As New Date(nYear, 1, 4)
        Dim nDay As Integer = (dStart.DayOfWeek + 6) Mod 7 + 1

        ' Beginn der 1. KW des Jahres
        Dim dFirst As Date = dStart.AddDays(1 - nDay)

        ' Gesuchte KW ermitteln
        Return dFirst.AddDays((nWeek - 1) * 7)
    End Function
    Public Shared Function LoadParametersFromInI(Spalte As String)
        Dim lines = IO.File.ReadAllLines(Application.StartupPath & "\start.ini")
        Dim colCount = lines.First.Split(";"c).Length
        Dim read As Boolean = False

        For Each line In lines
            Dim objFields = From field In line.Split(";"c)

            Select Case objFields(0).ToString
                Case Spalte
                    Return objFields(1).ToString
                    read = True
            End Select
        Next

        If read = False Then Return ""

    End Function
End Class
