예제 #1
0
        public Task LoadDriverFactory(NodeInstance nodeInstance, IDriverFactory factory, IDriverContext context)
        {
            var driver = factory.CreateDriver(context);

            nodeInstance.State = NodeInstanceState.Loaded;
            if (driver.BeforeInit())
            {
                _driverStore.Add(driver.Id, driver);
                nodeInstance.State = NodeInstanceState.Initialized;
                driver.Configure();
            }
            else
            {
                nodeInstance.State = NodeInstanceState.UnknownError;
            }

            _driverNodeStore.Add(driver.Id, driver);
            for (int i = 0; i <= driver.ChildrensCreated; ++i)
            {
                _licenseContract.IncrementDriverCount();
            }


            AddDriverRecursive(driver);
            return(Task.CompletedTask);
        }
예제 #2
0
        public Task <IDriver> LoadDriverFactory(NodeInstance nodeInstance, IDriverFactory factory, IDriverContext context)
        {
            var driver = factory.CreateDriver(context);

            nodeInstance.State = NodeInstanceState.Loaded;
            try
            {
                if (driver.BeforeInit())
                {
                    _driverStore.Add(driver.Id, driver);
                    nodeInstance.State = NodeInstanceState.Initialized;
                    driver.Configure();
                }
                else
                {
                    nodeInstance.State = NodeInstanceState.UnknownError;
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Error initialize driver {factory.DriverName}");
                nodeInstance.State = NodeInstanceState.UnknownError;
            }

            _driverNodeStore.AddChild(driver, driver);
            for (int i = 0; i <= driver.ChildrensCreated; ++i)
            {
                _licenseContract.IncrementDriverCount();
            }


            AddDriverRecursive(driver, driver);
            return(Task.FromResult(driver));
        }