public void CreateProcessConfigurationFile(ProcessConfigurationFile file)
        {
            var text = JsonConvert.SerializeObject(file, Formatting.Indented);

            File.WriteAllText(file.Filename, text);

            Configs.Add(file);
        }
        public void DeleteProcessConfigurationFile(ProcessConfigurationFile file)
        {
            if (!File.Exists(file.Filename))
            {
                throw new Exception($"File {file.Filename} does not exist.");
            }

            File.Delete(file.Filename);

            var index = Configs.FindIndex(c => c.Id.Equals(file.Id, StringComparison.OrdinalIgnoreCase));

            Configs.RemoveAt(index);
        }
        public void SaveProcessConfigurationFile(ProcessConfigurationFile file)
        {
            var text = JsonConvert.SerializeObject(file, Formatting.Indented);

            if (!File.Exists(file.Filename))
            {
                throw new Exception($"File {file.Filename} does not exist.");
            }

            File.WriteAllText(file.Filename, text);

            // Replace config in list with updated one.
            Configs[Configs.FindIndex(c => c.Id.Equals(file.Id, StringComparison.OrdinalIgnoreCase))] = file;
        }
Esempio n. 4
0
        private bool ConfigMatchesAllExtraCriteria(ProcessConfigurationFile config, Dictionary <string, string> availableCategoriesAndValues)
        {
            if (config?.ExtraMatchCriteria?.Any() != true)
            {
                // Return true if no extra rules set up.
                return(true);
            }

            foreach (var rule in config.ExtraMatchCriteria)
            {
                var matchCategory = rule.MatchProperty?.ToLower();
                var matchValue    = rule.MatchValue?.ToLower();

                if (!IsCriteriaMatch(availableCategoriesAndValues, matchCategory, matchValue))
                {
                    return(false);
                }
            }

            return(true);
        }