コード例 #1
0
        /// <summary>
        /// Fetches a greeting stream file object filled with all the properties for a greeting stream for a custom greeting off a
        /// directory handler
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server that the greeting is homed on.
        /// </param>
        /// <param name="pDirectoryHandlerObjectId">
        /// The objectID of the directory handler that owns the greeting to be fetched.
        /// </param>
        /// <param name="pLanguageCode">
        /// The language of the greeting stream to fetch
        /// </param>
        /// <param name="pGreetingStreamFile">
        /// The out parameter that the instance of the DirectoryHandlerGreetingStreamFile class filled in with the details of the
        /// fetched entry is passed back on.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetGreetingStreamFile(ConnectionServerRest pConnectionServer,
                                                          string pDirectoryHandlerObjectId,
                                                          int pLanguageCode,
                                                          out DirectoryHandlerGreetingStreamFile pGreetingStreamFile)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pGreetingStreamFile = null;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null Connection server object passed to GetGreetingStreamFile";
                return(res);
            }

            //create a new greeting instance passing the greeting type name and language which fills out the data automatically
            try
            {
                pGreetingStreamFile = new DirectoryHandlerGreetingStreamFile(pConnectionServer, pDirectoryHandlerObjectId, pLanguageCode);
                res.Success         = true;
            }
            catch (UnityConnectionRestException ex)
            {
                return(ex.WebCallResult);
            }
            catch (Exception ex)
            {
                res.ErrorText = "Failed to fetch greeting stream file in GetGreetingStreamFile:" + ex.Message;
            }

            return(res);
        }
コード例 #2
0
        /// <summary>
        /// Overloaded GetGreetingWavFile function that takes the directory handler ID and language code which looks up
        /// the stream file name to fetch from the Connection server.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server that houses the greeting being fetched.
        /// </param>
        /// <param name="pTargetLocalFilePath">
        /// The fully qualified file path on the local OS to store the WAV file for this stream.
        /// </param>
        /// <param name="pDirectoryHandlerObjectId">
        /// The directory handler that owns the greeting being fetched.
        /// </param>
        /// <param name="pLanguageCode">
        /// The language code (i.e. US English = 1033).
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetGreetingWavFile(ConnectionServerRest pConnectionServer,
                                                       string pTargetLocalFilePath,
                                                       string pDirectoryHandlerObjectId,
                                                       int pLanguageCode)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to GetGreetingWavFile";
                return(res);
            }

            //check and make sure a legit folder is referenced in the target path
            if (String.IsNullOrEmpty(pTargetLocalFilePath) ||
                (Directory.GetParent(pTargetLocalFilePath).Exists == false))
            {
                res.ErrorText = "Invalid local file path passed to GetGreetingWavFile: " + pTargetLocalFilePath;
                return(res);
            }

            if (string.IsNullOrEmpty(pDirectoryHandlerObjectId))
            {
                res.ErrorText = "Empty Directory handler ObjectId passed to GetGreetingWavFile";
                return(res);
            }

            //fetch the greeting stream file object for this greeting and language code.
            DirectoryHandlerGreetingStreamFile oStreamFile;

            try
            {
                oStreamFile = new DirectoryHandlerGreetingStreamFile(pConnectionServer, pDirectoryHandlerObjectId, pLanguageCode);
            }
            catch (Exception ex)
            {
                //this will be rather common - keep the wording here toned down.
                res.ErrorText = "No greeting stream file found for greeting in GetGreetingWavFile: " + ex.Message;
                return(res);
            }

            //fetch the StreamFile name from the directory - this identifies the actual WAV file in the streams folder on the Connection
            //server.  Normally if there's a greeting stream file record for a greeting there will be a stream file for it - but just
            //in case.
            if (String.IsNullOrEmpty(oStreamFile.StreamFile))
            {
                res.ErrorText = "No recording found for stream file";
                return(res);
            }

            //call the alternateive static definition that actually has the WAV file fetch logic in it.
            return(GetGreetingWavFile(pConnectionServer, pTargetLocalFilePath, oStreamFile.StreamFile));
        }