/// <summary>Sow the crop with the specified parameters.</summary> /// <param name="cultivar">The cultivar.</param> /// <param name="population">The population.</param> /// <param name="depth">The depth.</param> /// <param name="rowSpacing">The row spacing.</param> /// <param name="maxCover">The maximum cover.</param> /// <param name="budNumber">The bud number.</param> /// <param name="rowConfig">SkipRow configuration.</param> public void Sow(string cultivar, double population, double depth, double rowSpacing, double maxCover = 1, double budNumber = 1, double rowConfig = 1) { SowingDate = Clock.Today; SowingData = new SowPlant2Type(); SowingData.Plant = this; SowingData.Population = population; SowingData.Depth = depth; SowingData.Cultivar = cultivar; SowingData.MaxCover = maxCover; SowingData.BudNumber = budNumber; SowingData.RowSpacing = rowSpacing; SowingData.SkipRow = rowConfig; this.Population = population; // Find cultivar and apply cultivar overrides. cultivarDefinition = PMF.Cultivar.Find(Cultivars, SowingData.Cultivar); cultivarDefinition.Apply(this); // Invoke an AboutToSow event. if (Sowing != null) { Sowing.Invoke(this, new EventArgs()); } // Invoke a sowing event. if (PlantSowing != null) { PlantSowing.Invoke(this, SowingData); } Summary.WriteMessage(this, string.Format("A crop of " + CropType + " (cultivar = " + cultivar + ") was sown today at a population of " + Population + " plants/m2 with " + budNumber + " buds per plant at a row spacing of " + rowSpacing + " and a depth of " + depth + " mm")); }
public static TimePeriod CreateTimePeriodFromModel(TimePeriodModel model) { TimePeriod tp; switch (model.Type) { case "Cultivate": { tp = new Cultivate(); break; } case "Implant": { tp = new Implant(); break; } case "Bloom": { tp = new Bloom(); break; } case "Sowing": { tp = new Sowing(); break; } case "Harvest": { tp = new Harvest(); break; } case "SeedMaturity": { tp = new SeedMaturity(); break; } case "LifeTime": { tp = new LifeTime(); break; } default: tp = new LifeTime(); break; } tp.Id = model.Id; tp.Start = model.Start; tp.StartArea = model.StartArea; tp.StartMonth = model.StartMonth; tp.EndArea = model.EndArea; tp.EndMonth = model.EndMonth; if (model.Next != null) { tp.Next = CreateTimePeriodFromModel(model.Next); } return(tp); }
public void OnSow(SowPlant2Type Sow) { SowingData = Sow; // Go through all our children and find all organs. Organs.Clear(); foreach (object ChildObject in My.ChildrenAsObjects) { Organ Child = ChildObject as Organ; if (Child != null) { Organs.Add(Child); } } if (NewCrop != null) { NewCropType Crop = new NewCropType(); Crop.crop_type = CropType; Crop.sender = Name; NewCrop.Invoke(Crop); } if (Sowing != null) { Sowing.Invoke(); } // tell all our children about sow foreach (Organ Child in Organs) { Child.OnSow(Sow); } }
public int updateSowTask(MySqlConnection conn, Sowing sowing) { string taskSowQuery = "UPDATE sowingTask SET taskStatus = '" + sowing.TaskStatus + "' WHERE labourerName = '" + sowing.LabourerName + "'"; MySqlCommand sqlCmd = new MySqlCommand(taskSowQuery, conn); return(sqlCmd.ExecuteNonQuery()); }
public PlantCharacteristics( ICollection <string> names, string latinName, Sowing sowing, GardeningDate floweringTime) { Names = names.Select(name => new PlantName(name)).ToList(); LatinName = latinName; Sowing = sowing; FloweringTime = floweringTime; }
//Sowing Task public int addSowingSchedule(MySqlConnection cn, Sowing sowing) { string sowingQuery = "INSERT INTO sowingTask (labourerName, farmSector, taskStatus, startDate, endDate, method, seed, quantity, startTime, endTime)" + "VALUES ('" + sowing.LabourerName + "', " + sowing.FarmSector + ", '" + sowing.TaskStatus + "', '" + sowing.StartDate.ToString("yyyy-MM-dd") + "', '" + sowing.EndDate.ToString("yyyy-MM-dd") + "', '" + sowing.Method + "', '" + sowing.Seed + "', '" + sowing.Quantity + "', '" + sowing.StartTime.ToString("HH:mm:ss") + "', '" + sowing.EndTime.ToString("HH:mm:ss") + "' )"; MySqlCommand sqlCmd = new MySqlCommand(sowingQuery, cn); return(sqlCmd.ExecuteNonQuery()); }
private void btnSowUpd_Click(object sender, EventArgs e) { dbcon.connect(); Sowing sow = new Sowing(); sow.LabourerName = txtBoxSowLabr.Text; sow.TaskStatus = comBoxUpdSowTask.Text; ScheduleHandler scHand = new ScheduleHandler(); scHand.updateSowTask(dbcon.getConn(), sow); MessageBox.Show("Task Updated!"); }
private void OnSow(SowPlant2Type Sow) { plant_status = "alive"; if (NewCrop != null) { NewCropType Crop = new NewCropType(); Crop.crop_type = Crop_Type; Crop.sender = Name; NewCrop.Invoke(Crop); } if (Sowing != null) { Sowing.Invoke(); } }
//Buttons to save data into the database private void btnSaveSow_Click(object sender, EventArgs e) { try { dbconn.connect(); string checkQuery = "SELECT labourerName = @user FROM sowingTask WHERE (startDate >= @startDate AND endDate <= @endDate)"; using (MySqlCommand labourerValidation = new MySqlCommand(checkQuery, dbconn.getConn())) { labourerValidation.Parameters.AddWithValue("@user", comboBoxWorkers.Text); labourerValidation.Parameters.AddWithValue("@startDate", dateTimePickerSowStartDate.Value.Date); labourerValidation.Parameters.AddWithValue("@endDate", dateTimePickerSowEndDate.Value.Date); using (MySqlDataReader reader = labourerValidation.ExecuteReader()) { if (reader.HasRows) { MessageBox.Show("Labourer is already assigned to a task!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); reader.Close(); } else { dbconn.connect(); Sowing sow = new Sowing(); sow.LabourerName = comboBoxWorkers.Text; sow.FarmSector = int.Parse(comboBoxFarmSectorSow.Text); sow.TaskStatus = comBoxSowTaskStatus.Text; sow.StartDate = dateTimePickerDvStartDate.Value.Date; sow.EndDate = dateTimePickerDvEndDate.Value.Date; sow.Method = comboBoxMethods.Text; sow.Seed = comboBoxSeeds.Text; sow.Quantity = numericUpDownQauntity.Value; sow.StartTime = dateTimePickerStartSow.Value; sow.EndTime = dateTimePickerEndSow.Value; ScheduleHandler scHand = new ScheduleHandler(); scHand.addSowingSchedule(dbconn.getConn(), sow); MessageBox.Show("Task Assigned!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public int AddSowing(NewSowingVm newSowing, string userId) { var sowing = _mapper.Map <Sowing>(newSowing); sowing.UserId = userId; sowing.TypeTreatmentId = 5; Sowing newestSowing = _sowingRepository.GetNewestSowingDateTimeInField(sowing.FieldId); DateTime newestDateSowing = newestSowing.DateTreatment; DateTime oldDateSowing = sowing.DateTreatment; int sowingId = _sowingRepository.AddSowing(sowing); if (newestDateSowing < oldDateSowing) { _fieldRepository.ChangeCultivatedPlant(sowing.FieldId, sowing.CultivatedPlant, sowing.PlantVariety); } return(sowingId); }
private void testTimperiods() { SubjectManager subjectManager = new SubjectManager(); Subject subject = new Subject(); subject.Name = "ALTER FETTE SCHEIßE 3"; subject.Description = "ES FUNKT 3"; subjectManager.Create(subject); Sowing start = new Sowing(); start.AssignedTo = subject; start.StartArea = TimePeriodArea.Anfang; start.StartMonth = TimePeriodMonth.Januar; start.EndArea = TimePeriodArea.Anfang; start.EndMonth = TimePeriodMonth.Februar; start.Start = true; Harvest ende = new Harvest(); ende.AssignedTo = subject; ende.StartArea = TimePeriodArea.Mitte; ende.StartMonth = TimePeriodMonth.März; ende.EndArea = TimePeriodArea.Ende; ende.EndMonth = TimePeriodMonth.Juli; ende.Start = false; //ende = subjectManager.Create(ende); start.Next = ende; //start = subjectManager.Create(start); subject.TimePeriods.Add(start); subject.TimePeriods.Add(ende); subjectManager.Update(subject); var s = subjectManager.Get(subject.Id); }
public void OnSow(SowPlant2Type Sow) { SowingData = Sow; plant_status = "alive"; Population = SowingData.Population; if (NewCrop != null) { NewCropType Crop = new NewCropType(); Crop.crop_type = Crop_Type; Crop.sender = Name; NewCrop.Invoke(Crop); } if (Sowing != null) { Sowing.Invoke(); } }
public void OnSow(SowPlant2Type Sow) { if (Sow.Cultivar == "") { throw new Exception("Cultivar not specified on sow line."); } SowingData = Sow; // Go through all our children and find all organs. Organ1s.Clear(); foreach (object ChildObject in My.ChildrenAsObjects) { Organ1 Child1 = ChildObject as Organ1; if (Child1 != null) { Organ1s.Add(Child1); if (Child1 is AboveGround) { Tops.Add(Child1); } } } if (NewCrop != null) { NewCropType Crop = new NewCropType(); Crop.crop_type = CropType; Crop.sender = Name; NewCrop.Invoke(Crop); } if (Sowing != null) { Sowing.Invoke(); } WriteSowReport(Sow); }
/// <summary>Sow the crop with the specified parameters.</summary> /// <param name="cultivar">The cultivar.</param> /// <param name="population">The population.</param> /// <param name="depth">The depth mm.</param> /// <param name="rowSpacing">The row spacing mm.</param> /// <param name="maxCover">The maximum cover.</param> /// <param name="budNumber">The bud number.</param> /// <param name="rowConfig">SkipRow configuration.</param> public void Sow(string cultivar, double population, double depth, double rowSpacing, double maxCover = 1, double budNumber = 1, double rowConfig = 0) { SowingDate = clock.Today; SowingData = new SowingParameters(); SowingData.Plant = this; SowingData.Population = population; SowingData.Depth = depth; SowingData.Cultivar = cultivar; SowingData.MaxCover = maxCover; SowingData.BudNumber = budNumber; SowingData.RowSpacing = rowSpacing; SowingData.SkipType = rowConfig; if (rowConfig == 0) { // No skip row SowingData.SkipPlant = 1.0; SowingData.SkipRow = 0.0; } if (rowConfig == 1) { // Alternate rows (plant 1 – skip 1) SowingData.SkipPlant = 1.0; SowingData.SkipRow = 1.0; } if (rowConfig == 2) { // Planting two rows and skipping one row (plant 2 – skip 1) SowingData.SkipPlant = 2.0; SowingData.SkipRow = 1.0; } if (rowConfig == 3) { // Alternate pairs of rows (plant 2 – skip 2) SowingData.SkipPlant = 2.0; SowingData.SkipRow = 2.0; } // Adjusting number of plant per meter in each row SowingData.SkipDensityScale = 1.0 + SowingData.SkipRow / SowingData.SkipPlant; IsAlive = true; this.Population = population; // Find cultivar and apply cultivar overrides. Cultivar cultivarDefinition = FindAllDescendants <Cultivar>().FirstOrDefault(c => c.IsKnownAs(SowingData.Cultivar)); if (cultivarDefinition == null) { throw new ApsimXException(this, $"Cannot find a cultivar definition for '{SowingData.Cultivar}'"); } cultivarDefinition.Apply(this); // Invoke an AboutToSow event. if (Sowing != null) { Sowing.Invoke(this, new EventArgs()); } // Invoke a sowing event. if (PlantSowing != null) { PlantSowing.Invoke(this, SowingData); } summary.WriteMessage(this, string.Format("A crop of " + PlantType + " (cultivar = " + cultivar + ") was sown today at a population of " + Population + " plants/m2 with " + budNumber + " buds per plant at a row spacing of " + rowSpacing + " and a depth of " + depth + " mm")); }
public void UpdateSowing(Sowing sowing) { throw new System.NotImplementedException(); }
public int AddSowing(Sowing sowing) { _context.Sowings.Add(sowing); _context.SaveChanges(); return(sowing.Id); }