You are viewing limited content. For full access, please sign in.

Question

Question

When creating a document in Laserfiche using RA, I sometime get the error Laserfiche.RepositoryAccess.LockedObjectException: The operation cannot complete because an object is locked. [9045]

SDK
asked on June 10, 2015 Show version history

When creating a document in Laserfiche using RA, I sometime get the error Laserfiche.RepositoryAccess.LockedObjectException: The operation cannot complete because an object is locked. [9045]

 

Why is this appening and how can I fix this?

 

08-06-2015 04:30:17 : CopyToLaserfiche: (PO0030315500.txt) Laserfiche.RepositoryAccess.LockedObjectException: The operation cannot complete because an object is locked. [9045]
   at Laserfiche.RepositoryAccess.Entry.MakeDocFolder(String path, String volumeName, EntryType entryType, String lockToken, EntryNameOption options, Session session)
   at Laserfiche.RepositoryAccess.Document.Create(String documentPath, String volumeName, EntryNameOption options, Session session)
   at SynchroLaserfiche.LfService.CopyToLaserfiche(Session lfSession, FileInfo fileToCopy)
08-06-2015 04:30:49 : CopyToLaserfiche: (PO0030315500.tif) Laserfiche.RepositoryAccess.LockedObjectException: The operation cannot complete because an object is locked. [9045]
   at Laserfiche.RepositoryAccess.EntryLock.LockInternal(HttpUrl url, LockType type, Dictionary`2 additionalHeaders, String etag)
   at Laserfiche.RepositoryAccess.EntryLock.Lock(LockType type)
   at Laserfiche.RepositoryAccess.EntryInfo.Lock(LockType type)
   at Laserfiche.RepositoryAccess.DocumentInfo.Lock(LockType type)
   at SynchroLaserfiche.LfService.CopyToLaserfiche(Session lfSession, FileInfo fileToCopy)
08-06-2015 04:30:59 : CopyToLaserfiche: (PO0030315500.txt) Laserfiche.RepositoryAccess.LockedObjectException: The operation cannot complete because an object is locked. [9045]
   at Laserfiche.RepositoryAccess.Entry.MakeDocFolder(String path, String volumeName, EntryType entryType, String lockToken, EntryNameOption options, Session session)
   at Laserfiche.RepositoryAccess.Document.Create(String documentPath, String volumeName, EntryNameOption options, Session session)
   at SynchroLaserfiche.LfService.CopyToLaserfiche(Session lfSession, FileInfo fileToCopy)
08-06-2015 04:34:37 : WaitForFile: Le fichier C:\importationLF\PO0030311900.txt est verrouillé.
08-06-2015 04:34:55 : WaitForFile: Le fichier C:\importationLF\POX20150608043445080.nul est verrouillé.
08-06-2015 04:34:56 : WaitForFile: Le fichier C:\importationLF\POX20150608043445080.txt est verrouillé.
08-06-2015 04:39:13 : CopyToLaserfiche: (PO0030310901.tif) Laserfiche.RepositoryAccess.LaserficheRepositoryException: Not enough storage is available to complete this operation [-2147024882]
   at Laserfiche.RepositoryAccess.Entry.MakeDocFolder(String path, String volumeName, EntryType entryType, String lockToken, EntryNameOption options, Session session)
   at Laserfiche.RepositoryAccess.Document.Create(String documentPath, String volumeName, EntryNameOption options, Session session)
   at SynchroLaserfiche.LfService.CopyToLaserfiche(Session lfSession, FileInfo fileToCopy)
08-06-2015 04:39:23 : CopyToLaserfiche: (PO0030310901.txt) Laserfiche.RepositoryAccess.LockedObjectException: The operation cannot complete because an object is locked. [9045]
   at Laserfiche.RepositoryAccess.Entry.MakeDocFolder(String path, String volumeName, EntryType entryType, String lockToken, EntryNameOption options, Session session)
   at Laserfiche.RepositoryAccess.Document.Create(String documentPath, String volumeName, EntryNameOption options, Session session)
   at SynchroLaserfiche.LfService.CopyToLaserfiche(Session lfSession, FileInfo fileToCopy)
08-06-2015 04:40:34 : CopyToLaserfiche: (PO0030311200.tif) Laserfiche.RepositoryAccess.LaserficheRepositoryException: Not enough storage is available to complete this operation [-2147024882]
   at Laserfiche.RepositoryAccess.Entry.MakeDocFolder(String path, String volumeName, EntryType entryType, String lockToken, EntryNameOption options, Session session)
   at Laserfiche.RepositoryAccess.Document.Create(String documentPath, String volumeName, EntryNameOption options, Session session)
   at SynchroLaserfiche.LfService.CopyToLaserfiche(Session lfSession, FileInfo fileToCopy)

 

Public Sub CopyToLaserfiche(lfSession As Session, fileToCopy As FileInfo)
        Dim lfPath As String, extension As String, docInfo As DocumentInfo

        Try
            extension = fileToCopy.Extension.ToLower

            If extension = ".txt" Then
                lfPath = _CfgLfDestination + "txt\"
            Else
                lfPath = _CfgLfDestination
            End If

            ' Créer le document dans Laserfiche et le verrouiller
            Dim newDocId As Integer = Document.Create(lfPath + fileToCopy.Name, "DEFAULT", EntryNameOption.AutoRename, lfSession)
            docInfo = Document.GetDocumentInfo(newDocId, lfSession)
            docInfo.Lock(LockType.Exclusive)

            ' Importer le fichier dans le document Laserfiche
            Dim docImporter As New DocumentImporter
            docImporter.Document = docInfo

            ' Inner Try/Catch en cas de problème d'importation (exemple: fichier corrompu)
            Try
                If File.Exists(fileToCopy.FullName) Then
                    If extension = ".txt" Then
                        docImporter.ImportText(fileToCopy.FullName)
                    ElseIf extension = ".tif" Or extension = ".jpg" Then
                        docImporter.OcrImages = _CfgOcrImage
                        docImporter.ImportImages(fileToCopy.FullName)
                    ElseIf extension <> ".db" Then
                        docImporter.ImportEdoc(GetMimeType(fileToCopy), fileToCopy.FullName)
                    End If
                Else
                    Throw New Exception("Le fichier est inexistant ou introuvable.")
                End If

                ' Flagger le fichier pour la suppression
                _FilesToDelete.TryAdd(fileToCopy.FullName)
                docInfo.Unlock()
            Catch importEx As Exception
                WriteLog("CopyToLaserfiche: Erreur d'importation du fichier " + fileToCopy.Name + " Exception: " & importEx.ToString)

                ' Effacer le document Laserfiche
                docInfo.Delete()
                docInfo.Save()
                docInfo.Unlock()
                docInfo.Dispose()

                ' S'il existe, déplacer le fichier dans le répertoire des fichiers corrompus
                If File.Exists(fileToCopy.FullName) Then
                    File.Move(fileToCopy.FullName, _CfgCorruptedFilesDirectory + fileToCopy.Name)
                End If
            End Try
        Catch ex As Exception
            WriteLog("CopyToLaserfiche: (" + fileToCopy.Name + ") " & ex.ToString)
        Finally
            If docInfo IsNot Nothing Then
                docInfo.Unlock()
            End If
        End Try
    End Sub

 

0 0

Replies

replied on June 10, 2015

You want to use DocumentInfo.Create instead of Document.Create so you get a lock on the new document. Document.Create does not acquire a lock so it's possible for Workflow or other applications to get and lock the document while your code gets from line 14 to line 16.

3 0
You are not allowed to follow up in this post.

Sign in to reply to this post.