57 lines
1.9 KiB
VB.net
57 lines
1.9 KiB
VB.net
Imports System.IO
|
|
|
|
Namespace slt.Entities
|
|
Public Class sltDocument
|
|
Public Property ExtDocId As String
|
|
Public Property Name As String
|
|
Public Property Description As String
|
|
Public Property DocMimeType As String
|
|
Public Property DocModifyTimestamp As String
|
|
Public Property DocOrigin As String
|
|
Public Property DocOriginalFilename As String
|
|
Public Property DocSize As Long
|
|
Public Property StorPlaceId As String
|
|
Public Property ExternalId As String
|
|
Public Property Data As Byte()
|
|
|
|
Public Function GetUniqueFilename() As String
|
|
Dim oExtension = GetExtension()
|
|
If oExtension Is Nothing Then
|
|
Return Nothing
|
|
End If
|
|
|
|
Return ExtDocId & oExtension
|
|
End Function
|
|
|
|
Private Function GetExtension() As String
|
|
Dim oExtensionFromName = GetAllowedExtension(Name)
|
|
If oExtensionFromName IsNot Nothing Then
|
|
Return oExtensionFromName
|
|
End If
|
|
|
|
Dim oExtensionFromOriginalName = GetAllowedExtension(DocOriginalFilename)
|
|
If oExtensionFromOriginalName IsNot Nothing Then
|
|
Return oExtensionFromOriginalName
|
|
End If
|
|
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function GetAllowedExtension(pFilename As String) As String
|
|
If Path.HasExtension(pFilename) Then
|
|
Dim oExtension = Path.GetExtension(pFilename)
|
|
Dim oExtensionWithoutDot = oExtension.Substring(1).ToLower()
|
|
|
|
If Common.Constants.AllowedExtensions.Contains(oExtensionWithoutDot) Then
|
|
Return oExtension
|
|
Else
|
|
Return Nothing
|
|
End If
|
|
Else
|
|
Return Nothing
|
|
End If
|
|
End Function
|
|
|
|
End Class
|
|
End Namespace
|