He're the script:
namespace WorkflowActivity.Scripting.ScriptparaexportardocumentosfueradeLaserfiche
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using Laserfiche.DocumentServices;
using Laserfiche.RepositoryAccess;
using Laserfiche.Workflow.Activities;
using Laserfiche.SecurityTokenService;
using Laserfiche.UI;
using System.IO;
using LFSO90Lib;
using System.Xml.Serialization;
using System.Xml;
using System.Text.RegularExpressions;
using System.Xml.Linq;
/// <summary>
/// Provides one or more methods that can be run when the workflow scripting activity is performed.
/// </summary>
public class Script1 : RAScriptClass91 //RAScriptClass102
{
/// <summary>
/// This method is run when the activity is performed.
/// </summary>
protected override void Execute()
{
string valor = "";
string campo = "";
string paso = "0";
string _c = "";
string _v = "";
string NoExpediente = "";
string Clasificacion = "";
string rutabase = "C:\\Users\\rcairo\\Box Sync\\Conciliaciones PGS KHR DWT\\4. FACTURAS PGS KHR\\";
try
{
DocumentInfo DI = (DocumentInfo)this.BoundEntryInfo;
EntryInfo entry = Entry.GetEntryInfo(DI.Id, RASession);
var fvc = entry.GetFieldValues();
PageInfo pgInfo = DI.GetPageInfo(1);
DocumentStatistics docStats = DI.GetStatistics();
string volumeName = DI.VolumeName;
string pagePath = pgInfo.ImageFilePath;
string edocPath = docStats.ElecDocumentPath;
//CREAR FOLDER PRINCIPAL
string folderLocation = rutabase;
bool exists = System.IO.Directory.Exists(folderLocation);
if (!exists)
{
System.IO.Directory.CreateDirectory(folderLocation);
}
string p = DI.Path.Split('\\')[4] + "\\" + DI.Path.Split('\\')[5] + "\\" + DI.Path.Split('\\')[6] + "\\" + DI.Path.Split('\\')[7].Split('/')[0];
string filePath = @"C:\temp\Error.txt";
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine("Mensaje :" + p.Trim());
}
//CREAR FOLDER PARA DOCUMENTOS
string folderExpedienteLocation = rutabase + p + "\\";
bool existsNoExp = System.IO.Directory.Exists(folderExpedienteLocation);
if (!existsNoExp)
{
System.IO.Directory.CreateDirectory(folderExpedienteLocation);
}
DI.Lock(LockType.Exclusive);
DocumentExporter dExp = new DocumentExporter();
dExp.CompressionQuality = 50;
dExp.IncludeAnnotations = true;
dExp.BlackoutRedactions = true;
dExp.PageFormat = DocumentPageFormat.Jpeg;
var ExportOptions = PdfExportOptions.RenderAnnotationsAsImage | PdfExportOptions.IncludeText;
string path = folderExpedienteLocation;
string filename = DI.Name + ".pdf";
dExp.ExportPdf(DI, DI.AllPages, ExportOptions, path + filename);
DI.Unlock();
DI.Dispose();
}
catch(Exception ex){
string filePath = @"C:\temp\Error.txt";
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine("Mensaje :" + paso + Environment.NewLine + campo + ":" + valor + Environment.NewLine + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace +
"" + Environment.NewLine + "Fecha :" + DateTime.Now.ToString());
writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
}
}
}
//use System.Text.RegularExpressions before using this function
public bool vldRegex(string strInput)
{
//create Regular Expression Match pattern object
Regex myRegex = new Regex("/[0-9A-Fa-f]{6}/g");
//boolean variable to hold the status
bool isValid = false;
if (string.IsNullOrEmpty(strInput))
{
isValid = false;
}
else
{
isValid = myRegex.IsMatch(strInput);
}
//return the results
return isValid;
}
}
public class MetaData
{
public string Campo {get; set;}
public string Valor {get; set;}
}
}