Imports System
Imports System.Security.Principal

Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.Persistent.Base.Security
Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Security
Imports DevExpress.ExpressApp.Updating
Imports DevExpress.Xpo
Imports DevExpress.Data.Filtering
Imports System.IO
Imports System.Security
Imports System.Xml

Public Class Updater
    Inherits ModuleUpdater
    Public Sub New(ByVal ObjectSpace As IObjectSpace, ByVal currentDBVersion As Version)
        MyBase.New(ObjectSpace, currentDBVersion)
    End Sub
    Public Overrides Sub UpdateDatabaseAfterUpdateSchema()
        MyBase.UpdateDatabaseAfterUpdateSchema()

        Dim _FileData As DevExpress.Persistent.BaseImpl.FileData = ObjectSpace.CreateObject(Of DevExpress.Persistent.BaseImpl.FileData)()
        Dim _XLSImports As XLSImports
        Dim _FileStream As FileStream = File.OpenRead("Excels\XLSImports.xlsx")
        _XLSImports = ObjectSpace.FindObject(Of XLSImports)(CriteriaOperator.Parse("Oid=Oid"), False)
        If _XLSImports Is Nothing Then
            _XLSImports = ObjectSpace.CreateObject(Of XLSImports)()
            _FileData.LoadFromStream("XLSImports.xlsx", _FileStream)
            _XLSImports.XLSFileName = _FileData
            _XLSImports.Save()
        End If

        Dim _ResetObjects As ResetObjects = ObjectSpace.FindObject(Of ResetObjects)(CriteriaOperator.Parse("Oid=Oid"), False)
        If _ResetObjects Is Nothing Then
            _ResetObjects = ObjectSpace.CreateObject(Of ResetObjects)()
            _ResetObjects.Save()
        End If

        Dim _SpreadImport As SpreadImport
        _SpreadImport = ObjectSpace.FindObject(Of SpreadImport)(CriteriaOperator.Parse("1=1"))

        If _SpreadImport Is Nothing Then
            _SpreadImport = ObjectSpace.CreateObject(Of SpreadImport)()
            _SpreadImport.Save()
        End If
    End Sub


End Class
