Example #1
0
        /// <summary>
        /// returns a single PhoneSystem object from an ObjectId string passed in.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server that the phone system is homed on.
        /// </param>
        /// <param name="pObjectId">
        /// The ObjectId of the phone system to load
        /// </param>
        /// <param name="pPhoneSystem">
        /// The out param that the filled out instance of the PhoneSystem class is returned on.
        /// </param>
        /// <param name="pDisplayName">
        /// Optional display name
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetPhoneSystem(out PhoneSystem pPhoneSystem, ConnectionServerRest pConnectionServer, string pObjectId,
                                                   string pDisplayName = "")
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

            pPhoneSystem = null;

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

            //you need an objectID and/or a display name - both being blank is not acceptable
            if (string.IsNullOrEmpty(pObjectId) & string.IsNullOrEmpty(pDisplayName))
            {
                res.ErrorText = "Empty objectId and DisplayName passed to GetPhonesystem";
                return(res);
            }

            //create a new PhoneSystem instance passing the ObjectId (or display name) which fills out the data automatically
            try
            {
                pPhoneSystem = new PhoneSystem(pConnectionServer, pObjectId, pDisplayName);
                res.Success  = true;
            }
            catch (UnityConnectionRestException ex)
            {
                return(ex.WebCallResult);
            }
            catch (Exception ex)
            {
                res.ErrorText = "Failed to fetch phone system in GetPhonesystem:" + ex.Message;
            }

            return(res);
        }
Example #2
0
        /// <summary>
        /// Adds a new phone system with the display name provided
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server to add the phone system to
        /// </param>
        /// <param name="pDisplayName">
        /// Name of the phone system to add.  Display name should be unique among phone systems.
        /// </param>
        /// <param name="pPhoneSystem">
        /// If the phone system is added, an instance of it is created and passed back on 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 AddPhoneSystem(ConnectionServerRest pConnectionServer, string pDisplayName, out PhoneSystem pPhoneSystem)
        {
            pPhoneSystem = null;

            WebCallResult res = AddPhoneSystem(pConnectionServer, pDisplayName);

            //if the create goes through, fetch the phone system as an object and return it.
            if (res.Success)
            {
                res = GetPhoneSystem(out pPhoneSystem, pConnectionServer, res.ReturnedObjectId);
            }

            return(res);
        }