Esempio n. 1
0
        /// <summary>
        /// Serialises the object to XML.
        /// </summary>
        /// <returns></returns>
        public byte[] ToXmlBytes()
        {
            // It is an error if parameters are defined for Cancel or GetStatus request

            object proxy = null;

            switch (Operation)
            {
            case TaskOperationType.Submit:

                // Creating the proxy object
                var proxySubmit = new XsdNs.SubmitType();

                // Nothing to add to proxy here!

                // Adding the fields common with "update"
                PopulateTaskingRequestProxy(proxySubmit);
                proxy = proxySubmit;
                break;

            case TaskOperationType.Update:

                // Creating the proxy object
                var proxyUpdate = new XsdNs.UpdateType()
                {
                    targetTask = TaskId
                };

                // Adding the fields common with "submit"
                PopulateTaskingRequestProxy(proxyUpdate);
                proxy = proxyUpdate;
                break;

            case TaskOperationType.GetStatus:

                proxy = CreateGetStatusProxy();
                break;

            case TaskOperationType.Cancel:

                proxy = CreateCancelProxy();
                break;

            default:
                throw new NotSupportedException("Unsupported task operation " + Operation.ToString());
            }

            try
            {
                // Serialising
                return(XNeut.Helper.ToXmlBytes(proxy));
            }
            catch (InvalidOperationException e)
            {
                throw new XNeut.InvalidMessageException("XML serialisation failed", e);
            }
        }
Esempio n. 2
0
        private byte[] Serialise(XsdNs.ParameterDataType proxy)
        {
            // Using "submit" request as the wrapper
            var xmlDocProxy = new XsdNs.SubmitType()
            {
                service           = "SPS",
                version           = "2.0.0",
                procedure         = "my-procedure",
                taskingParameters = new XsdNs.TaskingRequestTypeTaskingParameters()
                {
                    ParameterData = proxy
                }
            };

            return(XNeut.Helper.ToXmlBytes(xmlDocProxy));
        }
Esempio n. 3
0
        private void ReadSubmitXml(byte[] xmlBytes)
        {
            XsdNs.SubmitType proxy = null;

            try
            {
                // Deserialising
                proxy = (XsdNs.SubmitType)XNeut.Helper.DeserialiseFromXml(typeof(XsdNs.SubmitType), xmlBytes);
            }
            catch (InvalidOperationException e)
            {
                throw new XNeut.InvalidMessageException("Failed to deserialise submit task request from XML", e);
            }

            ReadTaskingRequestItemsFromProxy(proxy);

            // Nothing else to read here
        }