Example #1
0
        public async Task <AvrCommandExecutionStatus> ExecuteAsync()
        {
            UriBuilder bob = new UriBuilder();

            bob.Host = mAvrDevice.DeviceDescribtor.Address.Host;
            bob.Path = sCommandPath;
            AvrHttpPostClient httpClient = new AvrHttpPostClient();

            httpClient.Uri       = bob.Uri;
            httpClient.XmlString = XmlString;
            AvrHttpResponse response = await httpClient.SendHttpRequest();

            StringReader reader = new StringReader(response.ResponseString);
            XmlDocument  doc    = new XmlDocument();

            try
            {
                doc.Load(reader);
            }
            catch (Exception e)
            {
                return(new AvrCommandExecutionStatus(response.Status, AvrCommandExecutionStatusCode.BAD_RESPONSE));
            }

            return(new AvrCommandExecutionStatus(response.Status, CommandStrategy.ProcessXmlResponse(mAvrDevice, doc)));
        }
Example #2
0
        public async Task <AvrCommandExecutionStatus> ExecuteAsync()
        {
            UriBuilder bob = new UriBuilder();

            bob.Host = mAvrDevice.DeviceDescribtor.Address.Host;
            bob.Path = CommandPath;
            AvrHttpGetClient httpClient = new AvrHttpGetClient();

            httpClient.Uri = bob.Uri;
            AvrHttpResponse response = await httpClient.SendHttpRequest();

            if (response.Status == HttpStatusCode.OK)
            {
                return(new AvrCommandExecutionStatus(response.Status, AvrCommandExecutionStatusCode.OK));
            }
            else
            {
                return(new AvrCommandExecutionStatus(response.Status, AvrCommandExecutionStatusCode.BAD_RESPONSE));
            }
        }