-
-
Save bradbrowne/e7e4d42402f7c9e158b81cf50fa573b3 to your computer and use it in GitHub Desktop.
<Activity mc:Ignorable="sap sap2010 sads" x:Class="ActivityBuilder" this:ActivityBuilder.WorkflowContainerName="GistDateMilliseconds" | |
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" | |
xmlns:gcx="http://apis.geocortex.com/2009" | |
xmlns:gfci="clr-namespace:Geocortex.Forms.Client.Items;assembly=Geocortex.EssentialsWpfApi" | |
xmlns:gwa="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow.Activities" | |
xmlns:gwa1="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow" | |
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:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger" | |
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" | |
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation" | |
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" | |
xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib" | |
xmlns:this="clr-namespace:" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | |
<x:Members> | |
<x:Property Name="WorkflowContainerName" Type="InArgument(x:String)" /> | |
</x:Members> | |
<mva:VisualBasic.Settings> | |
<x:Null /> | |
</mva:VisualBasic.Settings> | |
<sap2010:WorkflowViewState.IdRef>ActivityBuilder_1</sap2010:WorkflowViewState.IdRef> | |
<TextExpression.NamespacesForImplementation> | |
<sco:Collection x:TypeArguments="x:String"> | |
<x:String>System.Activities.XamlIntegration</x:String> | |
<x:String>System.Activities.Validation</x:String> | |
<x:String>System.Activities</x:String> | |
<x:String>System.Activities.Statements</x:String> | |
<x:String>System.Activities.Expressions</x:String> | |
<x:String>ESRI.ArcGIS.Client</x:String> | |
<x:String>ESRI.ArcGIS.Client.Geometry</x:String> | |
<x:String>ESRI.ArcGIS.Client.Tasks</x:String> | |
<x:String>Geocortex.Core.Extensions</x:String> | |
<x:String>Geocortex.Workflow.Activities</x:String> | |
<x:String>Geocortex.Forms.Client</x:String> | |
<x:String>Geocortex.Forms.Client.Items</x:String> | |
<x:String>Geocortex.Reporting</x:String> | |
<x:String>System</x:String> | |
<x:String>Microsoft.VisualBasic.Activities</x:String> | |
<x:String>System.Collections.Generic</x:String> | |
<x:String>System.Linq</x:String> | |
<x:String>System.Windows.Markup</x:String> | |
<x:String>Microsoft.VisualBasic.CompilerServices</x:String> | |
</sco:Collection> | |
</TextExpression.NamespacesForImplementation> | |
<TextExpression.ReferencesForImplementation> | |
<sco:Collection x:TypeArguments="AssemblyReference"> | |
<AssemblyReference>System.Activities</AssemblyReference> | |
<AssemblyReference>ESRI.ArcGIS.Client</AssemblyReference> | |
<AssemblyReference>Geocortex.Core</AssemblyReference> | |
<AssemblyReference>Geocortex.Workflow</AssemblyReference> | |
<AssemblyReference>Geocortex.EssentialsWpfApi</AssemblyReference> | |
<AssemblyReference>Geocortex.Reporting</AssemblyReference> | |
<AssemblyReference>System.Core</AssemblyReference> | |
<AssemblyReference>System</AssemblyReference> | |
<AssemblyReference>mscorlib</AssemblyReference> | |
<AssemblyReference>PresentationFramework</AssemblyReference> | |
<AssemblyReference>WindowsBase</AssemblyReference> | |
<AssemblyReference>PresentationCore</AssemblyReference> | |
<AssemblyReference>System.Xaml</AssemblyReference> | |
<AssemblyReference>System.ComponentModel.Composition</AssemblyReference> | |
<AssemblyReference>System.ServiceModel</AssemblyReference> | |
<AssemblyReference>System.Reactive.Core</AssemblyReference> | |
<AssemblyReference>Microsoft.VisualBasic</AssemblyReference> | |
</sco:Collection> | |
</TextExpression.ReferencesForImplementation> | |
<Sequence DisplayName="Main" sap2010:WorkflowViewState.IdRef="Sequence_1"> | |
<Sequence.Variables> | |
<Variable x:TypeArguments="x:Double" Name="completedDate" /> | |
<Variable x:TypeArguments="scg:Dictionary(x:String, x:Object)" Default="[New System.Collections.Generic.Dictionary(Of String, Object) From { { "COMPLETED_DATE", "/Date(1483189200000)/" } }]" Name="formResult" /> | |
</Sequence.Variables> | |
<gwa:DisplayForm FormDefinition="<FormDefinition xmlns="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ContainerFormItem xmlns:a="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items"><a:ArgumentName/><a:IsVisible>true</a:IsVisible><a:ItemID>Group1</a:ItemID><a:ToolTip/><a:ValidationItems xmlns:b="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation"/><a:Description/><a:FormItems><a:FormItem i:type="a:DatePickerFormItem"><a:ArgumentName>COMPLETED_DATE_STATIC</a:ArgumentName><a:IsVisible>true</a:IsVisible><a:ItemID>DatePicker1</a:ItemID><a:ToolTip/><a:ValidationItems xmlns:b="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation"><b:ValidationItem i:type="b:RequiredValidationItem"><b:Message>COMPLETED_DATE_STATIC is required.</b:Message></b:ValidationItem></a:ValidationItems><a:DateFormat>Long</a:DateFormat><a:IncludeTimePicker>false</a:IncludeTimePicker><a:InitialDate i:nil="true"/><a:InitializeWithCurrentDate>false</a:InitializeWithCurrentDate><a:Label><a:ArgumentName/><a:IsVisible>true</a:IsVisible><a:ItemID/><a:ToolTip/><a:ValidationItems xmlns:b="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation"/><a:LabelForItemID>DatePicker1</a:LabelForItemID><a:Text>COMPLETED_DATE_STATIC</a:Text></a:Label><a:TimePickerItem><a:ArgumentName/><a:IsVisible>true</a:IsVisible><a:ItemID/><a:ToolTip/><a:ValidationItems xmlns:b="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation"/><a:InitialTime i:nil="true"/><a:InitializeWithCurrentTime>true</a:InitializeWithCurrentTime><a:Label><a:ArgumentName/><a:IsVisible>true</a:IsVisible><a:ItemID/><a:ToolTip/><a:ValidationItems xmlns:b="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation"/><a:LabelForItemID/><a:Text>Label</a:Text></a:Label><a:TimeFormat>ShortTime</a:TimeFormat></a:TimePickerItem></a:FormItem></a:FormItems><a:MaxWidth>INF</a:MaxWidth><a:Orientation>Vertical</a:Orientation><a:VisibleControlID i:nil="true"/><a:VisibleControlValue i:nil="true"/></ContainerFormItem><KnownTypes xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:string>Geocortex.Forms.Client.Items.ContainerFormItem</a:string><a:string>Geocortex.Forms.Client.Items.DatePickerFormItem</a:string><a:string>Geocortex.Forms.Client.Items.Validation.RequiredValidationItem</a:string></KnownTypes><MaxHeight>800</MaxHeight><MaxWidth>1000</MaxWidth><Title>Form Title</Title><Version>1.1</Version></FormDefinition>" FormResults="[formResult]" sap2010:WorkflowViewState.IdRef="DisplayForm_1" WorkflowContainerName="[WorkflowContainerName]"> | |
<gwa:DisplayForm.Body> | |
<ActivityAction x:TypeArguments="gcx:FormDefinition"> | |
<ActivityAction.Argument> | |
<DelegateInArgument x:TypeArguments="gcx:FormDefinition" Name="form" /> | |
</ActivityAction.Argument> | |
<Sequence DisplayName="RuntimeModifications" sap2010:WorkflowViewState.IdRef="Sequence_3"> | |
<Sequence DisplayName="COMPLETED_DATE_DYNAMIC Form Item" sap2010:WorkflowViewState.IdRef="Sequence_2"> | |
<Sequence.Variables> | |
<Variable x:TypeArguments="gfci:DatePickerFormItem" Name="completedDatePicker" /> | |
</Sequence.Variables> | |
<Assign DisplayName="completedDatePicker Assign" sap2010:WorkflowViewState.IdRef="Assign_3"> | |
<Assign.To> | |
<OutArgument x:TypeArguments="gfci:DatePickerFormItem">[completedDatePicker]</OutArgument> | |
</Assign.To> | |
<Assign.Value> | |
<InArgument x:TypeArguments="gfci:DatePickerFormItem" xml:space="preserve">[new DatePickerFormItem With { | |
.Label=New LabelFormItem With { .Text="COMPLETED_DATE_DYNAMIC" }, | |
.InitializeWithCurrentDate=False, | |
.ArgumentName="COMPLETED_DATE_DYNAMIC" }]</InArgument> | |
</Assign.Value> | |
</Assign> | |
<AddToCollection x:TypeArguments="gfci:FormItem" Collection="[form.FormItems]" DisplayName="AddToCollection<FormItem>" sap2010:WorkflowViewState.IdRef="AddToCollection`1_1" Item="[completedDatePicker]" /> | |
</Sequence> | |
</Sequence> | |
</ActivityAction> | |
</gwa:DisplayForm.Body> | |
<gwa:DisplayForm.Buttons> | |
<gcx:FormButton CausesValidation="False" IsDefault="True" Label="Submit" Value="Submit" /> | |
</gwa:DisplayForm.Buttons> | |
<gwa:DisplayForm.FormOutArguments> | |
<gwa1:ArgumentWrapper x:TypeArguments="OutArgument" IsRequired="False" Name="COMPLETED_DATE_STATIC"> | |
<gwa1:ArgumentWrapper.Argument> | |
<OutArgument x:TypeArguments="s:Nullable(s:DateTime)" /> | |
</gwa1:ArgumentWrapper.Argument> | |
</gwa1:ArgumentWrapper> | |
</gwa:DisplayForm.FormOutArguments> | |
</gwa:DisplayForm> | |
<ForEach x:TypeArguments="scg:KeyValuePair(x:String, x:Object)" DisplayName="ForEach FormResult Item" sap2010:WorkflowViewState.IdRef="ForEach`1_1" Values="[FormResult]"> | |
<ActivityAction x:TypeArguments="scg:KeyValuePair(x:String, x:Object)"> | |
<ActivityAction.Argument> | |
<DelegateInArgument x:TypeArguments="scg:KeyValuePair(x:String, x:Object)" Name="item" /> | |
</ActivityAction.Argument> | |
<If Condition="[item.Value IsNot Nothing]" DisplayName="If item.Value IsNot Nothing" sap2010:WorkflowViewState.IdRef="If_2"> | |
<If.Then> | |
<Sequence DisplayName="Check Date" sap2010:WorkflowViewState.IdRef="Sequence_4"> | |
<gwa:ExternalLog DisplayName="item.Key and item.Value ExternalLog" sap2010:WorkflowViewState.IdRef="ExternalLog_1" Message="["Key: " + item.Key + ", Value: " + item.Value.ToString() + ", Type: " + item.Value.GetType().ToString()]" /> | |
<Switch x:TypeArguments="x:String" Expression="[item.Value.GetType().ToString]" sap2010:WorkflowViewState.IdRef="Switch`1_1"> | |
<Assign x:Key="System.String" DisplayName="Assign completedDate /Date(milliseconds)/" sap2010:WorkflowViewState.IdRef="Assign_4"> | |
<Assign.To> | |
<OutArgument x:TypeArguments="x:Double">[completedDate]</OutArgument> | |
</Assign.To> | |
<Assign.Value> | |
<InArgument x:TypeArguments="x:Double">[cdbl(item.Value.ToString.Replace("/Date(","").Replace(")/",""))]</InArgument> | |
</Assign.Value> | |
</Assign> | |
<Assign x:Key="System.DateTime" DisplayName="Assign completedDate" sap2010:WorkflowViewState.IdRef="Assign_5"> | |
<Assign.To> | |
<OutArgument x:TypeArguments="x:Double">[completedDate]</OutArgument> | |
</Assign.To> | |
<Assign.Value> | |
<InArgument x:TypeArguments="x:Double">[cdbl(cdate(item.Value).ToUniversalTime().Subtract(New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds)]</InArgument> | |
</Assign.Value> | |
</Assign> | |
</Switch> | |
<gwa:ExternalLog DisplayName="completedDate ExternalLog" sap2010:WorkflowViewState.IdRef="ExternalLog_3" Message="["completedDate: "+cstr(completedDate)]" /> | |
</Sequence> | |
</If.Then> | |
<If.Else> | |
<gwa:ExternalLog DisplayName="item.Key ExternalLog" sap2010:WorkflowViewState.IdRef="ExternalLog_2" Message="["Key: " + item.Key]" /> | |
</If.Else> | |
</If> | |
</ActivityAction> | |
</ForEach> | |
<sads:DebugSymbol.Symbol>d6ABQzpcUHJvZ3JhbSBGaWxlcyAoeDg2KVxMYXRpdHVkZSBHZW9ncmFwaGljc1xHZW9jb3J0ZXggRXNzZW50aWFsc1xHWDQ2MlxSRVNUIEVsZW1lbnRzXFNpdGVzXFRlbXBsYXRlc1xXb3JrZmxvd3NcQXNzZXRcR2lzdFxHZW9Db3J0ZXggLSBJZiBEYXRlKG1pbGxpc2Vjb25kcykueGFtbCEBcAGFAQECRAOUAQ4CAQFHTkfZAQIBAkkFbhcCASFvBZIBDwIBA0klSegZAgEwScoaSeMaAgEuSfUZSYMaAgEsTwthFgIBIm+gAW+uAQIBH3QJkAEOAgEEUA1gGAIBI3QXdDMCAQV2DYsBGAIBCo4BDY4BnAECAQdUD14YAgEoXw9f4QECASR3D3eWAgIBGngPiQEYAgEOigEPigG2AQIBC44BeY4BmQECAQhWSlZfAgEpX0tfXQIBJ1/HAV/eAQIBJXeKAXeTAgIBG3g9eF4CAQ95EYABGgIBFYEBEYgBGgIBEYoBgAGKAbMBAgEMfjx+fQIBGHs9e0wCARaGATyGAbcBAgEUgwE9gwFMAgES</sads:DebugSymbol.Symbol> | |
</Sequence> | |
<sap2010:WorkflowViewState.ViewStateManager> | |
<sap2010:ViewStateManager> | |
<sap2010:ViewStateData Id="Assign_3" sap:VirtualizedContainerService.HintSize="242,61" /> | |
<sap2010:ViewStateData Id="AddToCollection`1_1" sap:VirtualizedContainerService.HintSize="242,22" /> | |
<sap2010:ViewStateData Id="Sequence_2" sap:VirtualizedContainerService.HintSize="264,247"> | |
<sap:WorkflowViewStateService.ViewState> | |
<scg:Dictionary x:TypeArguments="x:String, x:Object"> | |
<x:Boolean x:Key="IsExpanded">True</x:Boolean> | |
</scg:Dictionary> | |
</sap:WorkflowViewStateService.ViewState> | |
</sap2010:ViewStateData> | |
<sap2010:ViewStateData Id="Sequence_3" sap:VirtualizedContainerService.HintSize="286,371"> | |
<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> | |
</sap2010:ViewStateData> | |
<sap2010:ViewStateData Id="DisplayForm_1" sap:VirtualizedContainerService.HintSize="816,814" /> | |
<sap2010:ViewStateData Id="ExternalLog_1" sap:VirtualizedContainerService.HintSize="473,59" /> | |
<sap2010:ViewStateData Id="Assign_4" sap:VirtualizedContainerService.HintSize="242,59" /> | |
<sap2010:ViewStateData Id="Assign_5" sap:VirtualizedContainerService.HintSize="242,59" /> | |
<sap2010:ViewStateData Id="Switch`1_1" sap:VirtualizedContainerService.HintSize="473,258" /> | |
<sap2010:ViewStateData Id="ExternalLog_3" sap:VirtualizedContainerService.HintSize="473,59" /> | |
<sap2010:ViewStateData Id="Sequence_4" sap:VirtualizedContainerService.HintSize="495,580"> | |
<sap:WorkflowViewStateService.ViewState> | |
<scg:Dictionary x:TypeArguments="x:String, x:Object"> | |
<x:Boolean x:Key="IsExpanded">True</x:Boolean> | |
</scg:Dictionary> | |
</sap:WorkflowViewStateService.ViewState> | |
</sap2010:ViewStateData> | |
<sap2010:ViewStateData Id="ExternalLog_2" sap:VirtualizedContainerService.HintSize="266,59" /> | |
<sap2010:ViewStateData Id="If_2" sap:VirtualizedContainerService.HintSize="786,723" /> | |
<sap2010:ViewStateData Id="ForEach`1_1" sap:VirtualizedContainerService.HintSize="816,868" /> | |
<sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="838,1846"> | |
<sap:WorkflowViewStateService.ViewState> | |
<scg:Dictionary x:TypeArguments="x:String, x:Object"> | |
<x:Boolean x:Key="IsExpanded">True</x:Boolean> | |
</scg:Dictionary> | |
</sap:WorkflowViewStateService.ViewState> | |
</sap2010:ViewStateData> | |
<sap2010:ViewStateData Id="ActivityBuilder_1" sap:VirtualizedContainerService.HintSize="878,1926" /> | |
</sap2010:ViewStateManager> | |
</sap2010:WorkflowViewState.ViewStateManager> | |
</Activity> |
I have updated the workflow to include the DisplayForm
so that you can run this and see the behaviour I am getting.
The DisplayForm
activity includes a DatePicker
with an ArgumentName
COMPLETED_DATE_STATIC and then in the RuntimeModifications Sequence
activity I am creating another DatePicker
form item with an ArgumentName
of COMPLETED_DATE_DYNAMIC:
When you run the workflow in GeoCortex the formResults
are populated with a Dictionary representing the dates specified and the type that is returned from COMPLETED_DATE_STATIC is System.DateTime
, whereas the type that is returned from COMPLETED_DATE_DYNAMIC is System.String
π’
When you run this workflow in Chrome you can see that the types different and they need to be handled differently:
[info]: 10:14:08.017: Key: COMPLETED_DATE_STATIC, Value: 10/01/2017 12:00:00 AM, Type: System.DateTime
[info]: 10:14:08.178: completedDate: 1483966800000
[info]: 10:14:08.322: Key: COMPLETED_DATE_DYNAMIC, Value: /Date(1483966800000)/, Type: System.String
[info]: 10:14:08.474: completedDate: 1483966800000
I am hoping that in a future version of GeoCortex this issue will be fixed so that I can handle the dates returned by DatePicker form items in a consistent manner, regardless of whether that are defined statically on a form or dynamically via the RuntimeModifications Sequence
activity. π
The issue is that instead of a .NET DateTime being returned from the DatePicker, a Javascript object string representing Unix epoch milliseconds is returned of the format "/Date(milliseconds)/".
This was an issue in a previous version of GeoCortex [4.5.1 or 4.4.3?] for DatePickers that were defined in the "Display Form" activity as static form items.
This was resolved in 4.6.2 for static form items, but it seems that it is still an issue for dynamic form items created in the "RuntimeModifications" sequence of the "Display Form" activity.
The attached screenshot shows the error that I get in Chrome when I try and "Assign" the form result to the .NET DateTime variable.
I am working around this by defensively checking the returned value from the form, because I hope in a future version this will be fixed for dynamic form items, as it was for static form items.