Beispiel #1
0
        /// <summary>
        /// Fetch a COSes ObjectId by it's name - fetching a COS needs to happen via ObjectId so we get all the properties - searching by name returns only the display
        /// name and ObjectId but not all the rest of the properties.
        /// </summary>
        /// <param name="pCosName">
        /// Display name of the COS to search for
        /// </param>
        /// <returns>
        /// ObjectId of the COS with the name if found, or blank string if not.
        /// </returns>
        private string GetObjectIdByCosName(string pCosName)
        {
            string strUrl = string.Format("{0}coses/?query=(DisplayName is {1})", HomeServer.BaseUrl, pCosName.UriSafe());

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

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

            List <ClassOfService> oCoses = HomeServer.GetObjectsFromJson <ClassOfService>(res.ResponseText, "Cos");

            if (oCoses == null)
            {
                return("");
            }

            foreach (var oCos in oCoses)
            {
                if (oCos.DisplayName.Equals(pCosName, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(oCos.ObjectId);
                }
            }

            return("");
        }
Beispiel #2
0
        /// <summary>
        /// Fetch the ObjectId of a template by it's name.  Empty string returned if not match is found.
        /// </summary>
        /// <param name="pName">
        /// Name of the template to find
        /// </param>
        /// <param name="pCount">
        /// Total number of templates found
        /// </param>
        /// <returns>
        /// ObjectId of template if found or empty string if not.
        /// </returns>
        private string GetObjectIdFromName(string pName, out int pCount)
        {
            pCount = 0;
            string strUrl = string.Format("{0}callhandlertemplates/?query=(DisplayName is {1})", HomeServer.BaseUrl, pName.UriSafe());

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false || res.TotalObjectCount != 1)
            {
                pCount = res.TotalObjectCount;
                return("");
            }

            List <CallHandlerTemplate> oTemplates = HomeServer.GetObjectsFromJson <CallHandlerTemplate>(res.ResponseText);

            foreach (var oTemplate in oTemplates)
            {
                if (oTemplate.DisplayName.Equals(pName, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(oTemplate.ObjectId);
                }
            }

            return("");
        }
Beispiel #3
0
        /// <summary>
        /// Fetch an external service ObjectId by it's name -
        /// </summary>
        /// <param name="pServiceName">
        /// Display name of the service to search for
        /// </param>
        /// <returns>
        /// ObjectId of the external service with the name if found, or blank string if not.
        /// </returns>
        private string GetObjectIdByServiceName(string pServiceName)
        {
            string strUrl = string.Format("{0}externalservices/?query=(DisplayName is {1})", HomeServer.BaseUrl, pServiceName.UriSafe());

            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false || res.TotalObjectCount == 0)
            {
                return("");
            }

            List <ExternalService> oServices = HomeServer.GetObjectsFromJson <ExternalService>(res.ResponseText);

            foreach (var oService in oServices)
            {
                if (oService.DisplayName.Equals(pServiceName, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(oService.ObjectId);
                }
            }

            return("");
        }
Beispiel #4
0
        /// <summary>
        /// Gets the list of all installed languages and resturns them as a generic list of InstalledLangauge objects.
        /// </summary>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        private WebCallResult GetInstalledLanguages()
        {
            string strUrl = HomeServer.BaseUrl + "installedlanguages";

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

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

            //if the call was successful the JSON dictionary should always be populated with something, but just in case do a check here.
            //if this is empty that means an error in this case - should always be at least one template
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0)
            {
                InstalledLanguages = new List <InstalledLanguage>();
                res.Success        = false;
                return(res);
            }

            InstalledLanguages = HomeServer.GetObjectsFromJson <InstalledLanguage>(res.ResponseText);

            if (InstalledLanguages == null || InstalledLanguages.Count == 0)
            {
                res.Success   = false;
                res.ErrorText = "Failed to fetch installed languages on server";
                return(res);
            }

            foreach (var oLanguage in InstalledLanguages)
            {
                oLanguage.HomeServer = HomeServer;
            }

            return(res);
        }
Beispiel #5
0
        /// <summary>
        /// Fetches a message handler object filled with all the properties for a specific entry identified with the ObjectId
        /// of the user that owns it
        /// CUPI returns it as a list even though it's a single entry so we have to treat it as though we're fetching a list of
        /// objects.
        /// </summary>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public WebCallResult GetMessageHandler()
        {
            string strUrl = string.Format("{0}users/{1}/messagehandlers", HomeServer.BaseUrl, SubscriberObjectId);
            List <MessageHandler> oTemp = new List <MessageHandler>();
            var res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, null);

            if (!res.Success)
            {
                return(res);
            }
            if (res.TotalObjectCount != 1)
            {
                res.Success   = false;
                res.ErrorText = "Object count returned from messageHandler fetch not equal to 1";
                return(res);
            }
            oTemp = HomeServer.GetObjectsFromJson <MessageHandler>(res.ResponseText);
            if (oTemp.Count != 1)
            {
                res.Success   = false;
                res.ErrorText = "Objects returned from JSON parse of messageHandler fetch not equal to 1";
                return(res);
            }

            var oItem = oTemp.First();

            this.DeliveryReceiptAction = oItem.DeliveryReceiptAction;
            this.EmailAction           = oItem.EmailAction;
            this.FaxAction             = oItem.FaxAction;
            this.ObjectId        = oItem.ObjectId;
            this.RelayAddress    = oItem.RelayAddress;
            this.VoicemailAction = oItem.VoicemailAction;


            ClearPendingChanges();
            return(res);
        }
Beispiel #6
0
        /// <summary>
        /// Fetch the ObjectId of a global user by it's alias.  Empty string returned if not match is found.
        /// </summary>
        /// <param name="pAlias">
        /// Alias of the global user to find
        /// </param>
        /// <returns>
        /// ObjectId of global user if found or empty string if not.
        /// </returns>
        private string GetObjectIdFromAlias(string pAlias)
        {
            string strUrl = string.Format("{0}globalusers?query=(Alias is {1})", HomeServer.BaseUrl, pAlias.UriSafe());

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false || res.TotalObjectCount == 0)
            {
                return("");
            }

            List <GlobalUser> oTemplates = HomeServer.GetObjectsFromJson <GlobalUser>(res.ResponseText);

            foreach (var oTemplate in oTemplates)
            {
                if (oTemplate.Alias.Equals(pAlias, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(oTemplate.ObjectId);
                }
            }

            return("");
        }
Beispiel #7
0
        /// <summary>
        /// Fetch the ObjectId of a schedule set by it's name.  Empty string returned if not match is found.
        /// </summary>
        /// <param name="pName">
        /// Name of the schedule set to find
        /// </param>
        /// <returns>
        /// ObjectId of schedule set if found or empty string if not.
        /// </returns>
        private string GetObjectIdFromName(string pName)
        {
            string strUrl = HomeServer.BaseUrl + string.Format("schedulesets/?query=(DisplayName is {0})", pName.UriSafe());

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false || res.TotalObjectCount == 0)
            {
                return "";
            }

            List<ScheduleSet> oTemplates = HomeServer.GetObjectsFromJson<ScheduleSet>(res.ResponseText);

            foreach (var oTemplate in oTemplates)
            {
                if (oTemplate.DisplayName.Equals(pName, StringComparison.InvariantCultureIgnoreCase))
                {
                    return oTemplate.ObjectId;
                }
            }

            return "";
        }
Beispiel #8
0
        /// <summary>
        /// Fetch a port group ObjectId by it's name -
        /// </summary>
        /// <param name="pPhoneSystemName">
        /// Display name of the port group to search for
        /// </param>
        /// <returns>
        /// ObjectId of the port group with the name if found, or blank string if not.
        /// </returns>
        private string GetObjectIdByPortGroupName(string pPhoneSystemName)
        {
            string strUrl = string.Format("{0}portgroups/?query=(DisplayName is {1})", HomeServer.BaseUrl, pPhoneSystemName.UriSafe());

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false || res.TotalObjectCount == 0)
            {
                return("");
            }

            List <PortGroup> oPortGroups = HomeServer.GetObjectsFromJson <PortGroup>(res.ResponseText);

            foreach (var oPortGroup in oPortGroups)
            {
                if (oPortGroup.DisplayName.Equals(pPhoneSystemName, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(oPortGroup.ObjectId);
                }
            }

            return("");
        }
Beispiel #9
0
        /// <summary>
        /// Fetch the ObjectId of a search space by it's name.  Empty string returned if not match is found.
        /// </summary>
        /// <param name="pName">
        /// Name of the search space to find
        /// </param>
        /// <returns>
        /// ObjectId of search space if found or empty string if not.
        /// </returns>
        private string GetObjectIdFromName(string pName)
        {
            string strUrl = HomeServer.BaseUrl + string.Format("searchspaces/?query=(Name is {0})", pName.UriSafe());

            //issue the command to the CUPI interface
            WebCallResult res = HomeServer.GetCupiResponse(strUrl, MethodType.GET, "");

            if (res.Success == false || res.TotalObjectCount == 0)
            {
                return("");
            }

            List <SearchSpace> oSearchSpaces = HomeServer.GetObjectsFromJson <SearchSpace>(res.ResponseText);

            foreach (var oSpace in oSearchSpaces)
            {
                if (oSpace.Name.Equals(pName, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(oSpace.ObjectId);
                }
            }

            return("");
        }