Ejemplo n.º 1
0
        /// <summary>
        /// Overloaded GetGreetingWAVFile function that takes the call handler ID, greeting type 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="pCallHandlerObjectId">
        /// The call handler that owns the greeting being fetched.
        /// </param>
        /// <param name="pGreetingType">
        /// The type of greeting (Alternate, Off Hours, Standard)
        /// </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 pCallHandlerObjectId,
                                                       GreetingTypes pGreetingType,
                                                       int pLanguageCode)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

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

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

            try
            {
                oStreamFile = new GreetingStreamFile(pConnectionServer, pCallHandlerObjectId, pGreetingType, pLanguageCode);
            }
            catch (UnityConnectionRestException ex)
            {
                return(ex.WebCallResult);
            }
            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));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fetches a greeting stream file object filled with all the properties for a specific object identified with the ObjectId
        /// of the call handler that owns it, the greeting type name (Standard, Alternate, Off Hours...) and language to fetch.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server that the greeting is homed on.
        /// </param>
        /// <param name="pCallHandlerObjectId">
        /// The objectID of the call handler that owns the greeting to be fetched.
        /// </param>
        /// <param name="pGreetingType">
        /// The name of the greeting to fetch (Standard, Alternate, Off Hours...)
        /// </param>
        /// <param name="pLanguageCode">
        /// The language of the greeting stream to fetch
        /// </param>
        /// <param name="pGreetingStreamFile">
        /// The out parameter that the instance of the GreetingStreamFile 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 pCallHandlerObjectId,
                                                          GreetingTypes pGreetingType,
                                                          int pLanguageCode,
                                                          out GreetingStreamFile pGreetingStreamFile)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pGreetingStreamFile = null;

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

            if (pGreetingType == GreetingTypes.Invalid)
            {
                res.ErrorText = "Invalid greeting type 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 GreetingStreamFile(pConnectionServer, pCallHandlerObjectId, pGreetingType,
                                                             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);
        }