コード例 #1
0
        private IList <Component> GetSemiRecipe(CompositionSubRecipeDto recipeDto)
        {
            IList <Component> recipe = new List <Component>();
            DataTable         table  = _repository.GetAll(CompositionRepository.AllRecipeQuery + recipeDto.NrD.ToString());

            foreach (DataRow row in table.Rows)
            {
                Component component = GetNewComponent();

                component.AddParent(recipeDto.ParentsId, recipeDto.Id);
                component.Level          = recipeDto.Level + 1;
                component.Name           = row["component"].ToString();
                component.Ordering       = Convert.ToInt32(row["ordering"]);
                component.IsSemiProduct  = Convert.ToBoolean(row["is_intermediate"]);
                component.SemiProductNrD = !row["intermediate_nrD"].Equals(DBNull.Value) ? Convert.ToInt64(row["intermediate_nrD"]) : -2;
                component.AmountOriginal = Convert.ToDouble(row["amount"]);
                double amount = Convert.ToDouble(row["amount"]);
                component.Amount    = amount * recipeDto.Amount / 100d;
                component.Mass      = amount * recipeDto.Mass / 100d;
                component.Operation = recipeDto.Operation != RecipeOperation.None ? RecipeOperation.Middle : RecipeOperation.None;
                component.PriceKg   = !row["price"].Equals(DBNull.Value) ? Convert.ToDouble(row["price"]) : 0d;
                component.Rate      = !row["rate"].Equals(DBNull.Value) ? Convert.ToDouble(row["rate"]) : 0d;
                component.Density   = !row["density"].Equals(DBNull.Value) ? Convert.ToDouble(row["density"]) : -1d;

                double voc = !row["VOC"].Equals(DBNull.Value) ? Convert.ToDouble(row["VOC"]) : -1d;
                UpdatePriceAndVoc(component, voc);
                CompositionSubRecipeDto subRecipeDto = new CompositionSubRecipeDto(component.Id, component.Level, component.SemiProductNrD, component.Operation, component.Amount, component.Mass, component.ParentsId);
                component.SemiRecipe = component.IsSemiProduct ? GetSemiRecipe(subRecipeDto) : new List <Component>();

                recipe.Add(component);
            }

            UpdateSemiOperation(recipeDto, recipe);
            return(recipe);
        }
コード例 #2
0
        public void UpdateComponent(Component component, CompositionData compositionData)
        {
            MaterialRepository materialRepository = new MaterialRepository();
            MaterialDto        material           = materialRepository.GetByName(component.Name);

            component.Density        = material.Density;
            component.IsSemiProduct  = material.IsIntermediate;
            component.SemiProductNrD = material.IntermediateNrD;
            component.PriceKg        = (double)material.Price;
            component.VocPercent     = material.VOC;
            component.SemiStatus     = "";

            if (material.Id > 0)
            {
                CurrencyRepository currencyRepository = new CurrencyRepository();
                CurrencyDto        currency           = currencyRepository.GetById(material.CurrencyId, CurrencyRepository.GetByIdQuery);

                component.Rate = (double)currency.Rate;
                UpdatePriceAndVoc(component, material.VOC);
            }

            CompositionSubRecipeDto recipeDto = new CompositionSubRecipeDto(component.Id, component.Level, component.SemiProductNrD, component.Operation, component.Amount, component.Mass, component.ParentsId);

            component.SemiRecipe = component.IsSemiProduct ? GetSemiRecipe(recipeDto) : new List <Component>();
        }
コード例 #3
0
        public void GetRecipe(IList <Component> recipe, CompositionData data)
        {
            DataTable table = _repository.GetAll(CompositionRepository.AllRecipeQuery + data.LabBookId.ToString());

            foreach (DataRow row in table.Rows)
            {
                Component component = GetNewComponent();

                component.Name           = row["component"].ToString();
                component.Ordering       = Convert.ToInt32(row["ordering"]);
                component.IsSemiProduct  = Convert.ToBoolean(row["is_intermediate"]);
                component.SemiProductNrD = !row["intermediate_nrD"].Equals(DBNull.Value) ? Convert.ToInt64(row["intermediate_nrD"]) : -2;
                component.AmountOriginal = Math.Round(Convert.ToDouble(row["amount"]) * data.Amount / 100d, 4);
                component.Amount         = component.AmountOriginal; // Convert.ToDouble(row["amount"]) * data.Amount / 100d;
                component.Mass           = component.Amount * data.Mass / 100d;
                component.Operation      = (RecipeOperation)Convert.ToInt32(row["operation"]);
                component.OperationName  = row["name"].ToString();
                component.Comment        = row["comment"].ToString();
                component.PriceKg        = !row["price"].Equals(DBNull.Value) ? Convert.ToDouble(row["price"]) : 0d;
                component.Rate           = !row["rate"].Equals(DBNull.Value) ? Convert.ToDouble(row["rate"]) : 0d;
                component.Density        = !row["density"].Equals(DBNull.Value) ? Convert.ToDouble(row["density"]) : -1d;

                double voc = !row["VOC"].Equals(DBNull.Value) ? Convert.ToDouble(row["VOC"]) : -1d;
                UpdatePriceAndVoc(component, voc);
                CompositionSubRecipeDto recipeDto = new CompositionSubRecipeDto(component.Id, component.Level, component.SemiProductNrD, component.Operation, component.Amount, component.Mass, component.ParentsId);
                component.SemiRecipe = component.IsSemiProduct ? GetSemiRecipe(recipeDto) : new List <Component>();

                recipe.Add(component);
            }
        }
コード例 #4
0
        private void UpdateSemiOperation(CompositionSubRecipeDto recipeDto, IList <Component> recipe)
        {
            if (recipeDto.Operation == RecipeOperation.End && recipe.Count > 0)
            {
                recipe[recipe.Count - 1].Operation = recipeDto.Operation;
            }

            if (recipe.Count == 1)
            {
                recipe[0].SubOrdering = SubRecipeOrdering.onlyOne;
            }
            else if (recipe.Count > 1)
            {
                recipe[0].SubOrdering = SubRecipeOrdering.top;
                recipe[recipe.Count - 1].SubOrdering = SubRecipeOrdering.bottom;
            }
        }