Open

Adding second/minute timer to a running task in 'Running tasks'

  • 16 October 2019
  • 5 replies
  • 47 views

Userlevel 6
Badge +11

I'm working on a piece of functionality that can import text files by reading them from a folder and then insert them into a table, after which I can validate and process the data. For this I set my task to 'No’ at 'Await result’. This way it will make use of 'Running tasks’ and be noted there.

Since it is possible that I'm importing big files with multiple ten-thousands of rows, it can take a while before it's finished. While it's busy with the SQL-statement, I'm not possible to execute any 'send_progress’, leaving me with no other option than to show this to the user for a long time:

 

What I would like the user to see is a second and/or minute timer to show the user that the database is executing the task and is not stuck but just busy for a while. This will most likely make sure the user doesn't press the ‘X’. 


5 replies

Userlevel 3
Badge +3

Hi, Mark,

 

Hmmz, that doesn't say to much to the user.

I have another idea, which I don't know it's doable through SQL procedures. Why don't you present the file size to the user through the progress message. I would think the user could reason this way why it takes a while before the progress continues presenting a large number of MBs or even GBs.

Is that a valid option in your case?


Regards, Erik

Userlevel 6
Badge +11

Hi, Mark,

 

Hmmz, that doesn't say to much to the user.

I have another idea, which I don't know it's doable through SQL procedures. Why don't you present the file size to the user through the progress message. I would think the user could reason this way why it takes a while before the progress continues presenting a large number of MBs or even GBs.

Is that a valid option in your case?


Regards, Erik

Hey Erik,

 

Didn't think about showing the size, if that is possible that would help a lot. That would mean that the 'Read file’ process action should return the size of the file to me, than I could use it. Could that be a possibility?

 

Kind regards,

Mark Jongeling

Userlevel 3
Badge +3

Could you provide a little more information about the solution you come up with?

I would think you should know the file and its size in the stored procedure of the task itself?

Userlevel 6
Badge +11

Could you provide a little more information about the solution you come up with?

I would think you should know the file and its size in the stored procedure of the task itself?

I just got something that I can use.

With the 'Read file’ I get a single parameter with the data of the file. This parameter value I save in a table called 'import_file’ so I can use it later on. Then by using the following SQL I am able to calculate the amount of KB.

declare @data varchar(max) = (select file_data from import_file where import_order_no = 4 /*Bigfile*/)

select cast(round(datalength(@data) / 1024.0, 0) as int) AS KB

Now I can use this to show to the user how big the file is that is going to be 'read’. 'Read’ in my context is making the one string of file data into usable rows of data; splitting the value into rows. This can take a while so that's why I want to show the user that the SQL-script is doing it's best set everything up. The bigger the file, the longer it will take.

Userlevel 6
Badge +11
Nu is het zo, de grootte van het bestand wordt nu getoond

Ziet er goed uit zo :smile: Thanks voor je suggestie. 

(Nog steeds zou ik een timer toch wel als optie willen)

Reply