コード例 #1
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;
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: PrivateList.cs プロジェクト: ItsMoShehab/CUC
        /// <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>
        /// 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);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: RtpCodecDef.cs プロジェクト: ItsMoShehab/CUC
        /// <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);
        }
コード例 #8
0
ファイル: VmsServer.cs プロジェクト: ItsMoShehab/CUC
        /// <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);
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
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);
        }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pConnectionServer"></param>
        /// <param name="pRestrictionTable"></param>
        /// <param name="pPropList"></param>
        /// <returns></returns>
        public static WebCallResult UpdateRestrictionTable(ConnectionServerRest pConnectionServer, RestrictionTable pRestrictionTable, ConnectionPropertyList pPropList)
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

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

            if (pRestrictionTable == null)
            {
                res.ErrorText = "Null RestrictionTable passed to UpdateRestrictionTable";
                return(res);
            }

            string strBody = "<RestrictionTable>";

            foreach (var oPair in pPropList)
            {
                strBody += string.Format("<{0}>{1}</{0}>", oPair.PropertyName, oPair.PropertyValue);
            }

            strBody += "</RestrictionTable>";

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "restrictiontables/" + pRestrictionTable.ObjectId);

            res = pConnectionServer.GetCupiResponse(strUrl, MethodType.PUT, strBody, false);
            if (res.Success == false)
            {
                return(res);
            }

            strBody = "<RestrictionPattern>";
            foreach (RestrictionPattern oPattern in pRestrictionTable.RestrictionPatterns())
            {
                strBody += string.Format("<{0}>{1}</{0}>", "ObjectId", oPattern.ObjectId);
            }
            strBody += "</RestrictionPattern>";
            strUrl   = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "restrictiontables/" + pRestrictionTable.ObjectId + "/restrictionpatterns");
            return(pConnectionServer.GetCupiResponse(strUrl, MethodType.PUT, strBody, false));
        }
コード例 #15
0
        public static WebCallResult GetRestrictionTable(ConnectionServerRest pConnectionServer, string pRestrictionTableObjectId, out RestrictionTable pRestrictionTable)
        {
            WebCallResult res = new WebCallResult {
                Success = false
            };

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

            string strUrl = ConnectionServerRest.AddClausesToUri(pConnectionServer.BaseUrl + "restrictiontables/" + pRestrictionTableObjectId);

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

            try
            {
                pRestrictionTable            = JsonConvert.DeserializeObject <RestrictionTable>(res.ResponseText);
                pRestrictionTable.HomeServer = pConnectionServer;
            }
            catch (Exception ex)
            {
                res.ErrorText = "Could not convert response text into a RestrictionTable object:" + ex;
                res.Success   = false;
                return(res);
            }

            return(res);
        }
コード例 #16
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);
        }
コード例 #17
0
ファイル: Role.cs プロジェクト: ItsMoShehab/CUC
        /// <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);
        }
コード例 #18
0
        /// <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);
        }
コード例 #19
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);
        }
コード例 #20
0
ファイル: Schedule.cs プロジェクト: ItsMoShehab/CUC
        /// <summary>
        /// Gets the list of all Schedules and resturns them as a generic list of Schedule objects.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that references the server the templates should be pulled from
        /// </param>
        /// <param name="pSchedules">
        /// Out parameter that is used to return the list of Schedule 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 GetSchedules(ConnectionServerRest pConnectionServer, out List <Schedule> pSchedules, int pPageNumber = 1,
                                                 int pRowsPerPage = 20, params string[] pClauses)
        {
            pSchedules = new List <Schedule>();

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

            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 + "schedules", oParams.ToArray());

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

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

            return(res);
        }
コード例 #21
0
        /// <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);
        }
コード例 #22
0
        /// <summary>
        /// Gets the list of all search spaces and resturns them as a generic list of SearchSpace objects.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that the search space should be pulled from
        /// </param>
        /// <param name="pSearchSpaces">
        /// Out parameter that is used to return the list of SearchSpace 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>
        /// <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>
        public static WebCallResult GetSearchSpaces(ConnectionServerRest pConnectionServer, out List <SearchSpace> pSearchSpaces, int pPageNumber = 1,
                                                    int pRowsPerPage = 20, params string[] pClauses)
        {
            WebCallResult res = new WebCallResult();

            pSearchSpaces = new List <SearchSpace>();

            if (pConnectionServer == null)
            {
                res.ErrorText = "Null ConnectionServer referenced passed to GetSearchSpaces";
                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(pConnectionServer.BaseUrl + "searchspaces", 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 received";
                res.Success   = false;
                return(res);
            }

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

            pSearchSpaces = pConnectionServer.GetObjectsFromJson <SearchSpace>(res.ResponseText);

            if (pSearchSpaces == null)
            {
                pSearchSpaces = new List <SearchSpace>();
                res.ErrorText = "Could not parse response text into SearchSpaces:" + 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 pSearchSpaces)
            {
                oObject.HomeServer = pConnectionServer;
            }

            return(res);
        }
コード例 #23
0
ファイル: PortGroup.cs プロジェクト: ItsMoShehab/CUC
        /// <summary>
        /// Gets the list of all port groups and resturns them as a generic list of PortGroup objects.
        /// </summary>
        /// <param name="pConnectionServer">
        /// The Connection server object that is being queried
        /// </param>
        /// <param name="pPortGroups">
        /// Out parameter that is used to return the list of PortGroup objects defined on Connection - there may be none - this list can be
        /// returned empty.
        /// </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).  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 GetPortGroups(ConnectionServerRest pConnectionServer, out List <PortGroup> pPortGroups, int pPageNumber = 1,
                                                  int pRowsPerPage = 20, params string[] pClauses)
        {
            WebCallResult res;

            pPortGroups = new List <PortGroup>();

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

            //add on the paging directive to existing clauses
            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 + "portgroups", 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, return empty list
            if (res.TotalObjectCount == 0 | res.ResponseText.Length < 25)
            {
                return(res);
            }

            pPortGroups = pConnectionServer.GetObjectsFromJson <PortGroup>(res.ResponseText);

            if (pPortGroups == null)
            {
                pPortGroups   = new List <PortGroup>();
                res.ErrorText = "Failed parsing JSON into PortGroups:" + res.ResponseText;
                res.Success   = false;
            }

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

            return(res);
        }