Ejemplo n.º 1
0
        public async Task <bool> Enqueue(string queueName, [FromBody] object message, string callback = null)
        {
            await QueueSender.SendAsync(queueName, new SimpleMessage
            {
                Message  = JsonConvert.SerializeObject(message),
                Callback = callback
            });

            return(true);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Post(string token)
        {
            var decrypted = TokenEncryption.Decrypt(token, DocumentsAPIConfiguration.APITokenKey);

            var callback = JsonConvert.DeserializeObject <CallbackModel>(decrypted);

            if (callback.FileIdentifier != null &&
                Request.ContentLength.HasValue &&
                Request.ContentLength.Value > 0
                )
            {
                SecurityContext.AssumeToken(callback.Token);

                var file = await FileStore.GetOneAsync(callback.FileIdentifier) ?? new FileModel(callback.FileIdentifier);

                file.Length   = Request.ContentLength.Value;
                file.MimeType = Request.ContentType ?? "application/octet-stream";
                file.Name     = "callback";
                file          = await FileContentsService.UploadEntireFileAsync(file, Request.Body);
            }

            await QueueSender.SendAsync(callback.Queue, JsonConvert.SerializeObject(callback));

            SuppressWrapper = true;
            return(Ok());
        }
Ejemplo n.º 3
0
        private void SendTestMessageToInboundQueue(object sender, RoutedEventArgs e)
        {
            var queueSender = new QueueSender(
                NamespaceTextBox.Text,
                InboundQueueNameTextBox.Text,
                InboundQueueSendSasTokenTextBox.Text);

            var systemProperties = new JObject
            {
                ["CorrelationId"] = Guid.NewGuid().ToString()
            };

            var body = new JObject
            {
                ["CallType"] = "Command",
                ["Uri"]      = "/api/component/Office.CombinedCeilingLights/status"
            };

            var content = new JObject
            {
                ["action"] = "nextState"
            };

            body["Content"] = content;

            Task.Run(async() => await queueSender.SendAsync(systemProperties, body));
        }
Ejemplo n.º 4
0
        private void SendTestMessageToOutboundQueue(object sender, RoutedEventArgs e)
        {
            var queueSender = new QueueSender(
                NamespaceTextBox.Text,
                OutboundQueueNameTextBox.Text,
                OutboundQueueSendSasTokenTextBox.Text);

            var properties = new JsonObject();
            var body       = new JsonObject();

            Task.Run(async() => await queueSender.SendAsync(properties, body));
        }
Ejemplo n.º 5
0
        private void SendTestMessageToInboundQueue(object sender, RoutedEventArgs e)
        {
            var queueSender = new QueueSender(
                NamespaceTextBox.Text,
                InboundQueueNameTextBox.Text,
                InboundQueueSendSasTokenTextBox.Text);

            var systemProperties = new JsonObject();

            systemProperties.SetNamedValue("CorrelationId", JsonValue.CreateStringValue(Guid.NewGuid().ToString()));

            var body = new JsonObject();

            body.SetNamedValue("CallType", JsonValue.CreateStringValue("Command"));
            body.SetNamedValue("Uri", JsonValue.CreateStringValue("/api/component/Office.CombinedCeilingLights/status"));

            var content = new JsonObject();

            content.SetNamedValue("action", JsonValue.CreateStringValue("nextState"));

            body.SetNamedValue("Content", content);

            Task.Run(async() => await queueSender.SendAsync(systemProperties, body));
        }