Exemplo n.º 1
0
 private void AssignSingleStatusReport(TaskStatusReport oneStatusReport)
 {
     StatusReports = new ReadOnlyCollection <TaskStatusReport>(
         new List <TaskStatusReport>()
     {
         oneStatusReport
     }
         );
 }
Exemplo n.º 2
0
        private XsdNs.SubmitResponseType ReadSubmitXml(byte[] xmlBytes)
        {
            var proxy = (XsdNs.SubmitResponseType)XNeut.Helper.DeserialiseFromXml(typeof(XsdNs.SubmitResponseType), xmlBytes);

            // Reading status report
            var oneStatusReport = new TaskStatusReport(proxy.result.StatusReport);

            AssignSingleStatusReport(oneStatusReport);

            return(proxy);
        }
Exemplo n.º 3
0
        // Listen to status updates from the server
        public void ListenToStatusUpdates()
        {
            // If your communication protocol is capable of publish-subscribe communication
            // (such as AMQP or MQTT), you can listen to status information instead of
            // requiring the client to request for status repeatedly.

            var messageXml   = WaitForStatus();
            var statusReport = new MsgMeas.TaskStatusReport(messageXml);

            var statusToPrint = string.Format("Task {0}: {1}", statusReport.TaskId, statusReport.TaskStatusCode.ToString());

            Console.WriteLine(statusToPrint);
        }
Exemplo n.º 4
0
        private XsdNs.UpdateResponseType ReadUpdateXml(byte[] xmlBytes)
        {
            var proxy = (XsdNs.UpdateResponseType)XNeut.Helper.DeserialiseFromXml(typeof(XsdNs.UpdateResponseType), xmlBytes);

            // Reading status report
            var oneStatusReport = new TaskStatusReport(proxy.result.StatusReport);

            AssignSingleStatusReport(oneStatusReport);

            // Intentionally, not processing the "targetTask" field because it is
            // almost redundant to the task field of TaskStatusReport. However, the
            // targetTask field is obligatory for an update response per the XML schema,
            // so it must be assigned in XML document creation.

            return(proxy);
        }
Exemplo n.º 5
0
        private XsdNs.GetStatusResponseType ReadGetStatusXml(byte[] xmlBytes)
        {
            var proxy = (XsdNs.GetStatusResponseType)XNeut.Helper.DeserialiseFromXml(typeof(XsdNs.GetStatusResponseType), xmlBytes);

            // Reading status reports
            var statusReportsTemp = new List <TaskStatusReport>();

            if (proxy.status != null)
            {
                foreach (var s in proxy.status)
                {
                    var currentStatRep = new TaskStatusReport(s.StatusReport);
                    statusReportsTemp.Add(currentStatRep);
                }
            }

            StatusReports = new ReadOnlyCollection <TaskStatusReport>(statusReportsTemp);

            return(proxy);
        }
Exemplo n.º 6
0
        private MsgMeas.TaskResponse CreateFailureResponse(MsgMeas.TaskOperationType operation)
        {
            var statusReport = new MsgMeas.TaskStatusReport("?", "?");

            MsgMeas.TaskResponse retval = null;

            // Creating a response object
            switch (operation)
            {
            case MsgMeas.TaskOperationType.Submit:
                retval = MsgMeas.TaskResponse.CreateSubmitResponse(statusReport);
                break;

            case MsgMeas.TaskOperationType.Update:
                retval = MsgMeas.TaskResponse.CreateUpdateResponse(statusReport);
                break;

            case MsgMeas.TaskOperationType.GetStatus:
                retval = MsgMeas.TaskResponse.CreateGetStatusResponse(
                    new SysColl.List <MsgMeas.TaskStatusReport> {
                    statusReport
                }
                    );
                break;

            case MsgMeas.TaskOperationType.Cancel:
                retval = MsgMeas.TaskResponse.CreateCancelResponse(statusReport);
                break;

            default:
                throw new InvalidOperationException("Unexpected operation " + operation.ToString());
            }

            // This indicates the server did not understand the request
            retval.RequestResult = MsgMeas.RequestResultType.BadRequest;
            return(retval);
        }
Exemplo n.º 7
0
        private MsgMeas.TaskStatusReport GetStatusReport()
        {
            var taskingParams = new MsgMeas.Item_DataRecord
            {
                { "myparam", new MsgMeas.Item_Category("myctg") }
            };

            var statusReport = new MsgMeas.TaskStatusReport(CurrentTaskId, MySupportedProcedure)
            {
                EstimatedTimeOfCompletion = DateTime.Now.AddMinutes(4).ToUniversalTime(),
                PercentCompletion         = 3.2,
                RequestStatus             = MsgMeas.TaskingRequestStatusCodeType.Accepted,
                StatusMessages            = new SysColl.List <string>()
                {
                    "Creation was successful", "Start was successful"
                },

                TaskStatusCode    = CurrentTaskStatus,
                UpdateTime        = DateTime.Now.ToUniversalTime(),
                TaskingParameters = taskingParams
            };

            return(statusReport);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Creates a response to a cancel request.
 /// </summary>
 /// <param name="statRep">Status report.</param>
 /// <returns>Response object.</returns>
 public static TaskResponse CreateCancelResponse(TaskStatusReport statRep)
 {
     return(new TaskResponse(TaskOperationType.Cancel, statRep));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a response to an update request.
 /// </summary>
 /// <param name="statRep">Status report.</param>
 /// <returns>Response object.</returns>
 public static TaskResponse CreateUpdateResponse(TaskStatusReport statRep)
 {
     return(new TaskResponse(TaskOperationType.Update, statRep));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a response to a submit request.
 /// </summary>
 /// <param name="statRep">Status report.</param>
 /// <returns>Response object.</returns>
 public static TaskResponse CreateSubmitResponse(TaskStatusReport statRep)
 {
     return(new TaskResponse(TaskOperationType.Submit, statRep));
 }
Exemplo n.º 11
0
 private TaskResponse(TaskOperationType operation, TaskStatusReport statRep)
     : this(operation, new List <TaskStatusReport>() { statRep })
 {
     // Empty ctor body (another ctor called)
 }