Ejemplo n.º 1
0
        /// <summary>
        /// Add a list in the current site based on the specified name, description, and list template identifier.
        /// </summary>
        /// <param name="listName">The title of the list which will be added.</param>
        /// <param name="description">Text which will be set as description of newly created list.</param>
        /// <param name="templateId">The template ID used to create this list.</param>
        /// <returns>Returns the AddList result.</returns>
        public AddListResponseAddListResult AddList(string listName, string description, int templateId)
        {
            if (null == this.listsProxy)
            {
                throw new InvalidOperationException("The Proxy instance is NULL, need to initialize the adapter");
            }

            AddListResponseAddListResult result = null;

            result = this.listsProxy.AddList(listName, description, templateId);
            this.VerifyTransportRequirement();

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a list in site collection.
        /// </summary>
        /// <param name="listName">The name of list that will be created in site collection.</param>
        /// <param name="templateID">A 32-bit integer that specifies the list template to use.</param>
        /// <param name="baseUrl">The site URL for connecting with the specified Document Workspace site.</param>
        /// <returns>A Boolean indicates whether the operation is executed successfully,
        /// TRUE means the operation is executed successfully, FALSE means not.</returns>
        public bool AddList(string listName, int templateID, string baseUrl)
        {
            this.RedirectBaseUrl(baseUrl);

            GetListCollectionResponseGetListCollectionResult getListResult = this.listsService.GetListCollection();

            // Check whether the specified list already exists in site collection.
            bool listIsExit = false;

            foreach (ListDefinitionCT list in getListResult.Lists)
            {
                string title = list.Title;
                if (title == listName)
                {
                    listIsExit = true;
                    break;
                }
            }

            // If the specified list does not exist in site collection, then create a new list.
            if (listIsExit == false)
            {
                // A 32-bit integer that specifies the list template to use.
                AddListResponseAddListResult result = this.listsService.AddList(listName, string.Empty, templateID);

                if (result.List != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }