Пример #1
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "HttpTriggerMovieMaker")] HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // Get request body
            var data = await req.Content.ReadAsStringAsync();

            log.Info(data);

            var response = data.Split('&').Select(s => s.Split(new[] { '=' }));
            Dictionary <string, string> keyVal = new Dictionary <string, string>();

            foreach (var item in response)
            {
                keyVal.Add(item[0], item[1]);
            }

            string channelId  = string.Empty;
            string message_ts = string.Empty;

            if (keyVal.ContainsKey("timestamp"))
            {
                message_ts = keyVal["timestamp"];
            }
            if (keyVal.ContainsKey("channel_id"))
            {
                channelId = keyVal["channel_id"];
            }

            if (!string.IsNullOrEmpty(message_ts) && !string.IsNullOrEmpty(channelId))
            {
                var slackclient = new SlackClient();
                var message     = await slackclient.getMessages(channelId, message_ts);

                var sbQueueClient = new SBQueueClient();
                await sbQueueClient.EnQueueMessage(message);

                //var deQueuedMessage= await sbQueueClient.DeQueueMessage();

                return(req.CreateResponse(HttpStatusCode.OK));
            }
            return(req.CreateResponse(HttpStatusCode.BadRequest));
        }