Exemple #1
0
        /// <summary>
        /// Find the SearchSpaceMemberObjectId from the partitionObjectId value - the partition objectId is unique for the collection associated
        /// with a search space and this is much easier than having the user have to go fetch the associated objectId when removing.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server being edited
        /// </param>
        /// <param name="pPartitionObjectId">
        /// Partition to remove from the search space member list
        /// </param>
        /// <param name="pSearchSpaceObjectId">
        /// Search space to edit
        /// </param>
        /// <returns>
        /// SearchSpaceMember ObjectId value if found, empty string if not.
        /// </returns>
        private static string GetSearchSpaceMemberObjectIdFromPartitionObjectId(ConnectionServerRest pConnectionServer,
                                                                                string pPartitionObjectId, string pSearchSpaceObjectId)
        {
            string strUrl = string.Format("{0}searchspaces/{1}/searchspacemembers/?query=(PartitionObjectId is {2})",
                                          pConnectionServer.BaseUrl, pSearchSpaceObjectId, pPartitionObjectId);

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

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

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

            foreach (var oMap in oMembers)
            {
                if (oMap.PartitionObjectId.Equals(pPartitionObjectId, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(oMap.ObjectId);
                }
            }

            return("");
        }
Exemple #2
0
        /// <summary>
        /// Gets the list of all servers and resturns them as a generic list of Server objects.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that is being queried
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        private WebCallResult GetServers(ConnectionServerRest pConnectionServer)
        {
            _servers = new List <Server>();

            string strUrl = pConnectionServer.BaseUrl + "cluster";

            //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.Success   = false;
                res.ErrorText = "Empty response received";
                return(res);
            }

            _servers = pConnectionServer.GetObjectsFromJson <Server>(res.ResponseText);

            return(res);
        }
Exemple #3
0
        /// <summary>
        /// Gets the list of all schedule sets and resturns them as a generic list of ScheduleSet objects. 
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that references the server the schedulesets should be pulled from
        /// </param>
        /// <param name="pScheduleSets">
        /// Out parameter that is used to return the list of ScheduleSet 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>
        /// <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)" 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 GetSchedulesSets(ConnectionServerRest pConnectionServer, out List<ScheduleSet> pScheduleSets, int pPageNumber = 1,
            int pRowsPerPage = 20, params string[] pClauses)
        {
            WebCallResult res;
            pScheduleSets = new List<ScheduleSet>();

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

            List<String> oParams;
            if (pClauses == null)
            {
                oParams = new List<string>();
            }
            else
            {
                oParams = pClauses.ToList();
            }

            oParams.Add("pageNumber=" + pPageNumber);
            oParams.Add("rowsPerPage=" + pRowsPerPage);

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "schedulesets",oParams.ToArray());

            //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 here - just return the empty list.
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return res;
            }

            pScheduleSets = pConnectionServer.GetObjectsFromJson<ScheduleSet>(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 pScheduleSets)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return res;
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
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);
        }
Exemple #8
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);
        }
Exemple #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);
        }
Exemple #10
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);
        }
Exemple #11
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);
        }
Exemple #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);
        }
Exemple #13
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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #16
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);
        }
Exemple #17
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);
        }
Exemple #18
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);
        }
Exemple #19
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);
        }
Exemple #20
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);
        }
Exemple #21
0
        /// <summary>
        /// This function allows for a GET of Ldapusers 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=(firstname startswith ab)"
        /// sort: "sort=(alias asc)"
        /// Escaping of spaces is done automatically, no need to account for that.
        /// </summary>
        /// <remarks>
        /// While this method name does have the plural in it, you'll want to use it for fetching single users as well.  If searching by
        /// pKid just construct a query in the form "query=(pkid is {pkid})".
        /// </remarks>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the users are being fetched from.
        /// </param>
        /// <param name="pUsers">
        /// The list of users returned from the CUPI call (if any) is returned as a generic list of UserLdap class instances via this out param.
        /// If no users are found this is returned as en empty
        /// </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 GetLdapUsers(ConnectionServerRest pConnectionServer, out List <UserLdap> pUsers, params string[] pClauses)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pUsers = new List <UserLdap>();

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "import/users/ldap", pClauses);

            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);
            }

            pUsers = pConnectionServer.GetObjectsFromJson <UserLdap>(res.ResponseText, "ImportUser");

            //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 oUser in pUsers)
            {
                oUser.HomeServer = pConnectionServer;
            }

            return(res);
        }
Exemple #22
0
        /// <summary>
        /// Returns a list of role objects that are assigned to the user - an empty list is returned if the user has no roles
        /// </summary>
        /// <param name="pConnectionServer" type="Cisco.UnityConnection.RestFunctions.ConnectionServerRest">
        ///  ConnectionServer the user is hosted on
        /// </param>
        /// <param name="pUserObjectId" type="string">
        ///  Unique Id of the user to get the roles for
        /// </param>
        /// <param name="pRoles">
        ///  List of Role objects corresponding to the roles assigned to the user.  Can return empty list.
        /// </param>
        /// <returns>
        ///  Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetRolesForUser(ConnectionServerRest pConnectionServer, string pUserObjectId, out List <Role> pRoles)
        {
            WebCallResult res;

            pRoles = new List <Role>();

            if (pConnectionServer == null)
            {
                res = new WebCallResult {
                    ErrorText = "Null ConnectionServer referenced passed to GetRolesForUser", Success = false
                };
                return(res);
            }

            res = pConnectionServer.GetCupiResponse(string.Format("{0}users/{1}/userroles", pConnectionServer.BaseUrl, pUserObjectId), 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 - a 0 count list is ok, though
            if (string.IsNullOrEmpty(res.ResponseText))
            {
                res.Success = false;
                return(res);
            }
            if (res.TotalObjectCount == 0)
            {
                res.Success = true;
                return(res);
            }

            pRoles = pConnectionServer.GetObjectsFromJson <Role>(res.ResponseText, "UserRole");

            //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 pRoles)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
Exemple #23
0
        /// <summary>
        /// Gets the list of all SmppProviders and resturns them as a generic list of SmppProvider objects.  This
        /// list can be used for providing drop down list selection for notification device creation purposes or the like.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that references the server the SmppProviders should be pulled from
        /// </param>
        /// <param name="pSmppProviders">
        /// Out parameter that is used to return the list of SmppProvider objects defined on Connection - the list may be empty
        /// </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 GetSmppProviders(ConnectionServerRest pConnectionServer, out List <SmppProvider> pSmppProviders,
                                                     params string[] pClauses)
        {
            WebCallResult res;

            pSmppProviders = new List <SmppProvider>();

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "smppproviders", 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's an error
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0)
            {
                return(res);
            }

            pSmppProviders = pConnectionServer.GetObjectsFromJson <SmppProvider>(res.ResponseText);

            if (pSmppProviders == null)
            {
                pSmppProviders = new List <SmppProvider>();
                res.Success    = false;
                res.ErrorText  = "Failed to parse SmppProviders from response text:" + res.ResponseText;
                return(res);
            }

            return(res);
        }
Exemple #24
0
        /// <summary>
        /// Gets the list of all roles and resturns them as a generic list of Role objects.  This
        /// list can be used for providing drop down list selection or the like.
        /// The roles in Connection are static and cannot be added to.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that the roles should be pulled from
        /// </param>
        /// <param name="pRoles">
        /// Out parameter that is used to return the list of Role objects defined on Connection
        /// </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=(rolename startswith ab)" 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 GetRolesForSystem(ConnectionServerRest pConnectionServer, out List <Role> pRoles, params string[] pClauses)
        {
            WebCallResult res;

            pRoles = new List <Role>();

            if (pConnectionServer == null)
            {
                res = new WebCallResult {
                    ErrorText = "Null ConnectionServer referenced passed to GetRolesForSystem", Success = false
                };
                return(res);
            }

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "roles", 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 means an error in this case - should always be at least one role
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0)
            {
                res.Success = false;
                return(res);
            }

            pRoles = pConnectionServer.GetObjectsFromJson <Role>(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 pRoles)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
Exemple #25
0
        /// <summary>
        /// Gets the list of all schedule sets and resturns them as a generic list of ScheduleSet objects. 
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that references the server the schedulesets should be pulled from
        /// </param>
        /// <param name="pScheduleSetObjectId">
        /// The schedule set to look for schedules for.
        ///  </param>
        /// <param name="pScheduleSetsMembers">
        /// Out parameter that is used to return the list of Schedule ObjectIds associated with the schedule set
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetSchedulesSetsMembers(ConnectionServerRest pConnectionServer, string pScheduleSetObjectId,
            out List<ScheduleSetMember> pScheduleSetsMembers)
        {
            WebCallResult res;
            pScheduleSetsMembers = new List<ScheduleSetMember>();

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

            string strUrl = string.Format("{0}schedulesets/{1}/schedulesetmembers", pConnectionServer.BaseUrl, pScheduleSetObjectId);

            //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 means an error in this case - should always be at least one template
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0)
            {
                res.Success = false;
                return res;
            }

            pScheduleSetsMembers = pConnectionServer.GetObjectsFromJson<ScheduleSetMember>(res.ResponseText);

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

            return res;
        }
Exemple #26
0
        /// <summary>
        /// Fetch all the timezones defined on the target Connection server and load them into a dictionary for fast fetching later.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server to fetch zones from.
        /// </param>
        private WebCallResult LoadTimeZones(ConnectionServerRest pConnectionServer)
        {
            _timeZones = new Dictionary <int, ConnectionTimeZone>();

            string strUrl = pConnectionServer.BaseUrl + "timezones";

            //issue the command to the CUPI interface
            WebCallResult 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 means an error in this case - should always be at least one template
            if (string.IsNullOrEmpty(res.ResponseText) || res.TotalObjectCount == 0)
            {
                res.Success = false;
                return(res);
            }

            List <ConnectionTimeZone> oTimeZones = pConnectionServer.GetObjectsFromJson <ConnectionTimeZone>(res.ResponseText, "TimeZone");

            if (oTimeZones == null || oTimeZones.Count == 0)
            {
                res.Success   = false;
                res.ErrorText = "Failed to fetch time zones from Connection server";
                return(res);
            }

            foreach (ConnectionTimeZone oZone in oTimeZones)
            {
                _timeZones.Add(oZone.TimeZoneId, oZone);
            }

            return(res);
        }
Exemple #27
0
        /// <summary>
        /// searches for a role by the name passed in - if one is found the ObjectId of that role is returned, otherwise blank is returned.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server to query
        /// </param>
        /// <param name="pRoleName">
        /// Name of the role to search for - this is not case sensitive
        /// </param>
        /// <returns>
        /// ObjectId of the role if found, blank string if not.
        /// </returns>
        public static string GetObjectIdFromName(ConnectionServerRest pConnectionServer, string pRoleName)
        {
            string strUrl = pConnectionServer.BaseUrl + string.Format("roles/?query=(RoleName is {0})", pRoleName.UriSafe());

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

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

            List <Role> oTemplates = pConnectionServer.GetObjectsFromJson <Role>(res.ResponseText);

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

            return("");
        }
        /// <summary>
        /// Gets the list of all call handler templates and resturns them as a generic list of CallHandlerTemplate objects.  This
        /// list can be used for providing drop down list selection for handler 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="pCallHandlerTemplates">
        /// Out parameter that is used to return the list of CallHandlerTemplate 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>
        /// <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 GetCallHandlerTemplates(ConnectionServerRest pConnectionServer, out List <CallHandlerTemplate> pCallHandlerTemplates
                                                            , int pPageNumber = 1, int pRowsPerPage = 20, params string[] pClauses)
        {
            WebCallResult res;

            pCallHandlerTemplates = new List <CallHandlerTemplate>();

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

            List <string> temp;

            if (pClauses == null)
            {
                temp = new List <string>();
            }
            else
            {
                temp = pClauses.ToList();
            }
            temp.Add("pageNumber=" + pPageNumber);
            temp.Add("rowsPerPage=" + pRowsPerPage);

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "callhandlertemplates", temp.ToArray());

            //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 recieved";
                res.Success   = false;
                return(res);
            }

            //not an error, just no templates returned with query
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pCallHandlerTemplates = pConnectionServer.GetObjectsFromJson <CallHandlerTemplate>(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 pCallHandlerTemplates)
            {
                oObject.HomeServer = pConnectionServer;
                oObject.ClearPendingChanges();
            }

            return(res);
        }
Exemple #29
0
        /// <summary>
        /// Gets the list of all external services and resturns them as a generic list of ExternalService 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 external service should be pulled from
        /// </param>
        /// <param name="pExternalServices">
        /// Out parameter that is used to return the list of ExternalService 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>
        /// <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=(displayname startswith ab)" 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 GetExternalServices(ConnectionServerRest pConnectionServer, out List <ExternalService> pExternalServices,
                                                        int pPageNumber = 1, int pRowsPerPage = 20, params string[] pClauses)
        {
            WebCallResult res;

            pExternalServices = new List <ExternalService>();

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

            List <String> oParams;

            if (pClauses == null)
            {
                oParams = new List <string>();
            }
            else
            {
                oParams = pClauses.ToList();
            }

            oParams.Add("pageNumber=" + pPageNumber);
            oParams.Add("rowsPerPage=" + pRowsPerPage);

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "externalservices", oParams.ToArray());

            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);
            }

            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pExternalServices = pConnectionServer.GetObjectsFromJson <ExternalService>(res.ResponseText);

            if (pExternalServices == null)
            {
                pExternalServices = new List <ExternalService>();
                res.ErrorText     = "Could not parse JSON into ExternalService:" + 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 pExternalServices)
            {
                oObject.HomeServer = pConnectionServer;
                oObject.ClearPendingChanges();
            }

            return(res);
        }
        /// <summary>
        /// GET all the members of a public distribution list returned as a generic list of DistributionListMember objects.
        /// </summary>
        /// <param name="pDistributionListObjectId">
        /// Distribution list to fetch membership for
        /// </param>
        /// <param name="pMemberList">
        /// list of members is returned on this out param as a generic list.
        /// </param>
        /// <param name="pConnectionServer">
        /// Connection server to query against
        /// </param>
        /// <param name="pPageNumber">
        /// Results page to fetch - defaults to 1
        /// </param>
        /// <param name="pRowsPerPage">
        /// Results to return per page, defaults to 20
        /// </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>
        /// WebCallResult instance
        /// </returns>
        public static WebCallResult GetDistributionListMembers(ConnectionServerRest pConnectionServer, string pDistributionListObjectId,
                                                               out List <DistributionListMember> pMemberList, int pPageNumber = 1, int pRowsPerPage = 20, params string[] pClauses)
        {
            WebCallResult res = new WebCallResult();

            pMemberList = new List <DistributionListMember>();


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

            if (string.IsNullOrEmpty(pDistributionListObjectId))
            {
                res.ErrorText = "Empty DistributionListObjectId passed to GetDistributionListMembers";
                return(res);
            }

            //tack on the paging items to the parameters list
            List <string> temp;

            if (pClauses == null)
            {
                temp = new List <string>();
            }
            else
            {
                temp = pClauses.ToList();
            }

            temp.Add("pageNumber=" + pPageNumber);
            temp.Add("rowsPerPage=" + pRowsPerPage);

            string strUrl = ConnectionServerRest.AddClausesToUri(string.Format("{0}distributionlists/{1}/distributionlistmembers", pConnectionServer.BaseUrl,
                                                                               pDistributionListObjectId), temp.ToArray());

            //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);
            }

            pMemberList = pConnectionServer.GetObjectsFromJson <DistributionListMember>(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 pMemberList)
            {
                //manually determine the member type here - this is a little hacky but it make life a bit easier by being able to filter
                //member types out in a way that is not provided by CUPI natively.
                if (!string.IsNullOrEmpty(oObject.MemberContactObjectId))
                {
                    oObject.MemberType = DistributionListMemberType.Contact;
                }
                else if (!string.IsNullOrEmpty(oObject.MemberDistributionListObjectId))
                {
                    oObject.MemberType = DistributionListMemberType.DistributionList;
                }
                else if (!string.IsNullOrEmpty(oObject.MemberUserObjectId))
                {
                    oObject.MemberType = DistributionListMemberType.LocalUser;
                }
                else
                {
                    oObject.MemberType = DistributionListMemberType.GlobalUser;
                }
            }

            return(res);
        }