Hi,
I’ve an input data table called “ModifiedJobsDT” as follows:
ModifiedJobsDT | |||||
---|---|---|---|---|---|
UiPathProcessName | FullProcessName | Environment Name | RPA Runtime (INPUT) | Runs/ Sessions | ProcessAndEnvironmentName |
Folder1_Ext-Process1 | Folder1_Ext-Process1-Dispatcher | Env1 | 0:07:56 | 7 | Folder1_Ext-Process1_Env1 |
Folder1_Ext-Process1 | Folder1_Ext-Process1-Performer | Env1 | 0:00:04 | 5 | Folder1_Ext-Process1_Env1 |
Folder1-Process1677 | Folder1-Process1677 | Env2 | 0:21:54 | 9 | Folder1-Process1677_Env2 |
BOE-DeleteOldMails | BOE-DeleteOldMails | Env3 | 0:00:21 | 1 | BOE-DeleteOldMails_Env3 |
Process5 | Process5 | Env4 | 0:02:35 | 7 | Process5_Env4 |
Folder1_Ext-Process1 | Folder1_Ext-Process1-Performer | Env5 | 0:02:35 | 7 | Folder1_Ext-Process1_Env5 |
I need to group data based on last column of above DT and prepare an output DT called “FinalJobsDT” as follows:
FinalJobsDT | |||||
---|---|---|---|---|---|
UiPathProcessName | FullProcessName | Environment Name | RPA Runtime (INPUT) | Runs/ Sessions | ProcessAndEnvironmentName |
Folder1_Ext-Process1 | Folder1_Ext-Process1-Dispatcher, Folder1_Ext-Process1-Performer | Env1 | 00:08:00 | 12 | Folder1_Ext-Process1_Env1 |
Folder1-Process1677 | Folder1-Process1677 | Env2 | 00:21:54 | 9 | Folder1-Process1677_Env2 |
BOE-DeleteOldMails | BOE-DeleteOldMails | Env3 | 00:00:21 | 1 | BOE-DeleteOldMails_Env3 |
Process5 | Process5 | Env4 | 00:02:35 | 7 | Process5_Env4 |
Folder1_Ext-Process1 | Folder1_Ext-Process1-Performer | Env5 | 00:02:35 | 7 | Folder1_Ext-Process1_Env5 |
I prepared a LINQ as follows:
FinalJobsDT = (From row In ModifiedJobsDT
Group row By pen = row(“ProcessAndEnvironmentName”).ToString
Into grp = Group
Let fpn = String.Join(“,”,(From name In grp Select Convert.ToString(grp(“FullProcessName”))).ToList)
Let runtime = grp.Sum(Function (x) Timespan.Parse(x(“RPA Runtime (INPUT)”))).ToString
Let runs = grp.Sum(Function (x) Convert.ToInt32(x(“Runs/ Sessions”))).ToString
Let result = New Object() {grp(0)(“UiPathProcessName”),fpn,grp(0)(“Environment Name”),runtime,runs,grp(0)(“ProcessAndEnvironmentName”)}
Select FinalJobsDT.Rows.Add(result)).CopyToDataTable
Can you please check and tell if I wrote the correct LINQ? If not, can you please guide me to prepare correct LINQ?
Also I’m getting compilation error when I’m using this LINQ in assign activity:
“Option strict on disallows implict conversions from String to Integer”
I made all columns as String in ModifiedJobsDT and then FinalJobsDT = ModifiedJobsDT.clone and then I’m using this LINQ