示例#1
0
        /// <summary>
        /// This function allows for a GET of coses from Connection via HTTP - it allows for passing any number of additional clauses
        /// for filtering (query directives), sorting and paging of results.  The format of the clauses should look like:
        /// filter: "query=(displayname startswith ab)"
        /// sort: "sort=(displayname asc)"
        /// page: "pageNumber=0"
        ///     : "rowsPerPage=8"
        /// Escaping of spaces is done automatically, no need to account for that.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the lists are being fetched from.
        /// </param>
        /// <param name="pClassOfServices">
        /// The list of coses returned from the CUPI call (if any) is returned as a generic list of ClassOfService class
        /// instances via this out param.  If no COSes are found an empty list is returned.
        /// </param>
        /// <param name="pClauses">
        /// Zero or more strings can be passed for clauses (filters, sorts, page directives).  Only one query and one sort parameter at a time
        /// are currently supported by CUPI - in other words you can't have "query=(alias startswith ab)" and "query=(FirstName startswith a)" in
        /// the same call.  Also if you have a sort and a query clause they must both reference the same column.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetClassesOfService(ConnectionServerRest pConnectionServer, out List <ClassOfService> pClassOfServices, params string[] pClauses)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pClassOfServices = new List <ClassOfService>();

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "coses", pClauses);

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.Success   = false;
                res.ErrorText = "Empty response recieved";

                return(res);
            }

            //not a failure, just return an empty list
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pClassOfServices = pConnectionServer.GetObjectsFromJson <ClassOfService>(res.ResponseText, "cos");

            if (pClassOfServices == null)
            {
                pClassOfServices = new List <ClassOfService>();
                res.ErrorText    = "Could not parse JSON into COS objects:" + res.ResponseText;
                res.Success      = false;
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pClassOfServices)
            {
                oObject.HomeServer = pConnectionServer;
                oObject.ClearPendingChanges();
            }

            return(res);
        }
示例#2
0
        /// <summary>
        /// Import an LDAP user as a local Unity Connection user.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server to import the user on.
        /// </param>
        /// <param name="pTemplateAlias">
        /// Alias of the user template to use when importing the user, required.
        /// </param>
        /// <param name="pPkid">
        /// Unique ID from the Call Manager database for the LDAP synchronized user.
        /// </param>
        /// <param name="pAlias">
        /// Alias of the user in LDAP to import
        /// </param>
        /// <param name="pFirstName">
        /// First name of the user to import
        /// </param>
        /// <param name="pLastName">
        /// Last name of the user to import
        /// </param>
        /// <param name="pExtension">
        /// Extension number to assign the user in Connection's diretory
        /// </param>
        /// <param name="pPropList">
        /// Name value pair list of optional values to include in the import.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class with details of the call and results from the server.
        /// </returns>
        public static WebCallResult ImportLdapUser(ConnectionServerRest pConnectionServer, string pTemplateAlias,
                                                   string pPkid, string pAlias, string pFirstName, string pLastName,
                                                   string pExtension, ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to ImportLdapUser";
                return(res);
            }

            //make sure that something is passed in for the 3 required params
            if (String.IsNullOrEmpty(pTemplateAlias) || string.IsNullOrEmpty(pPkid) || string.IsNullOrEmpty(pExtension))
            {
                res.ErrorText = "Empty value passed for one or more required parameters in ImportLdapUser on ConnectionServer.cs";
                return(res);
            }

            //create an empty property list if it's passed as null since we use it below
            if (pPropList == null)
            {
                pPropList = new ConnectionPropertyList();
            }

            //cheat here a bit and simply add the alias and extension values to the proplist where it can be tossed into the body later.
            pPropList.Add("pkid", pPkid);
            pPropList.Add("alias", pAlias);
            pPropList.Add("firstName", pFirstName);
            pPropList.Add("lastName", pLastName);
            pPropList.Add("dtmfAccessId", pExtension);

            //use JSON style body payload
            string strBody = "{";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("\"{0}\":\"{1}\",", oPair.PropertyName, oPair.PropertyValue);
            }
            strBody = strBody.TrimEnd(',') + "}";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "import/users/ldap?templateAlias=" + pTemplateAlias,
                                                    MethodType.POST, strBody);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                if (!string.IsNullOrEmpty(res.ResponseText) && res.ResponseText.Contains(@"/vmrest/users/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/users/", "").Trim();
                }
            }

            return(res);
        }
示例#3
0
        /// <summary>
        /// Fetches all private lists defined for the currently logged in user (if any).  An empty list may be returned.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the lists are being fetched from.
        /// </param>
        /// <param name="pOwnerUserObjectId">
        /// Owner of the private distribution list
        /// </param>
        /// <param name="pPrivateLists">
        /// The list of private lists returned from the CUPI call (if any) is returned as a generic list of PrivateList class
        /// instances via this out param.  If no lists are found found an empty list is returned.
        /// </param>
        /// <param name="pPageNumber">
        /// Results page to fetch - defaults to 1
        /// </param>
        /// <param name="pRowsPerPage">
        /// Results to return per page, defaults to 20
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetPrivateLists(ConnectionServerRest pConnectionServer, string pOwnerUserObjectId, out List <PrivateList> pPrivateLists,
                                                    int pPageNumber = 1, int pRowsPerPage = 20)
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

            pPrivateLists = new List <PrivateList>();

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

            if (string.IsNullOrEmpty(pOwnerUserObjectId))
            {
                res.ErrorText = "Empty OWnerUserObjectId passed to GetPrivateLists";
                return(res);
            }

            string strUrl = ConnectionServerRest.AddClausesToUri(string.Format("{0}users/{1}/privatelists", pConnectionServer.BaseUrl, pOwnerUserObjectId),
                                                                 "pageNumber=" + pPageNumber, "rowsPerPage=" + pRowsPerPage);

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.ErrorText = "Empty response received";
                res.Success   = false;
                return(res);
            }

            //not an error, just return empty list
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pPrivateLists = pConnectionServer.GetObjectsFromJson <PrivateList>(res.ResponseText);

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pPrivateLists)
            {
                oObject.HomeServer   = pConnectionServer;
                oObject.UserObjectId = pOwnerUserObjectId;
                oObject.ClearPendingChanges();
            }

            return(res);
        }
示例#4
0
        /// <summary>
        /// Returns all the greeting streams for a directory handler
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the greetings are being fetched from.
        /// </param>
        /// <param name="pDirectoryHandlerObjectId">
        /// GUID identifying the directory handler that owns the greetings being fetched
        /// </param>
        /// <param name="pGreetingStreamFiles">
        /// The list of DirectoryHandlerGreetingStreamFile objects are returned using 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 GetGreetingStreamFiles(ConnectionServerRest pConnectionServer,
                                                           string pDirectoryHandlerObjectId,
                                                           out List <DirectoryHandlerGreetingStreamFile> pGreetingStreamFiles)
        {
            WebCallResult res = new WebCallResult();

            res.Success          = false;
            pGreetingStreamFiles = null;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer passed to GetGreetingStreamFiles";
                return(res);
            }

            if (string.IsNullOrEmpty(pDirectoryHandlerObjectId))
            {
                res.ErrorText = "Empty DirectoryHandlerObjectId passed to GetGreetingStreamFiles";
                return(res);
            }

            string strUrl = string.Format("{0}handlers/directoryhandlers/{1}/directoryhandlerstreamfiles",
                                          pConnectionServer.BaseUrl, pDirectoryHandlerObjectId);

            //issue the command to the CUPI interface
            res = pConnectionServer.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 does not mean an error - return true here along with an empty list.
            if (string.IsNullOrEmpty(res.ResponseText) || res.ResponseText.Equals("null"))
            {
                pGreetingStreamFiles = new List <DirectoryHandlerGreetingStreamFile>();
                return(res);
            }

            pGreetingStreamFiles = pConnectionServer.GetObjectsFromJson <DirectoryHandlerGreetingStreamFile>(res.ResponseText, "DirectoryHandlerStreamFile");

            if (pGreetingStreamFiles == null)
            {
                pGreetingStreamFiles = new List <DirectoryHandlerGreetingStreamFile>();
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pGreetingStreamFiles)
            {
                oObject.HomeServer = pConnectionServer;
                oObject.DirectoryHandlerObjectId = pDirectoryHandlerObjectId;
            }

            return(res);
        }
示例#5
0
        /// <summary>
        /// Returns a generic list of partitions that are members of the search space
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being updated
        /// </param>
        /// <param name="pSearchSpaceObjectId">
        /// ObjectId of the search space to fetch partitions for
        /// </param>
        /// <param name="pPartitions">
        /// Genreic list of Partition objects associated with the search space - this list can be empty.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class.
        /// </returns>
        private static WebCallResult GetPartitions(ConnectionServerRest pConnectionServer, string pSearchSpaceObjectId, out List <Partition> pPartitions)
        {
            pPartitions = new List <Partition>();

            string strUrl = pConnectionServer.BaseUrl + string.Format("searchspaces/{0}/searchspacemembers", pSearchSpaceObjectId);

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.ErrorText = "Empty response received";
                res.Success   = false;
                return(res);
            }

            //no error, just return an empty list
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            List <SearchSpaceMember> oMembers = pConnectionServer.GetObjectsFromJson <SearchSpaceMember>(res.ResponseText);

            if (oMembers == null)
            {
                return(res);
            }

            //create an instance of each partition found in the membership list
            foreach (var oMember in oMembers)
            {
                try
                {
                    Partition oPartition = new Partition(pConnectionServer, oMember.PartitionObjectId);
                    pPartitions.Add(oPartition);
                }
                catch (UnityConnectionRestException ex)
                {
                    return(ex.WebCallResult);
                }
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pPartitions)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
示例#6
0
        /// <summary>
        /// Gets the list of all restriction patterns and resturns them as a generic list of RestrictionPattern objects.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that references the server the templates should be pulled from
        /// </param>
        /// <param name="pRestrictionTableObjectId">
        /// The objectId of the restriction table to fetch patterns for.
        /// </param>
        /// <param name="pRestrictionPatterns">
        /// Out parameter that is used to return the list of RestrictionTable objects defined on Connection - there must be at least one.
        /// </param>
        /// <param name="pPageNumber">
        /// Results page to fetch - defaults to 1
        /// </param>
        /// <param name="pRowsPerPage">
        /// Results to return per page, defaults to 20
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetRestrictionPatterns(ConnectionServerRest pConnectionServer, string pRestrictionTableObjectId,
                                                           out List <RestrictionPattern> pRestrictionPatterns, int pPageNumber = 1, int pRowsPerPage = 20)
        {
            WebCallResult res;

            pRestrictionPatterns = new List <RestrictionPattern>();

            if (pConnectionServer == null)
            {
                res           = new WebCallResult();
                res.ErrorText = "Null ConnectionServer referenced passed to GetRestrictionPatterns";
                return(res);
            }

            if (string.IsNullOrEmpty(pRestrictionTableObjectId))
            {
                res           = new WebCallResult();
                res.ErrorText = "Empty restriction table objectId passed to GetRestrictionPatterns";
                return(res);
            }

            string strUrl = ConnectionServerRest.AddClausesToUri(string.Format("{0}restrictiontables/{1}/restrictionpatterns", pConnectionServer.BaseUrl,
                                                                               pRestrictionTableObjectId), "pageNumber=" + pPageNumber, "rowsPerPage=" + pRowsPerPage);

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.ErrorText = "Empty response received";
                res.Success   = false;
                return(res);
            }

            //no error, just return an empty list
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pRestrictionPatterns = pConnectionServer.GetObjectsFromJson <RestrictionPattern>(res.ResponseText);

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pRestrictionPatterns)
            {
                oObject.HomeServer = pConnectionServer;
                oObject.RestrictionTableObjectId = pRestrictionTableObjectId;
            }

            return(res);
        }
示例#7
0
        /// <summary>
        /// Get a list of all users associated with a phone system
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server to do the query against
        /// </param>
        /// <param name="pObjectId">
        /// ObjectId of the phone system to get associations for
        /// </param>
        /// <param name="pAssociations">
        /// List of associated users is returned on this parameter
        /// </param>
        /// <param name="pPageNumber">
        /// Results page to fetch - defaults to 1
        /// </param>
        /// <param name="pRowsPerPage">
        /// Results to return per page, defaults to 20
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class with details of the fetch results.
        /// </returns>
        public static WebCallResult GetPhoneSystemAssociations(ConnectionServerRest pConnectionServer, string pObjectId,
                                                               out List <PhoneSystemAssociation> pAssociations, int pPageNumber = 1, int pRowsPerPage = 20)
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

            pAssociations = new List <PhoneSystemAssociation>();

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to GetPhoneSystemAssociation";
                return(res);
            }

            if (string.IsNullOrEmpty(pObjectId))
            {
                res.ErrorText = "Blank ObjectId passed to GetPhonesystemAssociations";
                return(res);
            }

            string strUrl = ConnectionServerRest.AddClausesToUri(string.Format("{0}phonesystems/{1}/phonesystemassociations", pConnectionServer.BaseUrl, pObjectId),
                                                                 "pageNumber=" + pPageNumber, "rowsPerPage=" + pRowsPerPage);

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.Success   = false;
                res.ErrorText = "Empty response received";
                return(res);
            }

            //not an error, just return the empty list
            if (res.TotalObjectCount == 0)
            {
                return(res);
            }

            pAssociations = pConnectionServer.GetObjectsFromJson <PhoneSystemAssociation>(res.ResponseText);

            if (pAssociations == null)
            {
                pAssociations = new List <PhoneSystemAssociation>();
                res.ErrorText = "Could not parse JSON into PhoneSystemAssociations:" + res.ResponseText;
                res.Success   = false;
                return(res);
            }

            return(res);
        }
示例#8
0
        /// <summary>
        /// This function allows for a GET of port group templates from Connection via HTTP - typically there are only three templates defined
        /// on the server and there's no provision for creating more so there's no filter clauses or the like supported to keep it simple.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the templates are being fetched from.
        /// </param>
        /// <param name="pTemplates">
        /// The list of port group templates is returned via 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 GetPortGroupTemplates(ConnectionServerRest pConnectionServer, out List <PortGroupTemplate> pTemplates)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pTemplates = new List <PortGroupTemplate>();

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "portgrouptemplates");

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.Success   = false;
                res.ErrorText = "Empty response received";
                return(res);
            }

            //not an error, just return an empty list
            if (res.TotalObjectCount == 0 || res.ResponseText.Length < 20)
            {
                return(res);
            }

            pTemplates = pConnectionServer.GetObjectsFromJson <PortGroupTemplate>(res.ResponseText);

            if (pTemplates == null)
            {
                pTemplates    = new List <PortGroupTemplate>();
                res.ErrorText = "Failed to parse JSON into PortGroupTemplates:" + res.ResponseText;
                res.Success   = false;
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pTemplates)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
示例#9
0
        /// <summary>
        /// Returns all the menu entries for a call handler.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the menu entries are being fetched from.
        /// </param>
        /// <param name="pCallHandlerObjectId">
        /// GUID identifying the call handler that owns the menu entries being fetched
        /// </param>
        /// <param name="pMenuEntries">
        /// The list of MenuEntry objects are returned using 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 GetMenuEntries(ConnectionServerRest pConnectionServer,
                                                   string pCallHandlerObjectId,
                                                   out List <MenuEntry> pMenuEntries)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pMenuEntries = null;

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

            string strUrl = string.Format("{0}handlers/callhandlers/{1}/menuentries", pConnectionServer.BaseUrl, pCallHandlerObjectId);

            //issue the command to the CUPI interface
            res = pConnectionServer.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 thats an error - there should alway be menu entries returned
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0)
            {
                pMenuEntries = new List <MenuEntry>();
                res.Success  = false;
                return(res);
            }

            pMenuEntries = pConnectionServer.GetObjectsFromJson <MenuEntry>(res.ResponseText);

            if (pMenuEntries == null)
            {
                pMenuEntries  = new List <MenuEntry>();
                res.ErrorText = "Could not parse JSON into MenuEntry list:" + res.ResponseText;
                res.Success   = false;
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pMenuEntries)
            {
                oObject.HomeServer          = pConnectionServer;
                oObject.CallHandlerObjectId = pCallHandlerObjectId;
                oObject.ClearPendingChanges();
            }

            return(res);
        }
示例#10
0
        /// <summary>
        /// Adds a new alternate extension at the index passed in for the user identified with the UserObjectID parameter.  If the extension
        /// conflicts with another in the partition or that alternate extension "slot" is already in use, Connection will return an error.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server that houses the user that owns the new alternate extension to be added.
        /// </param>
        /// <param name="pUserObjectId">
        /// GUID that identifies the user to add the alternate extension for.
        /// </param>
        /// <param name="pIdIndex">
        /// The alternate extension id to add the alternate extension to.  1-10 are administrator added extensions, 11 through 20 are user added.
        /// </param>
        /// <param name="pExtension">
        /// The DMTFAccessID (extension) to add.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddAlternateExtension(ConnectionServerRest pConnectionServer,
                                                          string pUserObjectId,
                                                          int pIdIndex,
                                                          string pExtension)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddAlternateExtension";
                return(res);
            }

            //make sure that something is passed in for the 2 required params - the extension is optional.
            if (String.IsNullOrEmpty(pExtension) || (string.IsNullOrEmpty(pUserObjectId)))
            {
                res.ErrorText = "Empty value passed for one or more required parameters in AddAlternateExtension";
                return(res);
            }

            //1 through 10 is admin added, 11 through 20 is user added.  Different versions of Connection allow for different numbers
            //in the SA etc... however 20 is currently the max upper bound so we check for that here - the back end CUPI call will fail
            //appropriately.
            if (pIdIndex > 20)
            {
                res.ErrorText = "Invalid IDIndex passed to AddAlternateExtension:" + pIdIndex.ToString();
                return(res);
            }

            string strBody = "<AlternateExtension>";

            //tack on the property value pair with appropriate tags
            strBody += string.Format("<IdIndex>{0}</IdIndex>", pIdIndex);
            strBody += string.Format("<DtmfAccessId>{0}</DtmfAccessId>", pExtension);

            strBody += "</AlternateExtension>";

            res =
                pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/alternateextensions",
                                                                pConnectionServer.BaseUrl, pUserObjectId), MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                string strPrefix = @"/vmrest/users/" + pUserObjectId + "/alternateextensions/";
                if (res.ResponseText.Contains(strPrefix))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(strPrefix, "").Trim();
                }
            }

            return(res);
        }
示例#11
0
        /// <summary>
        /// This function allows for a GET of RtpCodec definitions from Connection via HTTP
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the templates are being fetched from.
        /// </param>
        /// <param name="pCodecDefs">
        /// The list of rtp codecs defined on the server (typically only 5)
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetRtpCodecDefs(ConnectionServerRest pConnectionServer, out List <RtpCodecDef> pCodecDefs)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pCodecDefs = new List <RtpCodecDef>();

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "rtpcodecdefs");

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

            if (res.Success == false)
            {
                return(res);
            }
            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.Success   = false;
                res.ErrorText = "Empty response recieved";
                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's not an error, just return an empty list
            if (res.ResponseText.Length < 20 || res.TotalObjectCount == 0)
            {
                return(res);
            }

            pCodecDefs = pConnectionServer.GetObjectsFromJson <RtpCodecDef>(res.ResponseText);

            if (pCodecDefs == null)
            {
                pCodecDefs    = new List <RtpCodecDef>();
                res.ErrorText = "Could not parse JSON into RtpCodecDef objects:" + res.ResponseText;
                res.Success   = false;
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pCodecDefs)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
示例#12
0
        /// <summary>
        /// Returns all the Transfer Options for a call handler.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the transfer options are being fetched from.
        /// </param>
        /// <param name="pCallHandlerObjectId">
        /// GUID identifying the call handler that owns the transfer options being fetched
        /// </param>
        /// <param name="pTransferOptions">
        /// The list of TransferOption objects are returned using 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 GetTransferOptions(ConnectionServerRest pConnectionServer,
                                                       string pCallHandlerObjectId,
                                                       out List <TransferOption> pTransferOptions)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pTransferOptions = new List <TransferOption>();

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

            string strUrl = string.Format("{0}handlers/callhandlers/{1}/transferoptions", pConnectionServer.BaseUrl, pCallHandlerObjectId);

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

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

            //if this is empty thats an error - there should always be transfer options.
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0)
            {
                res.ErrorText = "No transfer options found for call handler";
                res.Success   = false;
                return(res);
            }

            pTransferOptions = pConnectionServer.GetObjectsFromJson <TransferOption>(res.ResponseText);

            if (pTransferOptions == null)
            {
                pTransferOptions = new List <TransferOption>();
                res.Success      = false;
                res.ErrorText    = "Could not parse JSON into TransferOptions:" + res.ResponseText;
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pTransferOptions)
            {
                oObject.HomeServer          = pConnectionServer;
                oObject.CallHandlerObjectId = pCallHandlerObjectId;
                oObject.ClearPendingChanges();
            }

            return(res);
        }
示例#13
0
        /// <summary>
        /// Overloaded GetGreetingWavFile function that takes the directory handler ID and language code which looks up
        /// the stream file name to fetch from the Connection server.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server that houses the greeting being fetched.
        /// </param>
        /// <param name="pTargetLocalFilePath">
        /// The fully qualified file path on the local OS to store the WAV file for this stream.
        /// </param>
        /// <param name="pDirectoryHandlerObjectId">
        /// The directory handler that owns the greeting being fetched.
        /// </param>
        /// <param name="pLanguageCode">
        /// The language code (i.e. US English = 1033).
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetGreetingWavFile(ConnectionServerRest pConnectionServer,
                                                       string pTargetLocalFilePath,
                                                       string pDirectoryHandlerObjectId,
                                                       int pLanguageCode)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to GetGreetingWavFile";
                return(res);
            }

            //check and make sure a legit folder is referenced in the target path
            if (String.IsNullOrEmpty(pTargetLocalFilePath) ||
                (Directory.GetParent(pTargetLocalFilePath).Exists == false))
            {
                res.ErrorText = "Invalid local file path passed to GetGreetingWavFile: " + pTargetLocalFilePath;
                return(res);
            }

            if (string.IsNullOrEmpty(pDirectoryHandlerObjectId))
            {
                res.ErrorText = "Empty Directory handler ObjectId passed to GetGreetingWavFile";
                return(res);
            }

            //fetch the greeting stream file object for this greeting and language code.
            DirectoryHandlerGreetingStreamFile oStreamFile;

            try
            {
                oStreamFile = new DirectoryHandlerGreetingStreamFile(pConnectionServer, pDirectoryHandlerObjectId, pLanguageCode);
            }
            catch (Exception ex)
            {
                //this will be rather common - keep the wording here toned down.
                res.ErrorText = "No greeting stream file found for greeting in GetGreetingWavFile: " + ex.Message;
                return(res);
            }

            //fetch the StreamFile name from the directory - this identifies the actual WAV file in the streams folder on the Connection
            //server.  Normally if there's a greeting stream file record for a greeting there will be a stream file for it - but just
            //in case.
            if (String.IsNullOrEmpty(oStreamFile.StreamFile))
            {
                res.ErrorText = "No recording found for stream file";
                return(res);
            }

            //call the alternateive static definition that actually has the WAV file fetch logic in it.
            return(GetGreetingWavFile(pConnectionServer, pTargetLocalFilePath, oStreamFile.StreamFile));
        }
示例#14
0
        /// <summary>
        /// Returns all questions for a specific interview handler
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the handler questions are being fetched from.
        /// </param>
        /// <param name="pInterviewHandlerObjectId">
        /// The unique identifier for the interview handler to fetch questions for.
        /// </param>
        /// <param name="pInterviewQuestions">
        /// The list of questions for the interviewer is passed back on this out param
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetInterviewQuestions(ConnectionServerRest pConnectionServer, string pInterviewHandlerObjectId,
                                                          out List <InterviewQuestion> pInterviewQuestions)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pInterviewQuestions = new List <InterviewQuestion>();

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

            if (string.IsNullOrEmpty(pInterviewHandlerObjectId))
            {
                res.ErrorText = "Empty interview handler Id passed to GetInterviewQuestions";
                return(res);
            }

            string strUrl = string.Format("{0}handlers/interviewhandlers/{1}/interviewquestions", pConnectionServer.BaseUrl, pInterviewHandlerObjectId);

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.Success   = false;
                res.ErrorText = "Empty response received";
                return(res);
            }

            //not an error, just return an empty list
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pInterviewQuestions = pConnectionServer.GetObjectsFromJson <InterviewQuestion>(res.ResponseText);

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pInterviewQuestions)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
示例#15
0
        /// <summary>
        /// Returns all the alternate extensions for a user.  If there are no alternate extensions a null list is returned.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the alternate extensions are being fetched from.
        /// </param>
        /// <param name="pUserObjectId">
        /// GUID identifying the user that owns the alternate extensions to be fetched.
        /// </param>
        /// <param name="pAlternateExtensions">
        /// The list of alternate extension objects are returned using 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 GetAlternateExtensions(ConnectionServerRest pConnectionServer,
                                                           string pUserObjectId,
                                                           out List <AlternateExtension> pAlternateExtensions)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pAlternateExtensions = new List <AlternateExtension>();

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

            string strUrl = string.Format("{0}users/{1}/alternateextensions", pConnectionServer.BaseUrl, pUserObjectId);

            //issue the command to the CUPI interface
            res = pConnectionServer.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 does not mean an error - return true here along with an empty list.
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0 || res.ResponseText.Length < 10)
            {
                return(res);
            }

            pAlternateExtensions = pConnectionServer.GetObjectsFromJson <AlternateExtension>(res.ResponseText);

            if (pAlternateExtensions == null)
            {
                pAlternateExtensions = new List <AlternateExtension>();
                res.Success          = false;
                res.ErrorText        = "Unable to parse response body into alternate extensions list:" + res.ResponseText;
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pAlternateExtensions)
            {
                oObject.ClearPendingChanges();
                oObject.HomeServer   = pConnectionServer;
                oObject.UserObjectId = pUserObjectId;
            }

            return(res);
        }
示例#16
0
        /// <summary>
        /// Allows for the creation of a new COS on the Connection server directory.  The display name must be provided .
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the COS is being added.
        /// </param>
        /// <param name="pDisplayName">
        /// Display name to be used for the new list.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the object being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddClassOfService(ConnectionServerRest pConnectionServer,
                                                      string pDisplayName,
                                                      ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddClassOfService";
                return(res);
            }

            //make sure that something is passed in for the 2 required params - the extension is optional.
            if (string.IsNullOrEmpty(pDisplayName))
            {
                res.ErrorText = "Empty value passed for display name in AddClassOfService";
                return(res);
            }

            //create an empty property list if it's passed as null since we use it below
            if (pPropList == null)
            {
                pPropList = new ConnectionPropertyList();
            }

            //cheat here a bit and simply add the alias and display name values to the proplist where it can be tossed into the body later.
            pPropList.Add("DisplayName", pDisplayName);

            string strBody = "<Cos>";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</Cos>";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "coses", MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                if (res.ResponseText.Contains(@"/vmrest/coses/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/coses/", "").Trim();
                }
            }

            return(res);
        }
示例#17
0
        /// <summary>
        /// Create a new routing rule condition in the Connection directory
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pRoutingRuleObjectId">
        /// Routing rule to add the condition for
        /// </param>
        /// <param name="pOperator">
        /// operator (equals, lessThan etc...)
        /// </param>
        /// <param name="pParameter">
        /// Parameter (calling number, called number etc...)
        /// </param>
        /// <param name="pOperandValue">
        /// Value to evaluate the parameter against using the operator
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class.
        /// </returns>
        public static WebCallResult AddRoutingRuleCondition(ConnectionServerRest pConnectionServer,
                                                            string pRoutingRuleObjectId,
                                                            RoutingRuleConditionOperator pOperator,
                                                            RoutingRuleConditionParameter pParameter,
                                                            string pOperandValue)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddRoutingRuleCondition";
                return(res);
            }

            if (string.IsNullOrEmpty(pRoutingRuleObjectId))
            {
                res.ErrorText = "Empty RoutingRuleObjectID passed to AddRoutingRuleCondition";
                return(res);
            }

            if (string.IsNullOrEmpty(pOperandValue))
            {
                res.ErrorText = "Empty pOperandValue passed to AddRoutingRuleCondition";
                return(res);
            }

            string strBody = "<RoutingRuleCondition>";

            //strBody += string.Format("<{0}>{1}</{0}>", "RoutingRuleObjectId", pRoutingRuleObjectId);
            strBody += string.Format("<{0}>{1}</{0}>", "Parameter", (int)pParameter);
            strBody += string.Format("<{0}>{1}</{0}>", "Operator", (int)pOperator);
            strBody += string.Format("<{0}>{1}</{0}>", "OperandValue", pOperandValue);

            strBody += "</RoutingRuleCondition>";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "routingrules/" + pRoutingRuleObjectId +
                                                    "/routingruleconditions", MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                if (res.ResponseText.Contains(@"/vmrest/routingrules/" + pRoutingRuleObjectId + "/routingruleconditions/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/routingrules/" + pRoutingRuleObjectId +
                                                                    "/routingruleconditions/", "").Trim();
                }
            }

            return(res);
        }
示例#18
0
        /// <summary>
        /// Adds a new port group server to a port group.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server to add the port group server to.
        /// </param>
        /// <param name="pPortGroupObjectId">
        /// Port group to add the port group server to.
        /// </param>
        /// <param name="pMediaPortGroupServiceEnum">
        /// </param>
        /// <param name="pHostOrIpAddress">
        /// Host address or IP address of the server to add.
        /// </param>
        /// <param name="pHostOrIpAddressV6">
        /// IPV6 host or ip address
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddPortGroupServer(ConnectionServerRest pConnectionServer, string pPortGroupObjectId, int pMediaPortGroupServiceEnum,
                                                       string pHostOrIpAddress, string pHostOrIpAddressV6 = "")
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddPortGroupServer";
                return(res);
            }

            //make sure that something is passed in for the required param
            if (string.IsNullOrEmpty(pPortGroupObjectId) | string.IsNullOrEmpty(pHostOrIpAddress))
            {
                res.ErrorText = "Empty value passed for host address or PortGroupObjectId in AddPortGroupServer";
                return(res);
            }

            string strBody = "<PortGroupServer>";

            strBody += string.Format("<MediaPortGroupObjectId >{0}</MediaPortGroupObjectId >", pPortGroupObjectId);
            strBody += string.Format("<MediaRemoteServiceEnum >{0}</MediaRemoteServiceEnum >", pMediaPortGroupServiceEnum);

            //tack on the property value pair with appropriate tags
            if (!string.IsNullOrEmpty(pHostOrIpAddress))
            {
                strBody += string.Format("<HostOrIPAddress>{0}</HostOrIPAddress>", pHostOrIpAddress);
            }

            if (!string.IsNullOrEmpty(pHostOrIpAddressV6))
            {
                strBody += string.Format("<HostOrIPAddressV6>{0}</HostOrIPAddressV6>", pHostOrIpAddressV6);
            }
            strBody += "</PortGroupServer>";

            res = pConnectionServer.GetCupiResponse(string.Format("{0}portgroups/{1}/portgroupservers", pConnectionServer.BaseUrl,
                                                                  pPortGroupObjectId), MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                string strPrefix = string.Format(@"/vmrest/portgroups/{0}/portgroupservers/", pPortGroupObjectId);
                if (res.ResponseText.Contains(strPrefix))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(strPrefix, "").Trim();
                }
            }

            return(res);
        }
示例#19
0
        /// <summary>
        /// This function allows for a GET of VMS Servers from Connection via HTTP - typically there are only one defined
        /// on the server so there's no filter clauses or the like supported to keep it simple.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the servers are being fetched from.
        /// </param>
        /// <param name="pServers">
        /// The list of VMSServers is returned via 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 GetVmsServers(ConnectionServerRest pConnectionServer, out List <VmsServer> pServers)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pServers = null;

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "vmsservers");

            //issue the command to the CUPI interface
            res = pConnectionServer.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's an error - a zero count is also not valid since there must always be one.
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0)
            {
                pServers    = new List <VmsServer>();
                res.Success = false;
                return(res);
            }

            pServers = pConnectionServer.GetObjectsFromJson <VmsServer>(res.ResponseText);

            if (pServers == null)
            {
                pServers      = new List <VmsServer>();
                res.ErrorText = "Could not parse JSON into VmsServers:" + res.ResponseText;
                res.Success   = false;
                return(res);
            }

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pServers)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
示例#20
0
        /// <summary>
        /// Create a new search space in the Connection directory
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pName">
        /// Name of the new search space - must be unique.
        /// </param>
        /// <param name="pDescription">
        /// Optional description of new search space.
        /// </param>
        /// <param name="pLocationObjectId">
        /// Optional location ObjectId to create the search space in - if not provided it will default to the primary location of the Connection server
        /// its being created in
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class.
        /// </returns>
        public static WebCallResult AddSearchSpace(ConnectionServerRest pConnectionServer,
                                                   string pName,
                                                   string pDescription      = "",
                                                   string pLocationObjectId = "")
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddSearchSpace";
                return(res);
            }

            //make sure that something is passed in for the 2 required params - the extension is optional.
            if (String.IsNullOrEmpty(pName))
            {
                res.ErrorText = "Empty value passed for partition name in AddSearchSpace";
                return(res);
            }

            string strBody = "<SearchSpace>";

            strBody += string.Format("<{0}>{1}</{0}>", "Name", pName);

            if (!string.IsNullOrEmpty(pDescription))
            {
                strBody += string.Format("<{0}>{1}</{0}>", "Description", pDescription);
            }

            if (!string.IsNullOrEmpty(pLocationObjectId))
            {
                strBody += string.Format("<{0}>{1}</{0}>", "LocationObjectId", pLocationObjectId);
            }

            strBody += "</SearchSpace>";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "searchspaces", MethodType.POST, strBody, false);

            //if the call went through then the ObjectId will be returned in the URI form.
            if (res.Success)
            {
                if (res.ResponseText.Contains(@"/vmrest/searchspaces/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/searchspaces/", "").Trim();
                }
            }

            return(res);
        }
示例#21
0
        /// <summary>
        /// Gets the list of all routing rule conditions associated with a routing rule.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that references the server the routing rule should be pulled from
        /// </param>
        /// <param name="pRoutingRuleObjectId">
        /// Routing rule to fetch conditions for
        /// </param>
        /// <param name="pRoutingRuleConditions">
        /// Out parameter that is used to return the list of RoutingRuleCondition objects defined on Connection.  This
        /// list can be empty, conditions are not required
        /// </param>
        /// <param name="pPageNumber">
        /// Results page to fetch - defaults to 1
        /// </param>
        /// <param name="pRowsPerPage">
        /// Results to return per page, defaults to 20
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetRoutingRuleConditions(ConnectionServerRest pConnectionServer, string pRoutingRuleObjectId,
                                                             out List <RoutingRuleCondition> pRoutingRuleConditions, int pPageNumber = 1, int pRowsPerPage = 20)
        {
            pRoutingRuleConditions = null;

            WebCallResult res = new WebCallResult {
                Success = false
            };

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to GetRoutingRuleConditions";
                return(res);
            }

            if (string.IsNullOrEmpty(pRoutingRuleObjectId))
            {
                res.ErrorText = "Empty RoutingRuleObjectId referenced passed to GetRoutingRuleConditions";
                return(res);
            }

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "routingrules/" + pRoutingRuleObjectId + "/routingruleconditions",
                                                                 "pageNumber=" + pPageNumber, "rowsPerPage=" + pRowsPerPage);

            //issue the command to the CUPI interface
            res = pConnectionServer.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 does not mean an error - routing rules don't need conditions
            if (string.IsNullOrEmpty(res.ResponseText) || (res.TotalObjectCount == 0))
            {
                pRoutingRuleConditions = new List <RoutingRuleCondition>();
                return(res);
            }

            pRoutingRuleConditions = pConnectionServer.GetObjectsFromJson <RoutingRuleCondition>(res.ResponseText);

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pRoutingRuleConditions)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
示例#22
0
        /// <summary>
        /// Returns the message counts for the inbox, deleted items and sent items folders for the user tied to the 
        /// mailbox of this MailboxInfo instance.
        /// </summary>
        /// <param name="pInboxCount"></param>
        /// <param name="pDeletedItemsCount"></param>
        /// <param name="pSentItemsCount"></param>
        /// <returns>
        /// Instance of the WebCallResult class with details of the fetch and results from the server
        /// </returns>
        public WebCallResult GetFolderMessageCounts(out int pInboxCount, out int pDeletedItemsCount,out int pSentItemsCount)
        {
            pSentItemsCount = 0;
            pDeletedItemsCount = 0;

            WebCallResult res = GetFolderCount(FolderTypes.inbox, out pInboxCount);
            if (res.Success == false) return res;

            res = GetFolderCount(FolderTypes.deleted, out pDeletedItemsCount);
            if (res.Success == false) return res;

            res = GetFolderCount(FolderTypes.sent, out pSentItemsCount);
            return res;
        }
示例#23
0
        /// <summary>
        /// Constructor requeires ConnectionServer object to pull time zone details from.
        /// </summary>
        public TimeZones(ConnectionServerRest pConnectionServer)
        {
            if (pConnectionServer == null)
            {
                throw new ArgumentException("Null ConnectionServer referenced pasted to TimeZones construtor");
            }

            WebCallResult res = LoadTimeZones(pConnectionServer);

            if (res.Success == false)
            {
                throw new UnityConnectionRestException(res, "Failed to fetch timezones in TimeZones constructor:" + res.ToString());
            }
        }
示例#24
0
        /// <summary>
        /// Create a new routing rule in the Connection directory
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pDisplayName">
        /// Display Name of the new routing rule - must be unique.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a property name and a new value for that property to apply to the rule being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult class.
        /// </returns>
        public static WebCallResult AddRoutingRule(ConnectionServerRest pConnectionServer, string pDisplayName, ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to AddRoutingRule";
                return(res);
            }

            if (String.IsNullOrEmpty(pDisplayName))
            {
                res.ErrorText = "Empty value passed for display name in AddRoutingRule";
                return(res);
            }

            //create an empty property list if it's passed as null since we use it below
            if (pPropList == null)
            {
                pPropList = new ConnectionPropertyList();
            }

            pPropList.Add("DisplayName", pDisplayName);

            string strBody = "<RoutingRule>";

            foreach (var oPair in pPropList)
            {
                //tack on the property value pair with appropriate tags
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</RoutingRule>";

            res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "routingrules",
                                                    MethodType.POST, strBody, false);

            //fetch the objectId of the newly created object off the return
            if (res.Success)
            {
                if (res.ResponseText.Contains(@"/vmrest/routingrules/"))
                {
                    res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/routingrules/", "").Trim();
                }
            }

            return(res);
        }
示例#25
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);
        }
示例#26
0
        /// <summary>
        /// This method allows for a GET of configuration valies from Connection via HTTP - it allows for passing any number of additional clauses
        /// for filtering (query directives), sorting and paging of results.  The format of the clauses should look like:
        /// filter: "query=(FullName startswith System)"
        /// sort: "sort=(fullname asc)"
        /// page: "pageNumber=0"
        ///     : "rowsPerPage=8"
        /// Escaping of spaces is done automatically, no need to account for that.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the values are being fetched from.
        /// </param>
        /// <param name="pConfigurationValues">
        /// The values found will be returned in this generic list of ConfigurationValues
        /// </param>
        /// <param name="pClauses">
        /// Zero or more strings can be passed for clauses (filters, sorts, page directives).  Only one query and one sort parameter at a time
        /// are currently supported by CUPI - in other words you can't have "query=(alias startswith ab)" and "query=(FirstName startswith a)" in
        /// the same call.  Also if you have a sort and a query clause they must both reference the same column.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetConfigurationValues(ConnectionServerRest pConnectionServer, out List <ConfigurationValue> pConfigurationValues,
                                                           params string[] pClauses)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pConfigurationValues = null;

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "configurationvalues", pClauses);

            //issue the command to the CUPI interface
            res = pConnectionServer.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 is not an error, just return the empty list
            if (string.IsNullOrEmpty(res.ResponseText))
            {
                pConfigurationValues = new List <ConfigurationValue>();
                res.Success          = false;
                return(res);
            }

            //no error, just return empty list.
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                pConfigurationValues = new List <ConfigurationValue>();
                return(res);
            }

            pConfigurationValues = pConnectionServer.GetObjectsFromJson <ConfigurationValue>(res.ResponseText);

            foreach (var oObject in pConfigurationValues)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
示例#27
0
        /// <summary>
        /// Gets the list of all notification templates and resturns them as a generic list of NotificationTemplate objects.  This
        /// list can be used for providing drop down list selection for user creation purposes or the like.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that references the server the templates should be pulled from
        /// </param>
        /// <param name="pTemplates">
        /// Out parameter that is used to return the list of NotificationTemplate objects defined on Connection -
        /// there must be at least one.
        /// </param>
        /// <param name="pPageNumber">
        /// Results page to fetch - defaults to 1
        /// </param>
        /// <param name="pRowsPerPage">
        /// Results to return per page, defaults to 20
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetNotificationTemplates(ConnectionServerRest pConnectionServer, out List <NotificationTemplate> pTemplates,
                                                             int pPageNumber = 1, int pRowsPerPage = 20)
        {
            WebCallResult res;

            pTemplates = new List <NotificationTemplate>();

            if (pConnectionServer == null)
            {
                res           = new WebCallResult();
                res.ErrorText = "Null ConnectionServer referenced passed to GetNotificationTemplates";
                return(res);
            }

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "notificationtemplates",
                                                                 "pageNumber=" + pPageNumber, "rowsPerPage=" + pRowsPerPage);

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.ErrorText = "Empty response received";
                res.Success   = false;
                return(res);
            }

            //not an error just return the empty list
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pTemplates = pConnectionServer.GetObjectsFromJson <NotificationTemplate>(res.ResponseText);

            //the ConnectionServer property is not filled in in the default class constructor used by the Json parser -
            //run through here and assign it for all instances.
            foreach (var oObject in pTemplates)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
示例#28
0
        /// <summary>
        /// Returns a list of CallHandlerOwner objects representing the owners (users or public distribution lists) for a particular
        /// system call handler.
        /// A call handler may have no owners in which case an empty list is returned.
        /// </summary>
        /// <param name="pConnectionServer"></param>
        /// <param name="pCallHandlerObjectId">
        /// Call handler to fetch owner information for.
        /// </param>
        /// <param name="pCallHandlerOwners">
        /// List of CallHandlerOwner objects.  Can represent users or public distribution lists.
        /// </param>
        /// <param name="pClauses">
        /// Optional search clauses such as "query=(name is testname)"
        /// </param>
        /// <returns>
        /// Instance of the WebCallResult object with details of the call and results.
        /// </returns>
        public static WebCallResult GetCallHandlerOwners(ConnectionServerRest pConnectionServer, string pCallHandlerObjectId,
                                                         out List <CallHandlerOwner> pCallHandlerOwners, params string[] pClauses)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pCallHandlerOwners = new List <CallHandlerOwner>();

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "handlers/callhandlers/" + pCallHandlerObjectId + "/callhandlerowners",
                                                                 pClauses);

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

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

            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.Success   = false;
                res.ErrorText = "Empty response recieved";

                return(res);
            }

            //not a failure, just return an empty list
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pCallHandlerOwners = pConnectionServer.GetObjectsFromJson <CallHandlerOwner>(res.ResponseText, "CallhandlerOwner");

            if (pCallHandlerOwners == null)
            {
                pCallHandlerOwners = new List <CallHandlerOwner>();
                res.ErrorText      = "Could not parse JSON into call handler owner objects:" + res.ResponseText;
                res.Success        = false;
            }
            return(res);
        }
示例#29
0
        /// <summary>
        /// Provide a list (IEnumerable) - a generic list is fine - of objects such as UserBase, CallHandler, Contact, UserTemplate,
        /// CallHandlerTemplate, Tenant etc... they will be presented to the user in a combo box using their display name or
        /// equivalent for selection.
        /// </summary>
        /// <param name="pComboBox">
        /// ComboBox control
        /// </param>
        /// <param name="pObjects">
        /// List of objects to include in the combobox
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class
        /// </returns>
        public static WebCallResult FillDropDownWithObjects(ref ComboBox pComboBox, IEnumerable <IUnityDisplayInterface> pObjects)
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

            if (pComboBox == null)
            {
                res.ErrorText =
                    "Null parameter passed for pComboBoxControl in FillInDropDownWithTenants on SettingsAccessDatabaseFunctions";
                return(res);
            }

            if (pObjects == null || !pObjects.Any())
            {
                res.ErrorText = "Empty list of items passed to FillDropDownWithObjects";
                return(res);
            }

            pComboBox.Items.Clear();
            try
            {
                _bindingObjects = new BindingList <IUnityDisplayInterface>();

                foreach (var oObject in pObjects)
                {
                    _bindingObjects.Add(oObject);
                }

                pComboBox.ValueMember   = null;
                pComboBox.DisplayMember = "SelectionDisplayString";
                pComboBox.DataSource    = _bindingObjects;
                pComboBox.ResetBindings();
            }
            catch (Exception ex)
            {
                res.ErrorText = "Failed binding list to comboBox:" + ex;
                return(res);
            }

            //force the first item in the list to be selected - we know there's at least one item in the list at
            //this point so this should be a safe operation
            if (pComboBox.Items.Count > 0)
            {
                pComboBox.SelectedIndex = 0;
            }
            res.Success = true;
            return(res);
        }
示例#30
0
        /// <summary>
        /// Uploads a WAV file indicated as a voice name for the target distribution list referenced by the pObjectID value.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the list is homed.
        /// </param>
        /// <param name="pSourceLocalFilePath">
        /// Full path on the local file system pointing to a WAV file to be uploaded as a voice name for the list referenced.
        /// </param>
        /// <param name="pObjectId">
        /// ObjectId of the distribution list to upload the voice name WAV file for.
        /// </param>
        /// <param name="pUserObjectId">
        /// User that owns the private list to set the voice name for.
        /// </param>
        /// <param name="pConvertToPcmFirst">
        /// Converts the wav file into a format Connection can handle before uploading
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult SetPrivateListVoiceName(ConnectionServerRest pConnectionServer, string pSourceLocalFilePath, string pObjectId,
                                                            string pUserObjectId, bool pConvertToPcmFirst = false)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to SetPrivateListVoiceName";
                return(res);
            }

            if (string.IsNullOrEmpty(pUserObjectId) || string.IsNullOrEmpty(pObjectId))
            {
                res.ErrorText = "Empty objectId or UserObjectId passed to SetPrivateListVoiceName";
                return(res);
            }

            //check and make sure a legit folder is referenced in the target path
            if (String.IsNullOrEmpty(pSourceLocalFilePath) || (File.Exists(pSourceLocalFilePath) == false))
            {
                res           = new WebCallResult();
                res.Success   = false;
                res.ErrorText = "Invalid local file path passed to SetPrivateListVoiceName: " + pSourceLocalFilePath;
                return(res);
            }

            //if the user wants to try and rip the WAV file into PCM 16/8/1 first before uploading the file, do that conversion here
            if (pConvertToPcmFirst)
            {
                string strConvertedWavFilePath = pConnectionServer.ConvertWavFileToPcm(pSourceLocalFilePath);

                if (string.IsNullOrEmpty(strConvertedWavFilePath) || File.Exists(strConvertedWavFilePath) == false)
                {
                    res.ErrorText = "Converted PCM WAV file path not found in SetPrivateListVoiceName: " + strConvertedWavFilePath;
                    return(res);
                }

                //point the wav file we'll be uploading to the newly converted G711 WAV format file.
                pSourceLocalFilePath = strConvertedWavFilePath;
            }

            //use the 8.5 and later voice name formatting here which simplifies things a great deal.
            string strResourcePath = string.Format(@"{0}users/{1}/privatelists/{2}/voicename", pConnectionServer.BaseUrl, pUserObjectId, pObjectId);

            //upload the WAV file to the server.
            return(pConnectionServer.UploadWavFile(strResourcePath, pSourceLocalFilePath));
        }