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

Question

Question

Workflow Trigger windows folder creation by SDK

asked on November 21, 2015 Show version history

I need to create a workflow to trigger folder creation on a specific path on windows to import the documents in this folder to laserfiche specific folder

I think I must use SDK 

I have little experience on workflow but I don't know anything about SDK

Can I have detailed steps please on what to do on SDK

0 0

Replies

replied on November 22, 2015 Show version history

Good afternoon Mohanad,

I think you should reconsideryour approach. If someone does give you the code to copy'n'paste, will you be able to support it if the customer requests changes or something goes wrong? You've said you know nothing about SDK so I would recommend spending the money on Import Agent as it's likely to save you money in the long term.

From experience, writing such code is not straight forward. For example, some file-types should be imported as Image and other as Electronic. The software may need to handle exceptions, such as losing connection to the monitored location. And if someone places a very large file in the monitored folder, then Workflow could potentially be held up for a minute, slowing down other workflow activities. This effect will become more pronounced as other large file are uploaded (since Workflow is multi-threaded). Also, depending on how the documents land in the folders they might need to have their mime-type or extension set. These are not the only considerations, just the first to come to mind.

Whilst it is possible to use workflow to monitor a folder and upload a document, in most situations it's best to have a stand-alone service to achieve the outcome as this won't lock Worlflow.

...In which case it's cheaper and more reliable to just purchase Import Agent (or use Quick Fields Agent if you have it).

Regards and good luck,

Ben

2 0
replied on November 22, 2015

Thanks Ben for your cooperation, but just for clarification, the files will be the same type (JPG) and the size will almost be the same.

In other words, we have another system which will export about 500 or 600 jpg documents  everyday for a specific windows path, and I need just to import these documents to specific Laserfiche folder.

Also regarding losing connection to the monitored location, I think that this will not happen, as I already created a windows batch file to copy the files from the other system server to Laserfiche workflow server, so the folder which need to be monitored will be local on the Laserfiche workflow server.

Thanks again for your help.

 

0 0
replied on November 22, 2015 Show version history

Mohanad,

Ben brings up some very valid points about importing documents through Workflow.  In addition, depending on your version of Workflow you have to code the Workflow script activity using either LFSO objects (Laserfiche Server Objects; older technology) or RA (Repository Access; newer technology). 

If you have the SDK you should have access to the SDK documentation.  A quick scan does show some code snippets for a document import using the RA DocumentServices object in the section titled 'Tutorial: Importing and Exporting through DocumentServices'.

Again, as Ben alludes to; the SDK code tutorials are primarily meant as a reference for full SDK integrations/applications, not for general use in Workflow script activities.

From the SDK documentation;

Dim document as New DocumentInfo(mySess) 
document.Create("\Folder1\MyNewDocument", "Volume1", EntryNameOption.AutoRename)
Dim DI As New DocumentImporter
DI.Document = document
DI.ImportImages("C:\Temp\Image.tif")

Note: The DocumentServices assembly is not included as a reference in a native Workflow script activity.  You will need to add a reference in the script activity to even be able to use it.

In addition you will need to write code to get the contents of the directory using the System.IO.Directory.EnumerateFiles(myPath) or System.IO.GetFiles(myPath) methods, iterate through those returned arrays, create a new LF document for each file, then import the images into the new document for each image.

Finally; if you are intent upon doing this I would make it a timed Workflow that would trigger based on some timing event that would occur during non-peak hours.

So as an academic exercise you could accomplish your goal but my feedback would be to invest in Import Agent for all of the reasons Ben mentions in his post.

1 0
replied on November 23, 2015

From what it sounds like Mohanad, you want a Workflow to monitor a windows folder and when a file is detected, then have the Workflow import the file into a Laserfiche directory. If that be the case, Workflow is not the tool for the job. Using Workflow to monitor the file system is possible, but a very bad idea. Workflow was not intended to do such things. As others have suggested, I would invest in Import Agent. Sure you could use the SDK to create a similar app, but at what cost. In this case, there really is no point in reinventing the wheel.

2 0
replied on November 21, 2015

Not quite clear on what you want to accomplish.  The message title refers to using the SDK to create  a Windows folder but the text of your message indicates perhaps that you want Workflow to monitor a local folder or UNC share and import those documents into Laserfiche?  ie Import Agent?

If you are looking to just create a folder on a local, mapped drive, or UNC share then here is some SDK Script activity code to do that;

        Protected Overrides Sub Execute()

            'You can hard code the path, create the path from the entry information, or retrieve
            'the value from an earlier workflow token.  In this example the workflow token
            'has a string value of 'C:\NewFolder'.  Values can include local or mapped drives
            'or a UNC path...
            Dim pathToCreate As String = Me.GetTokenValue("MyPathToken")

            'This variable will be a return token to the workflow to allow you to handle any errors...
            Dim success As Boolean = False

            'Wrap the transaction in a try/catch to capture any potential errors...
            Try

                'This is the only line of code you need to actually create the folder...
                'NOTE: The assumption is that the account that workflow is running under
                'has the specific permissions to create the folder!
                System.IO.Directory.CreateDirectory(pathToCreate)

                'Set the success flag to true...
                success = True

            Catch ex As Exception

                'Write any errors errors encountered to the workflow error tracking system...
                Me.WorkflowApi.TrackError(ex.message)

            End Try

            'Make the success token available to other workflow activities...
            Me.SetTokenValue("Success", success)

        End Sub

Here is a screen shot of a bare bones workflow;

1 0
replied on November 21, 2015

Thanks for your reply, but what I need is letting workflow to trigger a windows folder if any files created on it to import it to Laserfiche.

 

0 0
replied on November 21, 2015

Not quite clear on what you want to accomplish, can you provide some additional details?  It sounds like you want Workflow to read a local folder or UNC path and then import any files in that folder into a specific folder in Laserfiche.  i.e. Import Agent?

replied on November 21, 2015

You can use the sdk script task in Workflow or you could simply use the Import Agent to accomplish the same task.

0 0
replied on November 21, 2015

Unfortunately we don't have Import agent license.

We have SDK but i don't know anything about how to use it.

So kindly I need the required code ready to just copy it if applicable.

Thanks in advance.

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

Sign in to reply to this post.