Hi team
i need one solution
It’s attended bot so I need to download some web application text files based on time
For example my application data is like this
File Name Date Button
File1 27-09-2029 16-21-03 Download
File2 27-09-2029 16-20-22 Download
File3 27-09-2029 16-18-20 Download
File4 27-09-2029 16-15-03 Download
File5 27-09-2029 16-10-03 Download
File5 27-09-2029 16-05-03 Download
File5 27-09-2029 15-21-03 Download
if i run the bot at 16:21 PM i need to download all files between 16:21 PM to 15-21PM
If second run files will add one by one
File Name Date Button
File1 27-09-2029 17-45-20 Download
File1 27-09-2029 17-20-03 Download
File1 27-09-2029 17-16-20 Download
File1 27-09-2029 17-10-03 Download
File1 27-09-2029 17-05-03 Download
File1 27-09-2029 16-21-03 Download
File2 27-09-2029 16-20-22 Download
File3 27-09-2029 16-18-20 Download
File4 27-09-2029 16-15-03 Download
File5 27-09-2029 16-10-03 Download
File5 27-09-2029 16-05-03 Download
File5 27-09-2029 15-21-03 Download
if i run the bot second time i need to download all files between 17:45 PM to 16:21 PM
so this logic
1 Like
I assume u have got the data from
Website as a datatable dt
Try with this pseudo code
with the selected rows:
Assign dt = YourDataTable.AsEnumerable().Where(Function(row) DateTime.ParseExact(row("Date").ToString(), "dd-MM-yyyy HH-mm-ss", CultureInfo.InvariantCulture) >= DateTime.ParseExact("27-09-2029 16-21-03", "dd-MM-yyyy HH-mm-ss", CultureInfo.InvariantCulture) AndAlso DateTime.ParseExact(row("Date").ToString(), "dd-MM-yyyy HH-mm-ss", CultureInfo.InvariantCulture) <= DateTime.ParseExact("27-09-2029 15-21-03", "dd-MM-yyyy HH-mm-ss", CultureInfo.InvariantCulture)).CopyToDataTable()
Assign currentTime = Now
Assign startTime = currentTime.AddHours(-1)
Assign filteredRows = (From row In dt.AsEnumerable
Let rowTime = DateTime.ParseExact(row.Field(Of String)("Date"), "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture)
Where rowTime >= startTime AndAlso rowTime <= currentTime
Select row).ToArray
Assign filteredDt = filteredRows.CopyToDataTable
Hope this helps
Cheers @Anil_Rajavarapu1
Thanks for your quick respone
You mention this step
Assign startTime = currentTime.AddHours(-1)
if it is unattended bot every one hour bot will download files based time difference
but it’s attended bot so we can’t give AddHours(-1) correct me if i am wrong
they will run for 1 hour or maight be 2 hours or might be 3 1/2 hours
1 Like
U can get that bot time may be with an INPUT DIALOG BOX like
How much time difference is required @Anil_Rajavarapu1
it’s a dynamic and that to it’s a banking application
As per requirement if i run bot at 10am i need to download files beteween morning 6 AM 10 AM
After second run if i run bot 11am i need to download files beteween morning 11 AM 10 AM
after that if i missed 12Pm run
after i will run 1PM in that case i need to download files beteween morning 1 PM 11 AM
application format is like this
File Name Date Button
File1 27-09-2023 16-21-03 Download
File2 27-09-2023 16-20-22 Download
File3 27-09-2023 16-18-20 Download
File4 27-09-2023 16-15-03 Download
File5 27-09-2023 16-10-03 Download
File5 27-09-2023 16-05-03 Download
File5 27-09-2023 15-21-03 Download
Anil_G
(Anil Gorthi)
September 27, 2023, 12:25pm
6
@Anil_Rajavarapu1
Can you please give the dates properly…this is possible but 11 AM to 10 AM you mean the previous day 11AM to today 10 AM?
similarly other times
what you can do is check the time of run which is Now.Hours=10 then get from 6 to 10
Now.Hour = 11 accordingly you can change the start and end times
cheers
No No files will add like this in current day only
File Name Date Button
File1 27-09-2023 12:21:03 Download
File2 27-09-2023 11:20:22 Download
File3 27-09-2023 10:18:20 Download
File4 27-09-2023 09:15:03 Download
File5 27-09-2023 07:10:03 Download
File5 27-09-2023 07:05:03 Download
File5 27-09-2023 06:21:03 Download
Anil_G
(Anil Gorthi)
September 27, 2023, 1:29pm
8
@Anil_Rajavarapu1
So the time comes in 12 hour format? then how do we identify AM or PM?
cheers
Anil_G
(Anil Gorthi)
September 27, 2023, 1:52pm
10
@Anil_Rajavarapu1
then what is 11 AM to 10 AM…do you mean 10 to 11?
cheers
I am assuming whenever you trigger the bot, it has to download files based on previous run time.
Setup one asset with previous execution run →
E.g., LastTimeStamp → 15:21 (This has to be set only once).
When you execute next time → Say 16:21
Bot downloads files between 15:21 and 16:21
Update LastTimeStamp → 16:21
When you execute again → say 17:45
Bot downloads files between 16:21 and 17:45
Update LastTimeStamp → 17:45
This way you can download files based on your last executions.
Thanks.
Regards,
Kartheek Byggari
@KarthikByggari
if it’s possible please send code based on above steps
Here is the skeleton for the same. Added comments for better understanding.
kindly refer.
Here is the screenshot of asset.
DownloadFiles.xaml (12.3 KB)
Regards,
Kartheek Byggari
if i use this it’s going to false case
Debug and check the variables. So, it helps you to understand where it is going wrong.
yes already i have checked with debug but no luck
@Palaniyappan
@Anil_G
@KarthikByggari
Again i am giving logic
Due to unattended license cost is high we are doing with attended bot and every day we need to run the bot at every hour manually
my file download part should be like this ,there is 3 columns are there first check date &Time then click on download
File Name Date Button
File2 28-09-2023 11:20:22 Download
File3 28-09-2023 10:18:20 Download
File4 28-09-2023 09:15:03 Download
File5 28-09-2023 07:10:03 Download
File5 28-09-2023 07:05:03 Download
File5 28-09-2023 06:21:03 Download
If i run the bot at 12Pm i need to download all the files between 06:21:03 to 11:20:22
After that again files add with hourly basis in that list
File Name Date Button
File2 28-09-2023 13:20:08 Download
File2 28-09-2023 12:45:03 Download
File2 28-09-2023 12:20:22 Download
File2 28-09-2023 11:20:22 Download
File3 28-09-2023 10:18:20 Download
File4 28-09-2023 09:15:03 Download
File5 28-09-2023 07:10:03 Download
File5 28-09-2023 07:05:03 Download
File5 28-09-2023 06:21:03 Download
if i run 2PM for the next time need to download files between 11:20:22 to 13:20:08 but not 11:2022 file because we have already this file
Anil_G
(Anil Gorthi)
September 28, 2023, 6:45am
21
@Anil_Rajavarapu1
Then you can try this
Create an asset to save the last downloaded file time
Use the created asset to check when is the last download and depending on the current time I feel you need to download all files till the latest time so…the final time can be saved back to asset which can be used in next run as start time again
to check for times…first use for each ui elment or extract table and get the data…in both the cases you can use time comparision to check for the files you need for that here is an example code…modify as per you need DateTime.ParseExact("Timefrom Site","dd-MM-yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture) > DateTime.ParseExact("DateTimeFromAsset","dd-MM-yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture)
If the condition in step 3 is true…while using for each ui element click on download…or if using extract datatable then filter the required rows…and then use the time as identifier and then click on download
But remember to save the final time after whole of process so that next time it runs the check start from that specific time
Hope this helps
cheers