Beispiel #1
0
        public async Task <ActionResult> ReadStorageAsync()
        {
            await _componentRegistry.AddOrUpdateAsync(
                new ComponentModel(
                    "cid",
                    "DATA_ANALYSER",
                    "hcaneel",
                    "upda",
                    new JObject()
                    ));

            var component = await _componentRegistry.GetComponentByIdAsync("cid");

            return(Ok(new { comp = component }));
        }
Beispiel #2
0
        public async Task <SubscribedComponentResultModel> SubscribeComponentAsync(
            ComponentModel componentRegistrationModel)
        {
            try
            {
                await _componentRegistry.AddOrUpdateAsync(componentRegistrationModel);

                return(SubscribedComponentResultModel.Successful());
            }
            catch (Exception e)
            {
                string error = $"Subscription failed due to: {e.Message}";
                _logger.TrackError("SubscribeComponent", error, new { componentRegistrationModel, exception = e });
                return(SubscribedComponentResultModel.Failed(error));
            }
        }
Beispiel #3
0
        private async Task InsertComponent(string componentId)
        {
            IEnumerable <string> assert(ComponentModel a, ComponentModel b)
            {
                yield return(AssertProperty("Type", (r) => r.ComponentType, a, b));

                yield return(AssertProperty("Input channel", (r) => r.InputChannelName, a, b));

                yield return(AssertProperty("Update channel", (r) => r.UpdateChannelName, a, b));

                yield return(AssertProperty("Attribute count", (r) => r.Attributes.Count, a, b));
            }

            _logger.LogInformation("Starting testing storage api");


            var componentRegistrationModel = new ComponentModel(
                componentId,
                "DATA_ANALYSER",
                "channel.input",
                "channel.update",
                JObject.FromObject(new
            {
                AnalyserFormat = new
                {
                    Foo = "Bar",
                    Baz = "Boo"
                }
            }));

            await _componentRegistry.AddOrUpdateAsync(componentRegistrationModel);

            var retrieved = await _componentRegistry.GetComponentByIdAsync(componentId);

            var errors = assert(componentRegistrationModel, retrieved);

            AssertErrors("Component insert", errors);
        }