Public Sub FileUploaded(parts As Map)
Log("wsDataFileImport.FileUploaded: " & parts)
Try
If parts.ContainsKey("fileImport") Then
Dim filePart As Part = parts.Get("fileImport")
ws.Session.SetAttribute("fileImportStatus", "File uploaded successfully: " & filePart.SubmittedFilename & " size = " & NumberFormat(File.Size("", filePart.TempFile) / 1000, 0, 0) & "kb")
' UploadFileResult.SetText("File uploaded successfully: " & filePart.SubmittedFilename & " size = " & NumberFormat(File.Size("", filePart.TempFile) / 1000, 0, 0) & "kb")
' UploadFileResult.SetCSS("color", "black")
Dim Filename As String = File.GetName(filePart.SubmittedFilename)
' Delete any file there with the same name
If File.Exists(File.DirApp & Main.DirectorySeparator & "IMPORTS", Filename) = True Then File.Delete(File.DirApp & Main.DirectorySeparator & "IMPORTS", oCompany.UID &"_"& Filename)
' Copy the temp file to the IMPORTS directory WITH THE COMPANYID at the beginning of the filename
File.Copy(Main.TempDir, File.GetName(filePart.TempFile), File.DirApp & Main.DirectorySeparator & "IMPORTS", oCompany.UID &"_"& Filename)
' NOTE: The import process will run on a schedule via the bwAutoTasks
End If
File.Delete("", filePart.TempFile)
Catch
Log("wsDataFileImport.FileUploaded Catch: " & LastException)
End Try
End Sub