We have a SDK script to save documents from disk to the repository. We are testing around 200 documents and some are saving correctly and some have the below error message.
This is the SDK script
We have a SDK script to save documents from disk to the repository. We are testing around 200 documents and some are saving correctly and some have the below error message.
This is the SDK script
Your script imports pdfs, but your error is about a jpg file. Is it the import that goes wrong, or could it be the page extraction?
Hi friend, could you tell me which libraries you used, since it tells me I'm missing one library, and I'm using:
using System;
using Laserfiche.RepositoryAccess;
using Laserfiche.DocumentServices;
using Laserfiche.UI;
using Laserfiche.Workflow;
By the way, I borrowed yours since it's simple and easy.
What library is listed in your error message?
Side note: the script above makes its own connections and has no error handling, which makes it likely to run into connection limitations and leave orphaned connections to the repository when errors occur. It's best practice to use the built-in connection and reference it as RASession directly.
namespace WorkflowActivity.Scripting.Concatenalosjsonobtenidosdefecha { using System; using System.IO; using System.Text; using Laserfiche.RepositoryAccess; using Laserfiche.DocumentServices; using Laserfiche.UI; public class ConsolidarJsonFinal : RAScriptClass110 { protected override void Execute() { SaveDocument(); } private void SaveDocument() { try { Session lfSession = new Session(); lfSession.IsSecure = true; lfSession.Connect(new RepositoryRegistration("*********", "*****")); lfSession.LogIn("admin", "********"); var tokenValue = GetTokenValue("JsonAcumulador"); string jsonAcumulado = tokenValue != null ? tokenValue.ToString() : ""; if (string.IsNullOrWhiteSpace(jsonAcumulado)) { WorkflowApi.TrackError("No se encontraron datos JSON acumulados"); return; } string jsonFinal = string.Format("[{0}]", jsonAcumulado); string nombreArchivo = "FEIC_Consolidado_Fecha " + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"; string rutaCarpeta = @"C:\**********\********\Consolidados\"; string rutaArchivo = Path.Combine(rutaCarpeta, nombreArchivo); Directory.CreateDirectory(rutaCarpeta); File.WriteAllText(rutaArchivo, jsonFinal, Encoding.UTF8); SetTokenValue("JsonAcumulador", ""); SetTokenValue("RutaArchivoConsolidado", rutaArchivo); // Crear el documento en Laserfiche int documentId = Document.Create(@"\", nombreArchivo, EntryNameOption.AutoRename, lfSession); DocumentImporter documentImport = new DocumentImporter(); try { documentImport.ImportText(rutaArchivo); SetTokenValue("IdDoc", documentId); } catch (Exception e) { SetTokenValue("Errores", "Error al importar el documento: " + e.Message); WorkflowApi.TrackError("Error al importar el documento: " + e.Message); } lfSession.LogOut(); } catch (Exception ex) { WorkflowApi.TrackError("Error al consolidar JSON: " + ex.Message); throw; } } } }
Good morning friend, I'll give you a little context. It is a creation of a JSON file. This SDK is the last instance that concatenates everything found and saves it on the local drive C: at the same time it has to upload it to the repository but it always saves it correctly on drive C. However, when I try to upload it to the repository it gives me error 9006 or 405. Could you help me if the structure is wrong or how should I do it? Thank you very much for your help.
Hi Hugo,
You should set the Document you have created to the property Document of DocumentImporter before invoking ImportText.
9006 is not an error indicating missing dependencies, it's saying you have not specified a volume for your entry.
As i said before, don't make your own connection. Please take out the following lines and use the built-in RASession:
Session lfSession = new Session(); lfSession.IsSecure = true; lfSession.Connect(new RepositoryRegistration("*********", "*****")); lfSession.LogIn("admin", "********");
Then replace these lines
int documentId = Document.Create(@"\", nombreArchivo, EntryNameOption.AutoRename, lfSession); DocumentImporter documentImport = new DocumentImporter();
with
DocumentInfo document = new DocumentInfo(RASession); document.Create("\\Folder1\\MyNewDocument", "Volume1", EntryNameOption.AutoRename); DocumentImporter DI = new DocumentImporter();
and with the repository folder path and volume for your document.
I'm not sure what you're trying to achieve though. You are importing what seems to be a JSON file as text pages. So, depending on the JSON contents, it may not stay as valid JSON because text pages have limits on the length of a line and lines per page.
Hi All,
Unfortunately, it has been two years since this was posted and I'm unsure where/ what the original intention was, so I'm unable to contribute as the individual who initially posted their question is no longer working with us. I will leave the thread open as it looks like it might help others with similar issues.
Hello, good afternoon, check that I can't do it locally since where I want to send it is another repository (not the local one), it's another one that we have on another network, that's why I was using the user and the account for the same case, is there a way to connect like that? Check that my idea is if it's a json, the attempt to save it in the repository and then send it by email or is there a way to do it more efficiently so that I can send it by email at once instead of going through the whole process of saving it, because I understood that I can't send it from the SDK to email