Exemple #1
0
        public void ConvertDefaults(List <DefaultAssignment> defaults)
        {
            ProductModel pm = ModelWorkspace.CreateFromFile(pmxFile).ProductModel;
            var          pmProductModelStructure = pm.ProductModelStructure;

            foreach (var defaultAssignment in defaults)
            {
                //var characteristic = _parseUtils.FindSelectionCriteriaCharacteristic( defaultAssignment.HierarchyElement );
                //var precondition = _parseUtils.GeneratePrecondition( characteristic, defaultAssignment.HierarchyElement );

                var model   = defaultAssignment.Model;
                var coutry  = defaultAssignment.Country;
                var variant = defaultAssignment.Variant;

                var defaultModel = new LogicModel();
                defaultModel.AddRule("", "", ExprBld.IfThen(
                                         (ExprBld.Variables["Model"] == model)
                                         .And(ExprBld.Variables["coutry"] == coutry)
                                         .And(ExprBld.Variables["variant"] == variant),
                                         ExprBld.Variables[defaultAssignment.Assignment.Characteristic]) ==
                                     defaultAssignment.Assignment.Value);
                var compiler          = new Core.Compile.Compilation.Compiler(defaultModel);
                var defaultSolveData  = compiler.CompileNddSolve();
                var scopedDefaultData = new ScopedDefaultData(new[] { "model", "country", "variant" }, defaultSolveData);

                var packagedModelSerializer = new PackagedModelSerializer();
                var packagedModel           = packagedModelSerializer.LoadAsync(cameronPackage).Result.CopyAndInclude(scopedDefaultData);
                packagedModelSerializer.SaveAsync(cameronPackage,
                                                  new[] { packagedModel }).Wait();
            }
        }
        public void ConvertDefaults(List <DefaultAssignment> defaults)
        {
            var packagedModelSerializer = new PackagedModelSerializer();

            Log.Info($"Adding defaults to package {vtPackagePath}");
            var existingPackagedModel = packagedModelSerializer.LoadAsync(vtPackagePath, "MF7726D6_AGCO").Result;
            var variables             = existingPackagedModel.Variables.ModelVariables;

            var scopedDefaultDatas = CreateScopeDefaultData(defaults, variables);

            var newPackagedModel = existingPackagedModel.CopyAndInclude(scopedDefaultDatas.Cast <ICompiledData>().ToArray());

            Log.Info($"Saving package with defaults to {newPackagedModel}");
            packagedModelSerializer.SaveAsync(vtPackagePath, new[] { newPackagedModel }).Wait();
        }