forked from chrisleo/RPA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSortFiles.xaml
250 lines (250 loc) · 18.6 KB
/
SortFiles.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<Activity mc:Ignorable="sap sap2010" x:Class="Main" this:Main.SortingDirectionArg="ascending" this:Main.DirectoryPathArg="C:\work\RPA\项目总结资料" this:Main.SortingCriteriaArg="Size" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/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: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:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:this="clr-namespace:" xmlns:ui="http://schemas.uipath.com/workflow/activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<x:Members>
<x:Property sap2010:Annotation.AnnotationText="包含ascending/descending两种" Name="SortingDirectionArg" Type="InArgument(x:String)" />
<x:Property sap2010:Annotation.AnnotationText="待排序文件所在文件夹" Name="DirectoryPathArg" Type="InArgument(x:String)" />
<x:Property sap2010:Annotation.AnnotationText="排序类型:
1. CreationTime 
2. FullName 
3. Size 
4. LastAccessTime" Name="SortingCriteriaArg" Type="InArgument(x:String)" />
<x:Property Name="SortedFilesArg" Type="OutArgument(sl:IOrderedEnumerable(x:String))" />
</x:Members>
<mva:VisualBasic.Settings>
<x:Null />
</mva:VisualBasic.Settings>
<sap:VirtualizedContainerService.HintSize>1399.2,1480.8</sap:VirtualizedContainerService.HintSize>
<sap2010:WorkflowViewState.IdRef>Main_1</sap2010:WorkflowViewState.IdRef>
<TextExpression.NamespacesForImplementation>
<sco:Collection x:TypeArguments="x:String">
<x:String>System.Activities</x:String>
<x:String>System.Activities.Statements</x:String>
<x:String>System.Activities.Expressions</x:String>
<x:String>System.Activities.Validation</x:String>
<x:String>System.Activities.XamlIntegration</x:String>
<x:String>Microsoft.VisualBasic</x:String>
<x:String>Microsoft.VisualBasic.Activities</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.Diagnostics</x:String>
<x:String>System.Drawing</x:String>
<x:String>System.IO</x:String>
<x:String>System.Linq</x:String>
<x:String>System.Net.Mail</x:String>
<x:String>System.Xml</x:String>
<x:String>System.Xml.Linq</x:String>
<x:String>UiPath.Core</x:String>
<x:String>UiPath.Core.Activities</x:String>
<x:String>System.Windows.Markup</x:String>
<x:String>Microsoft.VisualBasic.CompilerServices</x:String>
<x:String>System.Security</x:String>
<x:String>System.Security.AccessControl</x:String>
</sco:Collection>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<sco:Collection x:TypeArguments="AssemblyReference">
<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>System.ComponentModel.Composition</AssemblyReference>
<AssemblyReference>System.ServiceModel</AssemblyReference>
<AssemblyReference>UiPath.IntelligentOCR</AssemblyReference>
<AssemblyReference>UiPath.Python</AssemblyReference>
<AssemblyReference>Microsoft.VisualStudio.Services.Common</AssemblyReference>
<AssemblyReference>UiPath.System.Activities</AssemblyReference>
<AssemblyReference>UiPath.UiAutomation.Activities</AssemblyReference>
<AssemblyReference>UiPath.Excel</AssemblyReference>
<AssemblyReference>UiPath.Mail</AssemblyReference>
<AssemblyReference>UiPath.PDF</AssemblyReference>
<AssemblyReference>UiPath.Word</AssemblyReference>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<Sequence sap2010:Annotation.AnnotationText="功能:按照指定方式对某一文件夹中的所有文件进行排序。(默认使用文件名称按照升序排)
依赖: 无
================================================================
入参:
 * SortingDirectionArg - 待排序文件所在文件夹
 * DirectoryPathArg- 排序类型,包含以下几种
 1) CreationTime :创建时间
 2) FullName :文件名称
 3) Size :文件大小
 4) LastAccessTime:最后访问时间
 *SortingCriteriaArg- 排序方式
 1) ascending:升序
 2) descending:降序
================================================================
出参:
 *SortedFilesArg-排好序的文件集合
================================================================" sap:VirtualizedContainerService.HintSize="1359.2,1400.8" sap2010:WorkflowViewState.IdRef="Sequence_1">
<Sequence.Variables>
<Variable x:TypeArguments="x:Boolean" Name="directoryExists" />
</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="IsAnnotationDocked">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<ui:PathExists DisplayName="Path exists In_DirectoryPath" Exists="[directoryExists]" sap:VirtualizedContainerService.HintSize="1336.8,90.4" sap2010:WorkflowViewState.IdRef="PathExists_1" Path="[DirectoryPathArg]" PathType="Folder" />
<If Condition="[directoryExists]" DisplayName="If In_DirectoryPath exists" sap:VirtualizedContainerService.HintSize="1336.8,740.8" sap2010:WorkflowViewState.IdRef="If_4">
<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>
<If.Then>
<TryCatch DisplayName="Try catch - Sort Files" sap:VirtualizedContainerService.HintSize="997.6,591.2" sap2010:WorkflowViewState.IdRef="TryCatch_1">
<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>
<TryCatch.Try>
<If Condition="[SortingDirectionArg.ToLower.Trim = "descending"]" DisplayName="If - descending" sap:VirtualizedContainerService.HintSize="980,360" sap2010:WorkflowViewState.IdRef="If_5">
<If.Then>
<Switch x:TypeArguments="x:String" DisplayName="Switch descending" Expression="[SortingCriteriaArg.ToLower.Trim]" sap:VirtualizedContainerService.HintSize="477.6,210.4" sap2010:WorkflowViewState.IdRef="Switch`1_7">
<Switch.Default>
<Assign sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_31">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderBy(Function(f) New fileinfo(f).FullName)]</InArgument>
</Assign.Value>
</Assign>
</Switch.Default>
<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 x:Key="creationtime" sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_32">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderByDescending(Function(f) New fileinfo(f).CreationTime)]</InArgument>
</Assign.Value>
</Assign>
<Assign x:Key="fullname" sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_33">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderByDescending(Function(f) New fileinfo(f).FullName)]</InArgument>
</Assign.Value>
</Assign>
<Assign x:Key="size" sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_34">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderByDescending(Function(f) New fileinfo(f).Length)]</InArgument>
</Assign.Value>
</Assign>
<Assign x:Key="lastaccesstime" sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_35">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderByDescending(Function(f) New fileinfo(f).LastAccessTime)]</InArgument>
</Assign.Value>
</Assign>
</Switch>
</If.Then>
<If.Else>
<Switch x:TypeArguments="x:String" DisplayName="Switch ascending" Expression="[SortingCriteriaArg.ToLower.Trim]" sap:VirtualizedContainerService.HintSize="477.6,210.4" sap2010:WorkflowViewState.IdRef="Switch`1_8">
<Switch.Default>
<Assign sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_36">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderBy(Function(f) New fileinfo(f).FullName)]</InArgument>
</Assign.Value>
</Assign>
</Switch.Default>
<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 x:Key="creationtime" sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_37">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderBy(Function(f) New fileinfo(f).CreationTime)]</InArgument>
</Assign.Value>
</Assign>
<Assign x:Key="fullname" sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_38">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderBy(Function(f) New fileinfo(f).FullName)]</InArgument>
</Assign.Value>
</Assign>
<Assign x:Key="size" sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_39">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderBy(Function(f) New fileinfo(f).Length)]</InArgument>
</Assign.Value>
</Assign>
<Assign x:Key="lastaccesstime" sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_40">
<Assign.To>
<OutArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[SortedFilesArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="sl:IOrderedEnumerable(x:String)">[Directory.EnumerateFiles(DirectoryPathArg,"*.*",SearchOption.AllDirectories).OrderBy(Function(f) New fileinfo(f).LastAccessTime)]</InArgument>
</Assign.Value>
</Assign>
</Switch>
</If.Else>
</If>
</TryCatch.Try>
<TryCatch.Catches>
<Catch x:TypeArguments="s:Exception" sap:VirtualizedContainerService.HintSize="983.2,22.4" sap2010:WorkflowViewState.IdRef="Catch`1_1">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">False</x:Boolean>
<x:Boolean x:Key="IsPinned">False</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<ActivityAction x:TypeArguments="s:Exception">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="s:Exception" Name="exception" />
</ActivityAction.Argument>
<ui:LogMessage DisplayName="Log message" sap:VirtualizedContainerService.HintSize="314.4,92.8" sap2010:WorkflowViewState.IdRef="LogMessage_1" Level="Warn" Message="["不能根据指定方式对文件排序: " + SortingCriteriaArg+environment.NewLine+exception.Message+exception.Source]" />
</ActivityAction>
</Catch>
</TryCatch.Catches>
</TryCatch>
</If.Then>
<If.Else>
<ui:LogMessage DisplayName="Log message - Empty Folder" sap:VirtualizedContainerService.HintSize="314.4,92.8" sap2010:WorkflowViewState.IdRef="LogMessage_4" Level="Error" Message="["文件夹 '" + DirectoryPathArg + "' 不存在!"]" />
</If.Else>
</If>
<ui:ForEach x:TypeArguments="x:String" CurrentIndex="{x:Null}" sap2010:Annotation.AnnotationText="测试,正式使用可删除" DisplayName="For Each" sap:VirtualizedContainerService.HintSize="1336.8,80.8" sap2010:WorkflowViewState.IdRef="ForEach`1_2" Values="[SortedFilesArg]">
<ui:ForEach.Body>
<ActivityAction x:TypeArguments="x:String">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:String" Name="item" />
</ActivityAction.Argument>
<Sequence DisplayName="Body" sap:VirtualizedContainerService.HintSize="232.8,187.2" sap2010:WorkflowViewState.IdRef="Sequence_2">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<WriteLine DisplayName="Write Line" sap:VirtualizedContainerService.HintSize="210.4,62.4" sap2010:WorkflowViewState.IdRef="WriteLine_1" Text="[item]" />
</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">False</x:Boolean>
<x:Boolean x:Key="IsPinned">False</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</ui:ForEach>
</Sequence>
</Activity>