Hello, I have this function but i don't know why don't run, anyone can help me? Thanks!
Public Shared Function ImportFileInContext(ByVal nombreFicheroDocumentum As String
, _
ByVal estructuraCarpetas As String
, _
ByVal file As Byte
(), _
ByVal extensionDocumentum As String
, _
ByVal hna_cia As String
, _
ByVal hna_tipo As String
, _
ByVal hna_clave As String
, _
ByVal asunto As String
, _
ByVal titulo As String
, _
ByVal keywords As String
(), _
ByVal hna_poliza As String
, _
ByVal hna_persona As String
, _
ByVal user As String
, _
ByVal repository As String
, _
ByVal url As String) As
String
'A la estructura de carpetas seleccionada le añadimos el año y mes actual para posteriores búsquedas y futuros purgados.
'La capturamos en el lado servidor para asegurarnos que la fecha no es manipulada en el equipo cliente.
estructuraCarpetas += Now.Year &"/" & Now.Month.ToString.PadLeft(2, "0"
)
If Not estructuraCarpetas.StartsWith("/")
Then
estructuraCarpetas ="/"
& estructuraCarpetas
End
If
If Not estructuraCarpetas.EndsWith("/")
Then
estructuraCarpetas +="/"
End
If
CreateFolderInRepository(estructuraCarpetas, user, repository, url)Dim m_objectIdentity As ObjectIdentity = New
ObjectIdentity(repository)
Dim miDataObject As New
DataObject(m_objectIdentity, hnaObjectType)
Dim localFullPath As String = "C:\Temp\" & nombreFicheroDocumentum & Now.Hour & Now.Minute & Now.Second & Now.Millisecond & "."
& extensionDocumentum
With
miDataObject.Properties.Set(
"object_name"
, nombreFicheroDocumentum.ToLower)
If asunto <> String.Empty
Then
.Properties.Set("subject"
, asunto.ToLower)
End
If
If titulo <> String.Empty
Then
.Properties.Set("title"
, titulo.ToLower)
End
If
'keywords puede ser de 0 a n.
If Not IsNothing(keywords) AndAlso keywords.Length > 0
Then
For i As Integer = 0 To
keywords.Length - 1keywords(i) = keywords(i).ToLower
Next
.Properties.Set("keywords"
, keywords)
End
If
If hna_cia <> String.Empty
Then
.Properties.Set("hna_cia", hna_cia.ToLower.PadLeft(3, "0"
))
End
If
If hna_persona <> String.Empty
Then
.Properties.Set("hna_persona", hna_persona.ToLower.PadLeft(9, "0"
))
End
If
If hna_poliza <> String.Empty
Then
.Properties.Set("hna_poliza", hna_poliza.ToLower.PadLeft(30, "0"
))
End
If
If hna_tipo <> String.Empty
Then
.Properties.Set("hna_tipo", hna_tipo.ToLower.PadLeft(32, "0"
))
End
If
If hna_clave <> String.Empty
Then
.Properties.Set("hna_clave", hna_clave.ToLower.PadLeft(50, "0"
))
End
If
'Transformamos el array de bytes a aun documento real.
Conversion.Conversiones.ConvertirBytesToFile(file, localFullPath).Properties.Set("a_content_type"
, extensionDocumentum.ToLower)
Dim m_objectPath As ObjectPath = New
ObjectPath(estructuraCarpetas.ToLower)m_objectIdentity =
New
ObjectIdentity(m_objectPath, repository)
Dim m_objectRelationship As ReferenceRelationship = New
ReferenceRelationship()m_objectRelationship.Name = Relationship.RELATIONSHIP_FOLDER
m_objectRelationship.Target = m_objectIdentity
m_objectRelationship.TargetRole = Relationship.ROLE_PARENT
.Contents.Add(New
FileContent(Path.GetFullPath(localFullPath), extensionDocumentum.ToLower)).Relationships.Add(m_objectRelationship)
End
With
Dim m_dataPackage As DataPackage = New
DataPackage(miDataObject)
Dim m_operationOptions As OperationOptions =
Nothing
Dim m_serviceFactory As
ServiceFactory = ServiceFactory.Instance
Dim m_servicecontext As
IServiceContext = ChangeContext(user, repository, url)
Dim m_objectService As IObjectService = m_serviceFactory.GetRemoteService(Of
IObjectService)(m_servicecontext, moduleName, url)
Dim result As
DataPackage = m_objectService.Create(m_dataPackage, m_operationOptions)
Dim res As String
= result.DataObjects(0).Identity.Value.ToString
'Borramos el fichero.
System.IO.File.Delete(localFullPath)Return
res
End
Function