Пример #1
0
        public List <DefaultAssignment> GetDefaults(Data.Model model)
        {
            var versions          = model.Versions.Select(v => "'" + v.Name + "'").Aggregate((s, e) => s + "," + e);
            var variants          = model.Versions.Select(v => "'" + v.Variant + "'").Aggregate((s, e) => s + "," + e);
            var hierarchyElements = $"'{model.Name}', {versions}, {variants}";

            Debug.WriteLine(hierarchyElements);
            using (var connection = new SqlCeConnection(_rulesConnectionString)) {
                var defaults = new List <DefaultAssignment>();
                connection.Open();
                var sql = $"select var, country, cstic, value from ZTVC_MF_S_DEF where char_prod in ({hierarchyElements})";
                Debug.WriteLine(sql);
                using (var cmd = new SqlCeCommand(sql,
                                                  connection)) {
                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        var variant           = reader.GetString(0);
                        var country           = reader.GetString(1);
                        var cstic             = reader.GetString(2);
                        var value             = reader.GetString(3);
                        var defaultAssignment =
                            new DefaultAssignment(model.Name, variant, country, new Assignment(cstic, value));
                        defaults.Add(defaultAssignment);
                    }
                }
                return(defaults);
            }
        }
Пример #2
0
 private bool ValuesInDomain(DefaultAssignment defaultAssignment, VariableCollection variables, string variableFullName)
 {
     return(variables[COUNTRY_VARIABLE].IsInDomain(defaultAssignment.Country) &&
            variables[MODEL_VARIABLE].IsInDomain(defaultAssignment.Model) &&
            variables[VARIANT_VARIABLE].IsInDomain(defaultAssignment.Variant) &&
            variables[variableFullName].IsInDomain(defaultAssignment.Assignment.Value));
 }