
Partial Class generate_print_driver_step3
    Inherits System.Web.UI.Page

    Public printItInstallerService As New com.racadtech.services.PrintDriverGenerator()
    Public ticket As New com.racadtech.services.Ticket1()
    Public _commonFunctions As New CommonFunctions()

    'Private Sub UpdateDebugWindow(ByVal value As String)
    '    Me.debugWindow.Text += value & Environment.NewLine
    'End Sub

    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.
        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")
        ticket.ErrorCode = Session("PrintItInstaller_ErrorCode")
        ' Enjoy! ;)
        'UpdateDebugWindow("TicketId=" & ticket.TicketId)
        'UpdateDebugWindow("StoreId=" & ticket.StoreId)
        'UpdateDebugWindow("ActivationId=" & ticket.ActivationId)
        'UpdateDebugWindow("PrinterName=" & ticket.PrinterName)
        'UpdateDebugWindow("CompanyName=" & ticket.CompanyName)
        'UpdateDebugWindow("CompanyNameShort=" & ticket.CompanyNameShort)
        'UpdateDebugWindow("IsSDCIntegrated=" & ticket.IsSDCIntegrated)
        'UpdateDebugWindow("WindowsDriverLocation=" & ticket.WindowsDriverLocation)
        'UpdateDebugWindow("MacDriverLocation=" & ticket.MacDriverLocation)
        'UpdateDebugWindow("QueuePosition=" & ticket.QueuePosition)
        'UpdateDebugWindow("IsComplete=" & ticket.IsComplete)

    End Sub


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'If ticket.ErrorCode > 0 Then
        '    ErrorCodeLabel.Visible = True
        '    CongratulationLabel.Visible = False

        'End If
        '' All stuff below commented because copying print driver from tmp directory 
        '' to real store web folder moved to Print Driver generstion part 

        'Dim _directory = ConfigurationManager.AppSettings("PrintItStoreDataPath") & "\" & ticket.StoreId

        ' Create directory IF doesn't exist.
        'If System.IO.Directory.Exists(_directory) = False Then
        '    Try
        '        System.IO.Directory.CreateDirectory(_directory)
        '    Catch ex As Exception
        '    End Try
        'End If

        ''Dim logFile As System.IO.StreamWriter = System.IO.File.CreateText(_directory & "\" & "debug.txt")

        ''logFile.WriteLine("[Directory] =  " & _directory)

        '' delete all print drivers before copying

        'Try
        '    Dim _file As String
        '    For Each _file In System.IO.Directory.GetFiles(_directory)
        '        'If (_file.StartsWith(_directory & "\GoPrint2")) Then
        '        'logFile.WriteLine("Find File :  " & _file)
        '        If _commonFunctions.GetDocumentName(_file, True, "\\").Split(".")(1) = "exe" Or _commonFunctions.GetDocumentName(_file, True, "\\").Split(".")(1) = "dmg" Then
        '            'logFile.WriteLine("File Extention : " & _commonFunctions.GetDocumentName(_file, True, "\\").Split(".")(1))
        '            System.IO.File.Delete(_file)
        '            'logFile.WriteLine("Try to Delete File :  " & _file)
        '        End If
        '        'End If
        '    Next _file
        'Catch ex As Exception
        '    'logFile.WriteLine("Can not Delete File  due to " & ex.Message)
        'End Try

        ''logFile.Close()
        ''logFile.Dispose()

        '' Copy Print Drivers to StoreData
        'Dim _oldWindowsDriverLocation = ticket.WindowsDriverLocation
        'Dim _oldMacDriverLocation = ticket.MacDriverLocation

        'Dim _windowsDocName = _commonFunctions.GetDocumentName(ticket.WindowsDriverLocation, True, "\\")
        'Dim _newWindowsDriverLocation = _directory & "\" & _windowsDocName

        'Try
        '    System.IO.File.Copy(ticket.WindowsDriverLocation, _newWindowsDriverLocation)
        '    'printItInstallerService.Copy(ticket.WindowsDriverLocation, _newWindowsDriverLocation)
        '    'WindowsPDLink.Visible = True
        '    'WindowsPDLink.NavigateUrl = "http://pd.printitat.net/" & ConfigurationManager.AppSettings("PrintItStoreDataVirtualDirectory") & "/" & ticket.StoreId & "/" & _windowsDocName
        '    'WindowsPDLink.NavigateUrl = "/" & ConfigurationManager.AppSettings("PrintItStoreDataVirtualDirectory") & "/" & ticket.StoreId & "/" & _windowsDocName
        'Catch ex As Exception
        '    'Label1.Text = ex.Message.ToString() & "<br/>"
        'End Try

        'Dim _macDocName = _commonFunctions.GetDocumentName(ticket.MacDriverLocation, True, "\\")
        'Dim _newMacDriverLocation = _directory & "\" & _macDocName

        'Try
        '    System.IO.File.Copy(ticket.MacDriverLocation, _newMacDriverLocation)
        '    'printItInstallerService.Copy(ticket.MacDriverLocation, _newMacDriverLocation)
        '    'MacPDLink.Visible = True
        '    'MacPDLink.NavigateUrl = "http://pd.printitat.net/" & ConfigurationManager.AppSettings("PrintItStoreDataVirtualDirectory") & "/" & ticket.StoreId & "/" & _macDocName
        '    'MacPDLink.NavigateUrl = "/" & ConfigurationManager.AppSettings("PrintItStoreDataVirtualDirectory") & "/" & ticket.StoreId & "/" & _macDocName
        'Catch ex As Exception
        '    'Label2.Text = ex.Message.ToString() & "<br/>"
        'End Try

        'Label1.Text = "<br/>ticket.WindowsDriverLocation : " & ticket.WindowsDriverLocation & _
        '"<br/>_newWindowsDriverLocation : " & _newWindowsDriverLocation & _
        '"<br/>ticket.MacDriverLocation : " & ticket.MacDriverLocation & _
        '"<br/>_newMacDriverLocation : " & _newMacDriverLocation

        If Session("EditUserFromAdmin") = True Then
            CongratulationLabel.Visible = False
            AdminLabel.Visible = True
        End If
    End Sub

End Class
