I'm trying to compose a script to take a Laserfiche .csv file through ExportElecDoc so I can save it as an Excel file for further manipulation before importing it back in during the course of a workflow. The script is working fine if I run it inside the SDK editor, but cannot find the file on my machine when I run it in the workflow. I put messages in to track it and it is during the ExportElecDoc phase where it looks like it can't find the path. I can't see why it works in the editor but not in the workflow, the script is the only activity in the workflow at the moment. I haven't used the ExportElecDoc function before, but it looks like the parameters match what I've seen in the forums. Anyone see where I'm going wrong here? Here is the script, the view in the SDK error log showing the messages that the run succeeded, and the error log in the workflow showing where it didn't:
namespace WorkflowActivity.Scripting.SDKScript { using System; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Text; using Laserfiche.RepositoryAccess; using Laserfiche.DocumentServices; using System.Linq; using System.Windows.Forms; using System.Security.Principal; using System.IO; using LFSO83Lib; using Laserfiche.RepositoryAccess.Data; using Laserfiche.RepositoryAccess.Common; using Microsoft.Office.Interop.Excel; //using SpreadsheetLight; using Excel = Microsoft.Office.Interop.Excel; public class Script1 : RAScriptClass91 { protected override void Execute() { Session mySess = this.RASession; string myFile = "C:\\Users\\rick.nagy\\Desktop\\Exportedcsv.csv"; this.WorkflowApi.TrackInformation("Logged in to repo"); DocumentInfo di = Document.GetDocumentInfo(2789782, mySess); if (di.IsElectronicDocument){ this.WorkflowApi.TrackInformation("checking extension"); MsgBox(" Document Extension: " + di.Extension); } DocumentExporter de = new DocumentExporter(); de.ExportElecDoc(di, myFile); di.Dispose(); this.WorkflowApi.TrackInformation("Exporting document"); StreamReader objReader = new StreamReader(myFile); string sLine = ""; ArrayList arrText = new ArrayList(); while (sLine != null) { sLine = objReader.ReadLine(); if (sLine != null) arrText.Add(sLine); } callExcel(arrText, true); DocumentInfo docInfo = new DocumentInfo(mySess); DocumentImporter dic = new DocumentImporter(); dic.Document = docInfo; string path = "\\NorthStar\\MIS\\RicksGeminiTest\\TempHold\\HeyJag\\"; docInfo.Create(Folder.GetFolderInfo(path, mySess), "Your Excel Report", "DEFAULT", EntryNameOption.AutoRename); docInfo.Unlock(); dic.ImportEdoc("application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", myFile); docInfo.Dispose(); this.WorkflowApi.TrackInformation("Report was saved"); } private void callExcel(ArrayList arrText, bool value) { try { String textString = null; foreach (var item in arrText) { textString = textString + item + Environment.NewLine; } Clipboard.SetText(textString); Microsoft.Office.Interop.Excel.Application xlexcel; Microsoft.Office.Interop.Excel.Workbook xlWorkBook; Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlexcel = new Excel.Application(); //xlexcel.Visible = true; xlWorkBook = xlexcel.Workbooks.Add(misValue); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); Excel.Range CR = (Excel.Range)xlWorkSheet.Cells[1, 1]; CR.Select(); xlWorkSheet.Paste(CR, false); if (value == true) { try { // saving the file as .xls xlWorkSheet.SaveAs(@"C:\Users\rick.nagy\Desktop\receivedNew.xls"); } catch (Exception){ MessageBox.Show("File already exists"); } } else { try { // saving the file as .xlsx xlWorkSheet.SaveAs(@"C:\Users\rick.nagy\Desktop\receivedNew.xlsx"); } catch (Exception){ MessageBox.Show("File already exists"); } } xlexcel.Quit(); } catch(Exception ex){ MessageBox.Show(ex.ToString()); } } } }