﻿Imports Telerik.WebControls

Partial Class order_centre_Default
    Inherits System.Web.UI.Page
    Private _webAdapter As New WebWS()
    Private _goPrint2Adapter As New com.racadtech.services.GoPrint2Client()
    Private pdfConverterWS As New com.racadtech.services.PDFConverter()

    Dim _customerId As String = ""
    Dim _activationId As String = ""
    Dim _files As String = "filename1@@@302131%%%"
    Dim _emailSent As String = ""
    Dim _ftpSent As String = ""
    Dim _jobOptions As String = ""
    Dim _uploadMethod As String = ""
    Dim _masterKey As String = MasterKey
    Dim _jobId As String = ""


    Public ReadOnly Property TempDirectory() As String
        Get
            Return ConfigurationManager.AppSettings.Get("PrintItTempDataPath").ToString()
        End Get
    End Property
    Public ReadOnly Property WebAdapter() As WebWS
        Get
            Return _webAdapter
        End Get
    End Property
    Public ReadOnly Property GoPrint2Adapter() As com.racadtech.services.GoPrint2Client
        Get
            Return _goPrint2Adapter
        End Get
    End Property
    Public ReadOnly Property JobFilesDirectory() As String
        Get
            Return ConfigurationManager.AppSettings.Get("JobFilesPath").ToString()
        End Get
    End Property
    Public ReadOnly Property JobFilesVirtualDirectory() As String
        Get
            Return ConfigurationManager.AppSettings.Get("JobFilesVirtualDirectory").ToString()
        End Get
    End Property
    Public ReadOnly Property MasterKey() As String
        Get
            Return "877k31hg333-d03423332wq-312dkazlfs-433398j543"
        End Get
    End Property
    Public ReadOnly Property CurrentUser() As String
        Get
            Return System.Web.HttpContext.Current.User.Identity.Name.ToString()
        End Get
    End Property
    Public ReadOnly Property CurrentUserId() As String
        Get
            Return Membership.GetUser(CurrentUser).ProviderUserKey.ToString()
        End Get
    End Property
    Public ReadOnly Property CurrentCustomerId() As String
        Get
            If Not Session("CustomerId") Is Nothing Then
                Return Session("CustomerId")
            Else
                Return WebAdapter.GetCustomerIdByUserId(CurrentUserId)
            End If            
        End Get
    End Property
    Public ReadOnly Property CurrentActivationId() As String
        Get
            Return WebAdapter.GetActivationIdByStoreId(Session("StoreId")).ToString()
        End Get
    End Property
    Public ReadOnly Property BaseImageURL() As String
        Get
            If Not Session("BaseImageURL") Is Nothing Then
                Return Session("BaseImageURL")
            Else
                Return "themes/orange/"
            End If
        End Get
    End Property

    Public ReadOnly Property CurrentLanguage() As String
        Get
            Return System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToLower().Substring(0, 2)
        End Get
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If (Not System.Web.HttpContext.Current.User.Identity.IsAuthenticated()) Then
            Response.Redirect("~/order_centre/login.aspx")
        End If

        ' Disable Language Panel.
        Dim _languagesPanel As Web.UI.WebControls.Panel = Me.Master.FindControl("LanguagesPanel")
        Dim _languagesSpacer As Web.UI.HtmlControls.HtmlGenericControl = Me.Master.FindControl("LanguagesSpacerLabel")
        _languagesPanel.Visible = False
        _languagesSpacer.InnerHtml = "<br /><br />"

        _customerId = CurrentCustomerId
        _activationId = CurrentActivationId
        _jobOptions = Session("JobOptions")

        ' Update Applet Language + Scope
        Me.UploaderControl1.AppletParams.Add("lang", CurrentLanguage)
		Me.UploaderControl1.AppletParams.Add("scope", 3)
    End Sub
End Class
