2 Replies Latest reply: May 5, 2016 8:36 AM by Anton Antonenko RSS

    Create an EDXtask with partial reaload into a specific category

      I have no publisher. I have a document with 2 tasks, one for FullReload and another one for Partial. I have created the first one by QMC, and the second with API, but I am not able to set the right category for the partial reload task. It is set to "Default". Do you know anothe way to create 2 tasks without publisher?

       

      This is my code

       

      StringBuilder response = new StringBuilder();

                  try

                  {

                      // Initiate backend client

                      IQMS apiClient = new QMSClient();

       

                      // Get a time limited service key

                      ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();

       

                      // Get QlikView Server

                      ServiceInfo qds = apiClient.GetServices(ServiceTypes.QlikViewServer).FirstOrDefault();

                      DocumentNode document = apiClient.GetUserDocuments(qds.ID).Where(x => x.Name.Equals(documentName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); //Get first source document for this example 

       

                      DocumentTask documentTask = new DocumentTask();

                      documentTask.QDSID = qds.ID;

                      documentTask.Document = document;

                      documentTask.Reload = new DocumentTask.TaskReload();

                      documentTask.Reload.Mode = TaskReloadMode.Partial;

       

                      documentTask.DocumentInfo = new DocumentTask.TaskDocumentInfo();

                      documentTask.DocumentInfo.Category = "Category";

       

                      documentTask.General = new DocumentTask.TaskGeneral();

                      documentTask.General.Enabled = true;

                      documentTask.General.TaskName = "Partial Reload of " + documentName;

                      documentTask.General.TaskDescription = "Creating a task via QMS API";

                      documentTask.Scope = DocumentTaskScope.General;

       

                      Guid triggerID = Guid.NewGuid();

                      // Create a list of trigger and add the scheduled trigger

                      List<Trigger> List_Trigger = new List<Trigger>();

                     

                      if(string.Equals(triggerType,"edx"))

                      {

                          // Create an external event trigger                   

                          ExternalEventTrigger evt = new ExternalEventTrigger();

                          evt.ID = triggerID;

                          evt.Type = TaskTriggerType.ExternalEventTrigger;

                         

                          evt.Enabled = true;                   

       

                          // add the external event trigger                   

                          List_Trigger.Add(evt);

                      }                   

                      else

                      {

                          // Create a scheduled trigger               

                          ScheduleTrigger st = new ScheduleTrigger();

                          st.ID = triggerID;

                          st.Type = TaskTriggerType.OnceTrigger;

                          st.Enabled = true;

                          st.StartAt = DateTime.Now;

                         

                          // Add the scheduled trigger

                          List_Trigger.Add(st);

                      }

                         

       

                      documentTask.Triggering = new DocumentTask.TaskTriggering();

                      documentTask.Triggering.Triggers = List_Trigger;                             

                     

                      documentTask.Triggering.TaskDependencies = new List<TaskInfo>();

                      documentTask.Triggering.ExecutionAttempts = 1;

                      documentTask.Triggering.ExecutionTimeout = 0;

       

                      // Scope plays an important role

                      documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.Triggering;

       

                      //Create task          

                      apiClient.SaveDocumentTask(documentTask);

       

                      // Scrive nel file di log

                      response.AppendLine("Creato il task " + documentTask.General.TaskName);

                  }

                  catch (System.Exception ex)

                  {

                      response.AppendLine(ex.Message);

                  }

                  return response.ToString();