#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
;Local $GUI, $hImage, $iITEM_COUNT = 10000
GUICreate("Test Management v1.0", 1060, 410)
$hListView = GUICtrlCreateListView("", 5, 5, 1050, 345, $LVS_SHOWSELALWAYS, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT + $LVS_EX_DOUBLEBUFFER)
;===================================================================
$Button1 = GUICtrlCreateButton("ReportData", 200, 362, 73, 33)
$Button2 = GUICtrlCreateButton("Complete", 300, 362, 73, 33)
$Button3 = GUICtrlCreateButton("Clear", 800, 362, 73, 33)
$PowerReset = GUICtrlCreateButton("Power Reset", 500, 362, 73, 33)
$SerialOverLan = GUICtrlCreateButton("SOL", 600, 362, 73, 33)
;$stopreportflash = GUICtrlCreateButton("Stopreportflash", 200, 392, 73, 33)
;$stopcompleteflash = GUICtrlCreateButton("Stopcompleteflash", 300, 392, 73, 33)
;===================================================================
GUISetState()
;GUISetState(@SW_SHOW)
_GUICtrlListView_AddColumn($hListView, "File Name", 0) ;disappear file name
_GUICtrlListView_AddColumn($hListView, "Test Case", 70)
_GUICtrlListView_AddColumn($hListView, "Product", 80)
_GUICtrlListView_AddColumn($hListView, "Serial", 90)
_GUICtrlListView_AddColumn($hListView, "BIOS", 40)
_GUICtrlListView_AddColumn($hListView, "BMC", 40)
_GUICtrlListView_AddColumn($hListView, "Count", 60)
_GUICtrlListView_AddColumn($hListView, "Status", 60)
_GUICtrlListView_AddColumn($hListView, "LOG err", 50)
_GUICtrlListView_AddColumn($hListView, "BMC err", 50)
_GUICtrlListView_AddColumn($hListView, "SDR err", 50)
_GUICtrlListView_AddColumn($hListView, "Sensor err", 65)
_GUICtrlListView_AddColumn($hListView, "BMC IP", 90)
_GUICtrlListView_AddColumn($hListView, "Tester", 50)
_GUICtrlListView_AddColumn($hListView, "Remind Time", 80)
_GUICtrlListView_AddColumn($hListView, "Upload Time", 120)
_GUICtrlListView_SetItemCount($hListView, 5000)
While 1
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;Double click value get
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Button1
AdlibUnRegister('_add_complete_items')
_add_report_items()
AdlibRegister('_add_report_items', 5000);reflash every 10sec
Case $Button2
AdlibUnRegister('_add_report_items')
_add_complete_items()
AdlibRegister('_add_complete_items', 5000);reflash every 10sec
; Case $stopreportflash
; AdlibUnRegister('_add_report_items')
; Case $stopcompleteflash
; AdlibUnRegister('_add_complete_items')
Case $Button3
MsgBox(0,"123","456",0)
Case $PowerReset
Run("PowerReset.exe")
Case $SerialOverLan
Run("SOL.exe")
EndSwitch
WEnd
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Exit
Func _add_report_items()
;_GUICtrlListView_SetHoverTime($hListView,6000)
;MsgBox($MB_SYSTEMMODAL, "Information", "Hover Time (milliseconds): " & _GUICtrlListView_GetHoverTime($hListView))
FileChangeDir("\\192.8.1.1\fs1\1")
Local $path, $aFileList, $aNewList[1][2]
$path = "\\192.8.1.1\fs1\1"
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
ReDim $aNewList[UBound($aFileList)][16] ;;;[Col count]
For $i = 0 To UBound($aFileList) - 1 Step 1
$aNewList[0][1] = $i
;$aNewList[$i][0] = $aFileList[$i]
$aNewList[$i][1] = FileReadLine($aFileList[$i], 1)
$aNewList[$i][2] = FileReadLine($aFileList[$i], 2)
$aNewList[$i][3] = FileReadLine($aFileList[$i], 3)
$aNewList[$i][4] = FileReadLine($aFileList[$i], 4)
$aNewList[$i][5] = FileReadLine($aFileList[$i], 5)
$aNewList[$i][6] = FileReadLine($aFileList[$i], 6)
$aNewList[$i][7] = FileReadLine($aFileList[$i], 7)
$aNewList[$i][8] = FileReadLine($aFileList[$i], 8)
$aNewList[$i][9] = FileReadLine($aFileList[$i], 9)
$aNewList[$i][10] = FileReadLine($aFileList[$i], 10)
$aNewList[$i][11] = FileReadLine($aFileList[$i], 11)
$aNewList[$i][12] = FileReadLine($aFileList[$i], 12)
$aNewList[$i][13] = FileReadLine($aFileList[$i], 13)
$aNewList[$i][14] = FileReadLine($aFileList[$i], 14)
$aNewList[$i][15] = FileReadLine($aFileList[$i], 15)
;$change1=FileReadLine($aFileList[$i], 1)
Next
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
_GUICtrlListView_AddArray($hListView, $aNewList)
EndIf
EndFunc
Func _add_complete_items()
FileChangeDir("\\192.8.1.1\fs1\2")
Local $path, $aFileList, $aNewList[1][2]
$path = "\\192.8.1.1\fs1\2"
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
ReDim $aNewList[UBound($aFileList)][16] ;;;[Col count]
For $i = 0 To UBound($aFileList) - 1 Step 1
$aNewList[0][1] = $i
;$aNewList[$i][0] = $aFileList[$i]
$aNewList[$i][1] = FileReadLine($aFileList[$i], 1)
$aNewList[$i][2] = FileReadLine($aFileList[$i], 2)
$aNewList[$i][3] = FileReadLine($aFileList[$i], 3)
$aNewList[$i][4] = FileReadLine($aFileList[$i], 4)
$aNewList[$i][5] = FileReadLine($aFileList[$i], 5)
$aNewList[$i][6] = FileReadLine($aFileList[$i], 6)
$aNewList[$i][7] = FileReadLine($aFileList[$i], 7)
$aNewList[$i][8] = FileReadLine($aFileList[$i], 8)
$aNewList[$i][9] = FileReadLine($aFileList[$i], 9)
$aNewList[$i][10] = FileReadLine($aFileList[$i], 10)
$aNewList[$i][11] = FileReadLine($aFileList[$i], 11)
$aNewList[$i][12] = FileReadLine($aFileList[$i], 12)
$aNewList[$i][13] = FileReadLine($aFileList[$i], 13)
$aNewList[$i][14] = FileReadLine($aFileList[$i], 14)
$aNewList[$i][15] = FileReadLine($aFileList[$i], 15)
Next
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
_GUICtrlListView_AddArray($hListView, $aNewList)
EndIf
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$Index= DllStructGetData($tInfo, "Index")
$DoubleClick = _GUICtrlListView_GetItemText($hListView, $Index,12)
;MsgBox(0, 'Connect SOL to BMC IP', _GUICtrlListView_GetItemText($hListView, $Index,12))
Run("cmd.exe")
sleep(500)
WinActivate("Administrator: C:\Windows\system32\cmd.exe")
sleep(500)
send("cd \TestStatusManagement\ipmitool_1.8.11")
sleep(500)
Send("{ENTER}")
sleep(500)
Send("ipmitool.exe -I lanplus -H "&$DoubleClick&" -U admin -P admin sol deactivate")
sleep(500)
Send("{ENTER}")
sleep(500)
Send("ipmitool.exe -I lanplus -H "&$DoubleClick&" -U admin -P admin sol activate")
sleep(500)
Send("{ENTER}")
Case $LVN_ITEMCHANGED ; An item has changed
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
$Index= DllStructGetData($tInfo, "Index")
$DoubleClick = _GUICtrlListView_GetItemText($hListView, $Index,12)
_DebugPrint("$LVN_ITEMCHANGED" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Test Case" & @TAB & DllStructGetData($hListView, "Test Case") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($hListView, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($hListView, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($hListView, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($hListView, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($hListView, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($hListView, "ActionY") & @LF & _
"-->Param:" & @TAB & DllStructGetData($hListView, "Param"))
MsgBox(0,"123",$hListView,0)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
;MsgBox(0,"123","456",0)
EndFunc