public void Execute(ClientContext ctx, ListTemplateType type, string title, Action<List> setAdditionalProperties = null)
        {
            Logger.Verbose($"Started executing {nameof(CreateListFromTemplate)} for title '{title}'", title);

            var web = ctx.Web;
            ctx.Load(web, w => w.Lists);
            ctx.ExecuteQuery();

            var candidate = web.Lists.SingleOrDefault(l => l.Title == title);
            if (candidate != null)
            {
                Logger.Warning($"List with title '{title}' already exist on web '{ctx.Url}'");
                return;
            }

            var newList =
                web.Lists.Add(
                    new ListCreationInformation
                    {
                        Title = title,
                        TemplateType = (int)type
                    });

            if (setAdditionalProperties != null)
            {
                setAdditionalProperties(newList);
                newList.Update();
            }

            ctx.ExecuteQuery();
        }
Esempio n. 2
0
        public void Execute(ClientContext ctx, ListTemplateType type, string title, Action <List> setAdditionalProperties = null)
        {
            Logger.Verbose($"Started executing {nameof(CreateListFromTemplate)} for title '{title}'", title);

            var web = ctx.Web;

            ctx.Load(web, w => w.Lists);
            ctx.ExecuteQuery();

            var candidate = web.Lists.SingleOrDefault(l => l.Title == title);

            if (candidate != null)
            {
                Logger.Warning($"List with title '{title}' already exist on web '{ctx.Url}'");
                return;
            }

            var newList =
                web.Lists.Add(
                    new ListCreationInformation
            {
                Title        = title,
                TemplateType = (int)type
            });

            if (setAdditionalProperties != null)
            {
                setAdditionalProperties(newList);
                newList.Update();
            }

            ctx.ExecuteQuery();
        }
Esempio n. 3
0
        private void CreateListInternal(Web web, ListTemplateType listType, string listName, bool enableVersioning, bool updateAndExecuteQuery = true, string urlPath = "")
        {
            ListCollection          listCol = web.Lists;
            ListCreationInformation lci     = new ListCreationInformation();

            lci.Title        = listName;
            lci.TemplateType = (int)listType;

            if (!string.IsNullOrEmpty(urlPath))
            {
                lci.Url = urlPath;
            }

            List newList = listCol.Add(lci);

            if (enableVersioning)
            {
                newList.EnableVersioning    = true;
                newList.EnableMinorVersions = true;
            }

            if (updateAndExecuteQuery)
            {
                newList.Update();
                web.Context.Load(listCol);
                web.Context.ExecuteQuery();
            }
        }
Esempio n. 4
0
        internal static (bool isList, bool isLibrary, bool isCatalog) DetectListType(ListTemplateType listTemplateType)
        {
            bool isList    = true;
            bool isCatalog = false;
            bool isLibrary = false;

            if (listTemplateType == ListTemplateType.DocumentLibrary ||
                listTemplateType == ListTemplateType.XMLForm ||
                listTemplateType == ListTemplateType.PictureLibrary ||
                listTemplateType == ListTemplateType.WebPageLibrary ||
                listTemplateType == ListTemplateType.DataConnectionLibrary ||
                listTemplateType == ListTemplateType.HelpLibrary ||
                listTemplateType == ListTemplateType.HomePageLibrary ||
                listTemplateType == ListTemplateType.MySiteDocumentLibrary ||
                listTemplateType == ListTemplateType.SharingLinks ||
                // IWConvertedForms
                listTemplateType == (ListTemplateType)10102 ||
                // Sharing Links
                listTemplateType == (ListTemplateType)3300)
            {
                isList    = false;
                isLibrary = true;
            }

            if (listTemplateType.ToString().EndsWith("Catalog") ||
                listTemplateType == ListTemplateType.MaintenanceLogs ||
                listTemplateType == ListTemplateType.NoCodePublic ||
                listTemplateType == ListTemplateType.UserInformation)
            {
                isList    = false;
                isCatalog = true;
            }

            return(isList, isLibrary, isCatalog);
        }
Esempio n. 5
0
 //gavdcodebegin 01
 static void SpCsPnpcoreCreateOneList(ClientContext spCtx)
 {
     ListTemplateType myTemplate       = ListTemplateType.GenericList;
     string           listName         = "NewListPnPCore";
     bool             enableVersioning = false;
     List             newList          = spCtx.Web.CreateList(myTemplate, listName, enableVersioning);
 }
Esempio n. 6
0
        public static List CreateList(string title, string description, string url, ListTemplateType templateType, Web web, QuickLaunchOptions quicklaunchOptions)
        {
            ClientContext clientContext = web.Context as ClientContext;

            ListCreationInformation createInfo = new ListCreationInformation();

            createInfo.Title = title;
            createInfo.TemplateType = (int)templateType;

            createInfo.QuickLaunchOption = quicklaunchOptions;

            if (!string.IsNullOrEmpty(description))
            {
                createInfo.Description = description;
            }

            if (!string.IsNullOrEmpty(url))
            {
                createInfo.Url = url;
            }

            // clientContext.Load(web.Lists);

            List newList = web.Lists.Add(createInfo);

            clientContext.ExecuteQuery();

            clientContext.Load(newList);
            clientContext.ExecuteQuery();

            return newList;
        }
Esempio n. 7
0
        private static void CreateListInternal(this Web web, ListTemplateType listType, string listName, bool enableVersioning, bool updateAndExecuteQuery = true, string urlPath = "")
        {
            ListCollection listCol = web.Lists;
            ListCreationInformation lci = new ListCreationInformation();
            lci.Title = listName;
            lci.TemplateType = (int)listType;

            if (!string.IsNullOrEmpty(urlPath))
                lci.Url = urlPath;

            List newList = listCol.Add(lci);

            if (enableVersioning)
            {
                newList.EnableVersioning = true;
                newList.EnableMinorVersions = true;
            }

            if (updateAndExecuteQuery)
            {
                newList.Update();
                web.Context.Load(listCol);
                web.Context.ExecuteQuery();
            }

        }
Esempio n. 8
0
        /// <summary>
        /// Adds a list to a site
        /// </summary>
        /// <param name="properties">Site to operate on</param>
        /// <param name="listType">Type of the list</param>
        /// <param name="featureID">Feature guid that brings this list type</param>
        /// <param name="listName">Name of the list</param>
        /// <param name="enableVersioning">Enable versioning on the list</param>
        public static List AddList(ClientContext ctx, Web web, ListTemplateType listType, string listName)
        {
            ListCollection listCollection = web.Lists;

            ctx.Load(listCollection, lists => lists.Include(list => list.Title).Where(list => list.Title == listName));
            ctx.ExecuteQuery();

            if (listCollection.Count == 0)
            {
                ListCollection          listCol = web.Lists;
                ListCreationInformation lci     = new ListCreationInformation();
                lci.Title        = listName;
                lci.TemplateType = (int)listType;
                List newList = listCol.Add(lci);
                newList.Description = "Demo list for remote event receiver lab";
                newList.Fields.AddFieldAsXml("<Field DisplayName='Description' Type='Text' />", true, AddFieldOptions.DefaultValue);
                newList.Fields.AddFieldAsXml("<Field DisplayName='AssignedTo' Type='Text' />", true, AddFieldOptions.DefaultValue);
                newList.Update();
                return(newList);
                //ctx.Load(listCol);
                //ctx.ExecuteQuery();
            }
            else
            {
                return(listCollection[0]);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Adds a list to a site
        /// </summary>
        /// <param name="properties">Site to operate on</param>
        /// <param name="listType">Type of the list</param>
        /// <param name="featureID">Feature guid that brings this list type</param>
        /// <param name="listName">Name of the list</param>
        /// <param name="enableVersioning">Enable versioning on the list</param>
        public static List AddList(ClientContext ctx, Web web, ListTemplateType listType, string listName)
        {
            ListCollection listCollection = web.Lists;
            ctx.Load(listCollection, lists => lists.Include(list => list.Title).Where(list => list.Title == listName));
            ctx.ExecuteQuery();

            if (listCollection.Count == 0)
            {
                ListCollection listCol = web.Lists;
                ListCreationInformation lci = new ListCreationInformation();
                lci.Title = listName;
                lci.TemplateType = (int)listType;
                List newList = listCol.Add(lci);
                newList.Description = "Demo list for remote event receiver lab";
                newList.Fields.AddFieldAsXml("<Field DisplayName='Description' Type='Text' />",true,AddFieldOptions.DefaultValue);
                newList.Fields.AddFieldAsXml("<Field DisplayName='AssignedTo' Type='Text' />",true,AddFieldOptions.DefaultValue);
                newList.Update();
                return newList;
                //ctx.Load(listCol);
                //ctx.ExecuteQuery();                
            }
            else
            {
                return listCollection[0];
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Adds a list to a site
 /// </summary>
 /// <param name="web">Site to be processed - can be root web or sub site</param>
 /// <param name="listType">Type of the list</param>
 /// <param name="listName">Name of the list</param>
 /// <param name="enableVersioning">Enable versioning on the list</param>
 /// <param name="updateAndExecuteQuery">Perform list update and executequery, defaults to true</param>
 public static void AddList(Web web, ListTemplateType listType, string listName)
 {
     ListCollection listCol = web.Lists;
     ListCreationInformation lci = new ListCreationInformation();
     lci.Title = listName;
     lci.TemplateType = (int)listType;
     List newList = listCol.Add(lci);
 }
Esempio n. 11
0
 public DisplayBuilder FromTemplate(ListTemplateType templateType, List <IListItem> listItems)
 {
     this.template = new ListTemplate()
     {
         Type      = templateType.ToString(),
         ListItems = listItems
     };
     return(this);
 }
Esempio n. 12
0
        /// <summary>
        /// Adds a list to a site
        /// </summary>
        /// <param name="web">Site to be processed - can be root web or sub site</param>
        /// <param name="listType">Type of the list</param>
        /// <param name="listName">Name of the list</param>
        /// <param name="enableVersioning">Enable versioning on the list</param>
        /// <param name="updateAndExecuteQuery">Perform list update and executequery, defaults to true</param>
        public static void AddList(Web web, ListTemplateType listType, string listName)
        {
            ListCollection          listCol = web.Lists;
            ListCreationInformation lci     = new ListCreationInformation();

            lci.Title        = listName;
            lci.TemplateType = (int)listType;
            List newList = listCol.Add(lci);
        }
Esempio n. 13
0
        public static void AddList(this Web web, ListTemplateType listType, string listName, bool enableVersioning, bool updateAndExecuteQuery = true, string urlPath = "")
        {
            if (string.IsNullOrEmpty(listName))
            {
                throw (listName == null)
                  ? new ArgumentNullException("listName")
                  : new ArgumentException(CoreResources.Exception_Message_EmptyString_Arg, "listName");
            }

            // Call actual implementation
            CreateListInternal(web, null, (int)listType, listName, enableVersioning, updateAndExecuteQuery, urlPath);
        }
        public static void AddList(this Web web, ListTemplateType listType, string listName, bool enableVersioning, bool updateAndExecuteQuery = true, string urlPath = "")
        {
            if (string.IsNullOrEmpty(listName))
            {
                throw (listName == null)
                  ? new ArgumentNullException("listName")
                  : new ArgumentException(CoreResources.Exception_Message_EmptyString_Arg, "listName");
            }

            // Call actual implementation
            CreateListInternal(web, null, (int)listType, listName, enableVersioning, updateAndExecuteQuery, urlPath);
        }
Esempio n. 15
0
        public Lista set(string title, string description, ListTemplateType type)
        {
            Web web = _context.Web;

            ListCreationInformation listCreationInfo = new ListCreationInformation();

            listCreationInfo.Title        = title;
            listCreationInfo.Description  = description;
            listCreationInfo.TemplateType = (int)type;

            List list = web.Lists.Add(listCreationInfo);

            _context.ExecuteQuery();
            //Se consulta por Title, porque el id no se tiene, y ademas como no puede existir dos listas con el mismo nombre, no hay problema de seleccionar una lista incorrecta
            return(getByTitle(title));
        }
        /// <summary>
        /// タイトルと説明、型を指定して、
        /// リストを作成します。
        /// </summary>
        /// <param name="title">タイトル</param>
        /// <param name="url">URL</param>
        /// <param name="description">説明</param>
        /// <param name="templateType">リストタイプ</param>
        public void Create(string title, string url, string description, ListTemplateType templateType = ListTemplateType.GenericList)
        {
            if (title.IsEmpty())
            {
                var sb = new StringBuilder();
                sb.AppendLine("タイトルが空です。")
                .AppendLine("入力して下さい。");
                throw new ArgumentException(sb.ToString(), "title");
            }

            if (this.Titles.Any(t => t == title))
            {
                var sb = new StringBuilder();
                sb.AppendFormat("[{0}] は既にこの Web サイトに存在します。", title);
                throw new DuplicateException(sb.ToString());
            }

            if (url.IsEmpty())
            {
                var sb = new StringBuilder();
                sb.AppendLine("サイト URL が空です。")
                .AppendLine("入力して下さい。");
                throw new ArgumentException(sb.ToString(), "url");
            }

            this.Execute(cn => {
                var creationInfo = new ListCreationInformation()
                {
                    Title        = title,
                    TemplateType = (int)templateType,
                    Url          = url,
                    Description  = description
                };

                var list = cn.Web.Lists.Add(creationInfo);
                //list.Description = description;

                list.Update();
            });

            {            // 作成完了
                var sb = new StringBuilder();
                sb.AppendFormat("[{0}({1})] を作成しました。", title, url).AppendLine();

                this.OnCreated(sb.ToString(), title);
            }
        }
 /// <summary>
 /// Create List
 /// </summary>
 /// <param name="description"></param>
 /// <param name="type"></param>
 /// <param name="versionControl"></param>
 /// <returns></returns>
 public bool Create(string description, ListTemplateType type, bool versionControl )
 {
     try
     {
         var guidList = Web.Lists.Add(Name, description, (SPListTemplateType) type);
         if (versionControl)
         {
             var list = Web.Lists[guidList];
             list.EnableVersioning = true;
             list.Update();
         }
     }
     catch (Exception exception)
     {
         Logger.Error(exception.Message);
         return false;
     }
     return true;
 }
Esempio n. 18
0
 /// <summary>
 /// Create List
 /// </summary>
 /// <param name="description"></param>
 /// <param name="type"></param>
 /// <param name="versionControl"></param>
 /// <returns></returns>
 public bool Create(string description, ListTemplateType type, bool versionControl)
 {
     try
     {
         var guidList = Web.Lists.Add(Name, description, (SPListTemplateType)type);
         if (versionControl)
         {
             var list = Web.Lists[guidList];
             list.EnableVersioning = true;
             list.Update();
         }
     }
     catch (Exception exception)
     {
         Logger.Error(exception.Message);
         return(false);
     }
     return(true);
 }
Esempio n. 19
0
        public async Task <IList> AddAsync(string title, ListTemplateType templateType)
        {
            if (title == null)
            {
                throw new ArgumentNullException(nameof(title));
            }

            if (templateType == 0)
            {
                throw new ArgumentException(string.Format(PnPCoreResources.Exception_CannotBeZero, nameof(templateType)));
            }

            var newList = CreateNewAndAdd() as List;

            newList.Title        = title;
            newList.TemplateType = templateType;

            return(await newList.AddAsync().ConfigureAwait(false) as List);
        }
Esempio n. 20
0
        static List EnsureListExist(ClientContext ctx, string title, ListTemplateType type)
        {
            ctx.Load(ctx.Web, w => w.Lists);
            ctx.ExecuteQuery();
            var candidate = ctx.Web.Lists.SingleOrDefault(l => l.Title == title && l.BaseTemplate == (int)type);

            if (candidate == null)
            {
                var list =
                    ctx.Web.Lists.Add(
                        new ListCreationInformation
                {
                    Title        = title,
                    TemplateType = (int)type
                });
                ctx.ExecuteQuery();
                return(list);
            }
            return(candidate);
        }
Esempio n. 21
0
        public void GivenThereIsListCalled(ListTemplateType listTemplateType, string listTitle)
        {
            var listTemplateBaseType = listTemplateType.GetBaseType();

            using (var cc = Context.CreateClientContext())
            {
                var list = cc.Web.Lists.GetByTitle(listTitle);
                cc.Load(list);

                // I wonder if there's a better way of querying if a list exists without relying on exceptions?
                try
                {
                    cc.ExecuteQuery();
                }
                catch (ServerException)
                {
                    list = null;
                }

                if (list != null)
                {
                    // The list already exists.
                    // Ensure that it is the correct type.
                    if (list.BaseType != listTemplateBaseType)
                    {
                        throw new SharePointSpecFlowException(String.Format("List with title {0} already exists, but it isn't the expected type of {1}.", listTitle, listTemplateBaseType));
                    }
                }
                else
                {
                    var lci = new ListCreationInformation();
                    lci.Title        = listTitle;
                    lci.TemplateType = (int)listTemplateType;
                    list             = cc.Web.Lists.Add(lci);
                    cc.Load(list);
                    cc.ExecuteQuery();
                }

                Context.LastListTitle = listTitle;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// 新建一个文档库
        /// </summary>
        /// <param name="siteUrl">站点的uri地址</param>
        /// <param name="DocumentLibraryName">文档库的显示名称</param>
        /// <returns>返回操作的信息</returns>
        public List CreateDocumentLibrary(string folderName, ListTemplateType folderType)
        {
            //新建一个List
            Microsoft.SharePoint.Client.List newList = null;
            try
            {
                if (clientContext != null)
                {
                    //文档库创建信息操作类
                    ListCreationInformation newListInfo = new ListCreationInformation();
                    //文档库的显示标题
                    newListInfo.Title = folderName;
                    //文档库
                    newListInfo.TemplateType = (int)folderType;

                    //创建客户端对象模型
                    using (clientContext)
                    {
                        //设置默认凭据

                        //获取站点(site)
                        Web site = clientContext.Web;
                        //添加文档库
                        newList = site.Lists.Add(newListInfo);
                        //加载文档库并执行
                        clientContext.Load(newList);
                        clientContext.ExecuteQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "CreateDocumentLibrary", ex.ToString(), folderName, folderType);
            }
            finally
            {
            }
            return(newList);
        }
        public static BaseType GetBaseType(this ListTemplateType ltt)
        {
            // From https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.client.listtemplatetype.aspx
            switch (ltt)
            {
            case ListTemplateType.GenericList:
            case ListTemplateType.Links:
            case ListTemplateType.Announcements:
            case ListTemplateType.Contacts:
            case ListTemplateType.Events:
            case ListTemplateType.Tasks:
            case ListTemplateType.DiscussionBoard:
            case ListTemplateType.WorkflowProcess:
            case ListTemplateType.CustomGrid:
            case ListTemplateType.WorkflowHistory:
            case ListTemplateType.GanttTasks:
                return(BaseType.GenericList);

            case ListTemplateType.DocumentLibrary:
            case ListTemplateType.PictureLibrary:
            case ListTemplateType.DataSources:
            case ListTemplateType.XMLForm:
            case ListTemplateType.NoCodeWorkflows:
            case ListTemplateType.WebPageLibrary:
                return(BaseType.DocumentLibrary);

            case ListTemplateType.Survey:
                return(BaseType.Survey);

            case ListTemplateType.IssueTracking:
                return(BaseType.Issue);

            default:
                throw new SharePointSpecFlowException(String.Format("Can't use ListTemplateType {0} as it can't be mapped to a BaseType.", ltt.ToString()));
            }
        }
Esempio n. 24
0
 public void GivenThereIsListCalled(ListTemplateType listTemplateType, string listTitle, string userName)
 {
     Context.LastUserName = userName;
     GivenThereIsListCalled(listTemplateType, listTitle);
 }
Esempio n. 25
0
 public void GivenThereIsListCalled(ListTemplateType listTemplateType, string listTitle, string userName, string siteUri)
 {
     Context.SiteUri      = new Uri(siteUri);
     Context.LastUserName = userName;
     GivenThereIsListCalled(listTemplateType, listTitle);
 }
Esempio n. 26
0
 public IList Add(string title, ListTemplateType templateType)
 {
     return(AddAsync(title, templateType).GetAwaiter().GetResult());
 }
Esempio n. 27
0
 private void CreateList(Web web, ListTemplateType listType, string listName, bool enableVersioning, bool updateAndExecuteQuery = true, string urlPath = "")
 {
     // Call actual implementation
     CreateListInternal(web, listType, listName, enableVersioning, updateAndExecuteQuery, urlPath);
 }
Esempio n. 28
0
 public IList AddBatch(Batch batch, string title, ListTemplateType templateType)
 {
     return(AddBatchAsync(batch, title, templateType).GetAwaiter().GetResult());
 }
Esempio n. 29
0
 public async Task <IList> AddBatchAsync(string title, ListTemplateType templateType)
 {
     return(await AddBatchAsync(PnPContext.CurrentBatch, title, templateType).ConfigureAwait(false));
 }
Esempio n. 30
0
        public static ListTemplateType GetTemplateType(string cTemplateType)
        {
            ListTemplateType oRetval = ListTemplateType.GenericList;

            try
            {
                switch (cTemplateType)
                {
                case "InvalidType":
                    oRetval = ListTemplateType.InvalidType;

                    break;

                case "NoListTemplate":
                    oRetval = ListTemplateType.NoListTemplate;

                    break;

                case "GenericList":
                    oRetval = ListTemplateType.GenericList;

                    break;

                case "DocumentLibrary":
                    oRetval = ListTemplateType.DocumentLibrary;

                    break;

                case "Survey":
                    oRetval = ListTemplateType.Survey;

                    break;

                case "Links":
                    oRetval = ListTemplateType.Links;

                    break;

                case "Announcements":
                    oRetval = ListTemplateType.Announcements;

                    break;

                case "Contacts":
                    oRetval = ListTemplateType.Contacts;

                    break;

                case "Events":
                    oRetval = ListTemplateType.Events;

                    break;

                case "Tasks":
                    oRetval = ListTemplateType.Tasks;

                    break;

                case "DiscussionBoard":
                    oRetval = ListTemplateType.DiscussionBoard;

                    break;

                case "PictureLibrary":
                    oRetval = ListTemplateType.PictureLibrary;

                    break;

                case "DataSources":
                    oRetval = ListTemplateType.DataSources;

                    break;

                case "WebTemplateCatalog":
                    oRetval = ListTemplateType.WebTemplateCatalog;

                    break;

                case "UserInformation":
                    oRetval = ListTemplateType.UserInformation;

                    break;

                case "WebPartCatalog":
                    oRetval = ListTemplateType.WebPartCatalog;

                    break;

                case "ListTemplateCatalog":
                    oRetval = ListTemplateType.ListTemplateCatalog;

                    break;

                case "XMLForm":
                    oRetval = ListTemplateType.XMLForm;

                    break;

                case "":
                    oRetval = ListTemplateType.MasterPageCatalog;

                    break;

                case "NoCodeWorkflows":
                    oRetval = ListTemplateType.NoCodeWorkflows;

                    break;

                case "WorkflowProcess":
                    oRetval = ListTemplateType.WorkflowProcess;

                    break;

                case "WebPageLibrary":
                    oRetval = ListTemplateType.WebPageLibrary;

                    break;

                case "CustomGrid":
                    oRetval = ListTemplateType.CustomGrid;

                    break;

                case "SolutionCatalog":
                    oRetval = ListTemplateType.SolutionCatalog;

                    break;

                case "NoCodePublic":
                    oRetval = ListTemplateType.NoCodePublic;

                    break;

                case "ThemeCatalog":
                    oRetval = ListTemplateType.ThemeCatalog;

                    break;

                case "DesignCatalog":
                    oRetval = ListTemplateType.DesignCatalog;

                    break;

                case "AppDataCatalog":
                    oRetval = ListTemplateType.AppDataCatalog;

                    break;

                case "DataConnectionLibrary":
                    oRetval = ListTemplateType.DataConnectionLibrary;

                    break;

                case "WorkflowHistory":
                    oRetval = ListTemplateType.WorkflowHistory;

                    break;

                case "GanttTasks":
                    oRetval = ListTemplateType.GanttTasks;

                    break;

                case "HelpLibrary":
                    oRetval = ListTemplateType.HelpLibrary;

                    break;

                case "AccessRequest":
                    oRetval = ListTemplateType.AccessRequest;

                    break;

                case "TasksWithTimelineAndHierarchy":
                    oRetval = ListTemplateType.TasksWithTimelineAndHierarchy;

                    break;

                case "MaintenanceLogs":
                    oRetval = ListTemplateType.MaintenanceLogs;

                    break;

                case "Meetings":
                    oRetval = ListTemplateType.Meetings;

                    break;

                case "Agenda":
                    oRetval = ListTemplateType.Agenda;

                    break;

                case "MeetingUser":
                    oRetval = ListTemplateType.MeetingUser;

                    break;

                case "Decision":
                    oRetval = ListTemplateType.Decision;

                    break;

                case "MeetingObjective":
                    oRetval = ListTemplateType.MeetingObjective;

                    break;

                case "TextBox":
                    oRetval = ListTemplateType.TextBox;

                    break;

                case "ThingsToBring":
                    oRetval = ListTemplateType.ThingsToBring;

                    break;

                case "HomePageLibrary":
                    oRetval = ListTemplateType.HomePageLibrary;

                    break;

                case "Posts":
                    oRetval = ListTemplateType.Posts;

                    break;

                case "Comments":
                    oRetval = ListTemplateType.Comments;

                    break;

                case "Categories":
                    oRetval = ListTemplateType.Categories;

                    break;

                case "Facility":
                    oRetval = ListTemplateType.Facility;

                    break;

                case "Whereabouts":
                    oRetval = ListTemplateType.Whereabouts;

                    break;

                case "CallTrack":
                    oRetval = ListTemplateType.CallTrack;

                    break;

                case "Circulation":
                    oRetval = ListTemplateType.Circulation;

                    break;

                case "Timecard":
                    oRetval = ListTemplateType.Timecard;

                    break;

                case "Holidays":
                    oRetval = ListTemplateType.Holidays;

                    break;

                case "IMEDic":
                    oRetval = ListTemplateType.IMEDic;

                    break;

                case "ExternalList":
                    oRetval = ListTemplateType.ExternalList;

                    break;

                case "MySiteDocumentLibrary":
                    oRetval = ListTemplateType.MySiteDocumentLibrary;

                    break;

                case "PublishingPages":
                    //oRetval = ListTemplateType.PublishingPages;

                    break;

                case "IssueTracking":
                    oRetval = ListTemplateType.IssueTracking;

                    break;

                case "AdminTasks":
                    oRetval = ListTemplateType.AdminTasks;

                    break;

                case "HealthRules":
                    oRetval = ListTemplateType.HealthRules;

                    break;

                case "HealthReports":
                    oRetval = ListTemplateType.HealthReports;

                    break;

                case "DeveloperSiteDraftApps":
                    oRetval = ListTemplateType.DeveloperSiteDraftApps;

                    break;

                default:
                    oRetval = ListTemplateType.GenericList;
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            return(oRetval);
        }
Esempio n. 31
0
        internal static string RestEntityTypeNameToUrl(Uri pnpContextUri, string restEntityTypeName, ListTemplateType listTemplateType)
        {
            var contextUrl = pnpContextUri.ToString().TrimEnd('/');

            (bool isList, _, bool isCatalog) = DetectListType(listTemplateType);

            // Translate special chars back to their regular values
            if (isCatalog)
            {
                restEntityTypeName = restEntityTypeName.Replace("OData__x005f_catalogs_x002f_", "");
            }
            var listUrl = restEntityTypeName.Replace("_x005f_", "_").Replace("_x0020_", " ");

            if (listTemplateType == ListTemplateType.UserInformation)
            {
                listUrl = "users";
            }

            if (isList)
            {
                // Regular list

                // Drop List suffix
                listUrl = listUrl.Substring(0, listUrl.Length - 4);
                return($"{contextUrl}/lists/{listUrl}");
            }
            else if (isCatalog)
            {
                // catalog
                return($"{contextUrl}/_catalogs/{listUrl}");
            }
            else
            {
                // library
                return($"{contextUrl}/{listUrl}");
            }
        }
Esempio n. 32
0
 private void CreateList(Web web, ListTemplateType listType, string listName, bool enableVersioning, bool updateAndExecuteQuery = true, string urlPath = "")
 {
     // Call actual implementation
     CreateListInternal(web, listType, listName, enableVersioning, updateAndExecuteQuery, urlPath);
 }
Esempio n. 33
0
        internal static string MicrosoftGraphNameToRestEntityTypeName(string microsoftGraphListName, ListTemplateType listTemplateType)
        {
            if (listTemplateType == ListTemplateType.UserInformation)
            {
                return("UserInfo");
            }

            (bool isList, _, bool isCatalog) = DetectListType(listTemplateType);

            string entityName = microsoftGraphListName.Replace("_", "_x005f_").Replace(" ", "_x0020_");

            if (isCatalog)
            {
                entityName = $"OData__x005f_catalogs_x002f_{entityName}";
            }

            // Build the name
            string entityNameToUse = $"{entityName.Replace(" ", "")}{(isList ? "List" : "")}";

            // Ensure first character is upper case
            entityNameToUse = entityNameToUse.First().ToString().ToUpper() + entityNameToUse.Substring(1);

            return(entityNameToUse);
        }
Esempio n. 34
0
 internal static bool IsLibrary(ListTemplateType listTemplateType)
 {
     (_, bool isLibrary, _) = DetectListType(listTemplateType);
     return(isLibrary);
 }
Esempio n. 35
0
 public ListAttribute(ListTemplateType type)
 {
     Type = type;
 }
 /// <summary>
 /// Create List
 /// </summary>
 /// <param name="description"></param>
 /// <param name="type"></param>        
 /// <returns></returns>
 public bool Create(string description, ListTemplateType type)
 {
     return Create(description,  type, false);
 }
Esempio n. 37
0
 internal static bool IsCatalog(ListTemplateType listTemplateType)
 {
     (_, _, bool isCatalog) = DetectListType(listTemplateType);
     return(isCatalog);
 }
Esempio n. 38
0
 internal static bool IsList(ListTemplateType listTemplateType)
 {
     (bool isList, _, _) = DetectListType(listTemplateType);
     return(isList);
 }
Esempio n. 39
0
 private static bool TryGetTemplateType(string templateType, out ListTemplateType listTemplateType)
 {
     return(Enum.TryParse(templateType, true, out listTemplateType));
 }