Пример #1
0
 private void OnBatchEnded(Batch batch)
 {
     if (BatchEnded != null)
     {
         BatchEnded(this, batch);
     }
 }
Пример #2
0
        public void CreateMeasures_WhenThereIsNoSequenceForTheMeasureCreatedDate_ApplicationExceptionThrown()
        {
            var standardId = Guid.NewGuid();

            var batchId = Guid.NewGuid();

            var geneticLineId = Guid.NewGuid();

            var batchCreatedDate = new DateTime(2015, 09, 09);

            var batch = new Batch() { CreatedDate = batchCreatedDate, Id = batchId, GeneticLineId = geneticLineId };

            var standardItem = new StandardItem()
            {
                Sequence = 1,
                StandardGeneticLine =
                    new StandardGeneticLine()
                    {
                        GeneticLineId = geneticLineId,
                        StandardId = standardId
                    }
            };

            var standardItems = new List<StandardItem>() { standardItem }.AsQueryable();

            var standardWithDataTypeWeek = new Standard()
            {
                Id = standardId,
                DataLoadTypeId = new Guid(GlobalConstants.WeeklyDataLoadType)
            };

            Mock.Get(_standardRepository)
                .Setup(x => x.Get(standardId))
                .Returns(standardWithDataTypeWeek);

            Mock.Get(_batchRepository)
                .Setup(x => x.Get(batchId))
                .Returns(batch);

            Mock.Get(_standardItemRepository)
                .Setup(repository => repository.GetAll(It.IsAny<Expression<Func<StandardItem, bool>>>()))
                .Returns(standardItems);

            var outOfScopeMeasureDate = new DateTime(2015, 09, 30);

            _measureService = new MeasureService(_uow, _clock);

            var measures = new List<LoadMeasureModel>() { new LoadMeasureModel()
                                                          {
                                                              BatchId = batchId,
                                                              StandardId = standardId,
                                                              CreatedDate = outOfScopeMeasureDate
                                                          }};

            _measureService.CreateMeasures(measures, batchId);
        }
Пример #3
0
        public void Create(Batch batch)
        {
            foreach (var batchBarn in batch.BatchBarns)
            {
                Uow.BatchBarns.Add(batchBarn);
            }

            Uow.Batches.Add(batch);

            Uow.Commit();
        }
Пример #4
0
        private void FrmObservationList_Load(object sender, EventArgs e)
        {
            using (var batchService = _serviceFactory.Create<IBatchService>())
            {
                batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);
            }

            UpdateGrid();
        }
Пример #5
0
 public void EndBatch(Batch batch, DateTime endDate)
 {
     batch.EndDate = endDate;
     Uow.Batches.Edit(batch);
     Uow.Commit();
 }
        private void FrmCreateEditSiloEmptying_Load(object sender, EventArgs e)
        {
            var formTitle = "";

            using (var batchService = _serviceFactory.Create<IBatchService>())
            {
                _batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);
                dtpDate.Value = DateTime.Now;
                formTitle = "Registrar Vaciamiento de Silo";
            }

            if (_emptyingId != Guid.Empty)
            {
                using (var service = _serviceFactory.Create<ISiloEmptyingService>())
                {
                    _siloEmptying = service.GetById(_emptyingId);
                    dtpDate.Value = _siloEmptying.Date;
                    formTitle = "Editar Vaciamiento de Silo";
                }
            }

            this.Text = formTitle;
            txtBatchName.Text = String.Format("Lote {0}", _stateController.CurrentSelectedBatch.Number);
        }
Пример #7
0
 private void FrmOnBatchEnded(object sender, Batch batch)
 {
     TransitionManager.LoadBatchSelectionView();
 }
        private void FrmCreateEditBatchVaccine_Load(object sender, EventArgs e)
        {
            var formTitle = "";
            txtRecommendedDate.Visible = false;
            lblRecommendedDate.Visible = false;

            using (var batchService = _serviceFactory.Create<IBatchService>())
            {
                _batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);

                dtpStartDate.Value = _batch.DateOfBirth;
                dtpEndDate.Value = _batch.DateOfBirth.AddDays(_batch.GeneticLine.ProductionWeeks * 7);
                txtRecommendedDate.Text = "";
                formTitle = string.Format("Lote {0} - Crear Vacunación", _batch.Number.ToString());
            }

            using (var vaccineService = _serviceFactory.Create<IVaccineService>())
            {
                var vaccines = vaccineService.GetAllActive().OrderBy(x => x.Name).ToList();
                ddlVaccines.ValueMember = "Id";
                ddlVaccines.DisplayMember = "Name";
                Vaccine item = new Vaccine();
                item.Name = "Seleccione una vacuna..";
                item.Id = Guid.Empty;
                vaccines.Insert(0,item);
                ddlVaccines.DataSource = vaccines;
                //ddlVaccines.Items.Add(item);
            }

            if (_batchVaccineId != Guid.Empty)
            {
                //Editar
                using (var batchVaccineService = _serviceFactory.Create<IBatchVaccineService>())
                {
                    _batchVaccine = batchVaccineService.GetById(_batchVaccineId);
                    if (_batchVaccine.Vaccine.RecommendedDay.HasValue)
                    {
                        txtRecommendedDate.Text = _batch.DateOfBirth.AddDays(_batchVaccine.Vaccine.RecommendedDay.Value).ToString();
                        txtRecommendedDate.ReadOnly = true;
                    }
                    else
                    {
                        txtRecommendedDate.Visible = false;
                        lblRecommendedDate.Visible = false;
                    }

                    dtpStartDate.Value = _batchVaccine.StartDate;
                    if (_batchVaccine.EndDate != null) dtpEndDate.Value = _batchVaccine.EndDate.Value;
                    ddlVaccines.SelectedValue = _batchVaccine.VaccineId;
                    formTitle = string.Format("Lote {0} - Editar Vacunación", _batch.Number.ToString());
                }
            }

            this.Text = formTitle;
        }
Пример #9
0
        public void CreateMeasures_WhenThereIsSequenceForTheMeasureCreatedDate_NoException()
        {
            var standardId = Guid.NewGuid();

            var batchId = Guid.NewGuid();

            var geneticLineId = Guid.NewGuid();

            var batchCreatedDate = new DateTime(2015, 09, 09);

            var batch = new Batch() { CreatedDate = batchCreatedDate, Id = batchId, GeneticLineId = geneticLineId };

            var standardItem = new StandardItem()
            {
                Sequence = 1,
                StandardGeneticLine =
                    new StandardGeneticLine()
                    {
                        GeneticLineId = geneticLineId,
                        StandardId = standardId
                    }
            };

            var standardItems = new List<StandardItem>() { standardItem }.AsQueryable();

            var standardWithDataTypeWeek = new Standard()
            {
                Id = standardId,
                DataLoadTypeId = new Guid(GlobalConstants.WeeklyDataLoadType)
            };

            Mock.Get(_standardRepository)
                .Setup(x => x.Get(standardId))
                .Returns(standardWithDataTypeWeek);

            Mock.Get(_batchRepository)
                .Setup(x => x.Get(batchId))
                .Returns(batch);

            Mock.Get(_standardItemRepository)
                .Setup(repository => repository.Get(It.IsAny<Expression<Func<StandardItem, bool>>>()))
                .Returns<Expression<Func<StandardItem, bool>>,
                         Expression<Func<StandardItem, object>>[]>((expression, includes) =>
                                                                   {
                                                                       return standardItems.FirstOrDefault(expression);
                                                                   });

            Mock.Get(_standardItemRepository)
                .Setup(repository => repository.GetAll(It.IsAny<Expression<Func<StandardItem, bool>>>()))
                .Returns(standardItems);

            var validMeasureDate = new DateTime(2015, 09, 16);

            _measureService = new MeasureService(_uow, _clock);

            var measures = new List<LoadMeasureModel>()
                           {
                               new LoadMeasureModel()
                               {
                                   BatchId = batchId,
                                   StandardId = standardId,
                                   CreatedDate = validMeasureDate
                               }
                           };

            _measureService.CreateMeasures(measures, batchId);

            Assert.IsTrue(true);
        }
Пример #10
0
        public void MaxDateAllowed_WhenStandardContains1WeekItem_Returns1WeekFromTheBatchCreatedDate()
        {
            var standardId = Guid.NewGuid();

            var geneticLineId = Guid.NewGuid();

            var batchCreatedDate = new DateTime(2015, 09, 09);

            var batch = new Batch() { CreatedDate = batchCreatedDate, GeneticLineId = geneticLineId };

            var standardItem = new StandardItem()
                               {
                                   Sequence = 1,
                                   StandardGeneticLine =
                                       new StandardGeneticLine()
                                       {
                                           GeneticLineId = geneticLineId,
                                           StandardId = standardId
                                       }
                               };

            var standardItems = new List<StandardItem>() { standardItem }.AsQueryable();

            var standardWithDataTypeWeek = new Standard()
                                           {
                                               Id = standardId,
                                               DataLoadTypeId = new Guid(GlobalConstants.WeeklyDataLoadType)
                                           };

            Mock.Get(_standardRepository)
                .Setup(x => x.Get(standardId))
                .Returns(standardWithDataTypeWeek);

            Mock.Get(_standardItemRepository)
                .Setup(repository => repository.GetAll(It.IsAny<Expression<Func<StandardItem, bool>>>()))
                .Returns(standardItems);

            _measureService = new MeasureService(_uow, _clock);

            var actualValue = _measureService.MaxDateAllowed(standardId, geneticLineId, batch.CreatedDate);

            DateTime expectedValue = new DateTime(2015, 09, 16);

            Assert.AreEqual(actualValue, expectedValue);
        }
Пример #11
0
 private void FrmOnBatchCreated(object sender, Batch batch)
 {
     LoadActiveBatches();
 }
        private void FrmCreateEditBatchMedicine_Load(object sender, EventArgs e)
        {
            var formTitle = "";

            using (var batchService = _serviceFactory.Create<IBatchService>())
            {
                _batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);

                dtpStartDate.Value = _batch.DateOfBirth;
                dtpEndDate.Value = _batch.DateOfBirth.AddDays(_batch.GeneticLine.ProductionWeeks * 7);
                txtObservation.Text = "";
                formTitle = string.Format("Lote {0} - Crear Medicamento", _batch.Number.ToString());
            }

            using (var medicineService = _serviceFactory.Create<IMedicineService>())
            {
                var vaccines = medicineService.GetAllActive().OrderBy(x => x.Name).ToList();
                ddlMedicines.ValueMember = "Id";
                ddlMedicines.DisplayMember = "Name";
                Medicine item = new Medicine();
                item.Name = "Selecciona un medicamento..";
                item.Id = Guid.Empty;
                vaccines.Insert(0,item);
                ddlMedicines.DataSource = vaccines;
            }

            if (_batchMedicineId != Guid.Empty)
            {
                //Editar
                using (var batchMedicineService = _serviceFactory.Create<IBatchMedicineService>())
                {
                    _batchMedicine = batchMedicineService.GetById(_batchMedicineId);
                    txtObservation.Text = _batchMedicine.Observation;
                    dtpStartDate.Value = _batchMedicine.StartDate;
                    if (_batchMedicine.EndDate != null) dtpEndDate.Value = _batchMedicine.EndDate.Value;
                    ddlMedicines.SelectedValue = _batchMedicine.MedicineId;
                    formTitle = string.Format("Lote {0} - Editar Medicamento", _batch.Number.ToString());
                }
            }

            this.Text = formTitle;
        }
        private void FrmCreateBatchObservation_Load(object sender, EventArgs e)
        {
            var formTitle = "";

            using (var batchService = _serviceFactory.Create<IBatchService>())
            {
                _batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);
                SetWeekAndDay(_batch.DateOfBirth,DateTime.Now);
                dtpObservationDate.Value = DateTime.Now;
                formTitle = string.Format("Lote {0} - Crear Observación", _batch.Number.ToString());
            }

            if (_observationId != Guid.Empty)
            {
                using (var batchObservationService = _serviceFactory.Create<IBatchObservationService>())
                {
                    _batchObservation = batchObservationService.GetById(_observationId);
                    SetWeekAndDay(_batch.DateOfBirth, _batchObservation.ObservationDate);
                    txtObservation.Text = _batchObservation.Content;
                    dtpObservationDate.Value = _batchObservation.ObservationDate;
                    formTitle = string.Format("Lote {0} - Editar Observación", _batch.Number.ToString());
                }
            }

            this.Text = formTitle;
            txtDay.Enabled = false;
            txtWeek.Enabled = false;
        }