public ActionResult SaveProductToFactoryInventory()
        {
            try
            {
                int    userId   = ((ViewUser)Session["user"]).UserId;
                string fileName = "Production_In_" + userId + "_" + DateTime.Now.ToString("ddMMMyyyy");
                var    filePath = Server.MapPath("~/Files/" + fileName);
                if (System.IO.File.Exists(filePath))
                {
                    var             scannedProduct = _iProductManager.GetScannedProductListFromTextFile(filePath).ToList();
                    ProductionModel model          = new ProductionModel
                    {
                        UserId          = userId,
                        ScannedProducts = scannedProduct,
                        TotalQuantity   = scannedProduct.Count
                    };
                    //if the file is exists read the file

                    int result = _iInventoryManager.SaveScannedProduct(model);
                    if (result > 0)
                    //if the scanned products save successfully then clear the file..
                    {
                        System.IO.File.Create(filePath).Close();
                        return(RedirectToAction("AddProductToTempFile"));
                    }
                }
                return(RedirectToAction("AddProductToTempFile"));
            }
            catch (Exception exception)
            {
                string message = exception.InnerException?.Message;
                return(RedirectToAction("AddProductToTempFile"));
            }
        }
Exemplo n.º 2
0
 private void addItemListDetail(ProductionModel productData)
 {
     //pnDetail.Controls.Clear();
     if (productData.ProductID > 0)
     {
         UCItemList ucItemList = new UCItemList();
         if (pnDetail.Controls.Count > 0)
         {
             ucItemList = (UCItemList)pnDetail.Controls[0];
         }
         else
         {
             ucItemList.Dock = DockStyle.Fill;
             pnDetail.Controls.Add(ucItemList);
         }
         ucItemList.lbProductName.Text     = productData.ProductNameDesc;
         ucItemList.txtNameDesc.Text       = productData.ProductNameDesc;
         ucItemList.txtNameSort.Text       = productData.ProductNameSort;
         ucItemList.txtPrice.Text          = money.Format2((productData.CurrentPrice.ToString()));
         ucItemList.btnSave.Tag            = productData;
         ucItemList.btnSave.Click         += ucItemList_btnSave_Click;
         ucItemList.btnRemove.Click       += ucItemList_btnRemove_Click;
         ucItemList.btnRemove.Tag          = productData;
         ucItemList.btnAddProtions.Visible = false;
         ucItemList.lbPortions.Visible     = false;
         ucItemList.Tag = productData;
         ucItemList.flpItemList.Controls.Clear();
         ucItemList.addUcMenuGroup(productData.ProductID, 1);
         ucItemList.cbProductColor.SelectedItem = productData.Color;
     }
     else
     {
         pnDetail.Controls.Clear();
     }
 }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int result = 0;

            foreach (PrintJobDetailModel item in LstPrinterJob)
            {
                PrintService.DeletePrintJob(item.CategoryID ?? 0, item.ProductID ?? 0, item.PrinterID ?? 0);
            }

            foreach (Control ctr in flpItem.Controls)
            {
                if (ctr is UCItemOfCategoryPrint)
                {
                    if (ctr.BackColor == Color.FromArgb(0, 153, 51))
                    {
                        ProductionModel      pro  = (ProductionModel)ctr.Tag;
                        PrinteJobDetailModel item = new PrinteJobDetailModel();
                        item.CategoryID = pro.CategoryID;
                        item.ProductID  = pro.ProductID;
                        item.PrinterID  = PriterID;
                        PrintService.InsertPrinterMapping(item);
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void btnRight_Click(object sender, EventArgs e)
 {
     foreach (Control ctr in flpThisgroupitems.Controls)
     {
         if (ctr.BackColor == Color.FromArgb(0, 102, 204))
         {
             UCMenuAdd       ucMenuGet = (UCMenuAdd)ctr;
             ProductionModel itemlef   = (ProductionModel)(ucMenuGet.Tag);
             ProductionModel item      = new ProductionModel();
             item.ProductID       = itemlef.ProductID;
             item.ProductNameDesc = itemlef.ProductNameDesc;
             listall.Add(item);
             var index = -1;
             for (int i = 0; i < listmap.Count; i++)
             {
                 if (listmap[i].ProductID == item.ProductID)
                 {
                     index = i;
                 }
             }
             if (index > -1)
             {
                 listmap.RemoveAt(index);
             }
         }
     }
     LoadThisGroupItems();
     LoadAllItem();
 }
Exemplo n.º 5
0
        public void GrammarModelShouldAddProductionModel()
        {
            var grammar = new GrammarModel();

            grammar.AddProduction(ProductionModel.From(""));
            Assert.AreEqual(1, grammar.ProductionModels.Count);
        }
Exemplo n.º 6
0
        public void GrammarModelToGrammarShouldCreateGrammar()
        {
            var grammarModel = new GrammarModel();

            var S = ProductionModel.From("S");
            var A = ProductionModel.From("A");
            var B = ProductionModel.From("B");

            var a     = new StringLiteralLexerRule("a");
            var b     = new StringLiteralLexerRule("b");
            var space = new StringLiteralLexerRule(" ");

            S.AddWithAnd(A.LeftHandSide);
            S.AddWithAnd(B.LeftHandSide);
            S.AddWithOr(B.LeftHandSide);
            A.AddWithAnd(new LexerRuleModel(a));
            B.AddWithAnd(new LexerRuleModel(b));

            grammarModel.AddProduction(S);
            grammarModel.AddProduction(A);
            grammarModel.AddProduction(B);

            var lexerRuleModel = new LexerRuleModel(space);

            grammarModel.AddLexerRule(lexerRuleModel);
            grammarModel.AddIgnoreSetting(new IgnoreSettingModel(new QualifiedName(lexerRuleModel.LexerRule.TokenName.Id)));

            grammarModel.Start = S;

            var grammar = grammarModel.ToGrammar();

            Assert.AreEqual(4, grammar.Productions.Count);
            Assert.AreEqual(1, grammar.Ignores.Count);
        }
Exemplo n.º 7
0
        public void GrammarModelToGrammarShouldCreateGrammar()
        {
            var grammarModel = new GrammarModel();

            var S = new ProductionModel("S");
            var A = new ProductionModel("A");
            var B = new ProductionModel("B");

            var a     = new StringLiteralLexerRule("a");
            var b     = new StringLiteralLexerRule("b");
            var space = new StringLiteralLexerRule(" ");

            S.AddWithAnd(A.LeftHandSide);
            S.AddWithAnd(B.LeftHandSide);
            S.AddWithOr(B.LeftHandSide);
            A.AddWithAnd(new LexerRuleModel(a));
            B.AddWithAnd(new LexerRuleModel(b));

            grammarModel.Productions.Add(S);
            grammarModel.Productions.Add(A);
            grammarModel.Productions.Add(B);

            grammarModel.IgnoreRules.Add(new LexerRuleModel(space));

            grammarModel.Start = S;

            var grammar = grammarModel.ToGrammar();

            Assert.AreEqual(4, grammar.Productions.Count);
            Assert.AreEqual(1, grammar.Ignores.Count);
        }
Exemplo n.º 8
0
        public void SaveUsingModelClass()
        {
            ProductionModel model = new ProductionModel {
                Location = location
            };

            DateTime before = DateTime.UtcNow.AddSeconds(-1);

            dynamic record = ViewPoint.Save(model);

            DateTime after = before.AddSeconds(5);

            Assert.That((object)record, Is.Not.Null);

            Assert.That(record.Location, Is.EqualTo(location));

            Assert.That(record.Id, Is.GreaterThan(0));

            Assert.That(Records, Is.Not.Empty);

            InMemoryRecord amplaRecord = Records[0];

            Assert.That(amplaRecord, Is.Not.Null);

            Assert.That(amplaRecord.Location, Is.EqualTo(location));
            Assert.That(amplaRecord.Module, Is.EqualTo(module));

            Assert.That(amplaRecord.GetFieldValue("Sample Period", DateTime.MinValue), Is.InRange(before, after));
        }
        public GrammarResult Grammar()
        {
            GrammarResult result = new GrammarResult();

            foreach (Production production in Compiler.Parser.Grammar.Instance)
            {
                ProductionModel productionModel = new ProductionModel {
                    Head = production.Identifier
                };

                production.ForEach(x =>
                {
                    productionModel.SubProductions.Add(new SubProductionModel
                    {
                        Expressions = x.Select(y => new ExpressionModel
                        {
                            Name = y.ToString(),
                            IsNonTerminalExpression = y is NonTerminalExpressionDefinition
                        }).ToList()
                    });
                });

                result.Productions.Add(productionModel);
            }

            return(result);
        }
Exemplo n.º 10
0
        public async Task <IActionResult> UpdateProductionAsync(int productionId, [FromBody] ProductionModel productionModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    foreach (var pair in ModelState)
                    {
                        if (pair.Key == nameof(productionModel.Name) && pair.Value.Errors.Count > 0)
                        {
                            return(BadRequest(pair.Value.Errors));
                        }
                    }
                }

                return(Ok(await _productionService.UpdateProductionAsync(productionId, productionModel)));
            }
            catch (NotFoundOperationException ex)
            {
                return(NotFound(ex.Message));;
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, $"Something happend: {ex.Message}"));
            }
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Index()
        {
            var model = new ProductionModel();

            model.productionOrders = await productionOrderService.GetAll();

            return(View("ProductionOrderView", model));
        }
Exemplo n.º 12
0
        public void GrammarModelToGrammarShouldAddProductionWhenEmptyDefinition()
        {
            var S            = new ProductionModel("S");
            var grammarModel = new GrammarModel(S);
            var grammar      = grammarModel.ToGrammar();

            Assert.AreEqual(1, grammar.Productions.Count);
        }
Exemplo n.º 13
0
        public int UpdatePositionProduct(ProductionModel item)
        {
            int    resut = 0;
            string sql   = "UPDATE PRODUCT SET Position='" + item.Position + "' WHERE ProductID='" + item.ProductID + "'";

            resut = _context.Database.ExecuteSqlCommand(sql);
            return(resut);
        }
Exemplo n.º 14
0
        private void btnUp_Click(object sender, EventArgs e)
        {
            if (indexOfItem > 0)
            {
                ProductionModel item = (ProductionModel)(ucAddMenu.Tag);
                flpThisgroupitems.Controls.SetChildIndex(ucAddMenu, indexOfItem - 1);

                indexOfItem = flpThisgroupitems.Controls.IndexOf(ucAddMenu);
            }
        }
Exemplo n.º 15
0
        public int SaveScannedProduct(ProductionModel model)
        {
            var maxProductionNo = _iInventoryGateway.GetmaxProductionRefByYear(DateTime.Now.Year);
            var productionRef   = GenerateProducitonRef(maxProductionNo);

            model.TransactionRef  = productionRef;
            model.TransactionType = "RE";

            return(_iInventoryGateway.SaveScannedProduct(model));
        }
        public ActionResult Post([FromBody] ProductionModel body)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ProductionModel item = _service.Create(body);

            return(CreatedAtAction("Get", new { id = item.Id }, item));
        }
Exemplo n.º 17
0
        IEnumerable <ProductionModel> Rule(EbnfRule rule)
        {
            var nonTerminal     = GetNonTerminalFromQualifiedIdentifier(rule.QualifiedIdentifier);
            var productionModel = new ProductionModel(nonTerminal);

            foreach (var production in Expression(rule.Expression, productionModel))
            {
                yield return(production);
            }
            yield return(productionModel);
        }
Exemplo n.º 18
0
        private void btnDown_Click(object sender, EventArgs e)
        {
            int total = flpThisgroupitems.Controls.Count;

            if (indexOfItem > 0 && indexOfItem < total)
            {
                ProductionModel item = (ProductionModel)(ucAddMenu.Tag);
                flpThisgroupitems.Controls.SetChildIndex(ucAddMenu, indexOfItem + 1);

                indexOfItem = flpThisgroupitems.Controls.IndexOf(ucAddMenu);
            }
        }
Exemplo n.º 19
0
        private IEnumerable <ProductionModel> Rule(EbnfRule rule)
        {
            var nonTerminal     = GetQualifiedName(rule.Identifier);
            var productionModel = ProductionModel.From(nonTerminal);

            foreach (var production in Expression(rule.Expression, productionModel))
            {
                yield return(production);
            }

            yield return(productionModel);
        }
Exemplo n.º 20
0
 public ProductionModel Get(int productionID)
 {
     using (var uow = new UnitOfWork(new DataContext()))
     {
         var obj   = uow.Productions.Get(productionID);
         var model = new ProductionModel();
         model.Date      = obj.Date;
         model.ProductID = obj.ProductID;
         model.Quantity  = obj.Quantity;
         return(model);
     }
 }
Exemplo n.º 21
0
        public void GrammarModelToGrammarShouldResolverProductionReferencesFromOtherGrammars()
        {
            var S = new ProductionModel {
                LeftHandSide = new NonTerminalModel(new FullyQualifiedName("ns1", "S"))
            };
            var A = new ProductionModel {
                LeftHandSide = new NonTerminalModel(new FullyQualifiedName("ns1", "A"))
            };

            S.Alterations.Add(
                new AlterationModel(
                    new[] { A }));
            A.Alterations.Add(
                new AlterationModel(
                    new[] { new LexerRuleModel(
                                new StringLiteralLexerRule("a")) })
                );
            var ns1GrammarModel = new GrammarModel
            {
                Start = S
            };

            ns1GrammarModel.Productions.Add(S);
            ns1GrammarModel.Productions.Add(A);

            var ns1ProductionReferece = new ProductionReferenceModel(ns1GrammarModel.ToGrammar());

            var Z = new ProductionModel {
                LeftHandSide = new NonTerminalModel(new FullyQualifiedName("ns2", "Z"))
            };
            var X = new ProductionModel {
                LeftHandSide = new NonTerminalModel(new FullyQualifiedName("ns2", "X"))
            };

            X.Alterations.Add(
                new AlterationModel(
                    new SymbolModel[]
            {
                Z, ns1ProductionReferece
            }));

            var ns2GrammarModel = new GrammarModel
            {
                Start = Z
            };

            ns2GrammarModel.Productions.Add(Z);
            ns2GrammarModel.Productions.Add(X);

            var ns2Grammar = ns2GrammarModel.ToGrammar();

            Assert.AreEqual(4, ns2Grammar.Productions.Count);
        }
Exemplo n.º 22
0
 private void UpdatePosition()
 {
     for (int i = 0; i < flpThisgroupitems.Controls.Count; i++)
     {
         ProductionModel item = (ProductionModel)(flpThisgroupitems.Controls[i].Tag);
         item.Position = flpThisgroupitems.Controls.IndexOf(flpThisgroupitems.Controls[i]);
         lstPosition.Add(item);
     }
     for (int j = 0; j < lstPosition.Count; j++)
     {
         ProductService.UpdatePositionProduct(lstPosition[j]);
     }
 }
Exemplo n.º 23
0
        public async Task <ProductionModel> CreateProductionAsync(ProductionModel productionModel)
        {
            var productionEntity = _mapper.Map <ProductionEntity>(productionModel);

            _libraryRepository.CreateProduction(productionEntity);
            var result = await _libraryRepository.SaveChangesAsync();

            if (result)
            {
                return(_mapper.Map <ProductionModel>(productionEntity));
            }

            throw new Exception("Database Error");
        }
Exemplo n.º 24
0
        public void GrammarModelConstructorGivenOnlyStartProductionShouldTraverseRecursiveStructureOnlyOnce()
        {
            var S = new ProductionModel("S");
            var A = new ProductionModel("A");

            S.AddWithAnd(S);
            S.AddWithOr(A);
            A.AddWithAnd(new LexerRuleModel(new StringLiteralLexerRule("a")));

            var grammarModel = new GrammarModel(S);
            var grammar      = grammarModel.ToGrammar();

            Assert.AreEqual(3, grammar.Productions.Count);
        }
        public void Add_ValidObjectPassed_ReturnsCreatedResponse()
        {
            // Arrange
            ProductionModel testItem = new ProductionModel()
            {
                Name = "Les Miserables"
            };

            // Act
            var createdResponse = _controller.Post(testItem);

            // Assert
            Assert.IsType <CreatedAtActionResult>(createdResponse);
        }
Exemplo n.º 26
0
        IEnumerable <ProductionModel> Factor(EbnfFactor factor, ProductionModel currentProduction)
        {
            switch (factor.NodeType)
            {
            case EbnfNodeType.EbnfFactorGrouping:
                var grouping = factor as EbnfFactorGrouping;
                foreach (var production in Grouping(grouping, currentProduction))
                {
                    yield return(production);
                }
                break;

            case EbnfNodeType.EbnfFactorOptional:
                var optional = factor as EbnfFactorOptional;
                foreach (var production in Optional(optional, currentProduction))
                {
                    yield return(production);
                }
                break;

            case EbnfNodeType.EbnfFactorRepetition:
                var repetition = factor as EbnfFactorRepetition;
                foreach (var production in Repetition(repetition, currentProduction))
                {
                    yield return(production);
                }
                break;

            case EbnfNodeType.EbnfFactorIdentifier:
                var identifier  = factor as EbnfFactorIdentifier;
                var nonTerminal = GetNonTerminalFromQualifiedIdentifier(identifier.QualifiedIdentifier);
                currentProduction.AddWithAnd(new NonTerminalModel(nonTerminal));
                break;

            case EbnfNodeType.EbnfFactorLiteral:
                var literal           = factor as EbnfFactorLiteral;
                var stringLiteralRule = new StringLiteralLexerRule(literal.Value);
                currentProduction.AddWithAnd(new LexerRuleModel(stringLiteralRule));
                break;

            case EbnfNodeType.EbnfFactorRegex:
                var regex        = factor as EbnfFactorRegex;
                var nfa          = _thompsonConstructionAlgorithm.Transform(regex.Regex);
                var dfa          = _subsetConstructionAlgorithm.Transform(nfa);
                var dfaLexerRule = new DfaLexerRule(dfa, regex.Regex.ToString());
                currentProduction.AddWithAnd(new LexerRuleModel(dfaLexerRule));
                break;
            }
        }
Exemplo n.º 27
0
        private IEnumerable <ProductionModel> Term(IEbnfTerm term, ProductionModel currentProduction)
        {
            foreach (var production in Factor(term.Factor, currentProduction))
            {
                yield return(production);
            }

            if (term is EbnfTermConcatenation concatenation)
            {
                foreach (var production in Term(concatenation.Term, currentProduction))
                {
                    yield return(production);
                }
            }
        }
        public async Task <ActionResult> Create(ProductionModel production)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            else
            {
                UoW.Productions.Add(production.Production);
                UoW.Ingredients.AddRange(production.Items);
                await UoW.Complete();

                return(RedirectToAction("Index"));
            }
        }
        public void Update_NotExistingGuidPassed_ReturnsNotFoundResponse()
        {
            // Arrange
            var proposedUpdate = new ProductionModel()
            {
                Id   = 13674,
                Name = "Phantom of the Opera"
            };

            // Act
            var badResponse = _controller.Put(proposedUpdate);

            // Assert
            Assert.IsType <NotFoundResult>(badResponse.Result);
        }
        public void Add_InvalidObjectPassed_ReturnsBadRequest()
        {
            // Arrange
            var nameMissingItem = new ProductionModel()
            {
                Id = 1
            };

            _controller.ModelState.AddModelError("Name", "Required");

            // Act
            var badResponse = _controller.Post(nameMissingItem);

            // Assert
            Assert.IsType <BadRequestObjectResult>(badResponse);
        }