Notify Errors

Feb 6, 2009 at 5:07 PM
Hi
First of all great job, your fileuploader is amazing.

i've problem getting error using a custom adapter.
when i notify the error throwing an exception or setting httpstatuscode i receive the error on the next file and the status is resetted to 200 so i get an alternate error state if i throw error for all uploaded files.
how can i notify the uploader from the adapter in the right way.

this is my custom adapter code:



Public Class DatabaseUploader
    Inherits com.flajaxian.FileUploaderAdapter

    Public Event ErrorOccurred(ByVal sender As Object, ByVal e As DatabaseUploaderErrorEventArgs)

    Public Overrides Sub ProcessFile(ByVal file As System.Web.HttpPostedFile)    
        Try
            SaveFile(file)
        Catch ex As Exception           
            OnErrorOccurred(file.FileName, ex)
        End Try
    End Sub

    Private Sub SaveFile(ByVal file As HttpPostedFile)
      
        Throw New Exception("DatabaseUploader: Error saving file " + file.FileName)

    End Sub

    Protected Overridable Sub OnErrorOccurred(ByVal fileName As String _
                                            , ByVal exception As Exception)
        RaiseEvent ErrorOccurred(Me, New DatabaseUploaderErrorEventArgs(fileName, exception))
    End Sub

End Class

Public Class DatabaseUploaderErrorEventArgs
    Inherits EventArgs
    Private _Exception As Exception
    Public Property Exception() As Exception
        Get
            Return _Exception
        End Get
        Private Set(ByVal value As Exception)
            _Exception = value
        End Set
    End Property
    Private _FileName As String
    Public Property FileName() As String
        Get
            Return _FileName
        End Get
        Private Set(ByVal value As String)
            _FileName = value
        End Set
    End Property

    Public Sub New(ByVal fileName As String, ByVal exception As Exception)
        Me.FileName = fileName
        Me.Exception = exception
    End Sub
End Class

and this is how i handle the error event on the web form

    Public Sub HandleError(ByVal sender As Object, ByVal args As DatabaseUploaderErrorEventArgs)
        HttpContext.Current.Response.StatusCode = 550
    End Sub


i have the same result if i notify the error hadling fileUploader's FileReceived event like this

    Protected Sub fileUploader_FileReceived(ByVal sender As Object, ByVal e As com.flajaxian.FileReceivedEventArgs) Handles fileUploader.FileReceived
        HttpContext.Current.Response.StatusCode = 550
    End Sub


thanks a lot and sorry for my bad english ...
Feb 6, 2009 at 5:10 PM
i forgot i handle client event this way

 function FileStateChanged(uploader, file, httpStatus, isLast) {
            Flajaxian.fileStateChanged(uploader, file, httpStatus, isLast);
            var msg = Flajaxian.$("divMsg");
            var done = Flajaxian.$("divDone");
            var fileUploader = Flajaxian.$("divUploader");

            //alert('file:' + file.name + ' state:' + file.state + ' hhtpStatus: ' + httpStatus);
            //state    Selected = 1; Uploading = 2; Uploaded = 3; Error = 5
            if (file.state == 5 || httpStatus > 200) {
                msg.innerHTML += "<img src='../images/icons/exclamation.png' alt='ko' />  File " + file.name + " non è stato caricato <BR>";
            }

            if (isLast) {                       
                done.innerHTML += "<img src='../images/icons/cog.png' alt='done' /> Caricamento completato <BR>";
                fileUploader.style.display = 'none';
            }
        }