150 lines
4.8 KiB
VB.net
150 lines
4.8 KiB
VB.net
Public Class ClassLicenses
|
|
|
|
Private _licenses() As ClassLicense
|
|
Private _machine As String
|
|
Private _company As String
|
|
Private _WDLizenz As String
|
|
|
|
' ++++++++++++++++++++++++++++++++++++++++++++++ Methoden ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
''' <summary>
|
|
''' Konstruktor für die Lizenzen-Sammlung
|
|
''' </summary>
|
|
''' <param name="licenseStringArray">In Array übertragene Lizenzinformationen</param>
|
|
''' <remarks></remarks>
|
|
Sub New(ByVal licenseStringArray(,) As String)
|
|
Try
|
|
If licenseStringArray IsNot Nothing Then
|
|
Dim license1() As String = licenseStringArray(0, 1).Split("#")
|
|
|
|
If license1.Length > 1 Then
|
|
Me._machine = license1(1)
|
|
Else
|
|
Me._machine = "all"
|
|
End If
|
|
Me._company = license1(0) 'licenseStringArray(0, 1)
|
|
frmStart._company = Me._company
|
|
|
|
Dim i As Integer
|
|
For i = 1 To licenseStringArray.GetLength(0) - 2 ' minus 2, weil GetLength nicht null-basiert ist und das erste Element Firma ist
|
|
Dim _date As Date
|
|
Dim anzprof As String = licenseStringArray(i, 3)
|
|
If anzprof.ToLower = "unlimited" Then
|
|
anzprof = 99
|
|
End If
|
|
Try
|
|
_date = CDate(licenseStringArray(i, 1))
|
|
Catch ex As Exception
|
|
|
|
If licenseStringArray(i, 1).ToString.EndsWith("2099") Then
|
|
_date = "2099-12-31"
|
|
Else
|
|
MsgBox(ex.Message & vbNewLine & Environment.OSVersion.ToString, MsgBoxStyle.Critical)
|
|
End If
|
|
|
|
End Try
|
|
|
|
Me.Add(licenseStringArray(i, 0), _date, licenseStringArray(i, 2), anzprof)
|
|
Next
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox("Fehler bei Auslesen der Licenses: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
|
|
''' <summary>
|
|
''' Fügt der Lizenz-Sammlung eine Lizenz hinzu
|
|
''' </summary>
|
|
''' <param name="modulename">Name des Moduls, für das eine Lizenz angelegt werden soll</param>
|
|
''' <param name="expires">Datum der Gültigkeit der Lizenz</param>
|
|
''' <remarks></remarks>
|
|
Public Sub Add(ByVal modulename As String, ByVal expires As Date, ByVal type As String, ByVal anzprof As String)
|
|
|
|
If Me._licenses IsNot Nothing Then
|
|
ReDim Preserve Me._licenses(Me._licenses.Length)
|
|
Else
|
|
ReDim Preserve Me._licenses(0)
|
|
End If
|
|
|
|
Me._licenses(Me._licenses.Length - 1) = New ClassLicense(modulename, expires, type, anzprof)
|
|
End Sub
|
|
|
|
|
|
''' <summary>
|
|
''' Liefert eine Lizenz an Hand des Modulnamens
|
|
''' </summary>
|
|
''' <param name="modulename">Name des zu suchenden Moduls</param>
|
|
''' <returns>liefert ein Lizenzobjekt</returns>
|
|
''' <remarks></remarks>
|
|
Public Function GetLicense(ByVal modulename As String) As ClassLicense
|
|
If Me._licenses IsNot Nothing Then
|
|
For Each license As ClassLicense In Me._licenses
|
|
If license.Modulename = modulename Then
|
|
Return license
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
Return Nothing
|
|
End Function
|
|
|
|
|
|
|
|
|
|
' ++++++++++++++++++++++++++++++++++++++++++++++ Properties ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
''' <summary>
|
|
''' liefert eine Sammlung von Lizenzobjekten
|
|
''' </summary>
|
|
''' <value></value>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public ReadOnly Property Licenses() As ClassLicense()
|
|
Get
|
|
Return Me._licenses
|
|
End Get
|
|
End Property
|
|
|
|
|
|
''' <summary>
|
|
''' liefert eine Lizenz an Hand des Modulnamens
|
|
''' </summary>
|
|
''' <param name="modulename">Name des zu suchenden Moduls</param>
|
|
''' <value></value>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public ReadOnly Property License(ByVal modulename As String) As ClassLicense
|
|
Get
|
|
Return Me.GetLicense(modulename)
|
|
End Get
|
|
End Property
|
|
|
|
|
|
''' <summary>
|
|
''' Liefert oder setzt den Firmennamen des Lizenzeigentümers
|
|
''' </summary>
|
|
''' <value></value>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
Public Property Company() As String
|
|
Get
|
|
Return Me._company
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me._company = value
|
|
End Set
|
|
End Property
|
|
Public Property machine() As String
|
|
Get
|
|
Return Me._machine
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me._machine = value
|
|
End Set
|
|
End Property
|
|
|
|
End Class
|