private void SaveButton_Click(object sender, RoutedEventArgs e) { try { Validate(); var plan = new CurrentPlan() { Description = DescriptionTextBox.Text, AddedDate = DateTime.Now, Name = NameTextBox.Text }; IocHelper.PlanService.SavePlan(plan); _plans.Add(plan); PlanDataGrid.ItemsSource = _plans.Skip(_skip).Take(10); PlanDataGrid.Items.Refresh(); InitPagerInfo(); DescriptionTextBox.Text = ""; NameTextBox.Text = ""; } catch (Exception exception) { MessageBox.Show(exception.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void SetUp() { rep = new PlanDbRepository(); plan = new CurrentPlan { AddedDate = DateTime.Now, Name = "Упячка", Description = "Упячка", IsDone = false, PossibleChangeDate = null }; }
public override void Start() { _plan_select_ctl = (NewPlanWiz1Ctl)(((Viewing.View)_app.Views[ViewTypes.NewPlanStep1]).ViewedForm); _plan_final = (NewPlanWizFinalCtl)(((Viewing.View)_app.Views[ViewTypes.NewPlanFinal]).ViewedForm); _plan_select_ctl.WizMgr = this; _plan_final.PlanWiz = this; _currentStep = NewPlanWizardSteps.PlanSelection; _app.LoadView(ViewTypes.NewPlanStep1); //start with a new, empty plan _plan = new CurrentPlan(); }
public ActionResult UpdatePlan(CurrentPlan plan) { try { var helper = new IocHelper(); helper.PlanService.UpdatePlan(plan); return(Json(plan, JsonRequestBehavior.AllowGet)); } catch (Exception e) { throw new HttpException(500, e.Message); } }
private void ChoosePlan() { var primaryIntention = Intentions.Pop(); var location = primaryIntention.Predicate as Tuple <int, int>; switch (primaryIntention.Name) { case TypesDesire.Dig: CurrentPlan = PlanLibrary.First(p => p.Name == TypesPlan.PathFinding); CurrentPlan.BuildPlan(new Tuple <int, int>(X, Y), location); break; } }
public ActionResult SavePlan(CurrentPlan plan) { try { plan.AddedDate = DateTime.Now; plan.IsDone = false; var helper = new IocHelper(); helper.PlanService.SavePlan(plan); return(Json(plan, JsonRequestBehavior.AllowGet)); } catch (Exception e) { throw new HttpException(500, e.Message); } }
//------------------------------------------------------------------------/ // Methods //------------------------------------------------------------------------/ /// <summary> /// Executes the next action in the current plan /// </summary> public void ContinuePlan() { // If there's nothing actions left in the plan, reassess? if (CurrentPlan.IsFinished) { this.Goal.Complete(this); this.Agent.gameObject.Dispatch<Plan.ExecutedEvent>(new Plan.ExecutedEvent()); //if (Tracing) Trace.Script("The plan for " + this.CurrentGoal.Name + " has been fulfilled!", this); //this.gameObject.Dispatch<Agent.> return; } this.CurrentAction = CurrentPlan.Next(); this.CurrentAction.Initialize(this.Agent); }
public ActionResult DeletePlan(int id) { try { var plan = new CurrentPlan { Id = id }; var helper = new IocHelper(); helper.PlanService.DeletePlan(plan); return(Json(true, JsonRequestBehavior.AllowGet)); } catch (Exception e) { throw new HttpException(500, e.Message); } }
private void Update() { if (currentGoal == null) { return; } var node = CurrentPlan.CurrentNode; node.OnUpdate(this); var p = node.Precondition; if (p.IsMet(this)) { CurrentPlan.Continue(this); } if (currentGoal.IsMet(this)) { ResetGoal(); } }
public TypesAction Action(List <Percept> percepts) { // Reactive Layer if (Mars.WaterAt(X, Y) && !WaterFound.Contains(new Tuple <int, int>(X, Y))) { return(TypesAction.Dig); } var waterPercepts = percepts.FindAll(p => p.Type == TypePercept.WaterSpot); if (waterPercepts.Count > 0) { foreach (var waterPercept in waterPercepts) { var belief = Beliefs.FirstOrDefault(b => b.Name == TypesBelief.PotentialWaterSpots); List <Tuple <int, int> > pred; if (belief != null) { pred = belief.Predicate as List <Tuple <int, int> >; } else { pred = new List <Tuple <int, int> > { waterPercept.Position }; Beliefs.Add(new Belief(TypesBelief.PotentialWaterSpots, pred)); } if (!WaterFound.Contains(waterPercept.Position)) { pred.Add(waterPercept.Position); } else { pred.RemoveAll( t => t.Item1 == waterPercept.Position.Item1 && t.Item2 == waterPercept.Position.Item2); if (pred.Count == 0) { Beliefs.RemoveAll(b => (b.Predicate as List <Tuple <int, int> >).Count == 0); } } } if (waterPercepts.Any(p => !WaterFound.Contains(p.Position))) { CurrentPlan = null; } } if (Beliefs.Count == 0) { if (_wanderTimes == WanderThreshold) { _wanderTimes = 0; InjectBelief(); } _wanderTimes++; return(RandomMove(percepts)); } if (CurrentPlan == null || CurrentPlan.FulFill()) { // Deliberative Layer Brf(percepts); Options(); Filter(); } return(CurrentPlan.NextAction()); }