Ejemplo n.º 1
0
        public DialogBuilder(Menus.Menu i_menu, Commands i_commands, DtmfKeyToSpokenEquivalentMappings i_DtmfToSpokenMapping, VxmlGenerationParameters i_VxmlGenerationParameters)
        {
            m_menu     = i_menu;
            m_commands = i_commands;
            m_commands.DtmfCanBeSpoken = m_menu.DtmfCanBeSpoken;                        // This setting is stored in the menu object but the logic becomes cleaner if the commands collection knows its value.

            if (m_menu.DtmfCanBeSpoken)
            {
                if (null == i_DtmfToSpokenMapping)
                {
                    Console.Error.WriteLine("{0} DialogBuilder: ERROR - DtmfCanBeSpoken is true but no DtmfToSpokenMapping is provided.", DateTime.Now.ToString());             //$$$ LP - use logger.
                    throw new ArgumentNullException("i_DtmfToSpokenMapping", "DtmfCanBeSpoken is true but no DtmfToSpokenMapping is provided.");
                }
                else if (0 == i_DtmfToSpokenMapping.Count)
                {
                    Console.Error.WriteLine("{0} DialogBuilder: ERROR - DtmfCanBeSpoken is true but DtmfToSpokenMapping is empty.", DateTime.Now.ToString());           //$$$ LP - use logger.
                    throw new ArgumentOutOfRangeException("i_DtmfToSpokenMapping", "DtmfCanBeSpoken is true but DtmfToSpokenMapping is empty.");
                }
            }

            m_DtmfToSpokenMapping = i_DtmfToSpokenMapping;

            if (m_menu.ConfirmationEnabled)
            {
                if (null == i_VxmlGenerationParameters)
                {
                    Console.Error.WriteLine("{0} DialogBuilder: ERROR - ConfirmationEnabled is true but no VxmlGenerationParameters is provided.", DateTime.Now.ToString());            //$$$ LP - use logger.
                    throw new ArgumentNullException("i_VxmlGenerationParameters", "ConfirmationEnabled is true but no VxmlGenerationParameters is provided.");
                }
            }

            m_VxmlGenerationParameters = i_VxmlGenerationParameters;
            FormName = i_menu.MenuName;
        }
Ejemplo n.º 2
0
        // The reason the menu and its associated commands are passed in (rather then retrieve the commands from the database inside the method)
        // is that this method is used to create a VXML file when a menu is saved on the Menu Editor page (at which point the commands already
        // exists in memory so no point wasting time retrieving them again).

        public static bool ProcessMenu(Menus.Menu i_menu, Commands i_commands, string i_sVxmlDirectory)
        {
            DtmfKeyToSpokenEquivalentMappings dtmfToSpokenMapping      = null;
            VxmlGenerationParameters          vxmlGenerationParameters = null;

            if (ConfigParams.IsVoiceRecognitionEnabled())
            {
                if (i_menu.DtmfCanBeSpoken)
                {
                    DialogDesignerDAL dal = new DialogDesignerDAL();

                    DialogDesignerDAL.ErrorCode ecDal = dal.GetDtmfToSpokenMapping(i_menu.LanguageCode, out dtmfToSpokenMapping);
                }
            }
            else
            {
                // If the system is not capable of voice recognition then it doesn't matter what the "DTMF keys can be spoken" setting in the menu is.

                i_menu.DtmfCanBeSpoken = false;
            }

            if (i_menu.ConfirmationEnabled)
            {
                vxmlGenerationParameters = GetVxmlGenerationParameters();
            }

            DialogBuilder dialogBuilder  = new DialogBuilder(i_menu, i_commands, dtmfToSpokenMapping, vxmlGenerationParameters);
            bool          bMenuGenerated = dialogBuilder.GenerateVxml(GetFileNameForMenu(i_menu, i_sVxmlDirectory));

            return(bMenuGenerated);
        }
Ejemplo n.º 3
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public ErrorCode GetDtmfToSpokenMapping(string i_sLanguageCode, out DtmfKeyToSpokenEquivalentMappings o_dtmfToSpokenMapping)
        {
            ErrorCode ecRet = ErrorCode.Success;

            o_dtmfToSpokenMapping = null;

            try
            {
                o_dtmfToSpokenMapping = new DtmfKeyToSpokenEquivalentMappings();

                using (IDbConnection sqlConn = GetDbConnection())
                {
                    using (IDbCommand sqlCmd = sqlConn.CreateCommand())
                    {
                        string sCmd = String.Format("SELECT {0}, {1} FROM tblDtmfKeyToSpokenEquivalent WHERE {2} = '{3}'",
                                                    m_csDtmfKeyColumn,
                                                    m_csSpokenEquivalentColumn,
                                                    m_csLanguageCode,
                                                    i_sLanguageCode);

                        sqlCmd.CommandText = sCmd;
                        sqlConn.Open();

                        using (IDataReader sqlReader = sqlCmd.ExecuteReader())
                        {
                            try
                            {
                                while (sqlReader.Read())
                                {
                                    o_dtmfToSpokenMapping.Add(new DtmfKeyToSpokenEquivalentMapping(sqlReader[m_csDtmfKeyColumn].ToString(), sqlReader[m_csSpokenEquivalentColumn].ToString()));
                                }
                            }
                            catch (Exception exc)
                            {
                                ecRet = ErrorCode.UnknownSql;
                                Console.Error.WriteLine(DateTime.Now.ToString() + " SBConfigStore.DialogDesignerDAL.GetDtmfToSpokenMapping exception1: " + exc.ToString());
                            }
                        }                         // using (IDataReader)

                        sqlConn.Close();
                    }             // using (IDbCommand)
                }                 // using (IDbConnection)
            }
            catch (Exception exc)
            {
                ecRet = ErrorCode.Unknown;
                Console.Error.WriteLine(DateTime.Now.ToString() + " SBConfigStore.DialogDesignerDAL.GetDtmfToSpokenMapping exception2: " + exc.ToString());
            }

            return(ecRet);
        }         // GetDtmfToSpokenMapping