Saturday, 3 February 2018

Utility Functions

Class Report

Public TestName,ResultFolder
Public objfso,objfile
Public objExl


Private Sub Class_Initialize()
   
    TestName=Environment.Value("TestName")
    ResultFolder=Environment.Value("ResultDir")
   
    msgbox "Hi"
   
End Sub


   




Sub Class_Terminate()


   
End Sub

Function GetExcelRowCount(strExcelFileName,strSheetName)

On Error Resume Next
Set objExl=CreateObject("Excel.Application")

'On error Resume Next
Set objwb=objExl.Workbooks.Open(strExcelFileName)
'If Err.Number<>0 Then
   
GetExcelRowCount="Error Occured While Opening Excel Workbook."
'Exit Function
'End If

Set objws=objwb.Worksheets(strSheetName)
If Err.Number<>0 Then
GetExcelRowCount="Error Occured While Opening Excel Workbook or WorkSheet"
Exit Function

Else

GetExcelRowCount=objws.UsedRange.Rows.Count

End If



Err.Reset

objexl.Quit

   
End Function


   
   
'End Function



Function ReportGenerator()

'  CreateFile
'  
'  CreateHeader
'  
'  WriteLog
 
     
  End Function

   






Function Maximise(objBrowser)


Window("hwnd:="&objBrowser.GetROProperty("hwnd")).Maximize
   
   
   
End Function





Function WriteXml(steXmlFileName,strNodeHierarchy)

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"

xmlDoc.Load(steXmlFileName)

If xmlDoc.ParseError.ErrorCode<>0 then

Print "XML parsing Error:"

WriteXml=False

End If

Set colNodes=xmlDoc.selectNodes(strNodeHierarchy)

Set colNodes=xmlDoc.selectNodes(strNodeHierarchy)

For Each objNode in colNodes
   objNode.Text = Date
Next
WriteXml=True
xmlDoc.Save steXmlFileName

Set xmlDoc=Nothing   


End Function

Function ReadXmlNode(steXmlFileName,strNodeHierarchy)

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load(steXmlFileName)

If xmlDoc.ParseError.ErrorCode<>0 then
Print "XML parsing Error:"
ReadXmlNode="XML parsing Error"
End If

Set colNodes=xmlDoc.selectNodes(strNodeHierarchy)

If colNodes.Length=1 Then
ReadXmlNode=colNodes.item(i).Text

Else
ReadXmlNode="Node Does Not Exist"

End If
'For Each objNode in colNodes
'
'            
'            msgbox objNode.Text &"Reading Node Value"
'            
'            If Trim(ReadXmlNode)="" Then
'            Msgbox "Node does not exists or Node Value is Blank. Exiting the function"
'            ReadXmlNode="Bad Data"
'            Exit Function 
'            End If
'Next
'
'ReadXmlNode=ReadData

xmlDoc.Save steXmlFileName
Set xmldoc=Nothing

End function


Function WriteXml(steXmlFileName,strNodeHierarchy)

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"

xmlDoc.Load(steXmlFileName)

If xmlDoc.ParseError.ErrorCode<>0 then

Print "XML parsing Error:"

WriteXml=False

End If

Set colNodes=xmlDoc.selectNodes(strNodeHierarchy)

Set colNodes=xmlDoc.selectNodes(strNodeHierarchy)

For Each objNode in colNodes
   objNode.Text = Date
Next
WriteXml=True
xmlDoc.Save steXmlFileName

Set xmlDoc=Nothing   
End Function

Function ReadXmlNode(steXmlFileName,strNodeHierarchy)

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load(steXmlFileName)

If xmlDoc.ParseError.ErrorCode<>0 then
Print "XML parsing Error:"
ReadXmlNode="XML parsing Error"
End If

Set colNodes=xmlDoc.selectNodes(strNodeHierarchy)

If colNodes.Length=1 Then
ReadXmlNode=colNodes.item(i).Text

Else
ReadXmlNode="Node Does Not Exist"

End If
'For Each objNode in colNodes
'
'            
'            msgbox objNode.Text &"Reading Node Value"
'            
'            If Trim(ReadXmlNode)="" Then
'            Msgbox "Node does not exists or Node Value is Blank. Exiting the function"
'            ReadXmlNode="Bad Data"
'            Exit Function 
'            End If
'Next
'
'ReadXmlNode=ReadData

xmlDoc.Save steXmlFileName
Set xmlDoc=Nothing       
'End FunctionmlFileName
'Set xmlDoc=Nothing        
End Function

End Class

Spring Boot : Exception Handler 14