I have been taking some of the code from the VB sample and adapting it for use in my C# code.
I have quite a few questions.
First, there is code in the VB sample that inspects js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].Events and if it is set determines how many "pulls" there were, and the PullTime for each.
In my tests, "Events" has always been null. Is it relevant to faxes? In what cases would we want to look at this?
Second, I am trying to figure out the best way to get key dates from the API, notably:
- The time that the job request was received by Easylink
- The time that Easylink started processing to attempt the first Fax
- The time that Easylink started processing for the most recent Fax attempt
- The time that the Fax was completed, either successfully or in error
My request code looks like this for the request. I am requesting the status on a single job at a time in the API.
PremiereConnect.JobDeliveryStatusResult js = new PremiereConnect.JobDeliveryStatusResult();
js = PC.JobDeliveryStatus(JobStatus_Request);
I get somewhat confusing data back. For (1), I tried to use js.Status.SubmissionTime and js.Status.CompletionTime. However these two dates are always the same. I think that these are probably the time I sent the JobDeliveryStatus API request over, and are not what I want!
For (2) and (4) I am using js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].FirstAttemptTime and js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].LastAttemptTime
where currDelivery is always set to zero in my code. That seems to work well, and the dates seem to be Central TZ dates, eg. firstAttemptTime at 5/10/2011 23:14:50, lastAttemptTime at 5/10/2011 23:16:05.
Question - is there ever a case where I need to use an index other than zero for the currDelivery variable? The VB sample iterates though a number of structures and I am not sure when or why we'd ever see more than one of any of these items. Can you help me understand when there would be more than one entry for each of the following data structures during a JobDeliveryStatus?
- JobDeliveryStatus
- JobData
- DeliveryGroup
- DeliveryDetail
I am not sure what to use for (3 - the time the most recent attempt started). When we ask for the status on a Fax that is in the process of being retried, will the LastAttemptTime reflect what we need?
Once a job is finished, I see js.JobDeliveryStatus[0].JobData[0].JobState[0] == "Delivered" and js.JobDeliveryStatus[0].JobData[0].JobState.Length is > 1. When I look at js.JobDeliveryStatus[0].JobData[0].JobState[n], I see that I get 2 or 3 states for each request, e.g. state[0] is Delivered, state[1] is Posted.
Question - is there a timestamp or any additional information associated with each state? And are the states in reverse chronological order, eg state[0] is always the current state? Will there always be state [0], even for a newly submitted job? In my testing I always see a state there, such as "Delivering" or "Delivered". I am not sure why I might need to look at the subsequent status entries or what they would tell me.
In summary, below are the key variables I am referencing. RIght now currDelivery is always set to 0 in my code.
Please let me know if my field interpretation is correct; if there is anything wrong with what I am doing; and if there are possible exception conditions I might want to be aware of.
js.JobDeliveryStatus[0].JobId.MRN // the job number
js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].Destination.Value // the fax number that was used during the tranmission
js.JobDeliveryStatus[0].JobData[0].CustomerReference.Value // our supplied cref value
js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].Attempts // number of attempts made, 0 if status is Delivering
js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].FirstAttemptTime // First attempt. 1/1/0001 00:00:00 if the job has not yet started
js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].LastAttemptTime // // Last attempt or time that job finished transmitting. 1/1/0001 00:00:00 if the job has not yet started
js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].State.code // e.g. 7 for Sent, 4 for Error, 1 for Pending
js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].State.Value.ToString() // the string text matching the State.code
js.JobDeliveryStatus[0].JobData[0].DeliveryGroup[0].DeliveryDetail[currDelivery].State.gammacode; // the all important Gamma code