|
| 1 | +<?xml version="1.0" encoding="utf-16"?> |
| 2 | +<Workflow xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:s="clr-namespace:System;assembly=mscorlib" |
| 5 | + xmlns:dt="clr-namespace:System.Data;assembly=System.Data" |
| 6 | + xmlns:ui="http://schemas.uipath.com/workflow/activities" |
| 7 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 8 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 9 | + mc:Ignorable="d" |
| 10 | + x:Class="DataProcessing" |
| 11 | + DisplayName="Data Processing"> |
| 12 | + <x:Members> |
| 13 | + <x:Property Name="inputData" Type="InArgument(dt:DataTable)" /> |
| 14 | + <x:Property Name="filteredData" Type="OutArgument(dt:DataTable)" /> |
| 15 | + <x:Property Name="logFilePath" Type="InArgument(x:String)" /> |
| 16 | + </x:Members> |
| 17 | + <Sequence DisplayName="Data Processing Sequence"> |
| 18 | + <Variable x:TypeArguments="dt:DataTable" Name="tempData" /> |
| 19 | + <Variable x:TypeArguments="s:String" Name="logMessage" /> |
| 20 | + |
| 21 | + <!-- Initialize Filtered Data --> |
| 22 | + <Assign DisplayName="Initialize Filtered Data" To="[filteredData]" Value="[New dt:DataTable()]" /> |
| 23 | + |
| 24 | + <TryCatch DisplayName="Try-Catch for Data Processing"> |
| 25 | + <Try DisplayName="Process Data"> |
| 26 | + <Sequence DisplayName="Data Processing Logic"> |
| 27 | + <!-- Clone Structure of Input Data --> |
| 28 | + <Assign DisplayName="Clone Input Data Structure" To="[tempData]" Value="[inputData.Clone()]" /> |
| 29 | + |
| 30 | + <!-- Filter Data --> |
| 31 | + <ForEach x:TypeArguments="dt:DataRow" DisplayName="For Each Row" Values="[inputData.Rows]"> |
| 32 | + <ActivityAction x:TypeArguments="dt:DataRow"> |
| 33 | + <Sequence DisplayName="Process Row"> |
| 34 | + <If DisplayName="Check Condition"> |
| 35 | + <If.Condition> |
| 36 | + <InArgument x:TypeArguments="s:Boolean">[item("Status").ToString.Equals("Active")]</InArgument> |
| 37 | + </If.Condition> |
| 38 | + <Then> |
| 39 | + <InvokeMethod DisplayName="Add Row to Filtered Data" TargetType="dt:DataTable" MethodName="ImportRow"> |
| 40 | + <Parameters> |
| 41 | + <InArgument x:TypeArguments="dt:DataRow">[item]</InArgument> |
| 42 | + </Parameters> |
| 43 | + </InvokeMethod> |
| 44 | + </Then> |
| 45 | + </If> |
| 46 | + </Sequence> |
| 47 | + </ActivityAction> |
| 48 | + </ForEach> |
| 49 | + |
| 50 | + <Assign DisplayName="Set Filtered Data" To="[filteredData]" Value="[tempData]" /> |
| 51 | + </Sequence> |
| 52 | + </Try> |
| 53 | + <Catch x:TypeArguments="s:Exception" DisplayName="Exception Handling"> |
| 54 | + <Sequence> |
| 55 | + <Assign DisplayName="Set Log Message" To="[logMessage]" Value="[String.Format('Error processing data: {0}', exception.Message)]" /> |
| 56 | + <InvokeMethod DisplayName="Log Error" TargetType="System.IO.File" MethodName="AppendAllText"> |
| 57 | + <Parameters> |
| 58 | + <InArgument x:TypeArguments="s:String">[logFilePath]</InArgument> |
| 59 | + <InArgument x:TypeArguments="s:String">[String.Format('{0} [ERROR]: {1}{2}', DateTime.Now.ToString('yyyy-MM-dd HH:mm:ss'), logMessage, Environment.NewLine)]</InArgument> |
| 60 | + </Parameters> |
| 61 | + </InvokeMethod> |
| 62 | + </Sequence> |
| 63 | + </Catch> |
| 64 | + </TryCatch> |
| 65 | + </Sequence> |
| 66 | +</Workflow> |
0 commit comments