コード例 #1
0
 private void XNodeEventService_ProductCreated(Model.Events.Products.ProductCreatedArgs obj)
 {
     tenantIOService.TryCreateProductDirectory(obj.Tenant, new Model.App.Products.Product()
     {
         Id = obj.Id, Name = obj.Name
     });
     logger.LogInformation($"Product '{obj.Name}' properties at {obj.Tenant} created");
 }
コード例 #2
0
        private void XNodeEventService_StorageConnected(Model.Events.Agents.AgentConnectedArgs obj)
        {
            logger.LogInformation($"Agent '{obj.Agent}' with id '{obj.AgentId}' is connected");

            foreach (var tenant in obj.Tenants)
            {
                logger.LogInformation($"Agent '{obj.AgentId}' is connected to '{tenant.Key}' tenant");

                // Trying to create new tenants locations in the storage.
                tenantIOService.TryCreateTenantDirectory(tenant.Key, tenant.Value);
                tenantIOService.WriteAgentStateInTenantLog(tenant.Key, obj.AgentId.ToString(), "connected");

                tenant.Value.Products.ToList().ForEach(product =>
                {
                    tenantIOService.TryCreateProductDirectory(tenant.Key, product.Value);

                    product.Value.Components.ToList().ForEach(component =>
                    {
                        tenantIOService.TryCreateComponentDirectory(tenant.Key, product.Key, component.Value);
                        component.Value.Topics.ToList().ForEach(topic =>
                        {
                            tenantIOService.TryCreateTopicDirectory(tenant.Key, product.Key, component.Key, topic.Value);
                        });
                    });
                });
            }
        }