1 | #Region ;**** Directives created by AutoIt3Wrapper_GUI **** |
---|
2 | #AutoIt3Wrapper_Icon=Boss1.ICO |
---|
3 | #AutoIt3Wrapper_Outfile=AutoTestManager.exe |
---|
4 | #AutoIt3Wrapper_Compression=4 |
---|
5 | #AutoIt3Wrapper_Res_Comment=This tool is used to sequence multiple test jobs. |
---|
6 | #AutoIt3Wrapper_Res_Description=AutoIt Test Manager |
---|
7 | #AutoIt3Wrapper_Res_Fileversion=0.8.2990.1 |
---|
8 | #AutoIt3Wrapper_Res_FileVersion_AutoIncrement=p |
---|
9 | #AutoIt3Wrapper_Res_LegalCopyright=Roy Kirby 2008 |
---|
10 | #AutoIt3Wrapper_Res_SaveSource=y |
---|
11 | #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% |
---|
12 | #AutoIt3Wrapper_Res_Field=Author|Roy B Kirby |
---|
13 | #AutoIt3Wrapper_Res_Field=Email|roykirby@lineone.net |
---|
14 | #AutoIt3Wrapper_Res_Field=Product Name|Auto Test Runner |
---|
15 | #AutoIt3Wrapper_Res_Field=Product Version|0.8 |
---|
16 | #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% |
---|
17 | #AutoIt3Wrapper_Res_Field=Compile Date|%date% %time% |
---|
18 | #AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y |
---|
19 | #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 |
---|
20 | #AutoIt3Wrapper_Run_Before=MKDIR "%scriptdir%\Release" |
---|
21 | #AutoIt3Wrapper_Run_After=copy "%out%" "%scriptdir%\Release\%scriptfile%.%fileversion%.exe" |
---|
22 | #AutoIt3Wrapper_Run_After=copy "%in%" "%scriptdir%\Release\%scriptfile%.%fileversion%.au3" |
---|
23 | #AutoIt3Wrapper_Run_After=copy "%out%" "%scriptdir%\Release |
---|
24 | #AutoIt3Wrapper_Run_Tidy=y |
---|
25 | #Tidy_Parameters=/tc 0 /gd /sci 0 /sdp"'\WinMerge\WinMerge.exe' '%new%' '%old%'" |
---|
26 | #AutoIt3Wrapper_Run_Obfuscator=y |
---|
27 | #Obfuscator_Parameters=/striponly |
---|
28 | #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** |
---|
29 | #AutoIt3Wrapper_Run_Debug_Mode=N |
---|
30 | |
---|
31 | ;#AutoIt3Wrapper_PlugIn_Funcs= |
---|
32 | #cs Introduction |
---|
33 | Script Name:AutoTestManager |
---|
34 | Purpose:This tool is used to sequence multiple automated tesing jobs. |
---|
35 | Similar to Rational Test Manager. |
---|
36 | #ce |
---|
37 | #Region ### Set Options |
---|
38 | Opt("WinWaitDelay", 100) |
---|
39 | Opt("WinTitleMatchMode", 4) |
---|
40 | Opt("WinDetectHiddenText", 1) |
---|
41 | Opt("MouseCoordMode", 2) |
---|
42 | Opt("MustDeclareVars", 1) |
---|
43 | #EndRegion ### Set Options |
---|
44 | #Region Declare |
---|
45 | Global Const $AT_ROOT_DIR = "H:\AtuoItTestControl" |
---|
46 | Global $g_nMsg = 0 |
---|
47 | Global $g_fDEBUG = False |
---|
48 | Global $g_fRun = False |
---|
49 | Global $g_fAllJobsDone = False |
---|
50 | Global $g_fProcessing = False |
---|
51 | Global $g_sTaskType = '' |
---|
52 | Global $g_sJobControlFolder = '' |
---|
53 | Global $g_sStartDateTime = '' |
---|
54 | Global $g_sStopDateTime = '' |
---|
55 | Global $g_sTestRunID = '' |
---|
56 | Global $sTitle = StringLeft(@ScriptName, StringInStr(@ScriptName, ".") - 1) |
---|
57 | Global $GUI_frmMainCaption = $sTitle & " - Ver " & FileGetVersion(@ScriptFullPath) |
---|
58 | Global $g_aStatusBarParts[2] = [350, -1] |
---|
59 | Global $g_aStatusBarPartsText[2] = ["Ready", ""] |
---|
60 | Global $hWndStartDate = 0 |
---|
61 | Global $hWndStopDate = 0 |
---|
62 | Global $g_iSleep = 10 |
---|
63 | Global $g_Computers_Status[250][5] |
---|
64 | Global $g_hDB = 0 |
---|
65 | Global $g_aStatusBarParts[3] = [150, 440, -1] |
---|
66 | Global $g_aStatusBarPartsText[3] = ["Ready", "", "000:00:00"] |
---|
67 | Global $g_aComputers = 0 |
---|
68 | Global $g_sRunStartTime = '' |
---|
69 | Global $g_iPercentDone = 0 |
---|
70 | Global $g_iStatus, $g_aResult, $g_iRows, $g_iColumns |
---|
71 | #EndRegion Declare |
---|
72 | |
---|
73 | #Region Includes |
---|
74 | #include <_os_File.au3> |
---|
75 | #include <_os_TileUtilities.au3> |
---|
76 | #include <ButtonConstants.au3> |
---|
77 | #include <Date.au3> |
---|
78 | #include <SQLite.au3> |
---|
79 | #include <SQLite.dll.au3> |
---|
80 | #include <WindowsConstants.au3> |
---|
81 | #include <GUIConstantsEx.au3> |
---|
82 | #include <GuiListView.au3> |
---|
83 | #include <GuiStatusBar.au3> |
---|
84 | #include <ProgressConstants.au3> |
---|
85 | #EndRegion Includes |
---|
86 | |
---|
87 | #Region ### START Koda GUI section ### Form=X:\AutoIt3Data\Scripts\AutoTest\AutoTestManager\Gui_frmMain.kxf |
---|
88 | Global $Gui_frmMain = GUICreate($GUI_frmMainCaption, 495, 468, 451, 151) |
---|
89 | Global $Gui_tab = GUICtrlCreateTab(5, 5, 486, 437) |
---|
90 | Global $Gui_tab0 = GUICtrlCreateTabItem("Topo93 Comp") |
---|
91 | Global $Gui_tab0_lblJob = GUICtrlCreateLabel("Test Job", 10, 40, 100, 17) |
---|
92 | Global $Gui_tab0_edtTestJob = GUICtrlCreateInput("", 110, 38, 350, 21) |
---|
93 | Global $Gui_tab0_lblDataRootV1 = GUICtrlCreateLabel("V1 Data Root Dir", 10, 65, 100, 17) |
---|
94 | Global $Gui_tab0_edtDataRootV1 = GUICtrlCreateInput("", 110, 63, 350, 21) |
---|
95 | Global $Gui_tab0_btnBrowseV1 = GUICtrlCreateButton("...", 463, 63, 21, 21, BitOR($BS_CENTER, $BS_VCENTER, $BS_FLAT)) |
---|
96 | Global $Gui_tab0_lblDataRootV2 = GUICtrlCreateLabel("V2 Data Root Dir", 10, 90, 100, 17) |
---|
97 | Global $Gui_tab0_edtDataRootV2 = GUICtrlCreateInput("", 110, 88, 350, 21) |
---|
98 | Global $Gui_tab0_btnBrowseV2 = GUICtrlCreateButton("...", 463, 88, 21, 21, BitOR($BS_CENTER, $BS_VCENTER, $BS_FLAT)) |
---|
99 | Global $Gui_tab0_lblStrumapPrm = GUICtrlCreateLabel("PRM config File", 10, 115, 100, 17) |
---|
100 | Global $Gui_tab0_edtStrumapPrm = GUICtrlCreateInput("", 110, 113, 350, 21) |
---|
101 | Global $Gui_tab0_btnBrowsePrm = GUICtrlCreateButton("...", 463, 113, 21, 21, BitOR($BS_CENTER, $BS_VCENTER, $BS_FLAT)) |
---|
102 | Global $Gui_tab0_lblStrumapVer = GUICtrlCreateLabel("Strumap Ver", 200, 140, 80, 17) |
---|
103 | Global $Gui_tab0_cboStrumapVer = GUICtrlCreateCombo("", 260, 138, 85, 25) |
---|
104 | Global $Gui_tab0_lblTopo96Ext = GUICtrlCreateLabel("Topo96 Ext", 10, 140, 100, 17) |
---|
105 | Global $Gui_tab0_cboTopo96Ext = GUICtrlCreateCombo("", 110, 138, 65, 25) |
---|
106 | Global $Gui_tab0_lblTopo93V1Ext = GUICtrlCreateLabel("Topo93 V1 Ext", 10, 165, 100, 17) |
---|
107 | Global $Gui_tab0_cboTopo93V1Ext = GUICtrlCreateCombo("", 110, 163, 65, 25) |
---|
108 | Global $Gui_tab0_lblTopo93V2Ext = GUICtrlCreateLabel("Topo93 V2 Ext", 10, 190, 100, 17) |
---|
109 | Global $Gui_tab0_cboTopo93V2Ext = GUICtrlCreateCombo("", 110, 188, 65, 25) |
---|
110 | Global $Gui_tab0_chkCreatePhseudo = GUICtrlCreateCheckbox("Create Pseudo", 370, 140, 100, 17) |
---|
111 | Global $Gui_tab0_chkUseGeoComp = GUICtrlCreateCheckbox("Use GeoComp", 370, 157, 100, 17) |
---|
112 | Global $Gui_tab0_chkSaveSbz = GUICtrlCreateCheckbox("Save SBZ Files", 370, 174, 100, 17) |
---|
113 | Global $Gui_tab0_chkClassifyErr = GUICtrlCreateCheckbox("Classify Errors", 370, 191, 100, 17) |
---|
114 | Global $Gui_tab0_btnStopPCs = GUICtrlCreateButton("Stop Selected PCs", 380, 405, 100, 30, $BS_FLAT) |
---|
115 | Global $Gui_tab0_btnRun = GUICtrlCreateButton("Run", 10, 405, 100, 30, $BS_FLAT) |
---|
116 | Global $Gui_tab0_btnClose = GUICtrlCreateButton("Close", 134, 405, 100, 30, $BS_FLAT) |
---|
117 | Global $Gui_tab0_MyButton3 = GUICtrlCreateButton("MyButton3", 258, 405, 100, 30, $BS_FLAT) |
---|
118 | Global $Gui_tab0_lsvComputers = GUICtrlCreateListView("", 10, 220, 475, 178, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SORTASCENDING), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) |
---|
119 | Global $Gui_tab0_hListView = ControlGetHandle($GUI_frmMainCaption, "", $Gui_tab0_lsvComputers) |
---|
120 | _GUICtrlListView_AddColumn($Gui_tab0_hListView, "Computers", 100) |
---|
121 | _GUICtrlListView_AddColumn($Gui_tab0_hListView, "Job", 100) |
---|
122 | _GUICtrlListView_AddColumn($Gui_tab0_hListView, "Status", 95) |
---|
123 | _GUICtrlListView_AddColumn($Gui_tab0_hListView, "Started", 115) |
---|
124 | _GUICtrlListView_AddColumn($Gui_tab0_hListView, "Time", 60) |
---|
125 | GUICtrlCreateTabItem("") |
---|
126 | Global $Gui_tab1 = GUICtrlCreateTabItem("MasterMap Comp") |
---|
127 | GUICtrlCreateTabItem("") |
---|
128 | Global $Gui_tab2 = GUICtrlCreateTabItem("ITN Validate") |
---|
129 | GUICtrlCreateTabItem("") |
---|
130 | Global $GUI_stbStatusBar = _GUICtrlStatusBar_Create($Gui_frmMain, $g_aStatusBarParts, $g_aStatusBarPartsText) |
---|
131 | Global $Gui_pgbProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH) |
---|
132 | Global $g_hProgress = GUICtrlGetHandle($Gui_pgbProgress) |
---|
133 | _GUICtrlStatusBar_SetMinHeight($GUI_stbStatusBar, 20) |
---|
134 | _GUICtrlStatusBar_EmbedControl($GUI_stbStatusBar, 1, $g_hProgress) |
---|
135 | |
---|
136 | _Settings_Read() |
---|
137 | GUISetState(@SW_SHOW) |
---|
138 | #EndRegion ### START Koda GUI section ### Form=X:\AutoIt3Data\Scripts\AutoTest\AutoTestManager\Gui_frmMain.kxf |
---|
139 | Global $tLastChecked = TimerInit() |
---|
140 | Global $iLastDBCheck = TimerInit() |
---|
141 | While 1 |
---|
142 | $g_nMsg = GUIGetMsg() |
---|
143 | Switch $g_nMsg |
---|
144 | Case $GUI_EVENT_CLOSE |
---|
145 | _Settings_Save() |
---|
146 | Exit |
---|
147 | Case $Gui_tab0_btnClose |
---|
148 | _Settings_Save() |
---|
149 | Exit |
---|
150 | Case $Gui_tab0_btnRun |
---|
151 | $g_fRun = False |
---|
152 | If Not (_Initialise() = 1) Then ContinueLoop |
---|
153 | If Not (_Database_Start() = 1) Then ContinueLoop |
---|
154 | If Not (_Database_Initialise() = 1) Then ContinueLoop |
---|
155 | If Not (_Computers_Clean() = 1) Then ContinueLoop |
---|
156 | $g_sRunStartTime = _NowCalc() |
---|
157 | $g_fRun = True |
---|
158 | Case $Gui_tab0_MyButton3 |
---|
159 | $g_iStatus = _SQLite_GetTable2d($g_hDB, "SELECT * FROM JOB_CONTROL ORDER BY FILE_SIZE DESC;", $g_aResult, $g_iRows, $g_iColumns) |
---|
160 | If $g_iStatus = $SQLITE_OK Then |
---|
161 | _ArrayDisplay($g_aResult, "Results") |
---|
162 | $g_iStatus = 1 |
---|
163 | EndIf |
---|
164 | EndSwitch |
---|
165 | |
---|
166 | If $g_fRun And TimerDiff($tLastChecked) > 2500 Then |
---|
167 | $g_aComputers = _ScanFor_ComputersOnline($g_sJobControlFolder) |
---|
168 | _Process_ComputersOnline($g_aComputers) |
---|
169 | $g_aComputers = _ScanFor_ComputersOffline($g_sJobControlFolder) |
---|
170 | _Process_ComputersOffline($g_aComputers) |
---|
171 | $g_aComputers = _ScanFor_JobsAborted($g_sJobControlFolder) |
---|
172 | _Process_JobsAborted($g_aComputers) |
---|
173 | $g_aComputers = _ScanFor_JobsCompleted($g_sJobControlFolder) |
---|
174 | _Process_JobsCompleted($g_aComputers) |
---|
175 | $g_aComputers = _ScanFor_JobRequests($g_sJobControlFolder) |
---|
176 | _Process_JobRequests($g_aComputers) |
---|
177 | $g_aComputers = _ScanFor_JobsRunning($g_sJobControlFolder) |
---|
178 | _Process_JobsRunning($g_aComputers) |
---|
179 | If $g_fAllJobsDone Then |
---|
180 | _Process_Results($g_sJobControlFolder, $g_Computers_Status) |
---|
181 | $g_fRun = False |
---|
182 | EndIf |
---|
183 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, _RuninngTime($g_sRunStartTime), 2) |
---|
184 | If TimerDiff($iLastDBCheck) > 120000 Then |
---|
185 | $g_iPercentDone = _PercentDone() |
---|
186 | $iLastDBCheck = TimerInit() |
---|
187 | EndIf |
---|
188 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Percentage Done " & $g_iPercentDone) |
---|
189 | $tLastChecked = TimerInit() |
---|
190 | EndIf |
---|
191 | WEnd |
---|
192 | |
---|
193 | |
---|
194 | Func _Computers_Clean() |
---|
195 | Local $sFolder = $g_sJobControlFolder & "\Computers" |
---|
196 | Local $asFileList[1] = [0] |
---|
197 | Local $sFilePattern |
---|
198 | Local $iState = 1 |
---|
199 | For $i = 1 To 7 |
---|
200 | Switch $i |
---|
201 | Case 1 |
---|
202 | $sFilePattern = "_RunningJob.atj" |
---|
203 | Case 2 |
---|
204 | $sFilePattern = "_CompletedJob.atj" |
---|
205 | Case 3 |
---|
206 | $sFilePattern = "_NextJob.atj" |
---|
207 | Case 4 |
---|
208 | $sFilePattern = "_NoMoreJobs.atj" |
---|
209 | Case 6 |
---|
210 | $sFilePattern = "_Stop.atj" |
---|
211 | Case 6 |
---|
212 | $sFilePattern = "_Aborted.atj" |
---|
213 | Case Else |
---|
214 | $sFilePattern = "_RequestJob.atj" |
---|
215 | EndSwitch |
---|
216 | ReDim $asFileList[1] |
---|
217 | $asFileList[0] = 0 |
---|
218 | $asFileList = _os_FilesListInTree($sFolder, $asFileList, 0, $sFilePattern) |
---|
219 | For $iFile = 1 To $asFileList[0] |
---|
220 | FileDelete($asFileList[$iFile]) |
---|
221 | Next |
---|
222 | Next |
---|
223 | Return $iState |
---|
224 | EndFunc ;==>_Computers_Clean |
---|
225 | Func _Database_Initialise() |
---|
226 | Local $sIniFile = $g_sJobControlFolder & "\config.ini" |
---|
227 | Local $iStatus = 1 |
---|
228 | Local $aResult = 0 |
---|
229 | Local $iRows = 0 |
---|
230 | Local $iColumns = 0 |
---|
231 | Local $sTile = '' |
---|
232 | Local $sSQL = '' |
---|
233 | ;~ Local $sTable = "JOB_CONTROL" |
---|
234 | Local $aRow |
---|
235 | Local $iJobCount = 0 |
---|
236 | Local $iJobCompletedCount = 0 |
---|
237 | Local $iMsgBoxAnswer |
---|
238 | Local $fFullRun = True |
---|
239 | Local $iFileSize = 0 |
---|
240 | Local $sJobList[1] = [0] |
---|
241 | Local $sMsg = '' |
---|
242 | |
---|
243 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Checking database") |
---|
244 | $sSQL = "SELECT Count(FILE) FROM JOB_CONTROL" |
---|
245 | _SQLite_QuerySingleRow($g_hDB, $sSQL, $aRow) ; Select single row and single field ! |
---|
246 | If $iStatus = $SQLITE_OK Then |
---|
247 | If IsArray($aRow) Then $iJobCount = $aRow[0] |
---|
248 | If $iJobCount > 0 Then |
---|
249 | $sSQL = "SELECT Count(END_TIME) FROM JOB_CONTROL WHERE END_TIME = NULL" |
---|
250 | _SQLite_QuerySingleRow($g_hDB, $sSQL, $aRow) ; Select single row and single field ! |
---|
251 | If $iStatus <> $SQLITE_OK Then |
---|
252 | Return SetError(@error, 0, 0) |
---|
253 | EndIf |
---|
254 | If IsArray($aRow) Then $iJobCompletedCount = $aRow[0] |
---|
255 | If $iJobCount > $iJobCompletedCount Then |
---|
256 | $sMsg = "This Job has previously been Run and " & $iJobCompletedCount & " out of " & $iJobCount & " Tests completed." & @CRLF & "Click Yes - to complete previous run" & @CRLF & "Click No - to deltete previous run and run all tests again." & @CRLF & "Click Cancel - to exit without any changes." |
---|
257 | |
---|
258 | ;~ $sMsg = "This Job has previously been Run and " _ |
---|
259 | ;~ & $iJobCompletedCount & " out of " & $iJobCount & " Tests completed." & @CRLF _ |
---|
260 | ;~ & "Click Yes - to complete previous run" & @CRLF _ |
---|
261 | ;~ & "Click No - to deltete previous run and run all tests again." & @CRLF _ |
---|
262 | ;~ & "Click Cancel - to exit without any changes." |
---|
263 | #Region --- CodeWizard generated code Start --- |
---|
264 | ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Default Button=Third, Icon=Question, Modality=System Modal, Miscellaneous=Top-most attribute |
---|
265 | $iMsgBoxAnswer = MsgBox(266787, "AutoTestManager - Info", $sMsg) |
---|
266 | Select |
---|
267 | Case $iMsgBoxAnswer = 6 ;Yes |
---|
268 | $fFullRun = False |
---|
269 | Case $iMsgBoxAnswer = 7 ;No |
---|
270 | $fFullRun = True |
---|
271 | Case $iMsgBoxAnswer = 2 ;Cancel |
---|
272 | Return 10 |
---|
273 | EndSelect |
---|
274 | #EndRegion --- CodeWizard generated code Start --- |
---|
275 | ElseIf $iJobCount > 0 Then |
---|
276 | $sMsg = "This Job has previously been Run and completed" & @CRLF & "Do you want to overwrite the previous run and run the tests again?" |
---|
277 | #Region --- CodeWizard generated code Start --- |
---|
278 | ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=Question, Modality=System Modal, Miscellaneous=Top-most attribute |
---|
279 | $iMsgBoxAnswer = MsgBox(266532, "AutoTestManager - Info", "") |
---|
280 | Select |
---|
281 | Case $iMsgBoxAnswer = 6 ;Yes |
---|
282 | $fFullRun = True |
---|
283 | Case $iMsgBoxAnswer = 7 ;No |
---|
284 | Return 10 |
---|
285 | EndSelect |
---|
286 | #EndRegion --- CodeWizard generated code Start --- |
---|
287 | EndIf |
---|
288 | EndIf |
---|
289 | EndIf |
---|
290 | |
---|
291 | If $fFullRun Then |
---|
292 | Local $sDataDir = IniRead($sIniFile, "SETTINGS", "V1CITFDataRootDir", "") |
---|
293 | If $sDataDir = '' Then |
---|
294 | #Region --- CodeWizard generated code Start --- |
---|
295 | ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Critical, Modality=System Modal, Miscellaneous=Top-most attribute |
---|
296 | MsgBox(266256, "AutoTestManager - Error", "V1CITFDataRootDir path has not been set. ") |
---|
297 | #EndRegion --- CodeWizard generated code Start --- |
---|
298 | Return 10 |
---|
299 | EndIf |
---|
300 | Local $sDataExt = IniRead($sIniFile, "SETTINGS", "V0FileExtention", "citf") |
---|
301 | $sDataDir = _os_PathNormalise($sDataDir) |
---|
302 | Local $sFilePattern = '' |
---|
303 | If StringLeft($sDataExt, 1) <> "." Then |
---|
304 | $sFilePattern = "*." & $sDataExt |
---|
305 | Else |
---|
306 | $sFilePattern = "*" & $sDataExt |
---|
307 | EndIf |
---|
308 | |
---|
309 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Searching for files") |
---|
310 | $sJobList = _ScanFor_JobsToDo($sDataDir, $sFilePattern) |
---|
311 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Loading database") |
---|
312 | |
---|
313 | $sSQL = "DROP TABLE IF EXISTS JOB_CONTROL" |
---|
314 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
315 | $sSQL = "CREATE TABLE IF NOT EXISTS JOB_CONTROL ( FILE TEXT UNIQUE, FILE_SIZE INTEGER, TILE TEXT, COMPUTER TEXT, START_TIME TEXT, END_TIME TEXT, TIME_TAKEN TEXT, SYNTAX_CITF TEXT, SYNTAX_NTF TEXT, Q1_CREATED TEXT, SYNTAX_Q1 TEXT, SYNTAX_Q2 TEXT, NO_FEATURES INTEGER, NO_DIFF INTEGER, RESULT TEXT, ERROR TEXT )" |
---|
316 | |
---|
317 | |
---|
318 | ;~ $sSQL = "CREATE TABLE IF NOT EXISTS JOB_CONTROL" & _ |
---|
319 | ;~ " (" & _ |
---|
320 | ;~ " FILE TEXT UNIQUE," & _ |
---|
321 | ;~ " FILE_SIZE INTEGER," & _ |
---|
322 | ;~ " TILE TEXT," & _ |
---|
323 | ;~ " COMPUTER TEXT," & _ |
---|
324 | ;~ " START_TIME TEXT," & _ |
---|
325 | ;~ " END_TIME TEXT," & _ |
---|
326 | ;~ " TIME_TAKEN TEXT," & _ |
---|
327 | ;~ " SYNTAX_CITF TEXT," & _ |
---|
328 | ;~ " SYNTAX_NTF TEXT," & _ |
---|
329 | ;~ " Q1_CREATED TEXT," & _ |
---|
330 | ;~ " SYNTAX_Q1 TEXT," & _ |
---|
331 | ;~ " SYNTAX_Q2 TEXT," & _ |
---|
332 | ;~ " NO_FEATURES INTEGER," & _ |
---|
333 | ;~ " NO_DIFF INTEGER," & _ |
---|
334 | ;~ " RESULT TEXT," & _ |
---|
335 | ;~ " ERROR TEXT )" |
---|
336 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
337 | If $iStatus <> $SQLITE_OK Then |
---|
338 | Return SetError(@error, 0, 0) |
---|
339 | EndIf |
---|
340 | $sSQL = "BEGIN TRANSACTION" |
---|
341 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
342 | For $i = 1 To $sJobList[0] |
---|
343 | $sTile = _os_otu_GetTileRefFromFileName($sJobList[$i]) |
---|
344 | $iFileSize = FileGetSize($sJobList[$i]) |
---|
345 | $sSQL = "INSERT OR REPLACE INTO JOB_CONTROL (FILE,FILE_SIZE,TILE) VALUES('" & $sJobList[$i] & "','" & $iFileSize & "','" & $sTile & "')" |
---|
346 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
347 | Next |
---|
348 | $sSQL = "END TRANSACTION" |
---|
349 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
350 | $sSQL = "CREATE INDEX IF NOT EXISTS IDX_FILE_SIZE ON JOB_CONTROL ( FILE_SIZE DESC )" |
---|
351 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
352 | $sSQL = "CREATE INDEX IF NOT EXISTS IDX_COMPUTER ON JOB_CONTROL ( COMPUTER )" |
---|
353 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
354 | $sSQL = "CREATE INDEX IF NOT EXISTS IDX_END_TIME ON JOB_CONTROL ( END_TIME ASC )" |
---|
355 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
356 | Else |
---|
357 | $sSQL = "UPDATE JOB_CONTROL SET " & _ |
---|
358 | " COMPUTER = NULL," & _ |
---|
359 | " START_TIME = NULL," & _ |
---|
360 | " END_TIME = NULL," & _ |
---|
361 | " TIME_TAKEN = NULL," & _ |
---|
362 | " SYNTAX_CITF = NULL," & _ |
---|
363 | " SYNTAX_NTF = NULL," & _ |
---|
364 | " Q1_CREATED = NULL," & _ |
---|
365 | " SYNTAX_Q1 = NULL," & _ |
---|
366 | " SYNTAX_Q2 = NULL," & _ |
---|
367 | " NO_FEATURES = NULL," & _ |
---|
368 | " NO_DIFF = NULL," & _ |
---|
369 | " RESULT = NULL," & _ |
---|
370 | " ERROR = NULL )" & _ |
---|
371 | " WHERE COMPUTER NOT NULL AND END_TIME = NULL" |
---|
372 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
373 | EndIf |
---|
374 | |
---|
375 | $sSQL = "SELECT * FROM JOB_CONTROL ORDER BY FILE_SIZE DESC;" |
---|
376 | $iStatus = _SQLite_GetTable2d($g_hDB, $sSQL, $aResult, $iRows, $iColumns) |
---|
377 | If $iStatus = $SQLITE_OK Then |
---|
378 | $iStatus = 1 |
---|
379 | EndIf |
---|
380 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Database ready") |
---|
381 | Return $iStatus |
---|
382 | EndFunc ;==>_Database_Initialise |
---|
383 | |
---|
384 | Func _Database_Start() |
---|
385 | Local $iStatus = 1 |
---|
386 | Local $sDatabase = $g_sJobControlFolder & "\AutoTestControl.db" |
---|
387 | |
---|
388 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Starting SQLite") |
---|
389 | |
---|
390 | _SQLite_Startup() |
---|
391 | If @error > 0 Then |
---|
392 | MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!") |
---|
393 | $iStatus = 0 |
---|
394 | EndIf |
---|
395 | $g_hDB = _SQLite_Open($sDatabase) |
---|
396 | If @error > 0 Then |
---|
397 | MsgBox(16, "SQLite Error", "Can't Load Database!") |
---|
398 | $iStatus = 0 |
---|
399 | EndIf |
---|
400 | Return $iStatus |
---|
401 | EndFunc ;==>_Database_Start |
---|
402 | |
---|
403 | Func _Database_Stop() |
---|
404 | _SQLite_Close($g_hDB) |
---|
405 | _SQLite_Shutdown() |
---|
406 | EndFunc ;==>_Database_Stop |
---|
407 | |
---|
408 | Func _Initialise() |
---|
409 | Local $aSettings[13][2] |
---|
410 | Local $sIniFile = '' |
---|
411 | Local $iStatus = 1 |
---|
412 | |
---|
413 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Initialising") |
---|
414 | |
---|
415 | $g_sJobControlFolder = _os_PathNormalise($AT_ROOT_DIR) & GUICtrlRead($Gui_tab0_edtTestJob) |
---|
416 | $aSettings[0][0] = 12 |
---|
417 | $aSettings[1][0] = "createPSEUDO" |
---|
418 | $aSettings[1][1] = "N" |
---|
419 | If BitAND(GUICtrlRead($Gui_tab0_chkCreatePhseudo), $GUI_CHECKED) Then $aSettings[1][1] = "Y" |
---|
420 | $aSettings[2][0] = "createSbz" |
---|
421 | $aSettings[2][1] = "N" |
---|
422 | If BitAND(GUICtrlRead($Gui_tab0_chkSaveSbz), $GUI_CHECKED) Then $aSettings[2][1] = "Y" |
---|
423 | $aSettings[3][0] = "parameterfile" |
---|
424 | $aSettings[3][1] = "C:\OsStrumap\CFG\PHOENIXCITF\phoenixCITF.prm" |
---|
425 | If GUICtrlRead($Gui_tab0_edtStrumapPrm) <> '' Then $aSettings[3][1] = GUICtrlRead($Gui_tab0_edtStrumapPrm) |
---|
426 | $aSettings[4][0] = "useGEOCOMP" |
---|
427 | $aSettings[4][1] = "Y" |
---|
428 | If BitAND(GUICtrlRead($Gui_tab0_chkUseGeoComp), $GUI_CHECKED) Then $aSettings[4][1] = "Y" |
---|
429 | $aSettings[5][0] = "useStrumapVersion" |
---|
430 | $aSettings[5][1] = "2.0.2977.0" |
---|
431 | If GUICtrlRead($Gui_tab0_cboStrumapVer) <> '' Then $aSettings[5][1] = GUICtrlRead($Gui_tab0_cboStrumapVer) |
---|
432 | $aSettings[6][0] = "V0FileExtention" |
---|
433 | $aSettings[6][1] = "citf" |
---|
434 | If GUICtrlRead($Gui_tab0_cboTopo96Ext) <> '' Then $aSettings[6][1] = GUICtrlRead($Gui_tab0_cboTopo96Ext) |
---|
435 | $aSettings[7][0] = "V1CITFDataRootDir" |
---|
436 | $aSettings[7][1] = "" |
---|
437 | If GUICtrlRead($Gui_tab0_edtDataRootV1) <> '' Then $aSettings[7][1] = GUICtrlRead($Gui_tab0_edtDataRootV1) |
---|
438 | $aSettings[8][0] = "V1FileExtention" |
---|
439 | $aSettings[8][1] = "q1" |
---|
440 | If GUICtrlRead($Gui_tab0_cboTopo93V1Ext) <> '' Then $aSettings[8][1] = GUICtrlRead($Gui_tab0_cboTopo93V1Ext) |
---|
441 | $aSettings[9][0] = "V1ResultsRootDir" |
---|
442 | $aSettings[9][1] = _os_FileGetFolder($aSettings[7][1]) & "\Result\V1" |
---|
443 | $aSettings[10][0] = "V2CITFDataRootDir" |
---|
444 | $aSettings[10][1] = "" |
---|
445 | If GUICtrlRead($Gui_tab0_edtDataRootV2) <> '' Then $aSettings[10][1] = GUICtrlRead($Gui_tab0_edtDataRootV2) |
---|
446 | $aSettings[11][0] = "V2FileExtention" |
---|
447 | $aSettings[11][1] = "q2" |
---|
448 | If GUICtrlRead($Gui_tab0_cboTopo93V2Ext) <> '' Then $aSettings[11][1] = GUICtrlRead($Gui_tab0_cboTopo93V2Ext) |
---|
449 | $aSettings[12][0] = "V2ResultsRootDir" |
---|
450 | $aSettings[12][1] = _os_FileGetFolder($aSettings[7][1]) & "\Result\V2" |
---|
451 | |
---|
452 | $sIniFile = $g_sJobControlFolder & "\config.ini" |
---|
453 | If Not DirCreate($g_sJobControlFolder) Then $iStatus = 0 |
---|
454 | If Not DirCreate($g_sJobControlFolder & "\Computers") Then $iStatus = 0 |
---|
455 | If Not DirCreate($g_sJobControlFolder & "\Logs") Then $iStatus = 0 |
---|
456 | If Not DirCreate($aSettings[9][1]) Then $iStatus = 0 |
---|
457 | If Not DirCreate($aSettings[12][1]) Then $iStatus = 0 |
---|
458 | If Not IniWriteSection($sIniFile, "SETTINGS", $aSettings, 1) Then $iStatus = 0 |
---|
459 | Return $iStatus |
---|
460 | EndFunc ;==>_Initialise |
---|
461 | |
---|
462 | Func _PercentDone() |
---|
463 | Local $iRval, $aResult, $iRows, $iColumns |
---|
464 | Local $iToDo, $iDone |
---|
465 | Local $sSQLAll = "SELECT Count(*) FROM JOB_CONTROL" |
---|
466 | Local $sSQLDone = "SELECT Count(*) FROM JOB_CONTROL WHERE END_TIME NOT NULL" |
---|
467 | $iRval = _SQLite_GetTable2d($g_hDB, $sSQLAll, $aResult, $iRows, $iColumns) |
---|
468 | If $iRval <> $SQLITE_OK Then $iToDo = 0 |
---|
469 | If $iRows Then |
---|
470 | $iToDo = $aResult[$iRows][$iColumns - 1] |
---|
471 | EndIf |
---|
472 | $iRval = _SQLite_GetTable2d($g_hDB, $sSQLDone, $aResult, $iRows, $iColumns) |
---|
473 | If $iRval <> $SQLITE_OK Then $iDone = 0 |
---|
474 | If $iRows Then |
---|
475 | $iDone = $aResult[$iRows][$iColumns - 1] |
---|
476 | EndIf |
---|
477 | If $iToDo > 0 Then |
---|
478 | Return StringFormat("%0.2f%%", (($iDone / $iToDo) * 100)) |
---|
479 | Else |
---|
480 | Return StringFormat("%0.2f%%", 100) |
---|
481 | EndIf |
---|
482 | EndFunc ;==>_PercentDone |
---|
483 | |
---|
484 | Func _Process_ComputersOnline(ByRef $aComputers) |
---|
485 | Local $iItem = -1 |
---|
486 | Local $hWnd = $Gui_tab0_hListView |
---|
487 | Local $sItemText = '' |
---|
488 | Local $fFound = False |
---|
489 | Local $iItemCount = 0 |
---|
490 | For $iPC = 1 To $aComputers[0] |
---|
491 | $iItem = _GUICtrlListView_FindText($hWnd, $aComputers[$iPC], -1, False, True) |
---|
492 | ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iItem = ' & $iItem & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console |
---|
493 | If $iItem < 0 Then |
---|
494 | $iItem = _GUICtrlListView_AddItem($hWnd, $aComputers[$iPC]) |
---|
495 | _GUICtrlListView_AddSubItem($hWnd, $iItem, "", 1) ; Job / Tile |
---|
496 | _GUICtrlListView_AddSubItem($hWnd, $iItem, "Unknown", 2) ; Status |
---|
497 | _GUICtrlListView_AddSubItem($hWnd, $iItem, "00:00:00", 3) ; Elapsed Time |
---|
498 | _GUICtrlListView_AddSubItem($hWnd, $iItem, "00:00:00", 4) ; Elapsed Time |
---|
499 | EndIf |
---|
500 | Next |
---|
501 | |
---|
502 | $iItemCount = _GUICtrlListView_GetItemCount($hWnd) |
---|
503 | ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iItemCount = ' & $iItemCount & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console |
---|
504 | $iItem = $iItemCount - 1 |
---|
505 | ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iItem = ' & $iItem & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console |
---|
506 | While $iItem >= 0 |
---|
507 | $sItemText = _GUICtrlListView_GetItemText($hWnd, $iItem) |
---|
508 | ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iItem = ' & $iItem & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console |
---|
509 | ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sItemText = ' & $sItemText & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console |
---|
510 | $fFound = False |
---|
511 | For $i = 1 To $aComputers[0] |
---|
512 | If $sItemText = $aComputers[$i] Then |
---|
513 | ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sItemText = ' & $sItemText & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console |
---|
514 | ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aComputers[$i] = ' & $aComputers[$i] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console |
---|
515 | $fFound = True |
---|
516 | ExitLoop |
---|
517 | EndIf |
---|
518 | Next |
---|
519 | If Not $fFound Then |
---|
520 | If _GUICtrlListView_DeleteItem($hWnd, $iItem) Then |
---|
521 | $iItem -= 1 |
---|
522 | EndIf |
---|
523 | EndIf |
---|
524 | $iItem -= 1 |
---|
525 | WEnd |
---|
526 | |
---|
527 | EndFunc ;==>_Process_ComputersOnline |
---|
528 | |
---|
529 | Func _Process_ComputersOffline(ByRef $aComputers) |
---|
530 | Local $iItem = -1 |
---|
531 | Local $hWnd = $Gui_tab0_hListView |
---|
532 | ;~ Local $sItemText = '' |
---|
533 | ;~ Local $fFound = False |
---|
534 | For $iPC = 1 To $aComputers[0] |
---|
535 | $iItem = _GUICtrlListView_FindText($hWnd, $aComputers[$iPC], -1, False, True) |
---|
536 | If $iItem >= 0 Then |
---|
537 | _GUICtrlListView_SetItem($hWnd, "", $iItem, 1); Job / Tile |
---|
538 | _GUICtrlListView_SetItem($hWnd, "Off Line", $iItem, 2) ; Status |
---|
539 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 3) ; Elapsed Time |
---|
540 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 3) ; Elapsed Time |
---|
541 | EndIf |
---|
542 | Next |
---|
543 | EndFunc ;==>_Process_ComputersOffline |
---|
544 | |
---|
545 | Func _Process_JobRequests(ByRef $aComputers) |
---|
546 | ;~ Local $sJobFile = '' |
---|
547 | ;~ Local $aRow = 0 |
---|
548 | Local $sSQL = "SELECT FILE, TILE, FILE_SIZE, START_TIME FROM JOB_CONTROL WHERE START_TIME IS NULL ORDER BY FILE_SIZE DESC LIMIT " |
---|
549 | Local $sSQL_REQ = '' |
---|
550 | Local $sSQL_CMD = '' |
---|
551 | Local $sFile = '' |
---|
552 | Local $hFile = 0 |
---|
553 | ;~ Local $hQuery = 0 |
---|
554 | Local $aResult, $iRows, $iColumns, $iRval |
---|
555 | Local $iItem = -1 |
---|
556 | Local $hWnd = $Gui_tab0_hListView |
---|
557 | ;~ Local $sItemText = '' |
---|
558 | ;~ Local $fFound = False |
---|
559 | |
---|
560 | ;Update Display |
---|
561 | For $iPC = 1 To $aComputers[0] |
---|
562 | $iItem = _GUICtrlListView_FindText($hWnd, $aComputers[$iPC], -1, False, True) |
---|
563 | If $iItem >= 0 Then |
---|
564 | _GUICtrlListView_SetItem($hWnd, "", $iItem, 1) ; tile |
---|
565 | _GUICtrlListView_SetItem($hWnd, "Job Requested", $iItem, 2) ; Status |
---|
566 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 3) ; Start Time |
---|
567 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 4) ; Elapsed Time |
---|
568 | EndIf |
---|
569 | Next |
---|
570 | |
---|
571 | $sSQL_REQ = $sSQL & $aComputers[0] + 10 & ";" |
---|
572 | $iRval = _SQLite_GetTable2d($g_hDB, $sSQL_REQ, $aResult, $iRows, $iColumns) |
---|
573 | ;~ _ArrayDisplay($aResult) |
---|
574 | For $i = 1 To $aComputers[0] |
---|
575 | If $iRval = $SQLITE_OK And IsArray($aResult) Then |
---|
576 | If $aResult[$i][1] <> '' Then |
---|
577 | $sFile = $g_sJobControlFolder & "\Computers\" & $aComputers[$i] & "\_NextJob.atj" |
---|
578 | $hFile = FileOpen($sFile, 2) |
---|
579 | FileWriteLine($hFile, $aResult[$i][0]) |
---|
580 | FileWriteLine($hFile, $aResult[$i][1]) |
---|
581 | FileClose($hFile) |
---|
582 | $sSQL_CMD = "UPDATE JOB_CONTROL SET COMPUTER = '" & $aComputers[$i] & "',START_TIME = '" & _NowCalc() & "' WHERE TILE = '" & $aResult[$i][1] & "';" |
---|
583 | _SQLite_Exec($g_hDB, $sSQL_CMD) |
---|
584 | $sFile = $g_sJobControlFolder & "\Computers\" & $aComputers[$i] & "\_RequestJob.atj" |
---|
585 | FileDelete($sFile) |
---|
586 | $iItem = _GUICtrlListView_FindText($hWnd, $aComputers[$i], -1, False, True) |
---|
587 | If $iItem >= 0 Then |
---|
588 | _GUICtrlListView_SetItem($hWnd, $aResult[$i][1], $iItem, 1) ; tile |
---|
589 | _GUICtrlListView_SetItem($hWnd, "Job Allocated", $iItem, 2) ; Status |
---|
590 | _GUICtrlListView_SetItem($hWnd, _NowCalc(), $iItem, 3) ; Start Time |
---|
591 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 4) ; Elapsed Time |
---|
592 | EndIf |
---|
593 | Else |
---|
594 | $sFile = $g_sJobControlFolder & "\Computers\" & $aComputers[$i] & "\_NoMoreJobs.atj" |
---|
595 | _FileCreate($sFile) |
---|
596 | $sFile = $g_sJobControlFolder & "\Computers\" & $aComputers[$i] & "\_RequestJob.atj" |
---|
597 | FileDelete($sFile) |
---|
598 | EndIf |
---|
599 | Else ;No more jobs |
---|
600 | $sFile = $g_sJobControlFolder & "\Computers\" & $aComputers[$i] & "\_NoMoreJobs.atj" |
---|
601 | _FileCreate($sFile) |
---|
602 | $sFile = $g_sJobControlFolder & "\Computers\" & $aComputers[$i] & "\_RequestJob.atj" |
---|
603 | FileDelete($sFile) |
---|
604 | EndIf |
---|
605 | Next |
---|
606 | EndFunc ;==>_Process_JobRequests |
---|
607 | |
---|
608 | Func _Process_JobsAborted(ByRef $aComputers) |
---|
609 | Local $iItem = -1 |
---|
610 | Local $hWnd = $Gui_tab0_hListView |
---|
611 | ;~ Local $sItemText = '' |
---|
612 | ;~ Local $fFound = False |
---|
613 | ;~ Local $sFile = '' |
---|
614 | |
---|
615 | For $iPC = 1 To $aComputers[0] |
---|
616 | $iItem = _GUICtrlListView_FindText($hWnd, $aComputers[$iPC], -1, False, True) |
---|
617 | If $iItem >= 0 Then |
---|
618 | _GUICtrlListView_SetItem($hWnd, "Job Aborted", $iItem, 2) ; Status |
---|
619 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 3) ; Elapsed Time |
---|
620 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 4) ; Elapsed Time |
---|
621 | EndIf |
---|
622 | Next |
---|
623 | EndFunc ;==>_Process_JobsAborted |
---|
624 | |
---|
625 | Func _Process_JobsCompleted(ByRef $aComputers) |
---|
626 | Local $iItem = -1 |
---|
627 | Local $hWnd = $Gui_tab0_hListView |
---|
628 | ;~ Local $sItemText = '' |
---|
629 | ;~ Local $fFound = False |
---|
630 | Local $aResults |
---|
631 | Local $aParts |
---|
632 | Local $sSQL = "UPDATE JOB_CONTROL SET " |
---|
633 | Local $sWhere = '' |
---|
634 | Local $sDateTime = '' |
---|
635 | Local $sFile = '' |
---|
636 | Local $iStatus = 0 |
---|
637 | |
---|
638 | For $iPC = 1 To $aComputers[0] |
---|
639 | $iItem = _GUICtrlListView_FindText($hWnd, $aComputers[$iPC], -1, False, True) |
---|
640 | If $iItem >= 0 Then |
---|
641 | $sDateTime = _GUICtrlListView_GetItemText($hWnd, $iItem, 4) |
---|
642 | _GUICtrlListView_SetItem($hWnd, "Completed", $iItem, 2) ; Status |
---|
643 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 3) ; Elapsed Time |
---|
644 | _GUICtrlListView_SetItem($hWnd, "00:00:00", $iItem, 4) ; Elapsed Time |
---|
645 | EndIf |
---|
646 | $sFile = $g_sJobControlFolder & "\Computers\" & $aComputers[$iPC] & "\_CompletedJob.atj" |
---|
647 | _FileReadToArray($sFile, $aResults) |
---|
648 | If IsArray($aResults) Then |
---|
649 | For $i = 1 To $aResults[0] |
---|
650 | $aParts = StringSplit($aResults[$i], "|") |
---|
651 | If IsArray($aParts) Then |
---|
652 | Switch $aParts[1] |
---|
653 | Case 'COMPUTER' |
---|
654 | If $sWhere = '' Then |
---|
655 | $sWhere = ' WHERE COMPUTER = "' & $aParts[2] & '"' |
---|
656 | Else |
---|
657 | $sWhere &= ' AND COMPUTER = "' & $aParts[2] & '"' |
---|
658 | EndIf |
---|
659 | Case 'TILE' |
---|
660 | If $sWhere = '' Then |
---|
661 | $sWhere = ' WHERE TILE = "' & $aParts[2] & '"' |
---|
662 | Else |
---|
663 | $sWhere &= ' AND TILE = "' & $aParts[2] & '"' |
---|
664 | EndIf |
---|
665 | Case 'SYNTAX_CITF' |
---|
666 | $sSQL &= 'SYNTAX_CITF = "' & $aParts[2] & '",' |
---|
667 | Case 'SYNTAX_NTF' |
---|
668 | $sSQL &= 'SYNTAX_NTF = "' & $aParts[2] & '",' |
---|
669 | Case 'Q1_CREATED' |
---|
670 | $sSQL &= 'Q1_CREATED = "' & $aParts[2] & '",' |
---|
671 | Case 'SYNTAX_Q1' |
---|
672 | $sSQL &= 'SYNTAX_Q1 = "' & $aParts[2] & '",' |
---|
673 | Case 'SYNTAX_Q2' |
---|
674 | $sSQL &= 'SYNTAX_Q2 = "' & $aParts[2] & '",' |
---|
675 | Case 'NO_FEATURES' |
---|
676 | $sSQL &= 'NO_FEATURES = ' & $aParts[2] & ',' |
---|
677 | Case 'NO_DIFF' |
---|
678 | $sSQL &= 'NO_DIFF = ' & $aParts[2] & ',' |
---|
679 | Case 'RESULT' |
---|
680 | $sSQL &= 'RESULT = "' & $aParts[2] & '",' |
---|
681 | Case 'MESSAGE' |
---|
682 | $sSQL &= 'ERROR = "' & $aParts[2] & '",' |
---|
683 | EndSwitch |
---|
684 | EndIf |
---|
685 | Next |
---|
686 | $sSQL &= ' END_TIME = "' & _NowCalc() & '",' |
---|
687 | $sSQL &= ' TIME_TAKEN = "' & $sDateTime & '"' |
---|
688 | $sSQL &= $sWhere |
---|
689 | $iStatus = _SQLite_Exec($g_hDB, $sSQL) |
---|
690 | If $iStatus Then |
---|
691 | ; TODO: |
---|
692 | EndIf |
---|
693 | FileDelete($sFile) |
---|
694 | Else |
---|
695 | ;~ 'MESSAGE = No Results were returned from test runner' |
---|
696 | FileDelete($sFile) |
---|
697 | EndIf |
---|
698 | Next |
---|
699 | EndFunc ;==>_Process_JobsCompleted |
---|
700 | |
---|
701 | Func _Process_JobsRunning(ByRef $aComputers) |
---|
702 | Local $iItem = -1 |
---|
703 | Local $hWnd = $Gui_tab0_hListView |
---|
704 | ;~ Local $sItemText = '' |
---|
705 | ;~ Local $fFound = False |
---|
706 | Local $sDateTime = '' |
---|
707 | |
---|
708 | For $iPC = 1 To $aComputers[0] |
---|
709 | $iItem = _GUICtrlListView_FindText($hWnd, $aComputers[$iPC], -1, False, True) |
---|
710 | If $iItem >= 0 Then |
---|
711 | _GUICtrlListView_SetItem($hWnd, "Job Running", $iItem, 2) ; Status |
---|
712 | $sDateTime = _GUICtrlListView_GetItemText($hWnd, $iItem, 3) |
---|
713 | _GUICtrlListView_SetItem($hWnd, _RuninngTime($sDateTime), $iItem, 4) ; Elapsed Time |
---|
714 | EndIf |
---|
715 | Next |
---|
716 | EndFunc ;==>_Process_JobsRunning |
---|
717 | |
---|
718 | Func _Process_Results(ByRef $sJobFolder, ByRef $aComputers) |
---|
719 | ;TODO: |
---|
720 | If IsArray($aComputers) Then |
---|
721 | Return ($sJobFolder <> '') |
---|
722 | Else |
---|
723 | Return -1 |
---|
724 | EndIf |
---|
725 | EndFunc ;==>_Process_Results |
---|
726 | |
---|
727 | Func _RuninngTime($sDateTime) |
---|
728 | Local $iSeconds |
---|
729 | Local $iH, $iM, $iS |
---|
730 | |
---|
731 | $iSeconds = _DateDiff("s", $sDateTime, _NowCalc()) |
---|
732 | $iH = Int($iSeconds / 3600) |
---|
733 | $iSeconds -= ($iH * 3600) |
---|
734 | $iM = Int($iSeconds / 60) |
---|
735 | $iSeconds -= ($iM * 60) |
---|
736 | $iS = Int($iSeconds) |
---|
737 | Return StringFormat("%0i:%02i:%02i", $iH, $iM, $iS) |
---|
738 | EndFunc ;==>_RuninngTime |
---|
739 | |
---|
740 | Func _ScanFor_ComputersOnline(ByRef $sJobFolder) |
---|
741 | Local $asFileList[1] = [0] |
---|
742 | ;~ Local $aComputer = '' |
---|
743 | Local $aTemp |
---|
744 | |
---|
745 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Cheking for PCs") |
---|
746 | |
---|
747 | $asFileList = _os_FoldersListInTree($sJobFolder & "\Computers", $asFileList, 0, "*") |
---|
748 | For $i = 1 To $asFileList[0] |
---|
749 | $aTemp = StringSplit($asFileList[$i], '\') |
---|
750 | If IsArray($aTemp) Then $asFileList[$i] = $aTemp[$aTemp[0]] |
---|
751 | Next |
---|
752 | Return $asFileList |
---|
753 | EndFunc ;==>_ScanFor_ComputersOnline |
---|
754 | |
---|
755 | Func _ScanFor_ComputersOffline(ByRef $sJobFolder) |
---|
756 | Local $asFileList[1] = [0] |
---|
757 | ;~ Local $aComputer = '' |
---|
758 | Local $aTemp |
---|
759 | |
---|
760 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Cheking for PCs") |
---|
761 | |
---|
762 | $asFileList = _os_FilesListInTree($sJobFolder & "\Computers", $asFileList, 0, "_Offline.atj") |
---|
763 | For $i = 1 To $asFileList[0] |
---|
764 | $aTemp = StringSplit($asFileList[$i], '\') |
---|
765 | If IsArray($aTemp) Then $asFileList[$i] = $aTemp[$aTemp[0] - 1] |
---|
766 | Next |
---|
767 | Return $asFileList |
---|
768 | EndFunc ;==>_ScanFor_ComputersOffline |
---|
769 | |
---|
770 | Func _ScanFor_JobRequests(ByRef $sJobFolder) |
---|
771 | Local $asFileList[1] = [0] |
---|
772 | ;~ Local $aComputer = '' |
---|
773 | Local $aTemp |
---|
774 | |
---|
775 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Cheking for Job Requests") |
---|
776 | |
---|
777 | $asFileList = _os_FilesListInTree($sJobFolder & "\Computers", $asFileList, 0, "_RequestJob.atj") |
---|
778 | For $i = 1 To $asFileList[0] |
---|
779 | $aTemp = StringSplit($asFileList[$i], '\') |
---|
780 | If IsArray($aTemp) Then $asFileList[$i] = $aTemp[$aTemp[0] - 1] |
---|
781 | Next |
---|
782 | Return $asFileList |
---|
783 | EndFunc ;==>_ScanFor_JobRequests |
---|
784 | |
---|
785 | Func _ScanFor_JobsAborted(ByRef $sJobFolder) |
---|
786 | Local $asFileList[1] = [0] |
---|
787 | ;~ Local $aComputer = '' |
---|
788 | Local $aTemp |
---|
789 | |
---|
790 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Cheking for Aborted Jobs") |
---|
791 | |
---|
792 | $asFileList = _os_FilesListInTree($sJobFolder & "\Computers", $asFileList, 0, "_Aborted.atj") |
---|
793 | For $i = 1 To $asFileList[0] |
---|
794 | $aTemp = StringSplit($asFileList[$i], '\') |
---|
795 | If IsArray($aTemp) Then $asFileList[$i] = $aTemp[$aTemp[0] - 1] |
---|
796 | Next |
---|
797 | Return $asFileList |
---|
798 | EndFunc ;==>_ScanFor_JobsAborted |
---|
799 | |
---|
800 | Func _ScanFor_JobsCompleted(ByRef $sJobFolder) |
---|
801 | Local $asFileList[1] = [0] |
---|
802 | ;~ Local $aComputer = '' |
---|
803 | Local $aTemp |
---|
804 | |
---|
805 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Cheking for Completed Jobs") |
---|
806 | |
---|
807 | $asFileList = _os_FilesListInTree($sJobFolder & "\Computers", $asFileList, 0, "_CompletedJob.atj") |
---|
808 | ;~ _ArrayDisplay($asFileList,"JobsCompleted") |
---|
809 | For $i = 1 To $asFileList[0] |
---|
810 | $aTemp = StringSplit($asFileList[$i], '\') |
---|
811 | If IsArray($aTemp) Then $asFileList[$i] = $aTemp[$aTemp[0] - 1] |
---|
812 | Next |
---|
813 | Return $asFileList |
---|
814 | EndFunc ;==>_ScanFor_JobsCompleted |
---|
815 | |
---|
816 | Func _ScanFor_JobsRunning(ByRef $sJobFolder) |
---|
817 | Local $asFileList[1] = [0] |
---|
818 | ;~ Local $aComputer = '' |
---|
819 | Local $aTemp |
---|
820 | |
---|
821 | _GUICtrlStatusBar_SetText($GUI_stbStatusBar, "Cheking for Running Jobs") |
---|
822 | |
---|
823 | $asFileList = _os_FilesListInTree($sJobFolder & "\Computers", $asFileList, 0, "_RunningJob.atj") |
---|
824 | For $i = 1 To $asFileList[0] |
---|
825 | $aTemp = StringSplit($asFileList[$i], '\') |
---|
826 | If IsArray($aTemp) Then $asFileList[$i] = $aTemp[$aTemp[0] - 1] |
---|
827 | Next |
---|
828 | Return $asFileList |
---|
829 | EndFunc ;==>_ScanFor_JobsRunning |
---|
830 | |
---|
831 | Func _ScanFor_JobsToDo($sJobFolder_In, $sFilePattern_In) |
---|
832 | Local $asFileList[1] = [0] |
---|
833 | |
---|
834 | $asFileList = _os_FilesListInTree($sJobFolder_In, $asFileList, 0, $sFilePattern_In) |
---|
835 | |
---|
836 | Return $asFileList |
---|
837 | EndFunc ;==>_ScanFor_JobsToDo |
---|
838 | |
---|
839 | Func _Settings_Read() |
---|
840 | Local $sValue = '' |
---|
841 | GUICtrlSetData($Gui_tab0_edtTestJob, IniRead(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "TestJob", "")) |
---|
842 | GUICtrlSetData($Gui_tab0_edtDataRootV1, IniRead(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "DataRootV1", "")) |
---|
843 | GUICtrlSetData($Gui_tab0_edtDataRootV2, IniRead(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "DataRootV2", "")) |
---|
844 | GUICtrlSetData($Gui_tab0_edtStrumapPrm, IniRead(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "StrumapPrm", "")) |
---|
845 | $sValue = IniRead(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "Topo96Ext", "") |
---|
846 | GUICtrlSetData($Gui_tab0_cboTopo96Ext, "citf|ctf", $sValue) |
---|
847 | $sValue = IniRead(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "Topo93V1Ext", "") |
---|
848 | GUICtrlSetData($Gui_tab0_cboTopo93V1Ext, "q1|v1", $sValue) |
---|
849 | $sValue = IniRead(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "Topo93V2Ext", "") |
---|
850 | GUICtrlSetData($Gui_tab0_cboTopo93V2Ext, "q2|v2", $sValue) |
---|
851 | $sValue = IniRead(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "StrumapVer", "") |
---|
852 | GUICtrlSetData($Gui_tab0_cboStrumapVer, "2.0.2981.1", $sValue) |
---|
853 | EndFunc ;==>_Settings_Read |
---|
854 | |
---|
855 | Func _Settings_Save() |
---|
856 | IniWrite(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "TestJob", GUICtrlRead($Gui_tab0_edtTestJob)) |
---|
857 | IniWrite(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "DataRootV1", GUICtrlRead($Gui_tab0_edtDataRootV1)) |
---|
858 | IniWrite(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "DataRootV2", GUICtrlRead($Gui_tab0_edtDataRootV2)) |
---|
859 | IniWrite(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "StrumapPrm", GUICtrlRead($Gui_tab0_edtStrumapPrm)) |
---|
860 | IniWrite(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "Topo96Ext", GUICtrlRead($Gui_tab0_cboTopo96Ext)) |
---|
861 | IniWrite(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "Topo93V1Ext", GUICtrlRead($Gui_tab0_cboTopo93V1Ext)) |
---|
862 | IniWrite(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "Topo93V2Ext", GUICtrlRead($Gui_tab0_cboTopo93V2Ext)) |
---|
863 | IniWrite(@ScriptDir & "\" & $sTitle & ".ini", "LAST_JOB", "StrumapVer", GUICtrlRead($Gui_tab0_cboStrumapVer)) |
---|
864 | EndFunc ;==>_Settings_Save |
---|
865 | |
---|
866 | Func _Status_Update($hWnd, ByRef $aComputers) |
---|
867 | If $hWnd > 0 Then Return 1 |
---|
868 | If Not IsArray($aComputers) Then Return 1 |
---|
869 | EndFunc ;==>_Status_Update |
---|