Esempio n. 1
0
 static BMAUtils()
 {
     m_helpers = new BMAHelper[3];
     for (int i = 0; i < 3; i++)
     {
         m_helpers[i] = new BMAHelper();
     }
 }
Esempio n. 2
0
        public static SkillResponse processRequest(SkillRequest request, ILogger log)
        {
            BMAHelper helper = null;
            var       name   = s_AlexaHelper.RetrieveAlexaClientName(log, request.Context.System.ApiAccessToken);

            if (name != null)
            {
                helper = BMAUtils.GetOrReserveBMAHelper(JsonConvert.DeserializeObject <string>(name), log);
            }
            else
            {
                return(new PermissionsProcessor(request, log).processRequest());
            }

            if (request.Session.Attributes == null)
            {
                request.Session.Attributes = new Dictionary <string, object>();
            }
            request.Session.Attributes["account_first"] = helper.m_first;
            request.Session.Attributes["account_last"]  = helper.m_rest;
            BaseProcessor processor = null;

            if (request.Request is LaunchRequest launchRequest)
            {
                processor = new OpenProcessor(request, log);
            }
            else if (request.Request is IntentRequest intentRequest)
            {
                if (intentRequest.Intent.Name == "reporthours")
                {
                    processor = new ReportHoursProcessor(request, log);
                }
                else if (intentRequest.Intent.Name == "addhours")
                {
                    processor = new AddHoursProcessor(request, log);
                }
                else if (intentRequest.Intent.Name == "designate")
                {
                    processor = new DesignateProcessor(request, log);
                }
                else if (intentRequest.Intent.Name == "AMAZON.HelpIntent")
                {
                    processor = new HelpProcessor(request, log);
                }
                else if (
                    intentRequest.Intent.Name == "AMAZON.CancelIntent" ||
                    intentRequest.Intent.Name == "AMAZON.StopIntent")
                {
                    processor = new CancelProcessor(request, log, "<speak>Ok.</speak>");
                }
                else
                {
                    processor = new CannotUnderstandProcessor(request, log);
                }
            }
            else if (request.Request is SessionEndedRequest sessionEndedRequest)
            {
                processor = new SessionEndedProcessor(request, log);
            }
            return(processor.processRequest());
        }