public EventViewModel(Event ev, EventListViewModel eventListViewModel)
 {
     this.EventListViewModel = eventListViewModel;
     this.Name = ev.Name;
     this.Probability = ev.Probability;
     this.AddEventCommand = new DelegateCommand<object>(this.OnAddEvent, this.CanAddEvent);
 }
 public void AddEvent(Event even)
 {
     var thisEventsHaveEven = this.Events.Any(ev => ev.Name.Trim() == even.Name.Trim());
     if (thisEventsHaveEven) return;
     this.EventWithExtensionViewModels.Add(new EventWithExtensionViewModel(even, this, base.ErrorCatcher));
     this.Events.Add(even);
 }
 public CombinationViewModel(Action act, Event ev, Combination comb, CombinationListViewModel combinationListViewModel)
 {
     CombinationListViewModel = combinationListViewModel;
     this.Action = act;
     this.Event = ev;
     this.Combination = comb;
 }
Example #4
0
 public EventWithParamViewModel(Event ev, EventParam eventParam, EventWithParamListViewModel eventWithParamListViewModel)
 {
     this.EventWithParamListViewModel = eventWithParamListViewModel;
     this.Name            = ev.Name;
     this.Probability     = ev.Probability;
     this.EventParam      = eventParam;
     this.AddEventCommand = new DelegateCommand <object>(this.OnAddEvent, this.CanAddEvent);
 }
 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 void AddEvent(Action act, Event ev)
 {
     foreach (var eventDepAction in EventsDependingActions)
         if (eventDepAction.Action == act)
         {
             eventDepAction.EventListViewModel.AddEvent(ev);
         }
 }
 public EventDepActionViewModel(BaseLayer baseLayer, Event eventTemplate, EventsDepActionsViewModel eventsDepActionsViewModel, IErrorCatch errorCatcher)
 {
     this.Actions = baseLayer.DssDbContext.Actions.Local;
     this.EditableEvent = eventTemplate;
     base.ErrorCatcher = errorCatcher;
     this.EventsDepActionsViewModel = eventsDepActionsViewModel;
     AddEventCommand = new DelegateCommand<object>(this.OnAddEvent);
 }
 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 EventsDependingActionViewModel(BaseLayer baseLayer, EventsDependingActionListViewModel eventsWithActionListViewModel)
 {
     var ev = new Event();
     this.Name = ev.Name;
     this.Probability = ev.Probability;
     Actions = baseLayer.DssDbContext.Actions.Local.ToList();
     EventsWithActionListViewModel = eventsWithActionListViewModel;
     AddEventCommand = new DelegateCommand<object>(this.OnAddEvent, this.CanAddEvent);
 }
 public EventWithExtensionViewModel(Event eventTemplate, EventsWithExtensionsViewModel eventsWithExtensionsViewModel, IErrorCatch errorCatcher)
 {
     ErrorCatcher = errorCatcher;
     this.EventsWithExtensionsViewModel = eventsWithExtensionsViewModel;
     this.EditableEvent = eventTemplate;
     this.Name = eventTemplate.Name;
     this.AddEventCommand = new DelegateCommand<object>(this.OnAddEvent);
     this.IsExtendableEventParam = eventTemplate.EventParams.ToList()[0].Value;
     this.IsExtendableEvent = Convert.ToBoolean(IsExtendableEventParam);
 }
 public EventWithParamViewModel(EventWithParamListViewModel eventWithParamListViewModel)
 {
     var ev = new Event();
     var paramValue = new EventParam();
     this.EventWithParamListViewModel = eventWithParamListViewModel;
     this.Name = ev.Name;
     this.Probability = ev.Probability;
     this.EventParam = paramValue;
     this.AddEventCommand = new DelegateCommand<object>(this.OnAddEvent, this.CanAddEvent);
 }
Example #12
0
        public EventWithParamViewModel(EventWithParamListViewModel eventWithParamListViewModel)
        {
            var ev         = new Event();
            var paramValue = new EventParam();

            this.EventWithParamListViewModel = eventWithParamListViewModel;
            this.Name            = ev.Name;
            this.Probability     = ev.Probability;
            this.EventParam      = paramValue;
            this.AddEventCommand = new DelegateCommand <object>(this.OnAddEvent, this.CanAddEvent);
        }
 public EventViewModel(Event eventTemplate, EventsViewModel eventsViewModel, IErrorCatch errorCatcher)
 {
     ErrorCatcher = errorCatcher;
     this.EventsViewModel = eventsViewModel;
     this.EditableEvent = eventTemplate;
     this.Name = eventTemplate.Name;
     this.EditableEventParams = new ObservableCollection<EventParam>();
     this.AddEventCommand = new DelegateCommand<object>(this.OnAddEvent);
     var eventParams = this.EditableEvent.EventParams.ToList();
     foreach (var eventParam in eventParams)
         this.EditableEventParams.Add(eventParam);
 }
 public void DeleteEvent(Event eEvent)
 {
     EventsDependingAction eventsDependingAction = null;
     foreach (var eDepA in EventsDependingActions)
     {
         if (eDepA.EventListViewModel.Events.Any(ev => ev == eEvent))
         {
             eventsDependingAction = eDepA;
             break;
         }
     }
     /*if (eventsDependingAction != null)
     {
         eventsDependingAction.EventListViewModel.DeleteEvent(eEvent);
     }*/
 }
Example #15
0
        public void AddEvent(Event ev, EventParam eventParam)
        {
            var haveThisEvInEvents = Events.Any(e => e.Name.Trim() == ev.Name.Trim());

            if (haveThisEvInEvents)
            {
                return;
            }
            EventWithParamViewModels.Add(new EventWithParamViewModel(ev, eventParam, this));
            Events.Add(ev);
            eventParam.Event = ev;
            EventParams.Add(eventParam);
            _baseLayer.DssDbContext.Events.Local.Add(ev);
            Sum();
            NavigationWindowShower.IsSaved = false;
        }
        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);
        }
 protected bool HaveEvent(Event eEvent, List<Combination> lastCombList)
 {
     return lastCombList.Any(combination => combination.Event == eEvent);
 }
Example #18
0
 public void GenerateEvents()
 {
     events = _baseLayer.DssDbContext.Events.Local;
     char[] name;
     decimal probability = 1m / game.Outcomes.Count;
     for (int i = 0; i < game.Outcomes.Count; i++)
     {
         name = new char[_preferences.numberofthrowings];
         for (int j = 0; j < game.Outcomes[i].Length; j++)
         {
             name[j] = InitialEvents[game.Outcomes[i][j]];
         }
         Event ev = new Event()
         {
             Name = new string(name),
             Probability = probability
         };
         ev.EventParams.Add(new EventParam() { EventParamName = bonus });
         events.Add(ev);
     }
 }
Example #19
0
 public void GenerateEvents()
 {
     events = baseLayer.DssDbContext.Events.Local;
     char[] name;
     decimal probability = 1m / game.Outcomes.Count;
     for (int i = 0; i < game.Outcomes.Count; i++)
     {
         name = new char[preferences.NumberOfThrowings];
         for (int j = 0; j < game.Outcomes[i].Length; j++)
         {
             name[j] = InitialEvents[game.Outcomes[i][j]];
         }
         Event ev = new Event()
         {
             Name = new string(name),
             Probability = probability
         };
         ev.EventParams.Add(new EventParam() { EventParamName = numberOfHeads, Value = numberOfHeadsInOutcomes[i] });
         ev.EventParams.Add(new EventParam() { EventParamName = numberOfTails, Value = numberOfTailsInOutcomes[i] });
         ev.EventParams.Add(new EventParam() { EventParamName = numberOfDoubleHeads, Value = numberOfDoubleHeadsInOutcomes[i] });
         events.Add(ev);
     }
     //events.Add(new Event() { Name = "Ничего не происходит", Probability = 1 });
 }
 public static bool HaveEvent(Event eEvent, IEnumerable<Combination> lastCombList)
 {
     return lastCombList.Any(combination => combination.Event == eEvent);
 }
 public void AddEvent(Event ev, EventParam eventParam)
 {
     var haveThisEvInEvents = Events.Any(e => e.Name.Trim() == ev.Name.Trim());
     if (haveThisEvInEvents) return;
     EventWithParamViewModels.Add(new EventWithParamViewModel(ev, eventParam, this));
     Events.Add(ev);
     eventParam.Event = ev;
     EventParams.Add(eventParam);
     _baseLayer.DssDbContext.Events.Local.Add(ev);
     Sum();
     NavigationWindowShower.IsSaved = false;
 }
        public void DeleteEvent(Event ev)
        {
            if (ev != null)
            {
                if (dssDbContext.Combinations.Local.Count > 0)
                {
                    var combinations = dssDbContext.Combinations.Local.ToList();
                    var removingCombinations =
                        combinations.Where(combination => combination.Event.Name == ev.Name).ToList();

                    foreach (var removedCombination in removingCombinations)
                        dssDbContext.Combinations.Local.Remove(removedCombination);
                }
                dssDbContext.Events.Local.Remove(ev);
            }
        }
 public void AddEvent(Event eEvent)
 {
     if (eEvent == null) return;
     dssDbContext.Events.Add(eEvent);
 }
 public void AddEventParam( Event eEvent, EventParam param, EventParamName name, decimal value)
 {
     if (param == null || eEvent == null) return;
     param.Event = eEvent;
     param.Value = value;
     param.EventParamName = name;
     dssDbContext.EventParams.Local.Add(param);
 }
 protected bool HaveEvent(Event eEvent, IEnumerable<Combination> lastCombinations)
 {
     return lastCombinations.Any(combination => combination.Event == eEvent);
 }
        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);
        }
Example #27
0
 private void LoadEventParams(Event oldEvent, Event newEvent)
 {
     var eventParams = (dssDbContext.EventParams.Where(ep => ep.EventId == oldEvent.Id));
     foreach (var eventParam in eventParams)
     {
         BaseLayer.BaseMethods.AddEventParam( newEvent, new EventParam(), new EventParamName{Name = eventParam.EventParamName.Name}, eventParam.Value);
     }
 }
Example #28
0
 private void LoadEvents()
 {
     foreach (var ev in Events)
     {
         if (ev != null)
         {
             var eEvent = new Event
                 {
                     Name = ev.Name,
                     Probability = ev.Probability,
                     SavingId = ev.SavingId
                 };
             LoadEventParams(ev, eEvent);
             BaseLayer.BaseMethods.AddEvent(eEvent);
         }
     }
 }