Could you explain a bit about FileIO:CrudClassName and the BindEvents Class.

May 28, 2010 at 9:52 AM

Could you explain a bit about FileIO:CrudClassName and the BindEvents Class.

Coordinator
May 28, 2010 at 12:22 PM

Hi,

 

These are the elements which provide extra possiblities to trap events for futher processing. For example if you want to do some checking if files are referenced in other pages in a database.

 

At a line to the web.config under appsettings for instanse 

 

<add key="FileIO:CrudClassName" value="KA.FileIO_CRUD" />

 

 

 

 

 

and add a class like this to trap the events

Imports FileManager

Public Class FileIO_CRUD
    Private thisOnderwerpen As Onderwerpen
    Public Sub OnFolderAdding(ByVal sender As Object, ByVal args As FolderAddingEventArgs) ' Handles handler.FolderAdding
        args.ReturnValue = 1
    End Sub
    Public Sub OnFolderAdded(ByVal sender As Object, ByVal args As FolderAddedEventArgs) ' Handles handler.FolderAdded
        args.ReturnValue = 1
    End Sub
    Public Sub OnFolderUpdating(ByVal sender As Object, ByVal args As FolderUpdatingEventArgs) ' Handles handler.FolderUpdating
        args.ReturnValue = 1
    End Sub
    Public Sub OnFolderUpdated(ByVal sender As Object, ByVal args As FolderUpdatedEventArgs) ' Handles handler.FolderUpdated
        thisOnderwerpen = New Onderwerpen
        Dim newpath As String = ReplacePathname(args.NewFolderPath) & "/" & args.NewFolderName
        Dim origpath As String = ReplacePathname(args.OrigFolderPath) & "/" & args.OrigFolderName
        'change all references to new folder location
        thisOnderwerpen.UpdateContentWithStr(origpath, newpath)
        args.ReturnValue = 1
    End Sub
    Public Sub OnFolderDeleting(ByVal sender As Object, ByVal args As FolderDeletingEventArgs) ' Handles handler.FolderDeleting
        thisOnderwerpen = New Onderwerpen
        Dim origfolder As String = ReplacePathname(args.OrigFolderPath) & "/" & args.OrigFolderName
        Dim has_references = thisOnderwerpen.LinkedInDoc(origfolder)
        If has_references Then
            args.ReturnValue = 0
        Else
            args.ReturnValue = 1
        End If
    End Sub
    Public Sub OnFolderDeleted(ByVal sender As Object, ByVal args As FolderDeletedEventArgs) ' Handles handler.FolderDeleted
        args.ReturnValue = 1
    End Sub
    Public Sub OnFileUpdating(ByVal sender As Object, ByVal args As FileUpdatingEventArgs) ' Handles handler.FileUpdating
        args.ReturnValue = 1
    End Sub
    Public Sub OnFileUpdated(ByVal sender As Object, ByVal args As FileUpdatedEventArgs) ' Handles handler.FileUpdated
        thisOnderwerpen = New Onderwerpen
        Dim newfile As String = ReplacePathname(args.NewFolderPath) & "/" & args.NewFileName
        Dim origfile As String = ReplacePathname(args.OrigFolderPath) & "" & args.OrigFileName
        'change all references to new file location
        thisOnderwerpen.UpdateContentWithStr(origfile, newfile)
        args.ReturnValue = 1
    End Sub
    Public Sub OnFileDeleting(ByVal sender As Object, ByVal args As FileDeletingEventArgs) ' Handles handler.FileDelting
        thisOnderwerpen = New Onderwerpen
        Dim origfile As String = ReplacePathname(args.OrigFolderPath) & "" & args.OrigFileName
        Dim has_references = thisOnderwerpen.LinkedInDoc(origfile)
        If has_references Then
            args.ReturnValue = 0
        Else
            args.ReturnValue = 1
        End If
    End Sub
    Public Sub OnFileDeleted(ByVal sender As Object, ByVal args As FileDeletedEventArgs) ' Handles handler.FileDeleted
        args.ReturnValue = 0
    End Sub
    Private Function ReplacePathname(ByVal astring As String) As String
        Return astring.Replace(FileManager.FileTree.PublicPathName, "").Replace("\", "/")
    End Function
End Class
Hope this is enough info, otherwise I am willing to help you further.
May 29, 2010 at 2:01 AM

Cannot imagine that you could answer this quick.

Thanks a lot for your clarification. :)