-
Notifications
You must be signed in to change notification settings - Fork 0
/
RF28Automation.bas
301 lines (216 loc) · 7.78 KB
/
RF28Automation.bas
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
Attribute VB_Name = "Main"
Option Explicit
Global objSessions As Object
Global objSystem As Object
Global Denver As Object
Sub Bt_TestInputDenver()
Set objSystem = CreateObject("BlueZone.System")
Set objSessions = objSystem.Sessions
Set Denver = objSystem.ActiveSession
Dim rowArray() As Variant
Dim rowCount As String
Dim row As Integer
rowCount = getRowCount
'loop through all lines in worksheets
For row = 2 To rowCount
'sets rowArray as empty
Erase rowArray
'make an array with all cells from selected row
rowArray = getArrayFromRow(row)
navDenverMain
navLEMA
If checkDCAM(CStr(rowArray(1))) Then
wait
'go to lsma
Denver.screen.SendKeys ("<PF7>")
wait
'checks cell r7 and converts to date
Denver.screen.putstring convertDateToString, 3, 52
wait
Denver.screen.SendKeys "<Enter>"
wait
'checks whether roster is entered or needs to be added
updateOrAdd
wait
'writes roster data to appropriate screen areas
enterDayHours (rowArray)
ThisWorkbook.Worksheets(1).Range("P" & row) = "Complete"
ThisWorkbook.Worksheets(1).Range("P" & row).Interior.ColorIndex = 4
Else
'set status to "Not on File"
ThisWorkbook.Worksheets(1).Range("P" & row) = "Invalid DCAM"
ThisWorkbook.Worksheets(1).Range("P" & row).Interior.ColorIndex = 3
End If
Next row
End Sub
Function AlphaNumericOnly(strSource As String) As String
Dim i As Integer
Dim strResult As String
For i = 1 To Len(strSource)
Select Case Asc(Mid(strSource, i, 1))
Case 48 To 57, 65 To 90, 97 To 122:
strResult = strResult & Mid(strSource, i, 1)
End Select
Next
AlphaNumericOnly = strResult
End Function
Sub wait()
Denver.screen.WaitHostQuiet (1)
End Sub
Sub navDenverMain()
Denver.screen.SendKeys ("<RESET>")
wait
Denver.screen.SendKeys ("<PF3><PF3><PF3><PF3>")
wait
Denver.screen.SendKeys ("denv<Enter>")
wait
Denver.screen.SendKeys ("5<Enter>")
wait
End Sub
Sub navLEMA()
Denver.screen.putstring "LEMA", 3, 41
wait
Denver.screen.SendKeys ("<Enter>")
wait
End Sub
Function getRowCount() As String
With ActiveSheet
getRowCount = .Cells(.Rows.Count, "A").End(xlUp).row
End With
End Function
Function getArrayFromRow(row As Integer) As Variant
Dim y As Integer
Dim rowArray(15) As Variant
'set array of cells()
For y = 1 To 15
With ActiveSheet
rowArray(y) = AlphaNumericOnly(Cells(row, y).Text)
End With
Next y
getArrayFromRow = rowArray
End Function
Function checkDCAM(dcam As String) As Boolean
Dim errorCheck As String
checkDCAM = False
Denver.screen.putstring dcam, 2, 73
wait
Denver.screen.SendKeys ("<Enter>")
wait
errorCheck = Denver.screen.Area(24, 40, 24, 41)
If errorCheck <> "98" Then
checkDCAM = True
End If
End Function
Function convertDateToString() As String
Dim cellDate As Date
cellDate = ThisWorkbook.Worksheets(1).Range("R3")
convertDateToString = Format(cellDate, "ddmmyy")
End Function
Sub updateOrAdd()
Dim checkScreen As String
checkScreen = Denver.screen.Area(24, 40, 24, 41)
If checkScreen = "96" Then
Denver.screen.putstring "ADD", 3, 73
wait
Denver.screen.SendKeys ("<Enter>")
wait
ElseIf checkScreen = "71" Then
Denver.screen.putstring "Update", 3, 73
wait
Denver.screen.SendKeys ("<Enter>")
wait
End If
End Sub
Sub enterDayHours(rowArray As Variant)
enterRosterInfo CStr(rowArray(2)), CStr(rowArray(3)), 28
enterRosterInfo CStr(rowArray(4)), CStr(rowArray(5)), 36
enterRosterInfo CStr(rowArray(6)), CStr(rowArray(7)), 44
enterRosterInfo CStr(rowArray(8)), CStr(rowArray(9)), 52
enterRosterInfo CStr(rowArray(10)), CStr(rowArray(11)), 60
enterRosterInfo CStr(rowArray(12)), CStr(rowArray(13)), 68
enterRosterInfo CStr(rowArray(14)), CStr(rowArray(15)), 76
wait
Denver.screen.SendKeys ("<Enter>")
wait
End Sub
Sub enterRosterInfo(st As String, et As String, co2 As Integer)
Select Case st
Case "SCK"
Denver.screen.putstring "SIC ", 6, co2
wait
Denver.screen.putstring " ", 7, co2
wait
Denver.screen.putstring " ", 8, co2 + 2
Case "HOL"
Denver.screen.putstring "VAC ", 6, co2
wait
Denver.screen.putstring " ", 7, co2
wait
Denver.screen.putstring " ", 8, co2 + 2
Case "OFF"
Denver.screen.putstring " ", 6, co2
wait
Denver.screen.putstring " ", 7, co2
wait
Denver.screen.putstring " ", 8, co2 + 2
Case "UAB"
Denver.screen.putstring " ", 6, co2
wait
Denver.screen.putstring " ", 7, co2
wait
Denver.screen.putstring " ", 8, co2 + 2
Case "ALM"
Denver.screen.putstring " ", 6, co2
wait
Denver.screen.putstring " ", 7, co2
wait
Denver.screen.putstring " ", 8, co2 + 2
Case "AAB"
Denver.screen.putstring " ", 6, co2
wait
Denver.screen.putstring " ", 7, co2
wait
Denver.screen.putstring " ", 8, co2 + 2
Case Else
If checkIfTime(st) Then
Denver.screen.putstring st, 6, co2
wait
Denver.screen.putstring et, 7, co2
wait
Denver.screen.putstring getWorkedTime(st, et), 8, co2 + 2
End If
End Select
End Sub
Function checkIfTime(inOutTime As String) As Boolean
checkIfTime = True
Select Case inOutTime
Case "ALM", "UAB", "HOL", "AAB", "SCK", "OFF", ""
checkIfTime = False
Case Else
checkIfTime = True
End Select
End Function
Function getWorkedTime(st As String, et As String) As String
Dim result As Integer
Dim startT As Integer
Dim endT As Integer
startT = CInt(st)
endT = CInt(et)
If endT > startT Then
result = (endT - startT) / 100
ElseIf endT < startT Then
result = (endT + 2400 - startT) / 100
End If
If result < 10 Then
getWorkedTime = "0" & CStr(result)
Else
getWorkedTime = "10"
End If
End Function
Sub clearScreen_Click()
Dim rowCount As Integer
With ActiveSheet
rowCount = .Cells(.Rows.Count, "A").End(xlUp).row
End With
ActiveSheet.Range("A2:P" & rowCount).Clear
End Sub