Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
' Copyright 2014 European Union.
' Licensed under the EUPL (the 'Licence');
'
' * You may not use this work except in compliance with the Licence.
' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
' * Unless required by applicable law or agreed to in writing,
' software distributed under the Licence is distributed on an "AS IS" basis,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'
' See the LICENSE.txt for the specific language governing permissions and limitations.
Imports System.Collections.Generic
Namespace My
' The following events are available for MyApplication:
'
' Startup: Raised when the application starts even before the creation of the Startup-forms.
' Shutdown: Raised after closing all the application forms. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application, and one is already active.
' NetworkAvailabilityChanged: Occurs when connecting or disconnecting to the network.
Partial Friend Class MyApplication
'Initialization
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
Dim s As String
Dim i As Int16
Dim file As cFile_V3
'Paths
MyAppPath = My.Application.Info.DirectoryPath & "\"
MyConfPath = MyAppPath & "Config\"
MyDeclPath = MyAppPath & "Declaration\"
FB_FilHisDir = MyConfPath & "FileHistory\"
'Log
LogFile = New cLogFile
If Not LogFile.StartLog() Then
MsgBox("Error! Can't access log file. Application folder needs read/write permissions!")
e.Cancel = True
End If
'If folder does not exist: Create!
If Not IO.Directory.Exists(MyConfPath) Then
Try
IO.Directory.CreateDirectory(MyConfPath)
Catch ex As Exception
MsgBox("Failed to create directory '" & MyConfPath & "'!", MsgBoxStyle.Critical)
LogFile.WriteToLog(tMsgID.Err, "Failed to create directory '" & MyConfPath & "'!")
e.Cancel = True
End Try
IO.File.Create(MyConfPath & "joblist.txt")
IO.File.Create(MyConfPath & "cyclelist.txt")
End If
If Not IO.Directory.Exists(FB_FilHisDir) Then
Try
IO.Directory.CreateDirectory(FB_FilHisDir)
'Preconfigure Directories.txt
Try
s = IO.Directory.GetParent(My.Application.Info.DirectoryPath).ToString & "\"
Catch ex As Exception
s = MyAppPath
End Try
Try
file = New cFile_V3
file.OpenWrite(FB_FilHisDir & "Directories.txt")
file.WriteLine(s)
For i = 2 To 20
file.WriteLine(" ")
Next
file.Close()
Catch ex As Exception
End Try
Catch ex As Exception
MsgBox("Failed to create directory '" & FB_FilHisDir & "'!", MsgBoxStyle.Critical)
LogFile.WriteToLog(tMsgID.Err, "Failed to create directory '" & FB_FilHisDir & "'!")
e.Cancel = True
End Try
End If
'Separator!
SetCulture = False
If System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator <> "." Then
SetCulture = True
Try
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en-US")
'MSGtoForm(8, "Set CurrentCulture to 'en-US'", True)
Catch ex As Exception
GUImsg(tMsgID.Err, "Failed to set Application Regional Settings to 'en-US'! Check system decimal- and group- separators!")
End Try
End If
'Initialise Classes
sKey = New csKey
JobFileList = New List(Of String)
JobCycleList = New List(Of String)
DEV = New cDEV
Declaration = New cDeclaration
Cfg = New cConfig 'ACHTUNG: cConfig.New löst cConfig.SetDefault aus welches sKey benötigt dehalb muss sKey schon vorher initialisiert werden!!
Cfg.FilePath = MyConfPath & "settings.json"
ProgBarCtrl = New cProgBarCtrl
'Config
Cfg.ConfigLOAD()
'Restart log if log file too large
LogFile.SizeCheck()
'License initialization
Lic = New vectolic.cLicense
Lic.AppVersion = VECTOvers
Lic.FilePath = MyAppPath & "license.dat"
End Sub
Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
e.ExitApplication = True
MsgBox("ERROR!" & ChrW(10) & ChrW(10) & e.Exception.Message.ToString, MsgBoxStyle.Critical, "Unexpected Error")
LogFile.WriteToLog(tMsgID.Err, ">>>Unexpected Error:" & e.Exception.ToString())
End Sub
End Class
End Namespace