4 Replies Latest reply: Apr 20, 2015 6:33 AM by Bas Knol RSS

    Get last execution using QMS API

    Leandro Abad

      Hi!

       

      I want to get the last execution of a task. How can I do it? I have a list of TaskInfo's object andi want to check the last execution of all the tasks even though it executed before the execution of the app.

       

      Im a little bit lost with it, which class should i use?

       

      PD: I am programming the app in C#

        • Re: Get last execution using QMS API

          Hi,

           

          I'm also looking to know how to extract the last execution of a task. Have you found the solution? It will be really helpfull if you can share it with me.

           

          Many thanks

            • Re: Get last execution using QMS API
              Bas Knol

              Hi,

               

              If you have a list of TaskInfo's, you can use the ID property of the TaskInfo object to get the taskId (guid).

              Use this guid as taskId for the GetTaskStatus method to get the TaskStatus object.

               

              The FinishedTime property (see line below) should return the last reload time of a task.

              Console.WriteLine(taskStatus.Extended.FinishedTime);
              

               

              Code example from QMS API documentation:

              using System;
              using System.Collections.Generic;
              using System.Linq;
              using QMSAPI;
              
              class Program
              {
                static void Main(string[] args)
                {
                     try
                     {
                          // create a QMS API client
                          IQMS apiClient = new QMSClient();
              
                          //retrieve a time limited service key
                          ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();
              
                          Guid taskId = new Guid("28a4fae4-8e75-4681-8ddc-751b7664a025"); //A known task id.
                          TaskStatus taskStatus = apiClient.GetTaskStatus(taskId, TaskStatusScope.Extended); // A service call.
                          Console.WriteLine(taskStatus.Extended.TaskSummary); // Print the resulting task summary.
                          Console.WriteLine(taskStatus.Extended.FinishedTime); // Print the resulting task finished time.
                     }
                     catch (Exception ex)
                     {
                          Console.WriteLine("An exception occurred: " + ex.Message);
                     }
              
                     // wait for user to press any key
                     Console.ReadLine();
                }
              }
              
              

               

              I hope this will get you started!

               

              Bas Knol

              The Implementation Group

                • Re: Get last execution using QMS API

                  Many thanks Bas, very useful your information. I have another discussion opened called: Create On Multiple Events Completed trigger using QMS API. Do you have information about it?

                   

                  We are trying to create all the different triggers that is possible to create with QMC and reaply it using the QMS API. We are able to create all triggers possibles like Once Trigger, Hourly Trigger... but we have problems with On Multiple Events Completed trigger. We are using MultipleEventTrigger method and filling all the information and the task is created but when we check on the QMC the Task completed dependencies is empty. It seems that the step of providing the task dependencies we do something wrong. Can someone help with that issue on provide some example?

                   

                  Our code:

                  ...

                  MultipleEventTrigger st = new MultipleEventTrigger();
                  st.ID = triggerID;
                  st.Type = TaskTriggerType.AndTrigger;
                  List<Trigger> trigger = new List<Trigger>();
                  st.TimeConstraint = 360;
                  st.Enabled = true;
                  st.SubTriggers = new List<Trigger>                       
                        {
                                       
                            taskTrigger[0]
                                        
                        }.ToArray();             
                    ...


                  Many thanks