/// <summary>
        /// Gets the default values for all modules in asynchronous fashion.
        /// </summary>
        /// <param name="firmwareVersion">The firmware version.</param>
        /// <param name="deviceType">Type of the device.</param>
        /// <returns></returns>
        public async Task <IEnumerable <ModuleReadModel> > GetDefaultValuesAllModulesAsync(string firmwareVersion, string deviceType)
        {
            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetDefaultValuesAllModulesAsync)} Getting default values for {firmwareVersion} and {deviceType}.");
            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetDefaultValuesAllModulesAsync)} Cloning firmware version git repository.");

            var firmwareVersionUrl = await _firmwareVersionServiceManager.GetFirmwareUrlAsync(deviceType).ConfigureAwait(false);

            _firmwareVersionServiceManager.SetGitRepoUrl(deviceType, firmwareVersionUrl);
            await _firmwareVersionServiceManager.CloneGitRepoAsync().ConfigureAwait(false);

            // read default values from toml file defaults.toml
            var defaultValueFromTomlFile =
                await _firmwareVersionServiceManager.GetDefaultTomlFileContentAsync(firmwareVersion).ConfigureAwait(false);

            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetDefaultValuesAllModulesAsync)} Getting list of modules {firmwareVersion} and {deviceType}.");
            var listOfModules = await _firmwareVersionServiceManager.GetListOfModulesAsync(firmwareVersion, deviceType).ConfigureAwait(false);

            _moduleServiceManager.SetConnection();
            // clone git repo when we need it.
            await _moduleServiceManager.CloneGitRepoAsync().ConfigureAwait(false);

            // get list of all modules.
            await _moduleServiceManager.UpdateMetaTomlAsync(listOfModules).ConfigureAwait(false);

            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetDefaultValuesAllModulesAsync)} Merging default values with module information. {firmwareVersion} and {deviceType}.");
            await MergeValuesWithModulesAsync(defaultValueFromTomlFile, listOfModules);

            return(listOfModules);
        }
Beispiel #2
0
        /// <summary>
        /// Gets all firmware versions asynchronous.
        /// </summary>
        /// <returns></returns>
        public async Task <IEnumerable <string> > GetAllFirmwareVersionsAsync(string deviceType)
        {
            EnsureArg.IsNotEmptyOrWhiteSpace(deviceType);
            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetAllFirmwareVersionsAsync)} Getting list of all firmware versions for device type {deviceType}.");
            var gitUrl = await _firmwareVersionServiceManager.GetFirmwareUrlAsync(deviceType).ConfigureAwait(false);

            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetAllFirmwareVersionsAsync)} Retrieved git repo url ( {gitUrl} ) for device type: {deviceType}.");
            _firmwareVersionServiceManager.SetGitRepoUrl(deviceType, gitUrl);

            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetAllFirmwareVersionsAsync)} Cloning git repo url ( {gitUrl} ) for device type: {deviceType}.");
            // clone git repository.
            await _firmwareVersionServiceManager.CloneGitRepoAsync().ConfigureAwait(false);

            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetAllFirmwareVersionsAsync)} Retrieving all tags from git repo url ( {gitUrl} ) for device type: {deviceType}.");
            var listFirmwareVersions = await _firmwareVersionServiceManager.GetAllFirmwareVersionsAsync()
                                       .ConfigureAwait(false);

            return(listFirmwareVersions);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the blocks asynchronous.
        /// </summary>
        /// <param name="firmwareVersion">The firmware version.</param>
        /// <param name="deviceType">Type of the device.</param>
        /// <returns></returns>
        public async Task <object> GetBlocksAsync(string firmwareVersion, string deviceType)
        {
            _logger.LogInformation($"{Prefix}: methodName: {nameof(GetBlocksAsync)} Getting list of blocks for {firmwareVersion}.");

            // clone repo here.
            await _blockServiceManager.CloneGitRepoAsync().ConfigureAwait(false);

            var firmwareVersionUrl = await _firmwareVersionServiceManager.GetFirmwareUrlAsync(deviceType).ConfigureAwait(false);

            _firmwareVersionServiceManager.SetGitRepoUrl(deviceType, firmwareVersionUrl);

            // clone repo here.
            await _firmwareVersionServiceManager.CloneGitRepoAsync().ConfigureAwait(false);

            // read default values from toml file defaults.toml
            var defaultValueFromTomlFile =
                await _firmwareVersionServiceManager.GetDefaultTomlFileContentAsync(firmwareVersion).ConfigureAwait(false);

            var blocks = await GetBlocksAsync(defaultValueFromTomlFile, false).ConfigureAwait(false);

            return(new { blocks });
        }
Beispiel #4
0
        /// <summary>
        /// Gets the compatible firmware versions asynchronous.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <returns></returns>
        public async Task <IEnumerable <string> > GetCompatibleFirmwareVersionsAsync(CompatibleFirmwareVersionReadModel module)
        {
            EnsureArg.IsNotNull(module);
            EnsureArg.IsNotEmptyOrWhiteSpace(module.FirmwareVersion);
            EnsureArg.IsNotEmptyOrWhiteSpace(module.DeviceType);
            EnsureArg.HasItems(module.Modules);

            var prefix           = nameof(CompatibleFirmwareVersionManager);
            var firmwareVersions = new List <string>();

            _logger.LogInformation($"{prefix}: methodName: {nameof(GetCompatibleFirmwareVersionsAsync)} Getting list of compatible firmware versions based on a firmware version.");
            _logger.LogInformation($"{prefix}: methodName: {nameof(GetCompatibleFirmwareVersionsAsync)} Cloning firmware version git repository.");
            var firmwareVersionUrl = await _firmwareVersionServiceManager.GetFirmwareUrlAsync(module.DeviceType).ConfigureAwait(false);

            _firmwareVersionServiceManager.SetGitRepoUrl(module.DeviceType, firmwareVersionUrl);
            await _firmwareVersionServiceManager.CloneGitRepoAsync().ConfigureAwait(false);

            var listOfTags = await _firmwareVersionServiceManager.GetAllFirmwareVersionsAsync().ConfigureAwait(false);

            listOfTags       = listOfTags.Where(x => !string.Equals(x, module.FirmwareVersion, StringComparison.OrdinalIgnoreCase)).ToList();
            firmwareVersions = await _firmwareVersionServiceManager.GetCompatibleFirmwareVersions(listOfTags, module.FirmwareVersion, module.DeviceType, module.Modules);

            return(firmwareVersions);
        }