<!--#include virtual="/NRConfig/LicenseConfig/CNCASPPageUI_LicenseConfig.inc"-->
<% 
'*****************************************************************************
' Copyright (C) 2001 Microsoft Corporation. All rights reserved.
'
' File:  NRCONFIG/CNCASPPageManager_LicenseConfig.inc
' Author: Microsoft Corporation
'
' Purpose:
'   	Provide init manager to access API, validate license key and update license key.
'
'Public Methods and Properties Exposed:
'	- Sub InitManager()
'	Public LicensedCompanyName
'	Public LicensedUserName
'	Public ProductID
'	Public LicenseType
'	Public ExpiryDate
'	Public ResServerIndex
'	Public Error
'	Public ErrorDetail
'	Public IsSupportedBrowser
'*****************************************************************************

'--Define constants

Class CNCASPPageManager_LicenseConfig
	
	'Public property
	Public LicensedCompanyName
	Public LicensedUserName
	Public ProductID
	Public LicenseType
	Public ExpiryDate
	Public ResServerIndex
	Public Error
	Public ErrorDetail
	Public IsSupportedBrowser
	
	'Define private variable
	Private m_pSCAPI
	
	
	'---- [Private] Standard Class_Initialize
	Private Sub Class_Initialize()
		
		'-- Create an instance of ServerConfiguration API
	   	SET m_pSCAPI = Server.Createobject("ServerConfigurationAPI.NRSCAPI")
		
		'-- Inititalize this API
		m_pSCAPI.Initialize ( )

		LicensedCompanyName=""
		LicensedUserName=""
		ProductID=""
		LicenseType=""
		ExpiryDate=""
		ResServerIndex = -1
		Error = IDS_OK_NO_ERROR 
		ErrorDetail = ""
		IsSupportedBrowser = False
		
	End Sub
	
	'*************************************************
	'Purpose: Response for all init asp page process for License tab and Dlg
	'         
	'Input:	  None
	'
	'Output:  Get values from API and set up properties 
   	'************************************************* 
    
	Public Sub InitManager()

		'--Check browser version and java script enable
		IsSupportedBrowser = VerifyIsSupportedBrowser

		'--Get Resolution index
		ResServerIndex = Request.QueryString("ResServerIndex")
		
		' -- Check ResServerIndex exist or not  
		ResServerIndexExist(ResServerIndex)
		
		'-- No Resolution Entry Point not run this code
		If ResServerIndex > ID_NO_RESOLUTION_ENTEY_POINT  Then	

			'--Get API data for both tab control renderer and General config UI
			Call GetAPIDataForUI

		Else
			' -- Err. Raise 
			Error = IDS_UI_WARNING_NOENTRYPOINTS_ISWRONG	
		End If

	End Sub

   	
  	'--[Private] Get API data for UI
	Private Sub GetAPIDataForUI()
		
		On Error Resume next
		Dim pLicenseSettings
		Set pLicenseSettings = m_pSCAPI.CMSLicenseSettings
		
		'--Error Check
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR & " " & IDS_UI_ERROR_GET_LICENSE_SETTING
			ErrorDetail = Err.Description
			Exit Sub
		End If


		'-- Get Company name 
		LicensedCompanyName = pLicenseSettings.LicensedCompany
		
		'--Error Check
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR & " " & IDS_UI_ERROR_GET_COMPANY_NAME
			ErrorDetail = Err.Description
			Exit Sub
		End If

		
		'-- Get User name 
		LicensedUserName = pLicenseSettings.LicensedUser
		
		'--Error Check
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR & " " & IDS_UI_ERROR_GET_USER_NAME
			ErrorDetail = Err.Description
			Exit Sub
		End If
		
		
		'-- Get Product ID 
		ProductID = pLicenseSettings.ProductID
				
		'--Error Check
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR & " " & IDS_UI_ERROR_GET_PRODUCT_ID
			ErrorDetail = Err.Description
			Exit Sub
		End If

		
		'-- Get LicenseType Type
		Dim eLicenseType
		eLicenseType = pLicenseSettings.LicenseType
						
		'--Error Check
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR & " " & IDS_UI_ERROR_GET_LICENSE_TYPE
			ErrorDetail = Err.Description
			Exit Sub
		End If
		
		If (eLicenseType = "") Or _
		   ((eLicenseType <> IDS_CMS_LICENSE_TYPE_UNKNOWN) AND _
		    (eLicenseType <> IDS_CMS_LICENSE_TYPE_EVALUATION) AND _
		    (eLicenseType <> IDS_CMS_LICENSE_TYPE_ENTERPRISE) AND _
		    (eLicenseType <> IDS_CMS_LICENSE_TYPE_DEVELOPER) AND _
		    (eLicenseType <> IDS_CMS_LICENSE_TYPE_CORRUPT_EVALUATION) AND _
		    (eLicenseType <> IDS_CMS_LICENSE_TYPE_INVALID)) Then
			LicenseType = IDS_CMS_LICENSE_TYPE_UNKNOWN
		Else
			LicenseType = eLicenseType
		End If

		
		'-- Get Expiry Date 
		'   ONLY IF LicenseType is Evaluation
		If (eLicenseType = IDS_CMS_LICENSE_TYPE_EVALUATION) Then
			
			ExpiryDate = pLicenseSettings.ExpirationDate
			
			'--Error Check
			If Err.Number <> 0 Then
				Error = IDS_UNEXPEXTED_ERROR & " " & IDS_UI_ERROR_GET_EXPIRY_DATE
				ErrorDetail = Err.Description
				Exit Sub
			End If

		End If
		
		
		'-- Clear object
		Set pLicenseSettings = Nothing
		Set m_pSCAPI = Nothing
		
	End Sub	
	
End Class
%>