Example #1
0
        public async void Get([FromForm] string text, [FromForm] string response_url)
        {
            var    client = new HttpClient();
            string hostid = text;

            XMLBilling billing = new XMLBilling();
            string     xmlData = await BillingSchemeReader.ReadDataAsync(hostid, billing);

            if (xmlData.Contains("billing"))
            {
                Billing bs = await BillingSchemeReader.ReadXML(xmlData);

                Result res = new Result(hostid, billing);
                res.PrepareSlackResponse(bs);

                await client.PostAsync(response_url, new StringContent(
                                           JsonConvert.SerializeObject(res),
                                           Encoding.UTF8,
                                           "application/json"));
            }
            else
            {
                Result res = new Result
                {
                    text = xmlData
                };

                await client.PostAsync(response_url, new StringContent(
                                           JsonConvert.SerializeObject(res),
                                           Encoding.UTF8,
                                           "application/json"));
            }
        }
Example #2
0
        public async Task <string> GetQ([FromQuery] string hostid)
        {
            XMLBilling billing = new XMLBilling();
            string     xmlData = await BillingSchemeReader.ReadDataAsync(hostid, billing);

            if (xmlData.Contains("billing"))
            {
                Billing bs = await BillingSchemeReader.ReadXML(xmlData);

                Result res = new Result(hostid, billing);
                res.PrepareSlackResponse(bs);

                return(JsonConvert.SerializeObject(res));
            }
            else
            {
                return(xmlData);
            }
        }