Read data from file within workflow
Is it possible to read data from a text file with workflow.
I would like to use a text file with version information in it (version number, date of version, contact person and contact information) to be opened in the Silverlightviewer. I thought it would be nice if I could create a general Workflow to do this so I can re-use the workflow in several different sites.
I hope someone can help me. For now I added a button in the viewer which opens a webpage with this information.
Many thanks in advance.
-
Hi Luuk,
I am not quite sure if I understand your question. The answer to "Is it possible to read data from a text file in workflow", is yes. You can simply add a Text Box to a Display Form activity and assign an arbitrary name to "Argument Name" attribute, which will be the name of the variable that will be output.
Your scenario however seems like a simple form with a few read-only fields. If adding a TextBox to a Displayform is not the answer you are looking for please elaborate on what are the steps of the workflow you have in mind.
Cheers
0 -
Hi Dan,
thanks for your reply but I do not understand your solution. Perhaps I must explain my problem better. I want to use the contents of a textfile (like an ini-file) to be seen on a form. The idea is that I save some version information in this text file which will be shown on a form within the Silverlightviewer by a click of a button. For now I am using an HTML page with the information.
By the way, I am using Workflow Designer 2.8.1.40.
Luuk
0 -
Hi Luuk,
Thanks for clarifying. Now, I think I understand your question. As far as I know there is no activity out of the box that can do that, so you need to write your own custom activity.
In the long list of possible enhancements to Forms, there was an idea to add a File Picker (or a file browser), but that would solve only the first step of your workflow. After that, you would need to parse the content of the file to extract the version or whatever else you are looking for.
I hope that makes sense.
Dan
0 -
Luuk,
One thing you can do if you want to use OOTB activities in your Workflow, is to put the text file on the server in a web-accessible folder. Then instead of retrieving the file from the file system you can use the DownloadString workflow activity.
Putting any variable into a form though will be challenging - I'd recommend using the ConfigureWorkflowContainer if you want to display values dynamically from the text file to the user.
John
0 -
It is possible to read a file directly from disk as a string. Use this in an Assign activity to populate a string variable:
System.Text.Encoding.ASCII.GetString(System.IO.File.ReadAllBytes("C:\somefile.txt"))
--Ryan
0 -
Thanks all,
I cracked it with help from Berend Veldkamp and I am now able to download a file from a URL and do what I want (or can) with it. I don't read it from disk but I download it from the local webserver on which Essentials is installed.
This is my xaml. It is a basic version of what I made, but it shows how I did it. I am going to try Ryan's suggestion to read the file from disk.
<Activity mc:Ignorable="sap" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="326,855" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:eacg="clr-namespace:ESRI.ArcGIS.Client.Geometry;assembly=ESRI.ArcGIS.Client" xmlns:eact="clr-namespace:ESRI.ArcGIS.Client.Tasks;assembly=ESRI.ArcGIS.Client" xmlns:gfc="clr-namespace:Geocortex.Forms.Client;assembly=Geocortex.EssentialsWpfApi" xmlns:ggg="clr-namespace:Geocortex.Gis.Geometries;assembly=Geocortex.Gis" xmlns:gr="clr-namespace:Geocortex.Reporting;assembly=Geocortex.Reporting" xmlns:gwa="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow" xmlns:gwa1="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow.Activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Core" xmlns:s3="clr-namespace:System;assembly=System.ServiceModel" xmlns:s4="clr-namespace:System;assembly=System.AddIn" xmlns:s5="clr-namespace:System;assembly=System.Web.Services" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sn="clr-namespace:System.Net;assembly=System" xmlns:sx="clr-namespace:System.Xml;assembly=System.Runtime.Serialization" xmlns:sx1="clr-namespace:System.Xml;assembly=System.Xml" xmlns:sx2="clr-namespace:System.Xml;assembly=System.Data" xmlns:sxl="clr-namespace:System.Xml.Linq;assembly=System.Xml.Linq" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Sequence sap:VirtualizedContainerService.HintSize="286,815" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Name="result" />
</Sequence.Variables>
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Sequence DisplayName="XMLSequence" sap:VirtualizedContainerService.HintSize="264,569">
<Sequence.Variables>
<Variable x:TypeArguments="sn:WebResponse" Name="response" />
<Variable x:TypeArguments="sn:WebRequest" Name="request" />
<Variable x:TypeArguments="sxl:XDocument" Name="xdoc" />
<Variable x:TypeArguments="x:String" Name="xmlresult" />
</Sequence.Variables>
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
<x:Boolean x:Key="IsPinned">False</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Assign sap:VirtualizedContainerService.HintSize="242,57">
<Assign.To>
<OutArgument x:TypeArguments="sn:WebRequest">[request]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sn:WebRequest">[System.Net.WebRequest.Create("http://localhost/Geocortex/Essentials/REST/sites/NVWA_AM/Viewers/NVWA_AM_Viewer/VirtualDirectory/Resources/www/versie.xml")]</InArgument>
</Assign.Value>
</Assign>
<Assign sap:VirtualizedContainerService.HintSize="242,57">
<Assign.To>
<OutArgument x:TypeArguments="sn:WebResponse">[response]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sn:WebResponse">[request.GetResponse()]</InArgument>
</Assign.Value>
</Assign>
<Assign sap:VirtualizedContainerService.HintSize="242,57">
<Assign.To>
<OutArgument x:TypeArguments="sxl:XDocument">[xdoc]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sxl:XDocument">[XDocument.Load(response.GetResponseStream())]</InArgument>
</Assign.Value>
</Assign>
<Assign sap:VirtualizedContainerService.HintSize="242,57">
<Assign.To>
<OutArgument x:TypeArguments="x:String">[xmlresult]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:String">[xdoc.ToString()]</InArgument>
</Assign.Value>
</Assign>
<Assign sap:VirtualizedContainerService.HintSize="242,57">
<Assign.To>
<OutArgument x:TypeArguments="x:String">[result]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:String">[xmlresult]</InArgument>
</Assign.Value>
</Assign>
</Sequence>
<gwa1:Alert sap:VirtualizedContainerService.HintSize="264,82" Text="[result]" Title="Info" />
</Sequence>
</Activity>0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
6 kommentarer