Example #1
0
 public static SmScenario Build(string name, int week, int scenarioMask, int scenarioWeekMin,
                                int scenarioWeekMax, int markdownCountStartWeek, int defaultMarkdownType,
                                DecisionState defaultDecisionState, bool allowPromoAsMarkdown, decimal minimumPromoPercentage,
                                int organisationId, int userId)
 {
     return(new SmScenario
     {
         ScenarioId = 0,
         Week = week,
         ScheduleWeekMin = scenarioWeekMin,
         ScheduleWeekMax = scenarioWeekMax,
         ScheduleStageMin = 1,
         ScheduleStageMax = 4,
         OrganisationId = organisationId,
         ScenarioName = name,
         ScheduleMask = scenarioMask,
         MarkdownCountStartWeek = markdownCountStartWeek,
         DefaultMarkdownType = defaultMarkdownType,
         DefaultDecisionState = defaultDecisionState,
         DefaultDecisionStateName = defaultDecisionState.ToString(),
         AllowPromoAsMarkdown = allowPromoAsMarkdown,
         MinimumPromoPercentage = minimumPromoPercentage,
         CreatedBy = userId
     });
 }
Example #2
0
        public ParserInterpreter(string grammarFileName, IVocabulary vocabulary, IEnumerable <string> ruleNames, ATN atn, ITokenStream input)
            : base(input)
        {
            this._grammarFileName = grammarFileName;
            this._atn             = atn;
            this._ruleNames       = ruleNames.ToArray();
            this.vocabulary       = vocabulary;
            // identify the ATN states where pushNewRecursionContext must be called
            this.pushRecursionContextStates = new BitSet(atn.states.Count);
            foreach (ATNState state in atn.states)
            {
                if (!(state is StarLoopEntryState))
                {
                    continue;
                }
                if (((StarLoopEntryState)state).isPrecedenceDecision)
                {
                    this.pushRecursionContextStates.Set(state.stateNumber);
                }
            }

            //init decision DFA
            int numberofDecisions = atn.NumberOfDecisions;

            this._decisionToDFA = new Dfa.DFA[numberofDecisions];
            for (int i = 0; i < numberofDecisions; i++)
            {
                DecisionState decisionState = atn.GetDecisionState(i);
                _decisionToDFA[i] = new Dfa.DFA(decisionState, i);
            }
            // get atn simulator that knows how to do predictions
            Interpreter = new ParserATNSimulator(this, atn, _decisionToDFA, null);
        }
Example #3
0
        /** identify the ATN states where we need to set the outer alt number.
         *  For regular rules, that's the block at the target to rule start state.
         *  For left-recursive rules, we track the primary block, which looks just
         *  like a regular rule's outer block, and the star loop block (always
         *  there even if 1 alt).
         */
        public virtual BitSet FindOuterMostDecisionStates()
        {
            BitSet track             = new BitSet(atn.states.Count);
            int    numberOfDecisions = atn.NumberOfDecisions;

            for (int i = 0; i < numberOfDecisions; i++)
            {
                DecisionState  decisionState = atn.GetDecisionState(i);
                RuleStartState startState    = atn.ruleToStartState[decisionState.ruleIndex];
                // Look for StarLoopEntryState that is in any left recursive rule
                if (decisionState is StarLoopEntryState)
                {
                    StarLoopEntryState loopEntry = (StarLoopEntryState)decisionState;
                    if (loopEntry.precedenceRuleDecision)
                    {
                        // Recursive alts always result in a (...)* in the transformed
                        // left recursive rule and that always has a BasicBlockStartState
                        // even if just 1 recursive alt exists.
                        ATNState blockStart = loopEntry.Transition(0).target;
                        // track the StarBlockStartState associated with the recursive alternatives
                        track.Set(blockStart.stateNumber);
                    }
                }
                else if (startState.Transition(0).target == decisionState)
                {
                    // always track outermost block for any rule if it exists
                    track.Set(decisionState.stateNumber);
                }
            }
            return(track);
        }
Example #4
0
    //This function is a callback for a changed Decision.
    //It disables the action-script for the old action and enables the script for the new one
    public void OnStateChanged(DecisionState newState, DecisionState oldState)
    {
        //Dissable old action component
        if (actionScripts.ContainsKey(oldState))
        {
            //here we need to grad the MonoBehaviour because it has the enabled property
            MonoBehaviour mono = (MonoBehaviour)GetComponent(actionScripts[oldState]);
            mono.enabled = false;
        }
        else
        {
            Debug.LogError("DecisionController OnStateChanged - oldState was not in the Dictionary");
            return;
        }

        //Enable new action component
        if (actionScripts.ContainsKey(newState))
        {
            //here we need to grad the MonoBehaviour because it has the enabled property
            MonoBehaviour mono = (MonoBehaviour)GetComponent(actionScripts[newState]);
            mono.enabled = true;
        }
        else
        {
            Debug.LogError("DecisionController OnStateChanged - newState was not in the Dictionary");
            return;
        }
    }
    public void Init()
    {
        foreach (DecisionState state in DecisionStates)
            state.Init();

        Current = FindState(StartState);
        Finished = false;
    }
Example #6
0
    // Use this for initialization
    void Start()
    {
        //the default action
        currentState = DecisionState.Explore;
        //currentState = DecisionState.GetFood;

        action_Ex = GetComponent <Action_Explore>();
        action_GF = GetComponent <Action_GetFood>();

        action_GF.RegisterActionIsDoneCallback(OnActionFinished);
    }
Example #7
0
        /** Return a list of parse trees, one for each alternative in a decision
         *  given the same input.
         *
         *  Very similar to {@link #getAllPossibleParseTrees} except
         *  that it re-parses the input for every alternative in a decision,
         *  not just the ambiguous ones (there is no alts parameter here).
         *  This method also tries to reduce the size of the parse trees
         *  by stripping away children of the tree that are completely out of range
         *  of startIndex..stopIndex. Also, because errors are expected, we
         *  use a specialized error handler that more or less bails out
         *  but that also consumes the first erroneous token at least. This
         *  ensures that an error node will be in the parse tree for display.
         *
         *  NOTES:
         * // we must parse the entire input now with decision overrides
         * // we cannot parse a subset because it could be that a decision
         * // above our decision of interest needs to read way past
         * // lookaheadInfo.stopIndex. It seems like there is no escaping
         * // the use of a full and complete token stream if we are
         * // resetting to token index 0 and re-parsing from the start symbol.
         * // It's not easy to restart parsing somewhere in the middle like a
         * // continuation because our call stack does not match the
         * // tree stack because of left recursive rule rewriting. grrrr!
         *
         * @since 4.5.1
         */
        public static IList <ParserRuleContext> GetLookaheadParseTrees(Grammar g,
                                                                       ParserInterpreter originalParser,
                                                                       ITokenStream tokens,
                                                                       int startRuleIndex,
                                                                       int decision,
                                                                       int startIndex,
                                                                       int stopIndex)
        {
            IList <ParserRuleContext> trees = new List <ParserRuleContext>();
            // Create a new parser interpreter to parse the ambiguous subphrase
            ParserInterpreter parser = DeriveTempParserInterpreter(g, originalParser, tokens);

            DecisionState decisionState = originalParser.Atn.decisionToState[decision];

            for (int alt = 1; alt <= decisionState.Transitions.Length; alt++)
            {
                // re-parse entire input for all ambiguous alternatives
                // (don't have to do first as it's been parsed, but do again for simplicity
                //  using this temp parser.)
                BailButConsumeErrorStrategy errorHandler = new BailButConsumeErrorStrategy();
                parser.ErrorHandler = errorHandler;
                parser.Reset();
                parser.AddDecisionOverride(decision, startIndex, alt);
                ParserRuleContext tt = parser.Parse(startRuleIndex);
                int stopTreeAt       = stopIndex;
                if (errorHandler.firstErrorTokenIndex >= 0)
                {
                    stopTreeAt = errorHandler.firstErrorTokenIndex; // cut off rest at first error
                }

                Interval overallRange = tt.SourceInterval;
                if (stopTreeAt > overallRange.b)
                {
                    // If we try to look beyond range of tree, stopTreeAt must be EOF
                    // for which there is no EOF ref in grammar. That means tree
                    // will not have node for stopTreeAt; limit to overallRange.b
                    stopTreeAt = overallRange.b;
                }

                ParserRuleContext subtree =
                    Trees.GetRootOfSubtreeEnclosingRegion(tt,
                                                          startIndex,
                                                          stopTreeAt);
                // Use higher of overridden decision tree or tree enclosing all tokens
                if (Trees.IsAncestorOf(parser.OverrideDecisionRoot, subtree))
                {
                    subtree = parser.OverrideDecisionRoot;
                }
                Trees.StripChildrenOutOfRange(subtree, parser.OverrideDecisionRoot, startIndex, stopTreeAt);
                trees.Add(subtree);
            }

            return(trees);
        }
Example #8
0
        public SmCalcProduct(SmScenario scenario, int modelId, SmProduct product, List <SmDenseSchedule> schedules, SmDepth depth)
        {
            ClientId      = scenario.OrganisationId;
            ModelId       = modelId;
            ScenarioId    = scenario.ScenarioId;
            ProductId     = product.ProductId;
            ProductName   = product.Name;
            PriceLadderId = product.PriceLadder.PriceLadderId;

            Recommendations = new List <SmCalcRecommendation>();

            HierarchyId   = product.HierarchyId;
            HierarchyName = product.HierarchyName;

            ScheduleCount                  = schedules.Count;
            ScheduleCrossProductCount      = 0;
            ScheduleProductMaskFilterCount = 0;
            ScheduleMaxMarkdownFilterCount = 0;
            ScheduleExceededFlowlineThresholdFilterCount = 0;

            HighPredictionCount      = 0;
            NegativeRevenueCount     = 0;
            InvalidMarkdownTypeCount = 0;
            MinimumAbsolutePriceChangeNotMetCount           = 0;
            MinimumRelativePercentagePriceChangeNotMetCount = 0;
            DiscountPercentageOutsideAllowedRangeCount      = 0;

            CurrentMarkdownCount = product.CurrentMarkdownCount;
            CurrentMarkdownType  = product.CurrentMarkdownType;
            CurrentSellingPrice  = product.CurrentSellingPrice;
            OriginalSellingPrice = product.OriginalSellingPrice;
            CurrentCostPrice     = product.CurrentCostPrice;
            CurrentStock         = product.CurrentStock;
            CurrentSalesQuantity = product.CurrentSalesQuantity;

            SellThroughTarget = product.SellThrough;

            SalesFlexFactor = product.SalesFlexFactor;

            MarkdownTypeConstraint               = product.MarkdownTypeConstraint;
            MinimumAbsolutePriceChange           = product.MinimumAbsolutePriceChange;
            MinimumRelativePercentagePriceChange = product.MinimumRelativePercentagePriceChange;
            MinDiscountsNew     = product.MinDiscountsNew;
            MinDiscountsFurther = product.MinDiscountsFurther;
            MaxDiscountsNew     = product.MaxDiscountsNew;
            MaxDiscountsFurther = product.MaxDiscountsFurther;

            CurrentMarkdownDepth       = depth.MarkdownDepth;
            CurrentDiscountLadderDepth = depth.DiscountLadderDepth;

            State         = ProductState.Fatal;
            DecisionState = scenario.DefaultDecisionState;
        }
 public async Task <int> SetDecisionState(int clientId, int scenarioId, DecisionState state)
 {
     using (var command = new NpgsqlCommand(
                @"UPDATE recommendation_product
           SET decision_state_name = @p_state
           WHERE client_id = @p_client_id AND scenario_id = @p_scenario_id",
                (NpgsqlConnection)Context.Connection))
     {
         command.Parameters.AddWithValue("p_client_id", NpgsqlDbType.Integer, clientId);
         command.Parameters.AddWithValue("p_scenario_id", NpgsqlDbType.Integer, scenarioId);
         command.Parameters.AddWithValue("p_state", NpgsqlDbType.Varchar, state.ToString());
         return(await command.ExecuteNonQueryAsync());
     }
 }
Example #10
0
        public DFA(DecisionState atnStartState, int decision)
        {
            this.atnStartState = atnStartState;
            this.decision      = decision;

            this.precedenceDfa = false;
            if (atnStartState is StarLoopEntryState && ((StarLoopEntryState)atnStartState).isPrecedenceDecision)
            {
                this.precedenceDfa = true;
                DFAState precedenceState = new DFAState(new ATNConfigSet());
                precedenceState.edges               = new DFAState[0];
                precedenceState.isAcceptState       = false;
                precedenceState.requiresFullContext = false;
                this.s0 = precedenceState;
            }
        }
Example #11
0
        /** Override this method so that we can record which alternative
         *  was taken at each decision point. For non-left recursive rules,
         *  it's simple. Set decisionStatesThatSetOuterAltNumInContext
         *  indicates which decision states should set the outer alternative number.
         *
         *  <p>Left recursive rules are much more complicated to deal with:
         *  there is typically a decision for the primary alternatives and a
         *  decision to choose between the recursive operator alternatives.
         *  For example, the following left recursive rule has two primary and 2
         *  recursive alternatives.</p>
         *
         *   e : e '*' e
         | '-' INT
         | e '+' e
         | ID
         |     ;
         |
         *  <p>ANTLR rewrites that rule to be</p>
         *
         *   e[int precedence]
         *       : ('-' INT | ID)
         *       ( {...}? '*' e[5]
         | {...}? '+' e[3]
         |       )*
         |      ;
         |
         *
         *  <p>So, there are two decisions associated with picking the outermost alt.
         *  This complicates our tracking significantly. The outermost alternative number
         *  is a function of the decision (ATN state) within a left recursive rule and the
         *  predicted alternative coming back from adaptivePredict().</p>
         *
         *  We use stateToAltsMap as a cache to avoid expensive calls to
         *  getRecursiveOpAlts().
         */
        protected override int VisitDecisionState(DecisionState p)
        {
            int predictedAlt = base.VisitDecisionState(p);

            if (p.NumberOfTransitions > 1)
            {
                //			System.out.println("decision "+p.decision+": "+predictedAlt);
                if (p.decision == this.overrideDecision &&
                    this._input.Index == this.overrideDecisionInputIndex)
                {
                    overrideDecisionRoot = (GrammarInterpreterRuleContext)Context;
                }
            }

            GrammarInterpreterRuleContext ctx = (GrammarInterpreterRuleContext)_ctx;

            if (decisionStatesThatSetOuterAltNumInContext.Get(p.stateNumber))
            {
                ctx.OuterAlternative = predictedAlt;
                Rule r = g.GetRule(p.ruleIndex);
                if (atn.ruleToStartState[r.index].isPrecedenceRule)
                {
                    int[]             alts = stateToAltsMap[p.stateNumber];
                    LeftRecursiveRule lr   = (LeftRecursiveRule)g.GetRule(p.ruleIndex);
                    if (p.StateType == StateType.BlockStart)
                    {
                        if (alts == null)
                        {
                            alts = lr.GetPrimaryAlts();
                            stateToAltsMap[p.stateNumber] = alts; // cache it
                        }
                    }
                    else if (p.StateType == StateType.StarBlockStart)
                    {
                        if (alts == null)
                        {
                            alts = lr.GetRecursiveOpAlts();
                            stateToAltsMap[p.stateNumber] = alts; // cache it
                        }
                    }
                    ctx.OuterAlternative = alts[predictedAlt];
                }
            }

            return(predictedAlt);
        }
        /// <summary>
        /// Method visitDecisionState() is called when the interpreter reaches
        /// a decision state (instance of DecisionState).
        /// </summary>
        /// <remarks>
        /// Method visitDecisionState() is called when the interpreter reaches
        /// a decision state (instance of DecisionState). It gives an opportunity
        /// for subclasses to track interesting things.
        /// </remarks>
        protected internal virtual int VisitDecisionState(DecisionState p)
        {
            int predictedAlt;

            ErrorHandler.Sync(this);
            int decision = p.decision;

            if (decision == overrideDecision && _input.Index == overrideDecisionInputIndex && !overrideDecisionReached)
            {
                predictedAlt            = overrideDecisionAlt;
                overrideDecisionReached = true;
            }
            else
            {
                predictedAlt = Interpreter.AdaptivePredict(_input, decision, _ctx);
            }
            return(predictedAlt);
        }
Example #13
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //colliders that get into the vision radius of this character
        colliders = Physics2D.OverlapCircleAll(this.transform.position, visionRadius);
        //FIXME: If we did see some food, this shouldnt be called any longer
        //only food colliders in the vision readius
        food = Physics2D.OverlapCircle(this.transform.position, visionRadius, LayerMask.GetMask("FoodLayer"));

        //here the actual state machine is implemented
        if (food != null && hasAction == false)
        {
            CurrentState = DecisionState.GetFood;
            hasAction    = true;
        }
        else if (hasAction == false)
        {
            CurrentState = DecisionState.Explore;
            hasAction    = true;
        }
    }
Example #14
0
        public async Task<int> Create(string name, int week, int scenarioMask, int senarioWeekMin,
                                      int scenarioWeekMax, int markdownCountStartWeek, int defaultMarkdownType, 
                                      DecisionState defaultDecisionState, bool allowPromoAsMarkdown, decimal minimumPromoPercentage,
                                      int organisationId, int userId, List<int> productIds, List<int> hierarchyIds)
        { 
            var scenario = SmScenario.Build(name, week, scenarioMask, senarioWeekMin, 
                                            scenarioWeekMax, markdownCountStartWeek, defaultMarkdownType,
                                            defaultDecisionState, allowPromoAsMarkdown, minimumPromoPercentage, 
                                            organisationId,userId );

            var scenarioId = await _scenarioRepository.CreateOrUpdate(scenario.Week, scenario.ScheduleWeekMin,
                scenario.ScheduleWeekMax, scenario.ScheduleStageMin,
                scenario.ScheduleStageMax, scenario.StageMax, scenario.StageOffsetMax, scenario.PriceFloor,
                  scenario.OrganisationId,scenario.CreatedBy, scenario.ScenarioName, scenario.ScheduleMask,
                    scenario.MarkdownCountStartWeek, scenario.DefaultMarkdownType, 
                scenario.DefaultDecisionState);

            if (hierarchyIds.Any())
            {
                var filters = hierarchyIds
                    .Select(x => new ScenarioHierarchyFilter {HierarchyId = x, ScenarioId = scenarioId})
                    .ToList();

                await _scenarioHierarchyFilterRepository.Create(filters);
            }

            if (productIds.Any())
            {
                var products = productIds
                    .Select(x => new ScenarioProductFilter { ProductId = x, ScenarioId = scenarioId })
                    .ToList();

                await _scenarioProductFilterRepository.Create(products);
            }

            return scenarioId;
        }
Example #15
0
        private async Task <SmRecommendationProductSummary> UpdateState(int clientId, int scenarioId, int productId, DecisionState state)
        {
            // Update decision state changing 'DecisionRecommendationGuid'
            await _recommendationProductRepository.SetDecisionState(clientId, scenarioId, productId, state);

            // Return updated product and 'DecisionRecommendationGuid'
            var result = await _recommendationProductSummaryRepository.GetByScenarioAndProductId(clientId, scenarioId, productId);

            return(SmRecommendationProductSummary.Build(result));
        }
Example #16
0
        protected virtual void TryParse(T parser, List <MultipleDecisionData> potentialAlternatives, List <int> currentPath, IDictionary <RuleContext, CaretReachedException> results)
        {
            RuleContext parseTree;

            try
            {
                parser.Interpreter.SetFixedDecisions(potentialAlternatives, currentPath);
                parseTree          = ParseImpl(parser);
                results[parseTree] = null;
            }
            catch (CaretReachedException ex)
            {
                if (ex.Transitions == null)
                {
                    return;
                }

                if (ex.InnerException is FailedPredicateException)
                {
                    return;
                }

                for (parseTree = ex.FinalContext; parseTree.Parent != null; parseTree = parseTree.Parent)
                {
                    // intentionally blank
                }

                if (ex.InnerException != null)
                {
                    IntervalSet alts         = new IntervalSet();
                    IntervalSet semanticAlts = new IntervalSet();
                    foreach (ATNConfig c in ex.Transitions.Keys)
                    {
                        if (semanticAlts.Contains(c.Alt))
                        {
                            continue;
                        }

                        alts.Add(c.Alt);

                        var recognizer = parser as Recognizer <IToken, ParserATNSimulator>;
                        if (recognizer == null || c.SemanticContext.Eval(recognizer, ex.FinalContext))
                        {
                            semanticAlts.Add(c.Alt);
                        }
                    }

                    if (alts.Count != semanticAlts.Count)
                    {
                        Console.WriteLine("Forest decision {0} reduced to {1} by predicate evaluation.", alts, semanticAlts);
                    }

                    int inputIndex = parser.InputStream.Index;
                    int decision   = 0;

                    int      stateNumber = ex.InnerException.OffendingState;
                    ATNState state       = parser.Atn.states[stateNumber];
                    if (state is StarLoopbackState)
                    {
                        Debug.Assert(state.NumberOfTransitions == 1 && state.OnlyHasEpsilonTransitions);
                        Debug.Assert(state.Transition(0).target is StarLoopEntryState);
                        state = state.Transition(0).target;
                    }
                    else
                    {
                        PlusBlockStartState plusBlockStartState = state as PlusBlockStartState;
                        if (plusBlockStartState != null && plusBlockStartState.decision == -1)
                        {
                            state = plusBlockStartState.loopBackState;
                            Debug.Assert(state != null);
                        }
                    }

                    DecisionState decisionState = state as DecisionState;
                    if (decisionState != null)
                    {
                        decision = decisionState.decision;
                        if (decision < 0)
                        {
                            Debug.WriteLine(string.Format("No decision number found for state {0}.", state.stateNumber));
                        }
                    }
                    else
                    {
                        if (state != null)
                        {
                            Debug.WriteLine(string.Format("No decision number found for state {0}.", state.stateNumber));
                        }
                        else
                        {
                            Debug.WriteLine("No decision number found for state <null>.");
                        }

                        // continuing is likely to terminate
                        return;
                    }

                    Debug.Assert(semanticAlts.MinElement >= 1);
                    Debug.Assert(semanticAlts.MaxElement <= parser.Atn.decisionToState[decision].NumberOfTransitions);
                    int[] alternatives = semanticAlts.ToArray();

                    MultipleDecisionData decisionData = new MultipleDecisionData(inputIndex, decision, alternatives);
                    potentialAlternatives.Add(decisionData);
                    currentPath.Add(-1);
                }
                else
                {
                    results[parseTree] = ex;
                }
            }
            catch (RecognitionException ex)
            {
                // not a viable path
            }
        }
Example #17
0
 public DFA(DecisionState atnStartState)
     : this(atnStartState, 0)
 {
 }
    public void Evaluate( float elapsedTime )
    {
        // don't do evaluation if we're finished with this map
        if (Finished == true)
            return;

        if (elapsedTime > CheckTime)
        {
            //UnityEngine.Debug.Log("DecisionMap.Evaluate() : Evaluate map= <" + Name + ">");

            // set next time
            CheckTime = elapsedTime + Interval;
            // process
            if (Current != null)
            {
				foreach (DecisionStateTransition dst in Current.Transitions)
                if (dst.DecisionCondition.Test() == true)
                {
                    // execute actions
					if (dst.DecisionAction != null)
                    	dst.DecisionAction.Execute();

                    // move to next state
                    DecisionState next = FindState(dst.SuccessState);
                    if (next != null)
                    {
                        UnityEngine.Debug.Log("DecisionMap.Evaluate(MAP=" + Name + ") : Move to state <" + next.Name + ">");
                        Current = next;
                    }
                    else
                    {
                        // no next state, just set this state as finished
                        Finished = true;
                    }
                }
            }
        }
    }
Example #19
0
 // TODO remove this in favour of log structure
 public async Task <int> CreateOrUpdate(int?week, int scheduleWeekMin, int scheduleWeekMax, int scheduleStageMin, int scheduleStageMax, int?stageMax,
                                        int?stageOffsetMax, decimal?priceFloor, int organisationId, int createdBy, string scenarioName, int scheduleMask, int markdownCountStartWeek, int defaultMarkdownType, DecisionState defaultDecisionState)
 {
     return(await Context.Connection.QuerySingleAsync <int>(
                @"INSERT INTO scenario (week, schedule_week_min, schedule_week_max, schedule_stage_min, schedule_stage_max, stage_max, stage_offset_max, price_floor, organisation_id, created_by, scenario_name, schedule_mask, markdown_count_start_week, default_markdown_type, default_decision_state_name)
             VALUES (@Week, @ScheduleWeekMin, @ScheduleWeekMax, @ScheduleStageMin, @ScheduleStageMax, @StageMax, @StageOffsetMax, @PriceFloor, @OrganisationId,@CreatedBy, @ScenarioName, @ScheduleMask, @MarkdownCountStartWeek, @DefaultMarkdownType, @DefaultDecisionStateName)
             ON CONFLICT (scenario_id) DO UPDATE 
             SET week = @Week,
                 schedule_week_min = @ScheduleWeekMin,
                 schedule_week_max = @ScheduleWeekMax,
                 schedule_stage_min = @ScheduleStageMin,
                 schedule_stage_max = @ScheduleStageMax,
                 stage_max = @StageMax,
                 stage_offset_max = @StageOffsetMax,
                 price_floor = @PriceFloor,      
                 organisation_Id = @OrganisationId,
                 created_by = @CreatedBy,
                 scenario_name = @ScenarioName,
                 schedule_mask = @ScheduleMask,
                 markdown_count_start_week = @MarkdownCountStartWeek,
                 default_markdown_type = @DefaultMarkdownType,
                 default_decision_state_name = @DefaultDecisionStateName
             RETURNING scenario_id",
                new
     {
         Week = week,
         ScheduleWeekMin = scheduleWeekMin,
         ScheduleWeekMax = scheduleWeekMax,
         ScheduleStageMin = scheduleStageMin,
         ScheduleStageMax = scheduleStageMax,
         StageMax = stageMax,
         StageOffsetMax = stageOffsetMax,
         PriceFloor = priceFloor,
         OrganisationId = organisationId,
         CreatedBy = createdBy,
         ScenarioName = scenarioName,
         ScheduleMask = scheduleMask,
         MarkdownCountStartWeek = markdownCountStartWeek,
         DefaultMarkdownType = defaultMarkdownType,
         DefaultDecisionStateName = defaultDecisionState.ToString()
     }));
 }
        public async Task SetDecisionState(int clientId, int scenarioId, int productId, DecisionState state)
        {
            var entity = await Context.RecommendationProduct.SingleAsync(x => x.ClientId == clientId && x.ScenarioId == x.ScenarioId && x.ProductId == productId);

            entity.DecisionStateName = state.ToString();
            Context.RecommendationProduct.Update(entity);
            await Context.SaveChangesAsync();
        }
Example #21
0
 private async Task <int> UpdateState(int clientId, int scenarioId, DecisionState state)
 {
     return(await _recommendationProductRepository.SetDecisionState(clientId, scenarioId, state));
 }