Example #1
0
        public JsonResult GetProductionLinesResult()
        {
            ProductionLineService     prodLineBL = new ProductionLineService();
            List <ProductionLinesDto> lines      = prodLineBL.GetAll();

            return(Json(lines, JsonRequestBehavior.AllowGet));
        }
        private ProductionLinesModel GetProductionLine(int lineId)
        {
            ProductionLinesModel model = new ProductionLinesModel();

            using (ProductionLineService service = new ProductionLineService())
            {
                var dto = service.Get(lineId);
                model = Mapper.Map <ProductionLinesDto, ProductionLinesModel>(dto);
            }
            return(model);
        }
        private ProductionLinesModel GetProductionLine(int prodLineId)
        {
            ProductionLinesModel productionLine = new ProductionLinesModel();

            using (ProductionLineService service = new ProductionLineService())
            {
                var dto = service.Get(prodLineId);
                productionLine = Mapper.Map <ProductionLinesDto, ProductionLinesModel>(dto);
            }
            return(productionLine);
        }
        public JsonResult GetLines()
        {
            List <ProductionLinesModel> productionLines = new List <ProductionLinesModel>();

            using (ProductionLineService service = new ProductionLineService())
            {
                var dto = service.GetAll().OrderBy(r => r.LineDesc).ToList();
                productionLines.AddRange(Mapper.Map <List <ProductionLinesDto>, List <ProductionLinesModel> >(dto));
            }
            return(Json(productionLines, JsonRequestBehavior.AllowGet));
        }
        public async void EnsureProductionLineIsNotFoundById()
        {
            var context = ContextMocker.GetContextMock();

            ContextMocker.SeedProductionLines(context);

            var ProductionLineService = new ProductionLineService(context);

            var ProductionLineId = new Guid("11113111-2222-2222-2222-111111111111");

            await Assert.ThrowsAsync <KeyNotFoundException>(() => (ProductionLineService.GetProductionLineById(ProductionLineId)));
        }
Example #6
0
        public ActionResult Index()
        {
            //  List<ProdLineReportOrderModel> model;
            List <ProductionLinesModel> model;

            using (var service = new ProductionLineService())
            {
                model = Mapper.Map <List <ProductionLinesDto>, List <ProductionLinesModel> >(service.GetByPlant(CurrentPlantId)).OrderBy(x => x.RepOrder).ToList();
            }

            return(View(model));
        }
Example #7
0
        public ActionResult Index(ProductionLinesModel model, int newOrder, int originalOrder)
        {
            using (var svc = new ProductionLineService())
            {
                //List<ProductionLinesModel> m = Mapper.Map<List<ProductionLinesDto>, List<ProductionLinesModel>>(svc.GetAll());
                var dto = Mapper.Map <ProductionLinesModel, ProductionLinesDto>(model);
                dto.PlantID = CurrentPlantId;
                svc.Reorder(dto, newOrder, originalOrder);
            }

            return(RedirectToAction("Index"));
        }
        public async void EnsureProductionLineIsFoundById()
        {
            var context = ContextMocker.GetContextMock();

            ContextMocker.SeedProductionLines(context);

            var ProductionLineService = new ProductionLineService(context);


            var ProductionLineId                  = new Guid("12111111-1111-1111-1111-111111111111");
            var expectedProductionLineId          = new Guid("12111111-1111-1111-1111-111111111111");
            var expectedMachineId                 = new Guid("11111111-1111-1111-1111-111111111111");
            var expectedProductionLineDescription = new ProductionLineDescription("Linha1");
            var result = await ProductionLineService.GetProductionLineById(ProductionLineId);

            Assert.Equal(expectedProductionLineId, result.Id);
            Assert.Equal(expectedProductionLineDescription, result.Description);
            Assert.Equal(expectedMachineId, result.Machines[0].Id);
        }
        public JsonResult GridByType(int typeID = 0, int rows = 0, int page = 0)
        {
            List <ProductionLineManagementModel> data = new List <ProductionLineManagementModel>();

            using (ProductionLineService svc = new ProductionLineService())
            {
                var dtos = svc.GetByType(typeID).OrderBy(t => t.LineDescCode).ToList();
                for (int i = 0; i < dtos.Count; i++)
                {
                    var model = AutoMapper.Mapper.Map <ProductionLinesDto, ProductionLineManagementModel>(dtos[i]);
                    model.Adhesive       = dtos[i].RCComp;
                    model.Compatibilizer = dtos[i].RCComp;
                    model.TPOLineRolls   = dtos[i].TPOMorC;
                    model.RollsProcessed = dtos[i].TPOMorC;
                    data.Add(model);
                }
            }
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Example #10
0
        static void Main(string[] args)
        {
            var serviceProvider = new ServiceCollection()
                                  .AddInfrastructure()
                                  .BuildServiceProvider();

            var server = new global::Grpc.Core.Server
            {
                Services = { ProductionLineService.BindService(new ProductionLineImpl(serviceProvider)) },
                Ports    = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("Production Line server listening on port " + Port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
        public JsonResult DeleteLine(int id = 0)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                using (ProductionLineService svc = new ProductionLineService())
                {
                    svc.Delete(id);
                }

                responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave);
            }
            catch (Exception exc)
            {
                responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message);
            }

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Index()
        {
            EquipmentRunTimeModel model = new EquipmentRunTimeModel();

            using (ProductionLineService service = new ProductionLineService()) {
                model.ProductionLineList = new SelectList(service.GetAll().OrderBy(l => l.LineDesc), "ID", "LineDesc");
            }

            // should only show 15 weeks starting from 5 weeks ago
            DateTime theWeek            = GetFirstDayOfWeek(DateTime.Now).AddDays((5 * 7 * -1));
            List <SelectListItem> weeks = new List <SelectListItem>();

            for (int weekIdx = -5; weekIdx <= 10; weekIdx++)
            {
                SelectListItem listItem = new SelectListItem();
                listItem.Value = theWeek.ToShortDateString();
                listItem.Text  = theWeek.ToShortDateString();
                weeks.Add(listItem);

                theWeek = theWeek.AddDays(7);
            }
            model.WeekStartingList = new SelectList(weeks, "Value", "Text", GetFirstDayOfWeek(DateTime.Now).ToShortDateString());
            return(View(model));
        }
        public JsonResult UpdateProdLineResult(ProductionLineManagementModel model)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                using (ProductionLineService svc = new ProductionLineService())
                {
                    var dto = svc.Get(model.Id);
                    dto = AutoMapper.Mapper.Map <ProductionLineManagementModel, ProductionLinesDto>(model, dto);

                    using (ProdLineTypeService typeSvc = new ProdLineTypeService())
                    {
                        ProdLineTypeDto typeDto = typeSvc.Get(dto.LineTypeID);
                        if (typeDto != null)
                        {
                            switch (typeDto.ProdLineTypeCode)
                            {
                            case "TPO":
                            case "RW":
                            {
                                switch (typeDto.ProdLineTypeCode)
                                {
                                case "TPO":
                                {
                                    dto.TPOMorC = model.TPOLineRolls;
                                }
                                break;

                                case "RW":
                                {
                                    dto.TPOMorC = model.RollsProcessed;
                                }
                                break;
                                }
                                dto.RCComp = "NA";
                            }
                            break;

                            case "RC":
                            case "CO":
                            {
                                switch (typeDto.ProdLineTypeCode)
                                {
                                case "RC":
                                {
                                    dto.RCComp = model.Compatibilizer;
                                }
                                break;

                                case "CO":
                                {
                                    dto.RCComp = model.Adhesive;
                                }
                                break;
                                }
                                dto.TPOMorC = "NA";
                            }
                            break;

                            default:
                            {
                                dto.TPOMorC = "NA";
                                dto.RCComp  = "NA";
                            }
                            break;
                            }
                        }
                    }

                    dto.ModifiedBy   = CurrentUser;
                    dto.LastModified = DateTime.Now;

                    if (dto.ID > 0)
                    {
                        svc.Update(dto);
                    }
                    else
                    {
                        dto.RepOrder = 1;

                        dto.DateEntered = DateTime.Now;
                        dto.EnteredBy   = CurrentUser;
                        dto.PlantID     = CurrentPlantId;
                        dto.ID          = svc.Add(dto);
                    }

                    model = AutoMapper.Mapper.Map <ProductionLinesDto, ProductionLineManagementModel>(dto);
                }

                responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave);
            }
            catch (Exception exc)
            {
                responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message);
            }

            model.ResponseMessage = responseMessage;

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Example #14
0
        public JsonResult GridByType(int lineID, int?rows, int?page)
        {
            rows = rows ?? DefaultPageSize;
            page = page ?? DefaultPage;

            int lineDescription;

            List <CurrentScrimViewModel>    list          = new List <CurrentScrimViewModel>();
            List <TPOCurrentRawMaterialDto> materialslist = new List <TPOCurrentRawMaterialDto>();

            if (lineID != null)
            {
                using (var service = new ProductionLineService())
                {
                    lineDescription = service.Get(lineID).ID;
                }

                using (var service = new TPOCurrentRawMaterialService())
                {
                    materialslist = service.GetAll().Where(q => q.LineID == lineDescription).ToList();
                }

                foreach (var dto in materialslist)
                {
                    RawMaterialReceivedDto rawMaterialReceivedDto = new RawMaterialReceivedDto();
                    RawMaterialDto         rawMaterialDto         = new RawMaterialDto();

                    CurrentScrimViewModel csvm = new CurrentScrimViewModel();

                    csvm.Id      = dto.ID;
                    csvm.PlantId = CurrentPlantId;

                    using (var service = new RawMaterialReceivedService())
                    {
                        rawMaterialReceivedDto = service.Get(dto.RawMaterialReceivedID ?? 0);
                        csvm.LotNumber         = rawMaterialReceivedDto.LotNumber;
                        csvm.RawMaterialID     = rawMaterialReceivedDto.Id;
                    }

                    using (var service = new RawMaterialService())
                    {
                        rawMaterialDto       = service.Get(Convert.ToInt32(rawMaterialReceivedDto.RawMaterialId));
                        csvm.RawMaterialCode = rawMaterialDto.Code;
                    }

                    csvm.EnteredBy    = dto.EnteredBy;
                    csvm.ModifiedBy   = dto.ModifiedBy;
                    csvm.DateEntered  = dto.DateEntered;
                    csvm.LastModified = dto.LastModified;

                    list.Add(csvm);
                }
            }

            int total;

            total = list.Count();
            List <CurrentScrimViewModel> currentPageDtos = new List <CurrentScrimViewModel>();

            if (rows.HasValue)
            {
                currentPageDtos.AddRange(list.OrderByDescending(r => r.DateEntered).Skip((page.Value - 1) * rows.Value).Take(rows.Value).ToList());
            }
            else
            {
                currentPageDtos.AddRange(list);
            }

            return(BuildJsonResult(currentPageDtos, total));
        }
 public ProductionLineController(Context context)
 {
     _serviceProductionLine = new ProductionLineService(context);
 }
Example #16
0
        public JsonResult CurrentScrimAjaxCreate(string id, int lineId)
        {
            ResponseMessage responseMessage;

            try
            {
                CurrentScrimViewModel currentSrimViewModel = JsonConvert.DeserializeObject <CurrentScrimViewModel>(id);

                if (currentSrimViewModel != null)
                {
                    TPOCurrentRawMaterialDto tpoCurrentRawMaterialdto = new TPOCurrentRawMaterialDto();

                    if (currentSrimViewModel.Id > 0)
                    {
                        using (TPOCurrentRawMaterialService service = new TPOCurrentRawMaterialService())
                        {
                            tpoCurrentRawMaterialdto = service.Get(currentSrimViewModel.Id);
                        }

                        using (RawMaterialReceivedService service = new RawMaterialReceivedService())
                        {
                            RawMaterialReceivedDto rawMaterialDto = new RawMaterialReceivedDto();
                            rawMaterialDto =
                                service.GetAll()
                                .Where(q => q.Id == Convert.ToInt32(currentSrimViewModel.LotNumber))
                                .ToList()
                                .FirstOrDefault();

                            tpoCurrentRawMaterialdto.RawMaterialReceivedID = rawMaterialDto.Id;
                        }
                    }
                    else
                    {
                        tpoCurrentRawMaterialdto.PlantID = CurrentPlantId;

                        using (ProductionLineService service = new ProductionLineService())
                        {
                            tpoCurrentRawMaterialdto.LineID = service.Get(lineId).ID;
                        }

                        using (RawMaterialReceivedService service = new RawMaterialReceivedService())
                        {
                            RawMaterialReceivedDto rawMaterialDto = new RawMaterialReceivedDto();
                            rawMaterialDto =
                                service.GetAll()
                                .Where(q => q.Id == Convert.ToInt32(currentSrimViewModel.LotNumber))
                                .ToList()
                                .FirstOrDefault();

                            tpoCurrentRawMaterialdto.RawMaterialReceivedID = rawMaterialDto.Id;
                        }
                    }

                    using (TPOCurrentScrimService service = new TPOCurrentScrimService())
                    {
                        if (currentSrimViewModel.Id > 0)
                        {
                            service.UpdateTPOCurrentRawMaterial(tpoCurrentRawMaterialdto);
                        }
                        else
                        {
                            service.AddTPOCurrentRawMaterial(tpoCurrentRawMaterialdto);
                        }
                    }
                }
                responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave);
            }
            catch (Exception exc)
            {
                responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message);
            }

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }
Example #17
0
        public JsonResult GetWorkOrderShiftData(int lineID, int shiftID, int workOrderID, DateTime prodDate)
        {
            WorkOrderShiftDataModel model = new WorkOrderShiftDataModel();

            //Set default units of measure
            using (UnitOfMeasureService svc = new UnitOfMeasureService())
            {
                var lengthDefault = svc.GetDefaultByTypeCode("L");
                if (lengthDefault != null)
                {
                    model.LengthUnitOfMeasure = lengthDefault.Code;
                }
                var weightDefault = svc.GetDefaultByTypeCode("W");
                if (weightDefault != null)
                {
                    model.WeightUnitOfMeasure = weightDefault.Code;
                }
            }

            //Get production line
            ProductionLinesDto lineDto = null;

            using (ProductionLineService lineSvc = new ProductionLineService())
            {
                lineDto = lineSvc.Get(lineID);
            }
            if (lineDto != null)
            {
                List <TPOCProductRollDto> rollDtos = new List <TPOCProductRollDto>();
                using (TPOCProductRollService rollSvc = new TPOCProductRollService())
                {
                    if (lineDto.TPOMorC == "M")
                    {
                        //Get master rolls
                        rollDtos.AddRange(rollSvc.GetMasterRollsByShift(lineID, shiftID, prodDate));
                    }
                    else
                    {
                        //Get child rolls
                        rollDtos.AddRange(rollSvc.GetChildRollsByShift(lineID, shiftID, prodDate));
                    }
                }
                //Filter for rolls specific to the work order
                var workOrderRolls = rollDtos.Where(r => r.WorkOrderID == workOrderID).ToList();
                model.RollCount1      = workOrderRolls.Count;
                model.Length1         = workOrderRolls.Sum(r => r.Length);
                model.Weight1         = workOrderRolls.Sum(r => r.Weight);
                model.ShiftRollWeight = rollDtos.Sum(r => r.Weight);

                //Get scraps
                List <TPOLineScrapDto> scrapDtos = new List <TPOLineScrapDto>();
                using (TPOLineScrapService scrapSvc = new TPOLineScrapService())
                {
                    scrapDtos.AddRange(scrapSvc.GetByShift(shiftID, prodDate));
                }
                //Filter for scraps specific to the work order
                var woScraps = scrapDtos.Where(s => s.WorkOrderID == workOrderID).ToList();
                for (int i = 0; i < woScraps.Count; i++)
                {
                    switch (woScraps[i].TPOLineScrapTypeDescription)
                    {
                    case "Second":
                    {
                        model.Length2 += woScraps[i].Length;
                        model.Weight2 += woScraps[i].Weight;
                    } break;

                    case "Third":
                    {
                        model.Length3 += woScraps[i].Length;
                        model.Weight3 += woScraps[i].Weight;
                    } break;

                    case "Fourth":
                    {
                        model.Length4 += woScraps[i].Length;
                        model.Weight4 += woScraps[i].Weight;
                    } break;
                    }
                }
                model.ShiftScrapWeight = scrapDtos.Sum(s => s.Weight);

                //Get downtime
                List <DownTimeDto> dtDtos = new List <DownTimeDto>();
                using (DownTimeService dtSvc = new DownTimeService())
                {
                    dtDtos.AddRange(dtSvc.GetByShift(lineID, shiftID, prodDate));
                }

                var woDowntime = dtDtos.Where(dt => dt.WorkOrderID == workOrderID).ToList();
                model.DownTimeMinutes      = woDowntime.Sum(dt => dt.DownTimeMinutes);
                model.ShiftDownTimeMinutes = dtDtos.Sum(dt => dt.DownTimeMinutes);

                //Get production line schedule
                List <ProductionLineScheduleDto> plSchedDtos = new List <ProductionLineScheduleDto>();
                using (ProductionLineScheduleService plSchedSvc = new ProductionLineScheduleService())
                {
                    plSchedDtos.AddRange(plSchedSvc.GetByShift(lineID, shiftID, prodDate));
                }

                model.ScheduledRunTime = plSchedDtos.Sum(s => s.MinutesScheduled);

                //Check if feeder entry forms need to be used
                if (lineDto.LineDescCode == "TPO")
                {
                    model.RMUse = true;
                    List <TPOFormulationLineProductDto> formDtos = new List <TPOFormulationLineProductDto>();
                    using (TPOFormulationLineProductService formSvc = new TPOFormulationLineProductService())
                    {
                        formDtos.AddRange(formSvc.GetByWorkOrder(lineID, workOrderID));
                    }
                    if (formDtos.Count > 0)
                    {
                        model.Form      = formDtos.First().TPOFormulationID;
                        model.Extruders = formDtos.First().TPOFormulationExtruders;
                    }

                    List <WorkOrderShiftDataDto> eorDtos = new List <WorkOrderShiftDataDto>();
                    using (WorkOrderShiftDataService eorSvc = new WorkOrderShiftDataService())
                    {
                        eorDtos.AddRange(eorSvc.GetByShift(lineID, shiftID, prodDate));

                        if (eorDtos.Count == 0)
                        {
                            eorSvc.Add(new WorkOrderShiftDataDto()
                            {
                                LineID         = lineID,
                                ProductionDate = prodDate,
                                ShiftID        = shiftID,
                                WorkOrderID    = workOrderID,
                                PlantID        = CurrentPlantId,
                                EnteredBy      = CurrentUser,
                                DateEntered    = DateTime.Now,
                                ModifiedBy     = CurrentUser,
                                LastModified   = DateTime.Now
                            });
                        }
                        else
                        {
                            model.ScrimA = eorDtos.First().ScrimAreaUsed;
                            model.ScrimW = eorDtos.First().ScrimWeightUsed;
                            model.Resin  = eorDtos.First().DrainedResin;
                        }
                    }
                }
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }