コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create readingsDTO
            ReadingsPost readingsDTO = new ReadingsPost();

            readingsDTO.deviceMeasurementID = 12314;
            readingsDTO.smartboxSN          = "A345346";
            readingsDTO.priority            = 5;
            readingsDTO.readings.Add(10);
            readingsDTO.readings.Add(12);
            readingsDTO.readings.Add(13);
            readingsDTO.breakerStatusID           = 2;
            readingsDTO.periodicalTaskID          = 10;
            readingsDTO.meterSN                   = "a1489021";
            readingsDTO.dateUTCAcquired           = 2318972401;
            readingsDTO.dateUTCStoredInGateway    = 12489210347;
            readingsDTO.meterStatusFlags          = 7863479;
            readingsDTO.meterStatusAnomaliesFlags = 0986290457;
            readingsDTO.meterCommErrorTypeID      = 30;
            readingsDTO.isSynchronized            = 2;

            //Try to POST readings to server
            try
            {
                var response = client.Post <ReadingsPostResponse>("/readings", readingsDTO);
                label1.Text = response.responsesMsg;
            }
            catch (WebServiceException webEx)
            {
                //Get error Message
                label1.Text = webEx.GetStatus().ToString() + ": " + webEx.StatusDescription;
            }
        }
コード例 #2
0
        [ResponseHeaderAddition]    //Response header addition profile
        public object Post(ReadingsPost readings)
        {
            ReadingsPostResponse res = new ReadingsPostResponse {
                responsesMsg = "a"
            };

            //Check if the response status code is correct to store info in DB and send back response
            if (Response.StatusCode == 200)
            {
                Info.hmac        = readings.smartboxSN;
                res.responsesMsg = readings.readings[0].ToString();
            }
            return(res);
        }