Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I can't seem to be able to set the name on the new task, task gets created with default name.
Here's my code, any ideas are welcome.
Dim QMSClient As New QMSBackendClient()
Dim QvsId As Guid
'Gets the request Key when the page is loaded
ServiceKeyClientMessageInspector.ServiceKey = QMSClient.GetTimeLimitedServiceKey()
'Fetching the ID of the first QVS resource
Dim qvsServices As QVPublisher.QMSBackendService.ServiceInfo()
qvsServices = QMSClient.GetServices(ServiceTypes.QlikViewDistributionService)
QvsId = New Guid(qvsServices(0).ID.ToString())
Dim qvDocs As QVPublisher.QMSBackendService.DocumentNode()
qvDocs = QMSClient.GetSourceDocuments(QvsId)
Dim qvDocTasks As New QVPublisher.QMSBackendService.DocumentTask
qvDocTasks.QDSID = QvsId
qvDocTasks.Document = qvDocs(1)
qvDocTasks.DocumentInfo = New QVPublisher.QMSBackendService.DocumentTask.TaskDocumentInfo
qvDocTasks.Distribute = New QVPublisher.QMSBackendService.DocumentTask.TaskDistribute
qvDocTasks.Reduce = New QVPublisher.QMSBackendService.DocumentTask.TaskReduce
qvDocTasks.Reload = New QVPublisher.QMSBackendService.DocumentTask.TaskReload
qvDocTasks.General = New QVPublisher.QMSBackendService.DocumentTask.TaskGeneral
qvDocTasks.General.TaskName = "API TEST"
qvDocTasks.General.Enabled = False
qvDocTasks.Triggering = New QVPublisher.QMSBackendService.DocumentTask.TaskTriggering
QMSClient.SaveDocumentTask(qvDocTasks)
Hi,
I have both the server and publisher. I was able to set the properties after I changed the document Task scope to "ALL". However I am not sure why it does not work when the scope is General.
Still looking into this.
Regards,
Samir
Yes I identified this. Thanks for the quick response
Regards,
Samir
Hi,
I have one more question. When I add the scope DocumentTaskScope.Triggering it becomes mandatory to set the properties of Task dependency. Is there any work around for this ?
I am using following code to trigger the task but it is not working properly -
Guid triggerID = new Guid("6eaf55f8-6737-48b5-b4d5-85f8a235ccb3");
//Guid triggerID = Guid.NewGuid();
// Create a scheduled trigger
ScheduleTrigger st = new ScheduleTrigger();
st.ID = triggerID;
st.Type = TaskTriggerType.OnceTrigger;
st.Enabled = true;
st.StartAt = DateTime.Now;
// Create a list of trigger and add the scheduled trigger
List<Trigger> List_Trigger = new List<Trigger>();
List_Trigger.Add(st);
/*
Trigger t = new Trigger();
List<Trigger> List_Trigger = new List<Trigger>();
t.Type = TaskTriggerType.OnceTrigger;
t.Enabled = true;
t.ID = triggerID;
List_Trigger.Add(t);*/
documentTask.Triggering = new DocumentTask.TaskTriggering();
documentTask.Triggering.Triggers = List_Trigger;
// Create list for task dependencies
List <TaskInfo> taskdep = new List<TaskInfo>();
TaskInfo tf = new TaskInfo();
tf.Enabled = false;
//tf.QDSID = qdsGuid;
tf.ID = Guid.NewGuid();
tf.Type = TaskType.DocumentTask;
taskdep.Add(tf);
documentTask.Triggering.TaskDependencies = taskdep;
documentTask.Triggering.ExecutionAttempts = 1;
documentTask.Triggering.ExecutionTimeout = 0;
// Scope plays an important role
documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.Triggering;
//documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.DocumentInfo;
//documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.DocumentInfo | DocumentTaskScope.Triggering;
//Create task
apiClient.SaveDocumentTask(documentTask);
The task is getting corrupted and QEMC gives an error.
Regards,
Samir
Did you try to pass an empty list?
Like this:
documentTask.Triggering.TaskDependencies = new List<TaskInfo>();
What error do you get in QEMC?
It is working after passing the empty list .
Earlier in QEMC the task was getting created with an empty trigger. When I tried to edit it QEMC gave an error saying that it could not load all the tasks.
Hi Bas,
Can you help me with the code to distribute the task ? I am using following code -
List<ServiceInfo> QVserviceList = apiClient.GetServices(ServiceTypes.QlikViewServer);
List<TaskDistributionEntry> List_TaskDist = new List<TaskDistributionEntry>();
List<DirectoryServiceObject> List_Dir = new List<DirectoryServiceObject>();
DirectoryServiceObject DSO = new DirectoryServiceObject();
DSO.Type = DirectoryServiceObjectType.Authenticated;
//DSO.Name = "Root Folder";
List_Dir.Add(DSO);
TaskDistributionEntry TDE = new TaskDistributionEntry();
TDE.Destination = new TaskDistributionDestination();
TDE.Destination.QlikViewServer = new TaskDistributionDestination.TaskDistributionDestinationQlikViewServer();
TDE.Destination.QlikViewServer.ID = QVserviceList[0].ID;
TDE.Destination.QlikViewServer.Name = QVserviceList[0].Name;
TDE.Destination.QlikViewServer.Mount = "Root Folder";
TDE.Destination.Type = TaskDistributionDestinationType.QlikViewServer;
TDE.Recipients = List_Dir;
List_TaskDist.Add(TDE);
documentTask.Distribute = new DocumentTask.TaskDistribute();
documentTask.Distribute.Static = new DocumentTask.TaskDistribute.TaskDistributeStatic();
documentTask.Distribute.Static.DistributionEntries = List_TaskDist;
documentTask.Distribute.Dynamic = new DocumentTask.TaskDistribute.TaskDistributeDynamic();
documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.DocumentInfo | DocumentTaskScope.Triggering | DocumentTaskScope.Reload | DocumentTaskScope.Reduce | DocumentTaskScope.Distribute;
However I am getting error -
"There was an error while trying to serialize parameter http://ws.qliktech.com/QMS/11/:documentTask. The InnerException message was 'Enum value '0' is invalid for type 'MyTestApplication.QMSAPI.UserIdentityValueType' and cannot be serialized. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.'. Please see InnerException for more details."
Thanks,
Samir
The exception has probably something to do with the property 'IdentityType' belonging to the the 'TaskDistributeDynamic' object.
Try to set some default values on the TaskDistributeDynamic object:
/// <summary>
/// Get default object for TaskDistributeDynamic
/// </summary>
/// <returns>DocumentTask.TaskDistribute.TaskDistributeDynamic</returns>
private DocumentTask.TaskDistribute.TaskDistributeDynamic GetTaskDistributeDynamic()
{
DocumentTask.TaskDistribute.TaskDistributeDynamic taskDistributeDynamic = new DocumentTask.TaskDistribute.TaskDistributeDynamic();
taskDistributeDynamic.Destinations = new List<TaskDistributionDestination>();
taskDistributeDynamic.FieldName = string.Empty;
taskDistributeDynamic.IdentityType = UserIdentityValueType.DisplayName;
return taskDistributeDynamic;
}
The QMS API uses the scope to see if it has to set values (for example) for 'reload' or 'distribute'.
As far as I know, if you define a task scope QMS API wants that every property for the objects in that task scope are set.
Otherwise it will give an error. Even if you don't use (in your case TaskDistributeDynamic) for setting up the task.
Set some default values and it will work. Just create a task in Q(E)MC and see what default values are set.
The 'TaskDistributeDynamic' object refers to the tab 'Distribute' -> 'Loop Field in Document' that you see in Q(E)MC when you are creating a task.
Hope this helps!
Yup. I defined the following property -
documentTask.Distribute.Dynamic.IdentityType = UserIdentityValueType.DisplayName;
and it is working fine now.
Thanks,
Samir
Hi,
I am trying to find an api which gives me list of existing triggers for the given task_id. Are you aware of any such api ? I am not able to find it in QMS API doc.
Thanks,
Samir.
Hi Samir,
Use the function 'GetDocumentTask' and pass your task_id as a parameter and a DocumentTaskScope.
Use 'DocumentTaskScope.All' to get all data that belong to the task.
The DocumentTask object has a member 'Triggering' which results in a object DocumentTask.TaskTriggering.
This object has a member 'Triggers', which is a list of triggers.
Try to cast a trigger in the list to the correct trigger type, for example ScheduleTrigger, ExternalEventTrigger.
You could use the 'Type' property of the trigger to check to which trigger object you should cast.
Good luck!