Пример #1
0
        /// <summary>
        /// Allows for the creation of a new private list on the Connection server directory.  The alias must be provided but the
        /// extension can be blank.
        /// </summary>
        /// <remarks>
        /// This is an alternateive AddDistributionList that passes back a PrivateList 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 distribution list.
        /// </param>
        /// <param name="pOwnerUserObjectId">
        /// The user that will be the owner of the new private list
        /// </param>
        /// <param name="pNumericId">
        /// Numeric id of the private list from 1 to 99.  Pass in 0 and the routine will create the list in the next available slot.
        /// </param>
        /// <param name="pPrivateLists">
        /// Out parameter that returns an instance of a PrivateList object if the creation completes ok.  If the user fails the creation then this is
        /// returned as NULL.
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult AddPrivateList(ConnectionServerRest pConnectionServer,
                                                   string pOwnerUserObjectId,
                                                   string pDisplayName,
                                                   int pNumericId,
                                                   out PrivateList pPrivateLists)
        {
            pPrivateLists = null;

            WebCallResult res = AddPrivateList(pConnectionServer, pOwnerUserObjectId, pDisplayName, pNumericId);

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

            return(res);
        }
Пример #2
0
        /// <summary>
        /// returns a single PrivateList 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="pOwnerUserObjectId">
        /// User that owns the private lists to be fetched
        /// </param>
        /// <param name="pObjectId">
        /// The ObjectId of the list to load
        /// </param>
        /// <param name="pDistributionList">
        /// The out param that the filled out instance of the PrivateList class is returned on.
        /// </param>
        /// <param name="pNumericId">
        /// Numeric ide of the private list (optional)
        /// </param>
        /// <returns>
        /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface.
        /// </returns>
        public static WebCallResult GetPrivateList(out PrivateList pDistributionList, ConnectionServerRest pConnectionServer, string pOwnerUserObjectId,
                                                   string pObjectId = "", int pNumericId = 0)
        {
            WebCallResult res = new WebCallResult();

            res.Success = false;

            pDistributionList = null;

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

            if (string.IsNullOrEmpty(pOwnerUserObjectId))
            {
                res.ErrorText = "Empty owner objectId passed to GetPrivateList";
                return(res);
            }

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

            //create a new PrivateList instance passing the ObjectId (or alias) which fills out the data automatically
            try
            {
                pDistributionList = new PrivateList(pConnectionServer, pOwnerUserObjectId, pObjectId, pNumericId);
                res.Success       = true;
            }
            catch (UnityConnectionRestException ex)
            {
                return(ex.WebCallResult);
            }

            return(res);
        }