Esempio n. 1
0
        private void SaveCaseAnalysis(BoxCasePalletAnalysis analysis, XmlElement parentElement, XmlDocument xmlDoc)
        {
            // create analysis element
            XmlElement xmlAnalysisElt = xmlDoc.CreateElement("AnalysisCase");
            parentElement.AppendChild(xmlAnalysisElt);
            // Name
            XmlAttribute analysisNameAttribute = xmlDoc.CreateAttribute("Name");
            analysisNameAttribute.Value = analysis.Name;
            xmlAnalysisElt.Attributes.Append(analysisNameAttribute);
            // Description
            XmlAttribute analysisDescriptionAttribute = xmlDoc.CreateAttribute("Description");
            analysisDescriptionAttribute.Value = analysis.Description;
            xmlAnalysisElt.Attributes.Append(analysisDescriptionAttribute);
            // BoxId
            XmlAttribute boxIdAttribute = xmlDoc.CreateAttribute("BoxId");
            boxIdAttribute.Value = string.Format("{0}", analysis.BoxProperties.Guid);
            xmlAnalysisElt.Attributes.Append(boxIdAttribute);
            // ConstraintSet : beg
            XmlElement constraintSetElement = xmlDoc.CreateElement("ConstraintSetCase");
            xmlAnalysisElt.AppendChild(constraintSetElement);
            XmlAttribute alignedLayersAttribute = xmlDoc.CreateAttribute("AlignedLayersAllowed");
            alignedLayersAttribute.Value = string.Format("{0}", analysis.ConstraintSet.AllowAlignedLayers);
            constraintSetElement.Attributes.Append(alignedLayersAttribute);
            XmlAttribute alternateLayersAttribute = xmlDoc.CreateAttribute("AlternateLayersAllowed");
            alternateLayersAttribute.Value = string.Format("{0}", analysis.ConstraintSet.AllowAlternateLayers);
            constraintSetElement.Attributes.Append(alternateLayersAttribute);
            // allowed box positions
            XmlAttribute allowedAxisAttribute = xmlDoc.CreateAttribute("AllowedBoxPositions");
            allowedAxisAttribute.Value = analysis.ConstraintSet.AllowOrthoAxisString;
            constraintSetElement.Attributes.Append(allowedAxisAttribute);
            // allowed layer patterns
            XmlAttribute allowedPatternAttribute = xmlDoc.CreateAttribute("AllowedPatterns");
            allowedPatternAttribute.Value = analysis.ConstraintSet.AllowedPatternString;
            constraintSetElement.Attributes.Append(allowedPatternAttribute);
            // stop criterions
            if (analysis.ConstraintSet.UseMaximumCaseWeight)
            {
                XmlAttribute maximumWeightAttribute = xmlDoc.CreateAttribute("MaximumCaseWeight");
                maximumWeightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.MaximumCaseWeight);
                constraintSetElement.Attributes.Append(maximumWeightAttribute);
            }
            if (analysis.ConstraintSet.UseMaximumNumberOfItems)
            {
                XmlAttribute maximumNumberOfItems = xmlDoc.CreateAttribute("ManimumNumberOfItems");
                maximumNumberOfItems.Value = string.Format("{0}", analysis.ConstraintSet.MaximumNumberOfItems);
                constraintSetElement.Attributes.Append(maximumNumberOfItems);
            }
            // solution filtering
            if (analysis.ConstraintSet.UseMinimumNumberOfItems)
            {
                XmlAttribute minimumNumberOfItems = xmlDoc.CreateAttribute("MinimumNumberOfItems");
                minimumNumberOfItems.Value = string.Format("{0}", analysis.ConstraintSet.MinimumNumberOfItems);
                constraintSetElement.Attributes.Append(minimumNumberOfItems);
            }
            // number of solutions to keep
            if (analysis.ConstraintSet.UseNumberOfSolutionsKept)
            {
                XmlAttribute numberOfSolutionsKept = xmlDoc.CreateAttribute("NumberOfSolutions");
                numberOfSolutionsKept.Value = string.Format("{0}", analysis.ConstraintSet.NumberOfSolutionsKept);
                constraintSetElement.Attributes.Append(numberOfSolutionsKept);
            }
            // ConstraintSet : end

            // Pallet solution descriptors
            XmlElement palletSolutionsElement = xmlDoc.CreateElement("PalletSolutionDescriptors");
            xmlAnalysisElt.AppendChild(palletSolutionsElement);
            foreach (PalletSolutionDesc desc in analysis.PalletSolutionsList)
                SavePalletSolutionDescriptor(desc, palletSolutionsElement, xmlDoc);
            // Solutions
            XmlElement solutionsElt = xmlDoc.CreateElement("CaseSolutions");
            xmlAnalysisElt.AppendChild(solutionsElt);
            int solIndex = 0;
            foreach (BoxCasePalletSolution caseSolution in analysis.Solutions)
                SaveCaseSolution(caseSolution, analysis.GetSelCaseSolutionBySolutionIndex(solIndex++), solutionsElt, xmlDoc);
        }