forked from chrisleo/RPA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenameFile.xaml
154 lines (154 loc) · 10.8 KB
/
RenameFile.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
<Activity mc:Ignorable="sap sap2010" x:Class="RenameFile2" this:RenameFile2.FolderPathArg="C:\work\RPA\RPAUtils\FileProcess\TestData\" this:RenameFile2.NewFileNameArg="NewFileName" this:RenameFile2.DateFormatArg="yyyyMMdd hhmmss" 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: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:ui="http://schemas.uipath.com/workflow/activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<x:Members>
<x:Property sap2010:Annotation.AnnotationText="指定文件夹" Name="FolderPathArg" Type="InArgument(x:String)" />
<x:Property sap2010:Annotation.AnnotationText="新文件重命名之后的前缀" Name="NewFileNameArg" Type="InArgument(x:String)" />
<x:Property sap2010:Annotation.AnnotationText="被应用在文件名中的日期格式" Name="DateFormatArg" Type="InArgument(x:String)" />
<x:Property sap2010:Annotation.AnnotationText="返回状态" Name="StatusArg" Type="OutArgument(x:String)" />
</x:Members>
<mva:VisualBasic.Settings>
<x:Null />
</mva:VisualBasic.Settings>
<sap:VirtualizedContainerService.HintSize>711.2,1551.2</sap:VirtualizedContainerService.HintSize>
<sap2010:WorkflowViewState.IdRef>RenameFile2_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>
</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.Data.DataSetExtensions</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>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<Sequence sap2010:Annotation.AnnotationText="功能: 对指定文件夹的所有文件进行重命名
依赖: 无
================================================================
入参:
 * FolderPathArg - 指定文件夹
 * NewFileNameArg - 新文件名称前缀,默认为NewFileName
具体命名规则,可以在Move file的Activity中自定义
 * DateFormatArg - 被应用在文件名中的时间格式,默认为yyyyMMdd hhmmss
================================================================
出参:
 * StatusArg- 重命名的状态日志,表名有多少文件被命名成功" DisplayName="RenameFile" sap:VirtualizedContainerService.HintSize="671.2,1471.2" sap2010:WorkflowViewState.IdRef="Sequence_1">
<Sequence.Variables>
<Variable x:TypeArguments="x:Boolean" Name="FolderExist" />
</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" Exists="[FolderExist]" sap:VirtualizedContainerService.HintSize="648.8,90.4" sap2010:WorkflowViewState.IdRef="PathExists_1" Path="[FolderPathArg]" PathType="Folder" />
<If sap2010:Annotation.AnnotationText="判断文件夹是否存在,存在则继续后续逻辑" Condition="[FolderExist]" sap:VirtualizedContainerService.HintSize="648.8,1028" sap2010:WorkflowViewState.IdRef="If_1">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsAnnotationDocked">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<If.Then>
<Sequence sap2010:Annotation.AnnotationText="在指定文件夹中重命名
重命名规则可在此定义" DisplayName="Rename File" sap:VirtualizedContainerService.HintSize="309.6,850.4" sap2010:WorkflowViewState.IdRef="Sequence_3">
<Sequence.Variables>
<Variable x:TypeArguments="scg:List(x:String)" Name="files" />
<Variable x:TypeArguments="x:Int32" Name="count" />
</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>
<Assign sap:VirtualizedContainerService.HintSize="287.2,60" sap2010:WorkflowViewState.IdRef="Assign_1">
<Assign.To>
<OutArgument x:TypeArguments="scg:List(x:String)">[files]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="scg:List(x:String)">[Directory.GetFiles(FolderPathArg).ToList]</InArgument>
</Assign.Value>
<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>
<Assign sap:VirtualizedContainerService.HintSize="287.2,60" sap2010:WorkflowViewState.IdRef="Assign_2">
<Assign.To>
<OutArgument x:TypeArguments="x:Int32">[count]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:Int32">0</InArgument>
</Assign.Value>
</Assign>
<ui:ForEach x:TypeArguments="x:Int32" CurrentIndex="{x:Null}" DisplayName="For each" sap:VirtualizedContainerService.HintSize="287.2,381.6" sap2010:WorkflowViewState.IdRef="ForEach`1_1" Values="[Enumerable.Range(0,files.Count)]">
<ui:ForEach.Body>
<ActivityAction x:TypeArguments="x:Int32">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:Int32" Name="item" />
</ActivityAction.Argument>
<Sequence DisplayName="Body" sap:VirtualizedContainerService.HintSize="265.6,247.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>
<ui:MoveFile ContinueOnError="{x:Null}" Destination="[Path.GetDirectoryName(files(item))+"\"+NewFileNameArg+"-"+item.toString+"["+datetime.Now.ToString(DateFormatArg)+"."+Right(Now.Millisecond.ToString,2)+"]"+Path.GetExtension(files(item))]" DisplayName="Move file" sap:VirtualizedContainerService.HintSize="243.2,22.4" sap2010:WorkflowViewState.IdRef="MoveFile_1" Overwrite="False" Path="[files(item)]" />
<Assign sap:VirtualizedContainerService.HintSize="243.2,60" sap2010:WorkflowViewState.IdRef="Assign_3">
<Assign.To>
<OutArgument x:TypeArguments="x:Int32">[count]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:Int32">[count+1]</InArgument>
</Assign.Value>
</Assign>
</Sequence>
</ActivityAction>
</ui:ForEach.Body>
</ui:ForEach>
<Assign sap:VirtualizedContainerService.HintSize="287.2,60" sap2010:WorkflowViewState.IdRef="Assign_4">
<Assign.To>
<OutArgument x:TypeArguments="x:String">[StatusArg]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:String">[count.ToString+" files renamed."]</InArgument>
</Assign.Value>
</Assign>
</Sequence>
</If.Then>
<If.Else>
<ui:LogMessage sap2010:Annotation.AnnotationText="文件夹不存在" DisplayName="Log message" sap:VirtualizedContainerService.HintSize="314.4,120.8" sap2010:WorkflowViewState.IdRef="LogMessage_1" Level="Error" Message="业务逻辑异常 - 指定文件夹不存在!">
<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:LogMessage>
</If.Else>
</If>
</Sequence>
</Activity>