Exemple #1
0
        /// <summary>
        /// Fetches the recorded WAV file off the greeting stream file.  You need to pass in a target file location on the local files sytem to
        /// store the WAV file and the stream file name on the server.  There is an overloaded version of this routine that takes the dir handler
        /// ID, greeting type and loanguage code instead of the stream file name which, in turn, looks up that stream file name and calls this
        /// version.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server that houses the greeting being fetched.
        /// </param>
        /// <param name="pTargetLocalFilePath">
        /// The fully qualified path to the file name where the WAV file will be stored on the local file system.
        /// </param>
        /// <param name="pConnectionStreamFileName">
        /// Stream file name for the greeting on the Connection server.
        /// </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 pConnectionStreamFileName)
        {
            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(pConnectionStreamFileName))
            {
                res.ErrorText = "Empty wav file name passed to GetGreetingWavFile";
                return(res);
            }

            //fetch the WAV file
            return(pConnectionServer.DownloadWavFile(pTargetLocalFilePath, pConnectionStreamFileName));
        }
Exemple #2
0
        /// <summary>
        /// Fetches the WAV file for a interview question and stores it on the Windows file system at the file location specified.  If the question
        /// does not have voice recorded, the WebcallResult structure returns false in the success proeprty and notes the question has no voice in
        /// the error text.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the question is homed.
        /// </param>
        /// <param name="pTargetLocalFilePath">
        /// Full path to the location to store the WAV file of the question's voice at on the local file system.  If a file already exists in the
        /// location, it will be deleted.
        /// </param>
        /// <param name="pObjectId">
        /// The ObjectId of the interview handler that owns the question.
        /// </param>
        /// <param name="pQuestionNumber">
        /// Number of the question to update (1 through 20)
        /// </param>
        /// <param name="pConnectionWavFileName">
        /// The the Connection stream file name is already known it can be passed in here and the question lookup does not need to take place.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetInterviewHandlerQuestionRecording(ConnectionServerRest pConnectionServer, string pTargetLocalFilePath, string pObjectId,
                                                                         int pQuestionNumber, string pConnectionWavFileName = "")
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to GetInterviewHandlerQuestionRecording";
                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 GetInterviewHandlerQuestionRecording: " + pTargetLocalFilePath;
                return(res);
            }

            //if the WAV file name itself is passed in that's all we need, otherwise we need to go do a fetch with the ObjectId
            //and pull the VoiceName wav file name from there (if it's present).
            if (string.IsNullOrEmpty(pConnectionWavFileName))
            {
                InterviewHandler oInterviewHandler;

                try
                {
                    oInterviewHandler = new InterviewHandler(pConnectionServer, pObjectId);
                }
                catch (UnityConnectionRestException ex)
                {
                    return(ex.WebCallResult);
                }
                catch (Exception ex)
                {
                    res.ErrorText = string.Format("Error fetching question in GetInterviewHandlerQuestionRecording with objectID{0}\n{1}",
                                                  pObjectId, ex.Message);
                    return(res);
                }

                //now fetch the question
                InterviewQuestion oQuestion;
                res = GetInterviewQuestion(out oQuestion, pConnectionServer, pObjectId, pQuestionNumber);
                if (res.Success == false)
                {
                    return(res);
                }

                //the property will be null if no voice is recorded.
                if (string.IsNullOrEmpty(oQuestion.VoiceFile))
                {
                    return(new WebCallResult
                    {
                        Success = false,
                        ErrorText = "No question recorded for interview handler question."
                    });
                }

                pConnectionWavFileName = oInterviewHandler.VoiceName;
            }
            //fetch the WAV file
            return(pConnectionServer.DownloadWavFile(pTargetLocalFilePath, pConnectionWavFileName));
        }