public ActionWithParamViewModel(Action action, ActionParam actionParam, ActionWithParamListViewModel actionWithParamListViewModel) { this.ActionWithParamListViewModel = actionWithParamListViewModel; this.Name = action.Name; this.ActionParam = actionParam; this.AddActionCommand = new DelegateCommand<object>(this.OnAddAction,this.CanAddAction); }
public CombinationViewModel(Action act, Event ev, Combination comb, CombinationListViewModel combinationListViewModel) { CombinationListViewModel = combinationListViewModel; this.Action = act; this.Event = ev; this.Combination = comb; }
public ActionWithParamViewModel(Action action, ActionParam actionParam, ActionWithParamListViewModel actionWithParamListViewModel) { this.ActionWithParamListViewModel = actionWithParamListViewModel; this.Name = action.Name; this.ActionParam = actionParam; this.AddActionCommand = new DelegateCommand <object>(this.OnAddAction, this.CanAddAction); }
public virtual void AddAction(Action act) { var thisActionsHaveAct = Actions.Any(a => a.Name.Trim() == act.Name.Trim()); if (thisActionsHaveAct) return; ActionViewModels.Add(new ActionViewModel(act, this, base.ErrorCatcher)); Actions.Add(act); }
public void TestCreateCombinationsMethod() { BaseLayer = new BaseLayer(); var task1 = new Task(); BaseLayer.Task = task1; var act1 = new Action { Name = "A1" }; var act2 = new Action { Name = "A2" }; var event1 = new Event { Name = "E1", Probability = Convert.ToDecimal(0.3) }; var event2 = new Event { Name = "E2", Probability = Convert.ToDecimal(0.7) }; BaseLayer.DssDbContext.Actions.Local.Add(act1); BaseLayer.DssDbContext.Actions.Local.Add(act2); BaseLayer.DssDbContext.Events.Local.Add(event1); BaseLayer.DssDbContext.Events.Local.Add(event2); DecisionSupportSystem.Task_1.LocalTaskLayer.CreateCombinations(BaseLayer); var combins = BaseLayer.DssDbContext.Combinations.Local.ToList(); Assert.AreEqual("A1", combins[0].Action.Name); }
public void AddAction(Action act) { var haveThisActInActions = Actions.Any(a => a.Name.Trim() == act.Name.Trim()); if (haveThisActInActions) return; ActionViewModels.Add(new ActionViewModel(act, this)); Actions.Add(act); }
public ActionViewModel(ActionListViewModel actionListViewModel) { var action = new Action(); this.ActionListViewModel = actionListViewModel; this.Name = action.Name; this.AddActionCommand = new DelegateCommand<object>(this.OnAddAction, this.CanAddAction); }
public void AddActionParam(Action action, ActionParam param, ActionParamName name, decimal value) { if (param == null || action == null) return; param.Action = action; param.Value = value; param.ActionParamName = name; dssDbContext.ActionParams.Local.Add(param); }
public ActionViewModel(ActionListViewModel actionListViewModel) { var action = new Action(); this.ActionListViewModel = actionListViewModel; this.Name = action.Name; this.AddActionCommand = new DelegateCommand <object>(this.OnAddAction, this.CanAddAction); }
public void AddCombination(Combination combination, Action action, Event eEvent, Task task, decimal cpValue) { combination.Cp = cpValue; combination.Action = action; combination.Event = eEvent; combination.Task = task; dssDbContext.Combinations.Local.Add(combination); }
public CombinationWithParamViewModel(Action act, Event ev, ActionParam actionParam, EventParam eventParam, CombinationWithParamListViewModel combinationWithParamListViewModel) { CombinationWithParamListViewModel = combinationWithParamListViewModel; this.Action = act; this.Event = ev; this.ActionParam = actionParam; this.EventParam = eventParam; }
public void AddEvent(Action act, Event ev) { foreach (var eventDepAction in EventsDependingActions) if (eventDepAction.Action == act) { eventDepAction.EventListViewModel.AddEvent(ev); } }
public ActionViewModelForTask9(Action action, ActionParam credit, ActionParam isExtensable, ActionParam period, ActionListViewModelForTask9 actionListViewModel) { this.ActionListViewModel = actionListViewModel; this.Name = action.Name; this.Credit = credit; this.IsExtendable = isExtensable; this.Period = period; this.AddActionCommand = new DelegateCommand<object>(this.OnAddAction,this.CanAddAction); }
public ActionWithParamViewModel(ActionWithParamListViewModel actionWithParamListViewModel) { var action = new Action(); var paramValue = new ActionParam(); this.ActionWithParamListViewModel = actionWithParamListViewModel; this.Name = action.Name; this.ActionParam = paramValue; this.AddActionCommand = new DelegateCommand<object>(this.OnAddAction, this.CanAddAction); }
public ActionViewModelForTask9(Action action, ActionParam credit, ActionParam isExtensable, ActionParam period, ActionListViewModelForTask9 actionListViewModel) { this.ActionListViewModel = actionListViewModel; this.Name = action.Name; this.Credit = credit; this.IsExtendable = isExtensable; this.Period = period; this.AddActionCommand = new DelegateCommand <object>(this.OnAddAction, this.CanAddAction); }
public ActionWithParamViewModel(ActionWithParamListViewModel actionWithParamListViewModel) { var action = new Action(); var paramValue = new ActionParam(); this.ActionWithParamListViewModel = actionWithParamListViewModel; this.Name = action.Name; this.ActionParam = paramValue; this.AddActionCommand = new DelegateCommand <object>(this.OnAddAction, this.CanAddAction); }
public void AddAction(Action act, ActionParam actionParam) { var haveThisActInActions = Actions.Any(a => a.Name.Trim() == act.Name.Trim()); if (haveThisActInActions) return; ActionWithParamViewModels.Add(new ActionWithParamViewModel(act, actionParam, this)); Actions.Add(act); actionParam.Action = act; ActionParams.Add(actionParam); NavigationWindowShower.IsSaved = false; }
public void AddAction(Action act) { var haveThisActInActions = Actions.Any(a => a.Name.Trim() == act.Name.Trim()); if (haveThisActInActions) { return; } ActionViewModels.Add(new ActionViewModel(act, this)); Actions.Add(act); }
private void LoadActionParams(Action oldAction, Action newAction) { var actionParams = (dssDbContext.ActionParams.Where(ap => ap.ActionId == oldAction.Id)); foreach (var actionParam in actionParams) { BaseLayer.BaseMethods.AddActionParam(newAction, new ActionParam(), new ActionParamName { Name = actionParam.ActionParamName.Name }, actionParam.Value); } }
public virtual void AddAction(Action act) { var thisActionsHaveAct = Actions.Any(a => a.Name.Trim() == act.Name.Trim()); if (thisActionsHaveAct) { return; } ActionViewModels.Add(new ActionViewModel(act, this, base.ErrorCatcher)); Actions.Add(act); }
public ActionViewModel(Action actionTemplate, ActionsViewModel actionsViewModel, IErrorCatch errorCatcher) { this.ActionsViewModel = actionsViewModel; this.EditableAction = actionTemplate; this.Name = actionTemplate.Name; this.EditableActionParams = new ObservableCollection<ActionParam>(); this.AddActionCommand = new DelegateCommand<object>(this.OnAddAction); var actionParams = this.EditableAction.ActionParams.ToList(); foreach (var actionParam in actionParams) this.EditableActionParams.Add(actionParam); base.ErrorCatcher = errorCatcher; }
public void AddAction(Action act, ActionParam actionParam) { var haveThisActInActions = Actions.Any(a => a.Name.Trim() == act.Name.Trim()); if (haveThisActInActions) { return; } ActionWithParamViewModels.Add(new ActionWithParamViewModel(act, actionParam, this)); Actions.Add(act); actionParam.Action = act; ActionParams.Add(actionParam); NavigationWindowShower.IsSaved = false; }
public ActionViewModel(Action actionTemplate, ActionsViewModel actionsViewModel, IErrorCatch errorCatcher) { this.ActionsViewModel = actionsViewModel; this.EditableAction = actionTemplate; this.Name = actionTemplate.Name; this.EditableActionParams = new ObservableCollection <ActionParam>(); this.AddActionCommand = new DelegateCommand <object>(this.OnAddAction); var actionParams = this.EditableAction.ActionParams.ToList(); foreach (var actionParam in actionParams) { this.EditableActionParams.Add(actionParam); } base.ErrorCatcher = errorCatcher; }
public void TestCreateCombinationsMethod() { BaseLayer = new BaseLayer(); var task1 = new Task(); BaseLayer.Task = task1; var act1 = new Action {Name = "A1"}; var act2 = new Action {Name = "A2"}; var event1 = new Event {Name = "E1", Probability = Convert.ToDecimal(0.3)}; var event2 = new Event {Name = "E2", Probability = Convert.ToDecimal(0.7)}; BaseLayer.DssDbContext.Actions.Local.Add(act1); BaseLayer.DssDbContext.Actions.Local.Add(act2); BaseLayer.DssDbContext.Events.Local.Add(event1); BaseLayer.DssDbContext.Events.Local.Add(event2); DecisionSupportSystem.Task_1.LocalTaskLayer.CreateCombinations(BaseLayer); var combins = BaseLayer.DssDbContext.Combinations.Local.ToList(); Assert.AreEqual("A1", combins[0].Action.Name); }
public void OnAddAction(object obj) { if (base.ErrorCatcher.EntityErrorCount != 0) { return; } if (IsExtendable) { EditableAction.Name = SelectedAction.Name + " с расширением"; EditableAction.ExtendableAction = SelectedAction; } var actionParams = new Collection <ActionParam>(); foreach (var actionParam in EditableAction.ActionParams) { actionParams.Add(new ActionParam { Action = actionParam.Action, Value = actionParam.Value, ActionId = actionParam.ActionId, Id = actionParam.Id, ActionParamName = new ActionParamName { Name = actionParam.ActionParamName.Name } }); } var action = new Action { Name = EditableAction.Name, SavingId = EditableAction.SavingId, Emv = EditableAction.Emv, Eol = EditableAction.Eol, ActionParams = actionParams, ExtendableAction = EditableAction.ExtendableAction }; this.ActionsWithExtensionsViewModel.AddAction(action); }
private void LoadActions() { foreach (var a in Actions) { var action = new Action { Name = a.Name, Eol = a.Eol, Emv = a.Emv, SavingId = a.SavingId }; if (a.ExtendableAction != null) { action.ExtendableAction = BaseLayer.DssDbContext.Actions.Local.Where( act => act.Name == a.ExtendableAction.Name) .Select(act => act.ExtendableAction) .First(); } LoadActionParams(a, action); BaseLayer.BaseMethods.AddAction(action); } }
private void LoadActionParams(Action oldAction, Action newAction) { var actionParams = (dssDbContext.ActionParams.Where(ap => ap.ActionId == oldAction.Id)); foreach (var actionParam in actionParams) { BaseLayer.BaseMethods.AddActionParam(newAction, new ActionParam(), new ActionParamName{Name = actionParam.ActionParamName.Name}, actionParam.Value); } }
protected bool HaveAction(Action act, List<Combination> lastCombList) { return lastCombList.Any(combination => combination.Action == act); }
public static bool HaveAction(Action act, IEnumerable<Combination> lastCombList) { return lastCombList.Any(combination => combination.Action == act); }
protected bool HaveAction(Action act, List <Combination> lastCombList) { return(lastCombList.Any(combination => combination.Action == act)); }
public void AddAction(Action action) { if (action == null) return; dssDbContext.Actions.Local.Add(action); }
public static bool HaveAction(Action act, IEnumerable <Combination> lastCombList) { return(lastCombList.Any(combination => combination.Action == act)); }
private void LoadActions() { foreach (var a in Actions) { var action = new Action { Name = a.Name, Eol = a.Eol, Emv = a.Emv, SavingId = a.SavingId }; if (a.ExtendableAction != null) action.ExtendableAction = BaseLayer.DssDbContext.Actions.Local.Where( act => act.Name == a.ExtendableAction.Name) .Select(act => act.ExtendableAction) .First(); LoadActionParams(a, action); BaseLayer.BaseMethods.AddAction(action); } }
public void TestTask_4() { var baseLayer = new BaseLayer(); var task1 = new Task(); baseLayer.Task = task1; var act1 = new Action { Name = "A1" }; var act2 = new Action { Name = "A2" }; var event1 = new Event { Name = "E1", Probability = Convert.ToDecimal(0.65) }; var event2 = new Event { Name = "E2", Probability = Convert.ToDecimal(0.2) }; var event3 = new Event { Name = "E3", Probability = Convert.ToDecimal(0.15) }; baseLayer.DssDbContext.Actions.Local.Add(act1); baseLayer.DssDbContext.Actions.Local.Add(act2); baseLayer.DssDbContext.Events.Local.Add(event1); baseLayer.DssDbContext.Events.Local.Add(event2); baseLayer.DssDbContext.Events.Local.Add(event3); DecisionSupportSystem.Task_4.TaskCombinationsView taskCombinationsView = new TaskCombinationsView(baseLayer); taskCombinationsView.CreateCombinations(); var combins = baseLayer.DssDbContext.Combinations.Local.ToList(); Assert.AreEqual("A1", combins[0].Action.Name, "A1-E1"); Assert.AreEqual("E1", combins[0].Event.Name, "A1-E1"); Assert.AreEqual("A1", combins[1].Action.Name, "A1-E2"); Assert.AreEqual("E2", combins[1].Event.Name, "A1-E2"); Assert.AreEqual("A1", combins[2].Action.Name, "A1-E3"); Assert.AreEqual("E3", combins[2].Event.Name, "A1-E3"); Assert.AreEqual("A2", combins[3].Action.Name, "A2-E1"); Assert.AreEqual("E1", combins[3].Event.Name, "A2-E1"); Assert.AreEqual("A2", combins[4].Action.Name, "A2-E2"); Assert.AreEqual("E2", combins[4].Event.Name, "A2-E2"); Assert.AreEqual("A2", combins[5].Action.Name, "A2-E3"); Assert.AreEqual("E3", combins[5].Event.Name, "A2-E3"); taskCombinationsView.CombinationWithParamViews[0].Procent.Value = Convert.ToDecimal(7.5); taskCombinationsView.CombinationWithParamViews[0].NominalPrice.Value = 0; taskCombinationsView.CombinationWithParamViews[1].Procent.Value = 8; taskCombinationsView.CombinationWithParamViews[1].NominalPrice.Value = 10; taskCombinationsView.CombinationWithParamViews[2].Procent.Value = 6; taskCombinationsView.CombinationWithParamViews[2].NominalPrice.Value = 5; taskCombinationsView.CombinationWithParamViews[3].Procent.Value = 1; taskCombinationsView.CombinationWithParamViews[3].NominalPrice.Value = 8; taskCombinationsView.CombinationWithParamViews[4].Procent.Value = 8; taskCombinationsView.CombinationWithParamViews[4].NominalPrice.Value = 20; taskCombinationsView.CombinationWithParamViews[5].Procent.Value = 6; taskCombinationsView.CombinationWithParamViews[5].NominalPrice.Value = 20; taskCombinationsView.SolveCp(); Assert.AreEqual(Convert.ToDecimal(7.5), combins[0].Cp); Assert.AreEqual(Convert.ToDecimal(8.8), combins[1].Cp); Assert.AreEqual(Convert.ToDecimal(6.3), combins[2].Cp); Assert.AreEqual(Convert.ToDecimal(1.08), combins[3].Cp); Assert.AreEqual(Convert.ToDecimal(9.6), combins[4].Cp); Assert.AreEqual(Convert.ToDecimal(7.2), combins[5].Cp); baseLayer.SolveThisTask(); Assert.AreEqual(Convert.ToDecimal(4.875), combins[0].Wp); Assert.AreEqual(0, combins[0].Col); Assert.AreEqual(0, combins[0].Wol); Assert.AreEqual(Convert.ToDecimal(1.76), combins[1].Wp); Assert.AreEqual(Convert.ToDecimal(0.8), combins[1].Col); Assert.AreEqual(Convert.ToDecimal(0.16), combins[1].Wol); Assert.AreEqual(Convert.ToDecimal(0.945), combins[2].Wp); Assert.AreEqual(Convert.ToDecimal(0.9), combins[2].Col); Assert.AreEqual(Convert.ToDecimal(0.135), combins[2].Wol); Assert.AreEqual(Convert.ToDecimal(0.702), combins[3].Wp); Assert.AreEqual(Convert.ToDecimal(6.42), combins[3].Col); Assert.AreEqual(Convert.ToDecimal(4.173), combins[3].Wol); Assert.AreEqual(Convert.ToDecimal(1.92), combins[4].Wp); Assert.AreEqual(0, combins[4].Col); Assert.AreEqual(0, combins[4].Wol); Assert.AreEqual(Convert.ToDecimal(1.08), combins[5].Wp); Assert.AreEqual(0, combins[5].Col); Assert.AreEqual(0, combins[5].Wol); var actions = baseLayer.DssDbContext.Actions.Local.ToList(); Assert.AreEqual(Convert.ToDecimal(7.58), actions[0].Emv); Assert.AreEqual(Convert.ToDecimal(3.702), actions[1].Emv); Assert.AreEqual(Convert.ToDecimal(0.295), actions[0].Eol); Assert.AreEqual(Convert.ToDecimal(4.173), actions[1].Eol); }
protected bool HaveAction(Action action, IEnumerable <Combination> lastCombinations) { return(lastCombinations.Any(combination => combination.Action == action)); }
public void Task1HaveActionMethodTest() { var baseLayer = new BaseLayer(); // добавляем две комбинации в таблицу Combinations // событие null потому, что проверяется наличие только действия baseLayer.DssDbContext.Combinations.Local.Add(new Combination { Action = new Action(), Event = null }); baseLayer.DssDbContext.Combinations.Local.Add(new Combination { Action = new Action(), Event = null }); // в случае если действие act уже присутствовало при создании комбинаций действие-событие т.е. данное действие имеется в таблице Combinations var act = baseLayer.DssDbContext.Combinations.Local[0].Action; // вызываем тестируемый метод bool actual = LocalTaskLayer.HaveAction(act, baseLayer.DssDbContext.Combinations.Local); // если в таблице Combinations имеется запись содержащий действие act метод возвратит true Assert.AreEqual(true, actual, "Ошибка, так как данное действие присутствует в таблице Combinations"); // случае если было добавлено новое действие, проверяем имеется ли это действие в таблице Combinations act = new Action(); actual = LocalTaskLayer.HaveAction(act, baseLayer.DssDbContext.Combinations.Local); // если в таблице Combinations не имеется запись метод возвратит false Assert.AreEqual(false, actual, "Ошибка, так как данного действия нет в таблице Combinations"); }
public void DeleteAction(Action act) { if (act != null) { if (dssDbContext.Combinations.Local.Count > 0) { var combinations = dssDbContext.Combinations.Local.ToList(); var removingCombinations = combinations.Where(combination => combination.Action.Name == act.Name).ToList(); var removedEvents = removingCombinations.Select(removedCombination => removedCombination.Event).ToList(); DeleteEventsByInList(removedEvents); foreach (var removingCombination in removingCombinations) dssDbContext.Combinations.Local.Remove(removingCombination); } dssDbContext.Actions.Local.Remove(act); } }
protected bool HaveAction(Action action, IEnumerable<Combination> lastCombinations) { return lastCombinations.Any(combination => combination.Action == action); }
public void OnAddAction(object obj) { if (base.ErrorCatcher.EntityErrorCount != 0) return; if (IsExtendable) { EditableAction.Name = SelectedAction.Name + " с расширением"; EditableAction.ExtendableAction = SelectedAction; } var actionParams = new Collection<ActionParam>(); foreach (var actionParam in EditableAction.ActionParams) actionParams.Add(new ActionParam { Action = actionParam.Action, Value = actionParam.Value, ActionId = actionParam.ActionId, Id = actionParam.Id, ActionParamName = new ActionParamName { Name = actionParam.ActionParamName.Name } }); var action = new Action { Name = EditableAction.Name, SavingId = EditableAction.SavingId, Emv = EditableAction.Emv, Eol = EditableAction.Eol, ActionParams = actionParams, ExtendableAction = EditableAction.ExtendableAction }; this.ActionsWithExtensionsViewModel.AddAction(action); }