Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bradbrowne/e7e4d42402f7c9e158b81cf50fa573b3 to your computer and use it in GitHub Desktop.
Save bradbrowne/e7e4d42402f7c9e158b81cf50fa573b3 to your computer and use it in GitHub Desktop.
πŸ› GeoCortex DatePicker created in RuntimeModifications returns "/Date(milliseconds)/" not System.DateTime
<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 { { &quot;COMPLETED_DATE&quot;, &quot;/Date(1483189200000)/&quot; } }]" Name="formResult" />
</Sequence.Variables>
<gwa:DisplayForm FormDefinition="&lt;FormDefinition xmlns=&quot;http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client&quot; xmlns:i=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;&lt;ContainerFormItem xmlns:a=&quot;http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items&quot;&gt;&lt;a:ArgumentName/&gt;&lt;a:IsVisible&gt;true&lt;/a:IsVisible&gt;&lt;a:ItemID&gt;Group1&lt;/a:ItemID&gt;&lt;a:ToolTip/&gt;&lt;a:ValidationItems xmlns:b=&quot;http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation&quot;/&gt;&lt;a:Description/&gt;&lt;a:FormItems&gt;&lt;a:FormItem i:type=&quot;a:DatePickerFormItem&quot;&gt;&lt;a:ArgumentName&gt;COMPLETED_DATE_STATIC&lt;/a:ArgumentName&gt;&lt;a:IsVisible&gt;true&lt;/a:IsVisible&gt;&lt;a:ItemID&gt;DatePicker1&lt;/a:ItemID&gt;&lt;a:ToolTip/&gt;&lt;a:ValidationItems xmlns:b=&quot;http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation&quot;&gt;&lt;b:ValidationItem i:type=&quot;b:RequiredValidationItem&quot;&gt;&lt;b:Message&gt;COMPLETED_DATE_STATIC is required.&lt;/b:Message&gt;&lt;/b:ValidationItem&gt;&lt;/a:ValidationItems&gt;&lt;a:DateFormat&gt;Long&lt;/a:DateFormat&gt;&lt;a:IncludeTimePicker&gt;false&lt;/a:IncludeTimePicker&gt;&lt;a:InitialDate i:nil=&quot;true&quot;/&gt;&lt;a:InitializeWithCurrentDate&gt;false&lt;/a:InitializeWithCurrentDate&gt;&lt;a:Label&gt;&lt;a:ArgumentName/&gt;&lt;a:IsVisible&gt;true&lt;/a:IsVisible&gt;&lt;a:ItemID/&gt;&lt;a:ToolTip/&gt;&lt;a:ValidationItems xmlns:b=&quot;http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation&quot;/&gt;&lt;a:LabelForItemID&gt;DatePicker1&lt;/a:LabelForItemID&gt;&lt;a:Text&gt;COMPLETED_DATE_STATIC&lt;/a:Text&gt;&lt;/a:Label&gt;&lt;a:TimePickerItem&gt;&lt;a:ArgumentName/&gt;&lt;a:IsVisible&gt;true&lt;/a:IsVisible&gt;&lt;a:ItemID/&gt;&lt;a:ToolTip/&gt;&lt;a:ValidationItems xmlns:b=&quot;http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation&quot;/&gt;&lt;a:InitialTime i:nil=&quot;true&quot;/&gt;&lt;a:InitializeWithCurrentTime&gt;true&lt;/a:InitializeWithCurrentTime&gt;&lt;a:Label&gt;&lt;a:ArgumentName/&gt;&lt;a:IsVisible&gt;true&lt;/a:IsVisible&gt;&lt;a:ItemID/&gt;&lt;a:ToolTip/&gt;&lt;a:ValidationItems xmlns:b=&quot;http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation&quot;/&gt;&lt;a:LabelForItemID/&gt;&lt;a:Text&gt;Label&lt;/a:Text&gt;&lt;/a:Label&gt;&lt;a:TimeFormat&gt;ShortTime&lt;/a:TimeFormat&gt;&lt;/a:TimePickerItem&gt;&lt;/a:FormItem&gt;&lt;/a:FormItems&gt;&lt;a:MaxWidth&gt;INF&lt;/a:MaxWidth&gt;&lt;a:Orientation&gt;Vertical&lt;/a:Orientation&gt;&lt;a:VisibleControlID i:nil=&quot;true&quot;/&gt;&lt;a:VisibleControlValue i:nil=&quot;true&quot;/&gt;&lt;/ContainerFormItem&gt;&lt;KnownTypes xmlns:a=&quot;http://schemas.microsoft.com/2003/10/Serialization/Arrays&quot;&gt;&lt;a:string&gt;Geocortex.Forms.Client.Items.ContainerFormItem&lt;/a:string&gt;&lt;a:string&gt;Geocortex.Forms.Client.Items.DatePickerFormItem&lt;/a:string&gt;&lt;a:string&gt;Geocortex.Forms.Client.Items.Validation.RequiredValidationItem&lt;/a:string&gt;&lt;/KnownTypes&gt;&lt;MaxHeight&gt;800&lt;/MaxHeight&gt;&lt;MaxWidth&gt;1000&lt;/MaxWidth&gt;&lt;Title&gt;Form Title&lt;/Title&gt;&lt;Version&gt;1.1&lt;/Version&gt;&lt;/FormDefinition&gt;" 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&lt;FormItem&gt;" 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="[&quot;Key: &quot; + item.Key + &quot;, Value: &quot; + item.Value.ToString() + &quot;, Type: &quot; + 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="[&quot;completedDate: &quot;+cstr(completedDate)]" />
</Sequence>
</If.Then>
<If.Else>
<gwa:ExternalLog DisplayName="item.Key ExternalLog" sap2010:WorkflowViewState.IdRef="ExternalLog_2" Message="[&quot;Key: &quot; + 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>
@bradbrowne
Copy link
Author

bradbrowne commented Jan 9, 2017

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:

gistdatemillisecondsstaticvsdynamic

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 😒

gistdatemillisecondssystemstringcase

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. πŸŽ‰

gistdatemillisecondschromeconsoleresults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment