Beispiel #1
0
        /// <summary>
        /// Allows for the creation of a new COS on the Connection server directory.  The name must be provided
        /// </summary>
        /// <remarks>
        /// This is an alternateive AddClassOfService that passes back a ClassOfService object with the newly created list filled
        /// out in it if the add goes through.
        /// </remarks>
        /// <param name="pConnectionServer">
        /// Reference to the ConnectionServer object that points to the home server where the list is being added.
        /// </param>
        /// <param name="pDisplayName">
        /// Display name to be used for the new cos.
        /// </param>
        /// <param name="pPropList">
        /// List ConnectionProperty pairs that identify a list's property name and a new value for that property to apply to the list being created.
        /// This is passed in as a ConnectionPropertyList instance which contains 1 or more ConnectionProperty instances.  Can be passed as null here.
        /// </param>
        /// <param name="oClassOfService">
        /// Out parameter that instance of Class of Service class is returned on if a match is found - null if no match is found.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddClassOfService(ConnectionServerRest pConnectionServer,
                                                      string pDisplayName,
                                                      ConnectionPropertyList pPropList,
                                                      out ClassOfService oClassOfService)
        {
            oClassOfService = null;

            WebCallResult res = AddClassOfService(pConnectionServer, pDisplayName, pPropList);

            //if the create goes through, fetch the list as an object and return it all filled in.
            if (res.Success)
            {
                res = GetClassOfService(out oClassOfService, pConnectionServer, res.ReturnedObjectId);
            }

            return(res);
        }
Beispiel #2
0
        /// <summary>
        /// returns a single ClassOfService object from an ObjectId string passed in or optionally an alias string.
        /// </summary>
        /// <param name="pConnectionServer">
        /// Connection server that the list is homed on.
        /// </param>
        /// <param name="pObjectId">
        /// The ObjectId of the list to load
        /// </param>
        /// <param name="pClassOfService">
        /// The out param that the filled out instance of the ClassOfService class is returned on.
        /// </param>
        /// <param name="pDisplayName">
        /// Optional display name to search on.  If both the ObjectId and alias are passed, the objectID is used.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetClassOfService(out ClassOfService pClassOfService, ConnectionServerRest pConnectionServer, string pObjectId = "",
                                                      string pDisplayName = "")
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pClassOfService = null;

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

            //you need an objectID and/or a display name - both being blank is not acceptable
            if ((string.IsNullOrEmpty(pObjectId)) & (string.IsNullOrEmpty(pDisplayName)))
            {
                res.ErrorText = "Empty objectId and name passed to GetClassOfServic";
                return(res);
            }

            //create a new COS instance passing the ObjectId (or alias) which fills out the data automatically
            try
            {
                pClassOfService = new ClassOfService(pConnectionServer, pObjectId, pDisplayName);
                res.Success     = true;
            }
            catch (UnityConnectionRestException ex)
            {
                return(ex.WebCallResult);
            }
            catch (Exception ex)
            {
                res.ErrorText = "Failed to fetch list in GetClassOfService:" + ex.Message;
            }

            return(res);
        }