コード例 #1
0
        public static void ClassInitialize(TestContext testContext)
        {
            TestContext = testContext;

            //setup mock server interface
            _mockTransport = new Mock <IConnectionRestCalls>();

            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = "{\"name\":\"vmrest\",\"version\":\"10.0.0.189\"}"
            });

            try
            {
                _mockServer = new ConnectionServerRest(_mockTransport.Object, "test", "test", "test", false);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed creating mock server instance:" + ex);
            }

            _mockServer.RaiseErrorEvent(It.IsAny <string>());

            _mockServer.ErrorEvents += MockServerOnErrorEvents;
        }
コード例 #2
0
        /// <summary>
        /// Lazy fetch method to return list of member partitions for the search space instance.  Impelmented as a method isntead of a property
        /// so it doesn't get triggered when a generic list of search space objects is bound to a grid or executed in LINQ function.
        /// </summary>
        /// <param name="pForceRefetchOfData">
        /// Pass as true to force the partitions to be refetched from the database even if they've already been populated
        /// </param>
        /// <returns>
        /// Generic list of Partition objects in order
        /// </returns>
        public List <Partition> GetSearchSpaceMembers(bool pForceRefetchOfData = false)
        {
            if (pForceRefetchOfData)
            {
                _partitions = null;
            }

            if (_partitions == null)
            {
                var res = GetPartitions(out _partitions);
                if (!res.Success)
                {
                    HomeServer.RaiseErrorEvent("Error fetching partitions from GetSearchSpaceMembers:" + res);
                }
            }

            return(_partitions);
        }
コード例 #3
0
        public List <PostGreetingRecordingStreamFile> GetGreetingStreamFiles(bool pForceDataRefetch = false)
        {
            if (pForceDataRefetch)
            {
                _greetingStreamFiles = null;
            }
            //fetch greeting options only if they are referenced
            if (_greetingStreamFiles == null)
            {
                var res = GetGreetingStreamFiles(out _greetingStreamFiles);
                if (!res.Success)
                {
                    HomeServer.RaiseErrorEvent("Error fetching greeting stream files:" + res);
                }
            }

            return(_greetingStreamFiles);
        }
コード例 #4
0
ファイル: PhoneRecording.cs プロジェクト: ItsMoShehab/CUC
        /// <summary>
        /// Plays a message file out of the current call session.  You can pass in any message Id you like from a mailbox you have rights to play
        /// messages for - typically this is only used for users logged into CUPI as themselves but the delegate mailbox role should also give you
        /// rights to other messages as well.
        /// </summary>
        /// <param name="pMessageId">
        /// The message ID to play out the phone interface.  THis is not just the ObjectId of the Message - it's the ID generated from the REST
        /// mailbox interface so it's preceeded with the file attachment number and a colon first.
        /// </param>
        /// <param name="pSpeed">
        /// Speed value - 50, 100, 150, 200 - 100 is normal speed, 50 is half etc...
        /// </param>
        /// <param name="pVolume">
        /// Volume value - 50, 100, 150, 200 - 100 is normal volume, 50 is half etc...
        /// </param>
        /// <param name="pStartPosition">
        /// Starting play position in milliseconds, defaults to 0 for the beginning of the file.  If you pass a value that exceeds the size of
        /// the message being played the play simply wont start.
        ///  </param>
        /// <param name="pUserObjectId">
        /// If running the phone interface as an administrator you need to pass the ObjectId of the user the message
        /// belongs to here - if using the "play my own message" type scenario, this is not necessary.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class with the results of the call.
        /// </returns>
        public WebCallResult PlayMessageFile(string pMessageId    = "", int pSpeed = 100, int pVolume = 100, int pStartPosition = 0,
                                             string pUserObjectId = "")
        {
            WebCallResult res = new WebCallResult();

            if (string.IsNullOrEmpty(pMessageId) && string.IsNullOrEmpty(RecordingResourceId))
            {
                res.Success   = false;
                res.ErrorText =
                    "No recording resource Id passed in and no recording is associated with the active session";
                return(res);
            }

            string strStreamFileId = string.IsNullOrEmpty(pMessageId) ? RecordingResourceId : pMessageId;

            string strUrl = string.Format("{0}calls/{1}", _homeServer.BaseUrl, _callId);

            if (!string.IsNullOrEmpty(pUserObjectId))
            {
                strUrl += "?userobjectid=" + pUserObjectId;
            }
            Dictionary <string, string> oParams = new Dictionary <string, string>();

            oParams.Add("op", "PLAY");
            oParams.Add("resourceType", "MESSAGE");
            oParams.Add("resourceId", strStreamFileId);
            oParams.Add("speed", pSpeed.ToString());
            oParams.Add("volume", pVolume.ToString());
            oParams.Add("startPosition", pStartPosition.ToString());
            oParams.Add("lastResult", "0");

            res = _homeServer.GetCupiResponse(strUrl, MethodType.POST, oParams);

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

            //the only value we're interested in here is the lastResult - if it's 0 then playback finished ok.
            object oValue;

            if (res.JsonDictionary == null)
            {
                _homeServer.RaiseErrorEvent("Error playing back message via CUTI, null value returned for last result");
                res.Success   = false;
                res.ErrorText = "Null result returned from play";
                return(res);
            }

            res.JsonDictionary.TryGetValue("lastResult", out oValue);
            if (oValue == null)
            {
                _homeServer.RaiseErrorEvent("Error playing back message via CUTI, null value returned for last result");
                res.Success   = false;
                res.ErrorText = "Null result returned from play";
                return(res);
            }
            if (oValue.ToString().Equals("0") == false)
            {
                res.Success   = false;
                res.ErrorText = "Result returned from play=" + oValue;
                return(res);
            }

            return(res);
        }