Пример #1
0
 public Entity.BaseResponse <bool> Manage()
 {
     Entity.BaseResponse <bool> response = new Entity.BaseResponse <bool>(true);
     try
     {
         using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
         {
             string strRequest = reader.ReadToEndAsync().Result;
             Entity.IOTAlertMessage objRequest = Newtonsoft.Json.JsonConvert.DeserializeObject <Entity.IOTAlertMessage>(strRequest);
             if (!string.IsNullOrWhiteSpace(strRequest))
             {
                 XmlSerializer xsSubmit = new XmlSerializer(typeof(Entity.IOTAlertMessage));
                 string        xml      = "";
                 using (var sww = new StringWriter())
                 {
                     using (XmlWriter writer = XmlWriter.Create(sww))
                     {
                         xsSubmit.Serialize(writer, objRequest);
                         xml = sww.ToString();
                     }
                 }
                 _ruleService.ManageWebHook(xml);
                 response.IsSuccess = true;
             }
         }
     }
     catch (Exception ex)
     {
         return(new Entity.BaseResponse <bool>(false, ex.Message));
     }
     return(response);
 }
Пример #2
0
        public Entity.BaseResponse <bool> Manage([FromBody] Entity.IOTAlertMessage request = null)
        {
            Entity.BaseResponse <bool> response = new Entity.BaseResponse <bool>(true);
            try
            {
                if (request == null)
                {
                    return(response);
                }

                XmlSerializer xsSubmit = new XmlSerializer(typeof(Entity.IOTAlertMessage));
                string        xml      = "";
                using (var sww = new StringWriter())
                {
                    using (XmlWriter writer = XmlWriter.Create(sww))
                    {
                        xsSubmit.Serialize(writer, request);
                        xml = sww.ToString(); // Your XML
                    }
                }
                _ruleService.ManageWebHook(xml);
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                return(new Entity.BaseResponse <bool>(false, ex.Message));
            }
            return(response);
        }