示例#1
0
        public IList <InstalledProduct> ScanProducts()
        {
            InstalledProducts = DecodeProducts(ProductsDbPath);

            var clientTypes = EnumExtensions.Values <WowClientType>();

            foreach (var clientType in clientTypes)
            {
                var clientLocation  = GetClientLocation(clientType);
                var productLocation = GetProductLocation(clientType);

                if (string.IsNullOrEmpty(clientLocation) && string.IsNullOrEmpty(productLocation))
                {
                    continue;
                }

                Log.Information($"clientLocation {clientLocation}, productLocation: {productLocation}");
                if (AreEqualPaths(clientLocation, productLocation))
                {
                    continue;
                }

                // If the path that the user selected is valid, then move on.
                if (!string.IsNullOrEmpty(clientLocation) && IsClientFolder(clientType, clientLocation))
                {
                    continue;
                }

                var locationPreference = GetClientLocationPreference(clientType);
                if (locationPreference == null)
                {
                    locationPreference = _preferenceRepository.Create(GetClientLocationPreferenceKey(clientType), string.Empty);
                }

                locationPreference.Value = productLocation;

                Log.Information($"locationPreference {locationPreference}");

                _preferenceRepository.SaveItem(locationPreference);

                var changedClient = new ChangedClient
                {
                    ClientType       = clientType,
                    NewLocation      = productLocation,
                    PreviousLocation = clientLocation
                };

                ProductChanged?.Invoke(this, new WarcraftEventArgs
                {
                    ChangedClient = changedClient
                });
            }

            return(InstalledProducts);
        }
示例#2
0
        public bool Create(PreferenceForCreationDto preferenceForCreation)
        {
            try
            {
                Preference DataEntity = _mapper.Map <Preference>(preferenceForCreation);

                _repository.Create(DataEntity);
                _repository.Save();

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside CreatePreference action: {ex.Message}");
                throw new Exception();
            }
        }