-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForEach.xaml
161 lines (161 loc) · 12.8 KB
/
ForEach.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<Activity mc:Ignorable="sap sap2010" x:Class="ForEach" sap:VirtualizedContainerService.HintSize="965,1499" sap2010:WorkflowViewState.IdRef="ActivityBuilder_1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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:str="clr-namespace:System.Text.RegularExpressions;assembly=System" xmlns:ui="http://schemas.uipath.com/workflow/activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextExpression.NamespacesForImplementation>
<scg:List x:TypeArguments="x:String" Capacity="32">
<x:String>System.Activities</x:String>
<x:String>System.Activities.Statements</x:String>
<x:String>System</x:String>
<x:String>System.Collections</x:String>
<x:String>System.Collections.Generic</x:String>
<x:String>System.Data</x:String>
<x:String>System.IO</x:String>
<x:String>System.Linq</x:String>
<x:String>UiPath.Core</x:String>
<x:String>UiPath.Core.Activities</x:String>
<x:String>System.Runtime.Serialization</x:String>
<x:String>System.Collections.ObjectModel</x:String>
<x:String>UiPath.Activities.System.Encode</x:String>
<x:String>System.Reflection</x:String>
<x:String>System.Runtime.InteropServices</x:String>
<x:String>UiPath.UIAutomationNext.Enums</x:String>
<x:String>System.Activities.DynamicUpdate</x:String>
<x:String>UiPath.Activities.System.Compression.Workflow</x:String>
<x:String>UiPath.Shared.Activities</x:String>
<x:String>System.Text.RegularExpressions</x:String>
<x:String>System.Activities.Expressions</x:String>
<x:String>System.Diagnostics</x:String>
<x:String>System.Drawing</x:String>
<x:String>System.Xml</x:String>
<x:String>System.Xml.Linq</x:String>
<x:String>System.Net.Mail</x:String>
<x:String>Microsoft.VisualBasic</x:String>
</scg:List>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<scg:List x:TypeArguments="AssemblyReference" Capacity="32">
<AssemblyReference>System.Activities</AssemblyReference>
<AssemblyReference>Microsoft.VisualBasic</AssemblyReference>
<AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System</AssemblyReference>
<AssemblyReference>System.Drawing</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
<AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>PresentationFramework</AssemblyReference>
<AssemblyReference>WindowsBase</AssemblyReference>
<AssemblyReference>PresentationCore</AssemblyReference>
<AssemblyReference>System.Xaml</AssemblyReference>
<AssemblyReference>UiPath.System.Activities</AssemblyReference>
<AssemblyReference>UiPath.UiAutomation.Activities</AssemblyReference>
<AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>
<AssemblyReference>System.Runtime.Serialization</AssemblyReference>
<AssemblyReference>System.Memory</AssemblyReference>
<AssemblyReference>UiPath.UIAutomationNext</AssemblyReference>
<AssemblyReference>UiPath.Excel.Activities</AssemblyReference>
<AssemblyReference>UiPath.Mail.Activities</AssemblyReference>
<AssemblyReference>UiPath.OCR.Activities</AssemblyReference>
<AssemblyReference>UiPath.UIAutomationCore</AssemblyReference>
<AssemblyReference>System.ServiceModel</AssemblyReference>
<AssemblyReference>Microsoft.Bcl.AsyncInterfaces</AssemblyReference>
<AssemblyReference>System.ValueTuple</AssemblyReference>
<AssemblyReference>System.ComponentModel.Composition</AssemblyReference>
<AssemblyReference>UiPath.Excel</AssemblyReference>
<AssemblyReference>UiPath.Mail</AssemblyReference>
<AssemblyReference>UiPath.OCR.Activities.Design</AssemblyReference>
<AssemblyReference>System.ServiceModel.Activities</AssemblyReference>
</scg:List>
</TextExpression.ReferencesForImplementation>
<ui:ForEach x:TypeArguments="x:Object" CurrentIndex="{x:Null}" sap2010:Annotation.AnnotationText="description:
 For Each loop to give the name of each item to a variable named (filename) after that using file name as an input for regex matches activity to compare the string with on of these dates (2018|2019|2020) if the match happens then the output (itemdate.Count) will be more than 1 so using this as if condition in which assign the value of year to a variable called (year) using this variable in creating a folder using it (dynamic Path) then moving this item to that folder. if the condition doesn't occur then it will create a file of today's date and move the item to it.

Pre-conditions:
filenames argument as string.
item date variable as " DisplayName="For Each" sap:VirtualizedContainerService.HintSize="975,1434" sap2010:WorkflowViewState.IdRef="ForEach`1_1" Values="[directory.GetFiles("C:\Users\"+Environment.UserName+"\Desktop\Project\nd340-c1-intro-to-uipath-rpa-project-starter-master\nd340-c1-intro-to-uipath-rpa-project-starter-master")]">
<ui:ForEach.Body>
<ActivityAction x:TypeArguments="x:Object">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:Object" Name="item" />
</ActivityAction.Argument>
<Sequence DisplayName="Body" sap:VirtualizedContainerService.HintSize="939,1093" sap2010:WorkflowViewState.IdRef="Sequence_7">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Name="filename" />
<Variable x:TypeArguments="scg:IEnumerable(str:Match)" Name="itemdate" />
<Variable x:TypeArguments="x:String" Name="year" />
</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>
<Assign sap2010:Annotation.AnnotationText="filename string variable to carry the name of each item 
" sap:VirtualizedContainerService.HintSize="897,117" sap2010:WorkflowViewState.IdRef="Assign_1">
<Assign.To>
<OutArgument x:TypeArguments="x:String">[filename]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:String">[Path.GetFileName(item.Tostring)]</InArgument>
</Assign.Value>
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsAnnotationDocked">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</Assign>
<ui:Matches sap2010:Annotation.AnnotationText="Regex match activity to get the name " BuilderPattern="(2018)|(2019)|(2020)" sap:VirtualizedContainerService.HintSize="897,90" sap2010:WorkflowViewState.IdRef="Matches_1" Input="[filename]" IsBuilderTabModified="True" Model="[{"Index":0,"OperationID":"ADV","OperationName":"Advanced","OperationValue":"(2018)|(2019)|(2020)","QuantifierFirstValue":"1","QuantifierID":"EXT","QuantifierName":"Exactly","QuantifierSecondValue":null}]" Pattern="(2018)|(2019)|(2020)" RegexOption="IgnoreCase" Result="[itemdate]">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsAnnotationDocked">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</ui:Matches>
<If sap2010:Annotation.AnnotationText="if loop to start sorting according to the information we have
as it tests if the filename has these numbers 2018|2019|2020
" Condition="[itemdate.Count >0]" sap:VirtualizedContainerService.HintSize="897,714" sap2010:WorkflowViewState.IdRef="If_2">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsAnnotationDocked">True</x:Boolean>
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<If.Then>
<Sequence sap:VirtualizedContainerService.HintSize="426,499" sap2010:WorkflowViewState.IdRef="Sequence_13">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<Assign sap2010:Annotation.AnnotationText="assign the value of the year of each item" sap:VirtualizedContainerService.HintSize="384,91" sap2010:WorkflowViewState.IdRef="Assign_4">
<Assign.To>
<OutArgument x:TypeArguments="x:String">[year]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:String">[itemdate(0).Value]</InArgument>
</Assign.Value>
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsAnnotationDocked">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</Assign>
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create Folder" sap:VirtualizedContainerService.HintSize="384,79" sap2010:WorkflowViewState.IdRef="CreateDirectory_4" Path="["C:\Users\"+Environment.UserName+"\Desktop\Project\nd340-c1-intro-to-uipath-rpa-project-starter-master\nd340-c1-intro-to-uipath-rpa-project-starter-master\"+year.ToString]" />
<ui:MoveFile ContinueOnError="{x:Null}" Destination="["C:\Users\"+Environment.UserName+"\Desktop\Project\nd340-c1-intro-to-uipath-rpa-project-starter-master\nd340-c1-intro-to-uipath-rpa-project-starter-master\"+year.ToString]" DisplayName="Move File" sap:VirtualizedContainerService.HintSize="384,157" sap2010:WorkflowViewState.IdRef="MoveFile_5" Overwrite="True" Path="[item.ToString]" />
</Sequence>
</If.Then>
<If.Else>
<Sequence sap:VirtualizedContainerService.HintSize="426,368" sap2010:WorkflowViewState.IdRef="Sequence_14">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Name="Todaydate" />
</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>
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create Folder" sap:VirtualizedContainerService.HintSize="384,79" sap2010:WorkflowViewState.IdRef="CreateDirectory_5" Path="["C:\Users\"+Environment.UserName+"\Desktop\Project\nd340-c1-intro-to-uipath-rpa-project-starter-master\nd340-c1-intro-to-uipath-rpa-project-starter-master\"+Datetime.today.tostring(“yyyy-MM-dd”)]" />
<ui:MoveFile ContinueOnError="{x:Null}" Destination="["C:\Users\"+Environment.UserName+"\Desktop\Project\nd340-c1-intro-to-uipath-rpa-project-starter-master\nd340-c1-intro-to-uipath-rpa-project-starter-master\"+Datetime.today.tostring(“yyyy-MM-dd”)]" DisplayName="Move File" sap:VirtualizedContainerService.HintSize="384,157" sap2010:WorkflowViewState.IdRef="MoveFile_6" Overwrite="True" Path="[item.ToString]" />
</Sequence>
</If.Else>
</If>
</Sequence>
</ActivityAction>
</ui:ForEach.Body>
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsAnnotationDocked">True</x:Boolean>
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</ui:ForEach>
</Activity>