
Partial Class generate_print_driver_step2
    Inherits System.Web.UI.Page

    Public isTicketComplete As Boolean = False
    Public printItInstallerService As New com.racadtech.services.PrintDriverGenerator()
    Public ticket As New com.racadtech.services.Ticket1()

    Public _selectedLanguage As String = ""

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        ' Reconstruct ticket object from session values.
        ' We need todo this because web service requires ticket object, and we can not store
        ' objects in session unless we serialize them.
        ticket.TicketId = Session("PrintItInstaller_TicketId")
        ticket.StoreId = Session("PrintItInstaller_StoreId")
        ticket.ActivationId = Session("PrintItInstaller_ActivationId")
        ticket.PrinterName = Session("PrintItInstaller_PrinterName")
        ticket.CompanyName = Session("PrintItInstaller_CompanyName")
        ticket.CompanyNameShort = Session("PrintItInstaller_CompanyNameShort")
        ticket.IsSDCIntegrated = Session("PrintItInstaller_IsSDCIntegrated")
        ticket.WindowsDriverLocation = Session("PrintItInstaller_WindowsDriverLocation")
        ticket.MacDriverLocation = Session("PrintItInstaller_MacDriverLocation")
        ticket.QueuePosition = Session("PrintItInstaller_QueuePosition")
        ticket.IsComplete = Session("PrintItInstaller_IsComplete")

        ' Check to see if ticket is completed. 
        ' ( Passing newly created ticket object based on previous session data. )
        ticket = printItInstallerService.IsTicketComplete(ticket)

        ' Storing new ticket object information into session, overwriting the previous data.
        Session("PrintItInstaller_TicketId") = ticket.TicketId
        Session("PrintItInstaller_StoreId") = ticket.StoreId
        Session("PrintItInstaller_ActivationId") = ticket.ActivationId
        Session("PrintItInstaller_PrinterName") = ticket.PrinterName
        Session("PrintItInstaller_CompanyName") = ticket.CompanyName
        Session("PrintItInstaller_CompanyNameShort") = ticket.CompanyNameShort
        Session("PrintItInstaller_IsSDCIntegrated") = ticket.IsSDCIntegrated
        Session("PrintItInstaller_WindowsDriverLocation") = ticket.WindowsDriverLocation
        Session("PrintItInstaller_MacDriverLocation") = ticket.MacDriverLocation
        Session("PrintItInstaller_QueuePosition") = ticket.QueuePosition
        Session("PrintItInstaller_IsComplete") = ticket.IsComplete
        Session("PrintItInstaller_ErrorCode") = ticket.ErrorCode
        If (ticket.IsComplete) Then
            ' Afterwards, we'll redirect to the final page.
            isTicketComplete = True
        Else
            isTicketComplete = False
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.ticketLbl.Text = GetLocalResourceObject("CurrentQueuePosition") & " : <b>" + ticket.QueuePosition.ToString() + "</b>"

        If (isTicketComplete) Then
            Me.METAREFRESH.Text = "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=generate_print_driver_step3.aspx'>"
        Else
            Me.METAREFRESH.Text = "<META HTTP-EQUIV='Refresh' CONTENT='5; URL=generate_print_driver_step2.aspx'>"
        End If
    End Sub

End Class
