Is there an interface to access the PDM Task List? Or do I need to access the PDM database directly?
The task list can be found in the administration app.
Understood. I'm trying to access it programmatically within a custom Add-In.
You can look inside the PDM Programmers guide.
Search for tasks, hope that helps.
Yes, I've used both IEdmTaskProperties & IEdmTaskInstance, but both of these interfaces are used to setup & manipulate your own custom task within a Task Add-In. I need something like an IEdmTaskManager to query the larger set of tasks running..
I just don't think it exists. Have to query DB
I'm not aware of a way to enumerate the configured tasks using the API.
Hope this helps,
Believe in The Q!
I believe you're correct, Tim, in that it isn't possible using the PDM API, but couldn't it be possible to open an SQL connection and query the TaskInstance table an retrieve the task info there? The InitUserID field could then be used to retrieve the user name from the Users table. I'm just spit balling here, but it seems like that should be possible. What say you?
Yes Jeff Borland, you are correct!
Greg could create an SQLConnection that queries the following and bind the results to a DataGrid to show the tasks by name:
SELECT T.TaskName [Task Name],
WHEN 1 THEN 'Waiting for Host'
WHEN 2 THEN 'Starting Up'
WHEN 3 THEN 'In Process'
WHEN 4 THEN 'Retrying'
WHEN 5 THEN 'Suspended'
WHEN 6 THEN 'Cancelling'
WHEN 7 THEN 'OK'
WHEN 8 THEN 'Cancelled'
WHEN 9 THEN 'Failed'
WHEN 10 THEN 'Suspending'
WHEN 11 THEN 'Resuming'
END [Task Status],
U.Username [Initiated by User], H.Hostname [Initiated on Computer], TI.StartTime [Start Time], TI.EndTime [End Time], TI.DocString [Task Results]
FROM TaskInstances TI
INNER JOIN Users U on U.UserID = TI.InitUserID
INNER JOIN Tasks T on T.TaskID = TI.TaskID
INNER JOIN Hosts H on H.HostID = TI.HostID
Here are my results:
Tim Webb thank you for the insight! I have managed to pull together a quite nice PDM Task List Report application inspired by your comment - my first application accessing information in SQL :-).
In addition to the information retrieved by your query I would like to also get information about the files being processed by each job in the task list. The information must be there since it is available in the Task List in the Administration module but I am an SQL rookie and after browsing around in the tables I haven't been able to find the information. Can you help me along...? Thanks a lot
Jorn, that's great news! I'm glad I could help. Yes, you can get the files. Here's my version of a query that lists the Tasks just like the Task List. Hope this helps!
SELECT T.TaskName [Task Name], CASE TI.TaskStatus WHEN 1 THEN 'Waiting for Host' WHEN 2 THEN 'Starting Up' WHEN 3 THEN 'In Process' WHEN 4 THEN 'Retrying' WHEN 5 THEN 'Suspended' WHEN 6 THEN 'Cancelling' WHEN 7 THEN 'OK' WHEN 8 THEN 'Cancelled' WHEN 9 THEN 'Failed' WHEN 10 THEN 'Suspending' WHEN 11 THEN 'Resuming' END [Task Status],U.Username [Initiated by User], H.Hostname [Initiated on Computer], TI.StartTime [Start Time], TI.EndTime [End Time], TI.DocString [Task Results], T.TaskName [Task Name], TI.CustomErrMsg [Task Data]FROM TaskInstances TIINNER JOIN Users U on U.UserID = TI.InitUserIDINNER JOIN Tasks T on T.TaskID = TI.TaskIDINNER JOIN Hosts H on H.HostID = TI.HostID
Thank you for the update, but I don't see how the addition of "TI.CustomErrMsg [Task Data]" to the query string brings information about the documents processed by each task. As far as I can see this results in empty values which is also visible when the query is executed within SQL - see image:
To be clear, I am looking for this information:
Am I missing something or...?
Oops! Yeah, that is definitely the wrong query. I was in a hurry and didn't verify that I provided the right query. Use this one instead!
--Query to show current task list statusSelect T.TaskName, Case when TI.TaskStatus = 1 then 'Waiting for host' when TI.TaskStatus = 2 then 'Starting up' when TI.TaskStatus = 3 then 'In process' when TI.TaskStatus = 4 then 'Retrying' when TI.TaskStatus = 5 then 'Suspended' when TI.TaskStatus = 6 then 'Cancelling' when TI.TaskStatus = 7 then 'OK' when TI.TaskStatus = 8 then 'Cancelled' when TI.TaskStatus = 9 then 'Failed' when TI.TaskStatus = 10 then 'Suspending' when TI.TaskStatus = 11 then 'Resuming'End AS [Task status],DATEADD(minute,DATEDIFF(minute,GETUTCDATE(),GETDATE()),TI.StartTime) AS [StartTime], DATEADD(minute,DATEDIFF(minute,GETUTCDATE(),GETDATE()),TI.EndTime) AS [EndTime],DATEDIFF(second, TI.StartTime,TI.EndTime) as [Duration(sec)],ISNULL(TI.CustomErrMsg,'') as [Error Message],ISNULL(H1.HostName, '') as [Executed From (Task Host)],ISNULL(U1.Username, '') as [Executed By],ISNULL(H2.HostName, '') as [Started From],ISNULL(U2.Username, '') as [Started By],ISNULL (' (' + substring((SELECT ( '; ' + P.Path + D.Filename ) From Documents D Join DocumentsInProjects DP on D.DocumentID = DP.DocumentID Join Projects P on DP.ProjectID = P.ProjectID Join TaskSelection TS on D.DocumentID = TS.DocumentID and P.ProjectID = TS.ProjectID and TS.TaskInstanceID = TI.TaskInstanceID FOR XML PATH( '' ) ), 3, 1000 ) +')','') as [Source Files],TI.TaskInstanceID From TaskInstances TI Join Tasks T On TI.TaskID = T.TaskID Left Join Hosts H1 On TI.HostID = H1.HostID Left Join Users U1 On TI.StatusUserID = U1.UserID Left Join Users U2 On TI.InitUserID = U2.UserID Left Join Hosts H2 On TI.InitHostID = H2.HostID --Where TI.TaskStatus < 7Order by (Case When TI.StartTime Is Null Then 3 End) desc, (Case When TI.EndTime Is Null Then 4 End) desc, (Case When NOT TI.StartTime Is Null then TI.EndTime end) desc
This is from KB solution ID S-052702
Thanks a lot Tim Webb. You're a friend :-). I got it working and the application is now ready to ship for final test at my customer. Being my first project involving SQL I was surprised to see how easy it was to get access to the database but one day soon I will have to stick my nose into SQL database structure and how to create queries - in order to understand that stuff better and get the information I need when working with databases.
Thought I would just share a screen shot of the final result taken from my own test environment. Once again - thanks a lot!
This is great news Jorn! This interface looks good.
Keep us posted on how this goes.
Thanks Tim! The final small flaws have been corrected, the application is now delivered, approved by the customer and in operation :-).
For those who might read this thread and think - why make such an application when the exact same information is available within the administration module?
I think that everyone using tasks in PDM sometimes experience that a task job is stalled in the system and hence blocking the execution of all pending tasks. Furthermore - in large installations with many users and limited task execution capacity, task jobs can pile up. In both cases users get impatient - they want to know when their job is done. In this particular case the system administrator got multiple queries every day from users about task jobs so he had to access the administration module each time - only to find out that the task engine was working fine but just being busy with many jobs.
With this tool all users and people without PDM (for example IT operations department) have quick and easy access to the task list and only when the system is stalled the administrator needs to take actions.
Thanks for expanding on your thoughts behind the design intent but I knew why there was value in your tool. I see it with a lot of customers just like you explained.
Good work Jorn! Keep up the great work!
I've also designed a similar web app for the same reasons. I'm working on making it a live updating page with websockets. That's a fun project in and of itself! I have it working on http, but I'm running into problems making it work on https. The fact that I'm trying to make this happen on IIS is even more challenging! Anyway, nice work! Here's a snip of what mine looks like:
Great solution Jeff! Looks nice. I also thought about going for a web based solution - but that was too big a step for me this time :-). What kind of issues are you facing with https?
Thanks Jorn. If I recall, specifically, the issue I was trying to overcome was creating the websocket connection to the websocket server via wss. Essentially, if I make the web page request via https, the websocket protocol must also be secure (wss). Apparently not a lot of people try to get this to work on IIS, so I'm pretty much learnign on the fly with this.
If our network guys would allow me to just use the http site so I can just use the unsecured websocket (ws) protocol, I'd already be live. But I have another site to design at the moment, so this one was back-burnered since I have this static prototype available for users to access temporarily.
I have a PDM Dashboard that EhCanadian (EhCanadian Consulting Inc. – SolidWorks Enterprise PDM API and Custom Development ) provided years ago. Works quite well.
Lee is one of our Partners and we market his dashboards as well.
He's the best!
Lee is a partner in everyone's heart.
Thank you for the plug and kind words, gentlemen.
Only possible if you query the vault's db.
Bluebyte.bizProductivity tools for SOLIDWORKS and PDM
Retrieving data ...