Esempio n. 1
0
        /// <summary>
        /// returns a single PortGroup object from an ObjectId string passed in.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server that the PortGroup is homed on.
        /// </param>
        /// <param name="pObjectId">
        /// The ObjectId of the PortGroup to load
        /// </param>
        /// <param name="pPortGroup">
        /// The out param that the filled out instance of the PortGroup class is returned on.
        /// </param>
        /// <param name="pDisplayName">
        /// Optional display name to search for a port group by
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetPortGroup(out PortGroup pPortGroup, ConnectionServerRest pConnectionServer, string pObjectId,
                                                 string pDisplayName = "")
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

            pPortGroup = null;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null Connection server object passed to GetPortGroup";
                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 display name passed to GetPortGroup";
                return(res);
            }

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

            return(res);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new port group - port groups get ports assigned to them and are, in turn, assigned to phone systems.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server to create the new port gorup on.
        /// </param>
        /// <param name="pDisplayName">
        /// Display name of the new port gorup
        /// </param>
        /// <param name="pPhoneSystemObjectId">
        /// Phone system to associate the port group to.
        /// </param>
        /// <param name="pHostOrIpAddress">
        /// Host name or IP address of the phone system (i.e. the Call Manager server)
        /// </param>
        /// <param name="pPhoneIntegrationMethod">
        /// SIP, SCCP or PIMG/TIMG
        /// </param>
        /// <param name="pSccpDevicePrefix">
        /// When setting up a port group for SCCP you need to provide a device prefix such as "UnityUM1-VI".  For other integration types this can
        /// be left blank
        /// </param>
        /// <param name="pPortGroup">
        /// instance of the newly created PortGroup is passed back on this out parameter
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class with details of the method call and the results from the server.
        /// </returns>
        public static WebCallResult AddPortGroup(ConnectionServerRest pConnectionServer, string pDisplayName, string pPhoneSystemObjectId,
                                                 string pHostOrIpAddress, TelephonyIntegrationMethodEnum pPhoneIntegrationMethod, string pSccpDevicePrefix, out PortGroup pPortGroup)
        {
            pPortGroup = null;
            WebCallResult res = AddPortGroup(pConnectionServer, pDisplayName,
                                             pPhoneSystemObjectId, pHostOrIpAddress,
                                             pPhoneIntegrationMethod, pSccpDevicePrefix);

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

            return(GetPortGroup(out pPortGroup, pConnectionServer, res.ReturnedObjectId));
        }