/// <summary> /// Simple helper method that returns the port group template ObjectId based on the integration method - most often this is all /// you need from the port group templates when creating a new phone system configuration. /// </summary> /// <param name="pConnectionServer"> /// Connection server the port group templates are stored on /// </param> /// <param name="pIntegrationMethod"> /// SIP, SCCP, PIMG/TIMG /// </param> /// <param name="pPortGroupTemplateObjectId"> /// The ObjectId of the template associated with the integration method is passed back out on this parameter /// </param> /// <returns> /// instance of the WebCallResult class with details of the call and it's results from the server. /// </returns> public static WebCallResult GetPortGroupTemplateObjectId(ConnectionServerRest pConnectionServer, TelephonyIntegrationMethodEnum pIntegrationMethod, out string pPortGroupTemplateObjectId) { pPortGroupTemplateObjectId = ""; List <PortGroupTemplate> oList; WebCallResult res = GetPortGroupTemplates(pConnectionServer, out oList); if (res.Success == false) { return(res); } foreach (var oTemplate in oList) { if (oTemplate.CopyTelephonyIntegrationMethodEnum == pIntegrationMethod) { pPortGroupTemplateObjectId = oTemplate.ObjectId; return(res); } } //if we're here the integration type wasn't found res.Success = false; res.ErrorText = "Telephony Integration Method not found with passed in value:" + pIntegrationMethod; return(res); }
/// <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)); }
/// <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> /// <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 = "") { WebCallResult res = new WebCallResult { Success = false }; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to AddPortGroup"; return(res); } //make sure that something is passed in for the required param if (String.IsNullOrEmpty(pDisplayName) | string.IsNullOrEmpty(pPhoneSystemObjectId) | string.IsNullOrEmpty(pHostOrIpAddress)) { res.ErrorText = "Empty value passed for one or more required parameters in AddPortGroup"; return(res); } //get template object Id string strMediaPortGroupTemplateObjectId; res = PortGroupTemplate.GetPortGroupTemplateObjectId(pConnectionServer, pPhoneIntegrationMethod, out strMediaPortGroupTemplateObjectId); if (res.Success == false) { return(res); } string strBody = "<PortGroup>"; //tack on the property value pair with appropriate tags strBody += string.Format("<DisplayName>{0}</DisplayName>", pDisplayName.HtmlBodySafe()); strBody += string.Format("<MediaPortGroupTemplateObjectId>{0}</MediaPortGroupTemplateObjectId>", strMediaPortGroupTemplateObjectId); strBody += string.Format("<MediaSwitchObjectId>{0}</MediaSwitchObjectId>", pPhoneSystemObjectId); strBody += string.Format("<HostOrIPAddress>{0}</HostOrIPAddress>", pHostOrIpAddress); strBody += string.Format("<TelephonyIntegrationMethodEnum>{0}</TelephonyIntegrationMethodEnum>", (int)pPhoneIntegrationMethod); if (pPhoneIntegrationMethod == TelephonyIntegrationMethodEnum.SCCP) { strBody += string.Format("<SkinnyDevicePrefix>{0}</SkinnyDevicePrefix>", pSccpDevicePrefix); } strBody += "</PortGroup>"; res = pConnectionServer.GetCupiResponse(string.Format("{0}portgroups", pConnectionServer.BaseUrl), MethodType.POST, strBody, false); //if the call went through then the ObjectId will be returned in the URI form. if (res.Success) { const string strPrefix = @"/vmrest/portgroups/"; if (res.ResponseText.Contains(strPrefix)) { res.ReturnedObjectId = res.ResponseText.Replace(strPrefix, "").Trim(); } } return(res); }