Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MHTML using aspNetMHT
Message
De
04/02/2015 15:07:18
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
MHTML using aspNetMHT
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01614890
Message ID:
01614890
Vues:
23
A while ago, I posted a thread about some changes in the way I was generating a MHTML file. I tested aspNetMHT and it works very well. For those interested, here is as simple as the class is:
Public Class MHTML

    Public cDirectory As String = ""
    Public cFile As String = ""
    Public cLicenseKey As String = ""
    Public cMessage As String = ""
    Public cUrl As String = ""
    Private oApp As App = Nothing
    Private oProcess As LXProcess = Nothing

    ' This is when we access the class in a desktop mode
    Sub New(ByVal toApplication As App)
        oApp = toApplication
    End Sub

    ' This is when we access the class in a Web or Web Service mode
    Public Sub New(ByVal toProcess As LXProcess)
        oProcess = toProcess
        oApp = oProcess.oApp
    End Sub

    ' Get the MHTML file
    Public Function GetMHTML() As Boolean
        Dim lcDirectory As String = ""
        Dim lcFile As String = ""
        Dim lcLicenseKey As String = ""
        Dim llSuccess As Boolean = False
        Dim loMHT As aspNetMHT.MHT = Nothing

        ' Reset the values
        cMessage = ""

        ' Initialization
        lcFile = Trim(cFile)
        lcLicenseKey = Trim(cLicenseKey)

        ' Initialization
        lcDirectory = oApp.GetPath(cDirectory)

        ' Initialization
        aspNetMHT.MHT.LoadLicenseKey(lcLicenseKey)

        ' Load the Url
        loMHT = New aspNetMHT.MHT(cUrl)

        ' Parse the HTML into its MHT counterpart
        loMHT.Parse()

        ' Save it to a file
        loMHT.SaveToFile(lcDirectory + lcFile)

        llSuccess = True

        ' Reset the values
        cLicenseKey = ""

        Return llSuccess
    End Function

End Class
Then, from a client application:
        Dim loMHTML As Framework.MHTML = New Framework.MHTML(oApp)

        ' If we cannot get the MHtml
        loMHTML.cUrl = lcUrl
        loMHTML.cDirectory = lcDirectory
        loMHTML.cFile = lcFile
        loMHTML.cLicenseKey = lcLicenseKey
        If Not loMHTML.GetMHTML() Then
            MessageBox.Show(loMHTML.cMessage, oApp.cTitle, MessageBoxButtons.OK, MessageBoxIcon.Stop)
            Exit Sub
        End If
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
Répondre
Fil
Voir

Click here to load this message in the networking platform