예제 #1
0
        /// <summary>
        /// Fetches a greetingstreamfile option object filled with all the properties for a specific entry identified with the ObjectId
        /// of the call handler that owns it and the name of the greeting rule (Standard, Alternate, OffHours...)
        /// </summary>
        /// <param name="pCallHandlerObjectId">
        /// The objectID of the call handler that owns the greeting stream to be fetched.
        /// </param>
        /// <param name="pGreetingType">
        /// The name of the greeting option to fetch (Standard, Alternate, OffHours...)
        /// </param>
        /// <param name="pLanguageCode">
        /// Language of the stream file to fetch
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public WebCallResult GetGreetingStreamFile(string pCallHandlerObjectId, GreetingTypes pGreetingType, int pLanguageCode)
        {
            string strUrl = string.Format("{0}handlers/callhandlers/{1}/greetings/{2}/greetingstreamfiles/{3}",
                                          HomeServer.BaseUrl, pCallHandlerObjectId, pGreetingType.Description(), pLanguageCode);

            //issue the command to the CUPI interface
            return(HomeServer.FillObjectWithRestGetResults(strUrl, this));
        }
예제 #2
0
 /// <summary>
 /// Update the recorded WAV file for a greeting stream for a specific language.  Each greeting can have multiple language versions recorded
 /// so the language along with the greeting itself need to be identified for updating.
 /// You have the option of having the WAV file converted into raw PCM prior to uploading to prevent codec compatibility issues with the
 /// recording.
 /// This does NOT set the "play what" flag to indicate the greeting should play this WAV file instead of the system generated greeting. You
 /// will need to edit the greeting properties directly for that.
 /// </summary>
 /// <param name="pConnectionServer">
 /// The server the greeting being edited is homed on.
 /// </param>
 /// <param name="pCallHandlerObjectId">
 /// The call handler that owns the greeting being edited.
 /// </param>
 /// <param name="pGreetingType">
 /// The greeting type (Standard, Off Hours, Alternate, Busy, Internal, Error, Holiday).
 /// </param>
 /// <param name="pLanguageCode">
 /// Language code to use (i.e. US English = 1033).  The LanguageCodes enum deinfed in the ConnectionServer class can be helpfull here.
 /// </param>
 /// <param name="pSourceLocalFilePath">
 /// The full path to a WAV file to upload as the greeting stream.
 /// </param>
 /// <param name="pConvertToPcmFirst">
 /// Optional parameter to convert the WAV file into PCM first.  Most codecs are handled by this conversion including G729a, MP3, GSM 610 etc...
 /// however if the file conversion fails then the upload itself is not attempted and failure is returned.
 /// If the file is already in PCM the conversion operation is just a copy and the upload proceeds as normal.
 /// </param>
 /// <returns>
 /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
 /// </returns>
 public static WebCallResult SetGreetingWavFile(ConnectionServerRest pConnectionServer,
                                                string pCallHandlerObjectId,
                                                GreetingTypes pGreetingType,
                                                int pLanguageCode,
                                                string pSourceLocalFilePath,
                                                bool pConvertToPcmFirst = false)
 {
     return(Greeting.SetGreetingWavFile(pConnectionServer, pSourceLocalFilePath, pCallHandlerObjectId, pGreetingType, pLanguageCode, pConvertToPcmFirst));
 }
예제 #3
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));
        }
예제 #4
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);
        }
예제 #5
0
        /// <summary>
        /// Creates a new instance of the GreetingStreamFile class.  Requires you pass a handle to a ConnectionServer object which will be used for
        /// fetching and updating data for this object.
        /// If you pass the pLanguageCode parameter the greeting stream is automatically filled with data for that entry from the server.
        /// If not then an empty instance of the GreetingStreamFile class is returned (so you can fill it out on your own).
        /// </summary>
        /// <param name="pConnectionServer">
        /// Instance of a ConnectonServer object which points to the home server for the greeting stream is being created.
        /// </param>
        /// <param name="pCallHandlerObjectId">
        /// GUID identifying the Call Handler that owns the greeting that owns this greeting stream file.
        /// </param>
        /// <param name="pGreetingType">
        /// The greeting rule to fetch (Standard, Alternate, OffHours, Busy, Internal, Error, Holdiay) for the greeting that owns this stream file.
        /// </param>
        /// <param name="pLanguageCode">
        /// The language of the greeting stream file to return (i.e. 1033 is US English).
        /// </param>
        public GreetingStreamFile(ConnectionServerRest pConnectionServer, string pCallHandlerObjectId, GreetingTypes pGreetingType,
                                  int pLanguageCode = -1)
        {
            if (pConnectionServer == null)
            {
                throw new ArgumentException("Null ConnectionServer passed to GreetingStreamFile constructor.");
            }

            //we must know what call handler we're associated with.
            if (String.IsNullOrEmpty(pCallHandlerObjectId))
            {
                throw new ArgumentException("Invalid CallHandlerObjectID passed to GreetingStreamFile constructor.");
            }

            HomeServer = pConnectionServer;

            //remember the objectID of the owner of the menu entry as the CUPI interface requires this in the URL construction
            //for operations editing them.
            CallHandlerObjectId = pCallHandlerObjectId;
            GreetingType        = pGreetingType;

            //if the user didn't pass in a specific language code then exit here, otherwise load up the greeting stream file instance with data
            //from Connection
            if (pLanguageCode == -1)
            {
                return;
            }

            LanguageCode = pLanguageCode;

            //if the language code is passed in then fetch the data on the fly and fill out this instance
            WebCallResult res = GetGreetingStreamFile(pCallHandlerObjectId, pGreetingType, pLanguageCode);

            if (res.Success == false)
            {
                throw new UnityConnectionRestException(res, string.Format("Greeting stream file not found in GreetingStreamFile constructor " +
                                                                          "using CallHandlerObjectID={0} and greeting type={1} and language{2}\n\rError={3}",
                                                                          pCallHandlerObjectId, pGreetingType, pLanguageCode, res.ErrorText));
            }
        }
예제 #6
0
        /// <summary>
        /// Returns all the greeting streams for a greeting
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the greetings are being fetched from.
        /// </param>
        /// <param name="pCallHandlerObjectId">
        /// GUID identifying the call handler that owns the greetings being fetched
        /// </param>
        /// <param name="pGreetingType">
        /// The greeting type (Standard, Alternate, Off Hours ...) to fetch greeting streams for.
        /// </param>
        /// <param name="pGreetingStreamFiles">
        /// The list of GreetingStreamFile objects are returned using this out parameter.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetGreetingStreamFiles(ConnectionServerRest pConnectionServer,
                                                           string pCallHandlerObjectId,
                                                           GreetingTypes pGreetingType,
                                                           out List <GreetingStreamFile> pGreetingStreamFiles)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pGreetingStreamFiles = new List <GreetingStreamFile>();

            if (string.IsNullOrEmpty(pCallHandlerObjectId))
            {
                res.ErrorText = "Empty CallHandlerObjectId or GreetingType passed to GetGreetingSTreamFiles";
                return(res);
            }

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

            string strUrl = string.Format("{0}handlers/callhandlers/{1}/greetings/{2}/greetingstreamfiles",
                                          pConnectionServer.BaseUrl, pCallHandlerObjectId, pGreetingType.Description());

            //issue the command to the CUPI interface
            res = pConnectionServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false)
            {
                return(res);
            }

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.ErrorText = "Empty response received";
                res.Success   = false;
                return(res);
            }

            pGreetingStreamFiles = pConnectionServer.GetObjectsFromJson <GreetingStreamFile>(res.ResponseText);

            if (pGreetingStreamFiles == null)
            {
                pGreetingStreamFiles = new List <GreetingStreamFile>();
                res.ErrorText        = "Could not parse JSON into GreetingStreamFile objects:" + res.ResponseText;
                res.Success          = false;
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            pGreetingStreamFiles.RemoveAll(oGreetingStreams => oGreetingStreams == null);
            foreach (var oObject in pGreetingStreamFiles)
            {
                oObject.HomeServer          = pConnectionServer;
                oObject.CallHandlerObjectId = pCallHandlerObjectId;
            }

            return(res);
        }