Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collection is removed from memory after a while
Message
De
15/11/2013 17:04:58
 
 
À
15/11/2013 14:05:50
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01588067
Message ID:
01588119
Vues:
27
Ok, here is a revised version. This works. I had to make reference to a higher object declared at the application level and work with it along the way.

This is the application class declaration:
    ' Images in memory
    Public oImageData As Dictionary(Of String, ImageData) = New Dictionary(Of String, ImageData)
This is the application class ImageData:
' ImageData class
Public Class ImageData
    Private cExtension As String = ""
    Private nHeight As Integer = 0
    Private nWidth As Integer = 0

    Friend Property Extension() As String
        Get
            Return cExtension
        End Get
        Private Set(tcValue As String)
            cExtension = tcValue
        End Set
    End Property

    Friend Property Height() As Integer
        Get
            Return nHeight
        End Get
        Private Set(tnValue As Integer)
            nHeight = tnValue
        End Set
    End Property

    Friend Property Width() As Integer
        Get
            Return nWidth
        End Get
        Private Set(tnValue As Integer)
            nWidth = tnValue
        End Set
    End Property

    Friend Sub New(tnWidth As Integer, tnHeight As Integer, tcExtension As String)
        Width = tnWidth
        Height = tnHeight
        Extension = tcExtension
    End Sub

End Class
This is the initialization part:
        ' If this is the Web site
        If oApp.nApplicationMode = 3 Then

            ' If we have some images in memory
            If oApp.oAdmin.oRow("Image").length > 0 Then

                ' Load the application into the string builder
                loStringBuilderFile.LoadString(oApp.oAdmin.oRow("Image"))

                ' For each image
                For lnCounter = 1 To loStringBuilderFile.nLine

                    ' Get the line
                    If Not loStringBuilderFile.MLine(lnCounter) Then
                        Return False
                    End If

                    lcImage = loStringBuilderFile.cLine

                    ' If the file exists
                    If oApp.FileExist(oApp.cGraphicFat + lcImage) Then

                        ' Get the image details making it OK to reender the HTML without flickering
                        loImage = New System.Drawing.Bitmap(oApp.cGraphicFat + lcImage)
                        lnWidth = loImage.Width
                        lnHeight = loImage.Height

                        ' Initializaiton
                        lcName = Trim(lcImage)
                        lnLocation = oApp.At(".", lcName)
                        lcExtension = ""

                        ' If we have found it
                        If lnLocation > 0 Then

                            ' If this is not the last character
                            If lnLocation < lcName.Length Then
                                lcExtension = Mid(lcName, lnLocation + 1)
                            End If

                        End If

                        oApp.oImageData.Add(UCase(lcImage), New ImageData(lnWidth, lnHeight, lcExtension))
                    Else
                        AddError(oApp.cGraphicFat + lcImage + " does not exist.")
                    End If

                Next

            End If

        End If
This is the query part:
    ' Return True or False if an image is loaded in memory
    ' expC1 Name
    Public Function IsImageInMemory(ByVal tcName As String) As Boolean
        Dim lcName As String = ""
        Dim llFound As Boolean = False
        Dim loImageData As ImageData = Nothing

        ' Initialization
        lcName = UCase(Trim(tcName))

        ' If the image is found in the dictionary
        If oProcess.oApp.oImageData.TryGetValue(lcName, loImageData) Then
            llFound = True

            ' Initialization
            nWidth = loImageData.Width
            nHeight = loImageData.Height

        End If

        Return llFound
    End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform