Example #1
0
        public ErrorMessage FinishSpecifications(string materialName, bool isNew)
        {
            ErrorMessage errorMsg = null;

            if (materialComponentList.Count < 1)
            {
                string msg = "The specified drying material contains no substance.";
                errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, "Inappropriate Specification", msg);
            }
            DoNormalization();
            CompositeSubstance dryMat = new CompositeSubstance(materialName, materialComponentList);

            //ArrayList dryMaterialCompList = new ArrayList();
            //dryMaterialCompList.Add(s);
            //dryMaterialCompList.Add(moistureSubstance);

            if (isNew)
            {
                if (catalog.IsInCatalog(materialName))
                {
                    errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "There is already in the material catalog a material called " + materialName);
                }
                else if (materialType == MaterialType.GenericMaterial && specificHeatOfAbsoluteDryMaterial.Value <= 0.0)
                {
                    errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "Specific heat of absolute dry material cannot be less than or equal to 0");
                }
                else
                {
                    dryingMaterial = new DryingMaterial(materialName, materialType, dryMat, moistureSubstance, true);
                    dryingMaterial.SpecificHeatOfAbsoluteDryMaterial = specificHeatOfAbsoluteDryMaterial.Value;
                    dryingMaterial.DuhringLines = duhringLines;
                    errorMsg = catalog.AddDryingMaterial(dryingMaterial);
                }
            }
            else
            {
                if (!materialName.Equals(dryingMaterial.Name) && catalog.GetDryingMaterial(materialName) != null)
                {
                    errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "There is already in the material catalog a material called " + materialName);
                }
                else if (materialType == MaterialType.GenericMaterial && specificHeatOfAbsoluteDryMaterial.Value <= 0.0)
                {
                    errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "Specific heat of absolute dry material cannot be less than or equal to 0");
                }
                else
                {
                    //dryingMaterial.Name = materialName;
                    //dryingMaterial.MaterialType = materialType;
                    //dryingMaterial.AbsoluteDryMaterial = dryMat;
                    //dryingMaterial.Moisture = moistureSubstance;
                    //dryingMaterial.SpecificHeatOfAbsoluteDryMaterial = specificHeatOfAbsoluteDryMaterial.Value;
                    //dryingMaterial.DuhringLines = duhringLines;
                    double   originalSpecificHeatOfAbsoluteDryMaterial = dryingMaterial.SpecificHeatOfAbsoluteDryMaterial;
                    CurveF[] originalDuhringLines = dryingMaterial.DuhringLines;
                    if (originalDuhringLines != null)
                    {
                        originalDuhringLines.Clone();
                    }

                    try {
                        dryingMaterial.Update(materialName, specificHeatOfAbsoluteDryMaterial.Value, duhringLines);
                        errorMsg = catalog.UpdateDryingMaterial(dryingMaterial);
                    }
                    catch (Exception) {
                        dryingMaterial.SpecificHeatOfAbsoluteDryMaterial = originalSpecificHeatOfAbsoluteDryMaterial;
                        dryingMaterial.DuhringLines = originalDuhringLines;
                        errorMsg = new ErrorMessage(ErrorType.SimpleGeneric, StringConstants.INAPPROPRIATE_SPECIFIED_VALUE, "Either specified absolute material specific heat or duhring lines are not appropriate.");
                    }
                }
            }

            return(errorMsg);
        }
Example #2
0
 public DryingMaterialChangedEventArgs(DryingMaterial dryingMaterial, bool isNameChangeOnly)
 {
     this.dryingMaterial   = dryingMaterial;
     this.isNameChangeOnly = isNameChangeOnly;
 }