<%

'*****************************************************************************
' Microsoft Content Management Server
'
' File: SDReportInfo.INC
'
' Purpose:
'   ASP server-side include file that generates the report information section 
'	of an export or import report. This file is included by the main report file.
'
' GLOBAL DEPENDENCIES:
'	pReportXMLTag [in] - the root XML tag of the report XML.
'
'*****************************************************************************

	' grab the client time zone bias in order to do all date adjustments	
	' (declared in SDReportUtility.INC)
	g_lClientTimeZoneBias = pReportXMLTag.ReportInfo.ResClient.TimeZoneBias
	

	'*************************************************************************
	' Description:
	'	Gets the creation date from the report XML and returns it as a 
	'	nicely formatted string.
	'
	' Returns:
	'	Report creation date as a string
	'*************************************************************************
	function getCreationDate
		' grab the date field from the XML. As the attribute value is returned
		' as a variant string, first convert it to a double, and then to a 
		' date. Next, conversion to a string will produce a date in the
		' required format

		dim dateCreation
		' Note: the creation date is the client side's profile creation date,
		'       LastModified date represents the report creation time.


		' HOTFIX #8110 - block below fixes around locale-specific Date format.
		
		Dim lCurrentLCID		
		lCurrentLCID = GetLocale
		
		If lCurrentLCID = lLCID_ENGLISH_US Then
			dateCreation = CDate( CDbl( pReportXMLTag.ReportInfo.LastModified.Date ) )
		Else
			' switch locale to English (U.S.) to process date value				
			Call SetLocale( lLCID_ENGLISH_US )

			Dim bErrOccurred
			Dim lErrNum
			Dim strErrSource
			Dim strErrDescription
			
			bErrOccurred = False
			
			' enable error handling here to ensure reset of locale 			
			On Error Resume Next			
			
			dateCreation = CDate( CDbl( pReportXMLTag.ReportInfo.LastModified.Date ) )			
			
			' Cache error info for later before it's cleared
			If Err.Number <> 0 Then
				bErrOccurred = True
				lErrNum = Err.Number
				strErrSource = Err.Source
				strErrDescription = Err.Description				
			End If
			
			'disable error handling			
			On Error Goto 0

			' revert to original locale (even if date conversion failed)
			Call SetLocale( lCurrentLCID )
			
			If bErrOccurred Then
				' raise the exception now
				call Err.Raise( lErrNum, "getCreationDate: " & strErrSource, strERROR_FAILED_DATE_CONVERSION & ": " & strErrDescription )
			End If			
		End If

		' if we do in fact have a valid date, convert it to a string		
		if IsDate( dateCreation ) then
			dim lClientLCID
			lClientLCID = pReportXMLTag.ReportInfo.ResClient.LocaleID
			
			bErrOccurred = false
			on error resume next
			
			call SetLocale(lClientLCID)
			
			getCreationDate = CStr( dateCreation )
			
			call SetLocale(lCurrentLCID)
		else
			getCreationDate = "Unknown"	
		end if
		
	end function  'getCreationDate


	'*************************************************************************
	' Description:
	'	Gets the filename of the ROP file (for export or import) from the report 
	'   XML
	'
	' Returns:
	'	ROP filename
	'*************************************************************************
	function getROPFilename
	
		dim strROPFilename
		strROPFilename = pReportXMLTag.ROP.URL
		
		if strROPFilename = "" then
			strROPFilename = "None Specified"
		end if
		
		getROPFilename = strROPFilename
		
	end function  'getROPFilename
	
	
	'*************************************************************************
	' Description:
	'	Gets the user that generated the report from the report XML.
	'
	' Returns:
	'	user name
	'*************************************************************************
	function getReportUser
	
		getReportUser = pReportXMLTag.ReportInfo.Creation.User
	
	end function  'getReportUser
	
	
	'*************************************************************************
	' Description:
	'	Gets the hostname or IP address of the client machine that the report
	'	generation was triggered from.
	'
	' Returns:
	'	Client hostname or IP address
	'*************************************************************************
	function getClientMachine
	
		getClientMachine = pReportXMLTag.ReportInfo.ResClient.MachineName
	
	end function  'getClientMachine


	'*************************************************************************
	' Description:
	'	Gets the version number  of the client machine that the report generation
	'   was triggered from.
	'
	' Returns:
	'	Client version string
	'*************************************************************************
	function getClientVersion
	
		getClientVersion = pReportXMLTag.ReportInfo.ResClient.Version
	
	end function  'getClientVersion


	'*************************************************************************
	' Description:
	'	Gets the URL of the server machine upon which this report was generated.
	'
	' Returns:
	'	Server URL
	'*************************************************************************
	function getServerMachine
	
		getServerMachine = pReportXMLTag.ReportInfo.ResServer.URL
	
	end function  'getServerMachine


	'*************************************************************************
	' Description:
	'	Gets the version of the server  machine upon which this report was
	'	generated
	'
	' Returns:
	'	Server version string
	'*************************************************************************
	function getServerVersion
	
		getServerVersion = pReportXMLTag.ReportInfo.ResServer.Version
	
	end function  'getServerVersion
%>

<BLOCKQUOTE style="MARGIN-RIGHT: 0px">

	<P>

	<TABLE CLASS="OptionsTable" >
	  
	  <TR>
	    <TD><B>Package file</B>:</TD>
	    <TD><B> <%= getROPFilename %> </B></TD>
	  </TR>
	  
	  <TR>
	    <TD CLASS="OptionsTableData" >Generated on:</TD>
	    <TD> <%= getCreationDate %> </TD>
	  </TR>
	  
	  <TR>
	    <TD>Report generated by:</TD>
	    <TD> <%= getReportUser %> </TD>
	  </TR>
	  
	  <TR>
	    <TD>Client Machine:</TD>
	    <TD> <%= getClientMachine %> </TD>
	  </TR>
	  
	  <TR>
	    <TD>Client Version:</TD>
	    <TD> <%= getClientVersion %> </TD>
	  </TR>
	  
	  <TR>
	    <TD>Server URL:</TD>
	    <TD> <%= getServerMachine %> </TD>
	  </TR>
	  
	  <TR>
	    <TD>Server Version:</TD>
	    <TD> <%= getServerVersion %> </TD>
	  </TR>
	  
	</TABLE>
	    
	</P>

</BLOCKQUOTE>