Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text

Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base

Public Class MobileListDashboardVC
    Inherits Nuvolar.Module.MobileListDashboardsVC

    Public Sub New()
		MyBase.New()

		'This call is required by the Component Designer.
		InitializeComponent()
		RegisterActions(components) 

	End Sub

    Private Sub aViewDashboardBase_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aViewDashboardBase.Execute
        Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
        Dim _MobileListDashboards As MobileListDashboards = TryCast(View.SelectedObjects(0), MobileListDashboards)

        If _MobileListDashboards IsNot Nothing Then
            If _MobileListDashboards.BusinessDirectory IsNot Nothing Then
                Dim _FileName As String = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetTempPath, _MobileListDashboards.BusinessDirectory.FileData.FileName)
                Dim _StreamFile As System.IO.Stream = New System.IO.FileStream(_FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)
                _MobileListDashboards.BusinessDirectory.FileData.SaveToStream(_StreamFile)
                _StreamFile.Close()

                If IO.File.Exists(_FileName) Then
                    GLOBAL_DASHBOARD_XML_DashboardXmlFile = _FileName
                    GLOBAL_DASHBOARD_XML_UserName = _MobileListDashboards.BusinessDirectory.DashBoard_UserName
                    GLOBAL_DASHBOARD_XML_Password = _MobileListDashboards.BusinessDirectory.DashBoard_Password
                    GLOBAL_DASHBOARD_XML_ServerName = _MobileListDashboards.BusinessDirectory.DashBoard_Server
                    GLOBAL_DASHBOARD_XML_DatabaseName = _MobileListDashboards.BusinessDirectory.DashBoard_Database
                    Select Case _MobileListDashboards.BusinessDirectory.SQLType
                        Case eSQLType.MSSQL
                            GLOBAL_DASHBOARD_XML_SQLType = "MSSQL"
                        Case eSQLType.MySQL
                            GLOBAL_DASHBOARD_XML_SQLType = "MYSQL"
                        Case eSQLType.PostgreSQL
                            GLOBAL_DASHBOARD_XML_SQLType = "PSQL"
                    End Select

                    DevExpress.ExpressApp.Web.WebWindow.CurrentRequestWindow.RegisterStartupScript("ShowCustomFormScriptKey", String.Format("window.open('{0}');", "Controls/DashboardViewer.aspx"))
                End If
            End If
        End If
    End Sub
End Class
