Beispiel #1
0
        public static CSOMOperation CreateWeb(this CSOMOperation operation, string title, int?lcid, string url = "", string template = "")
        {
            operation.LogInfo($"Creating web {title}");

            url = url.IsNotNullOrEmpty() ? url : operation.NormalizeUrl(title);
            Web rootWeb = operation.DecideWeb();

            lcid = (int)((uint?)lcid ?? operation.DecideWeb().Language);

            operation.LogDebug($"Web creation information set to Title: {title}, Url: {url}, Lcid: {lcid}, Template: {template}");
            WebCreationInformation webInformation = new WebCreationInformation
            {
                Title       = title,
                Url         = url,
                WebTemplate = template,
                Language    = lcid.Value
            };

            var web = rootWeb.Webs.Add(webInformation);

            operation.LoadWebWithDefaultRetrievals(web);

            operation.SetLevel(OperationLevels.Web, web);
            operation.ActionQueue.Enqueue(new DeferredAction {
                ClientObject = web, Action = DeferredActions.Load
            });

            return(operation);
        }
Beispiel #2
0
        public static CSOMOperation LoadList(this CSOMOperation operation, string name, Action <ClientContext, Microsoft.SharePoint.Client.List> listLoader = null)
        {
            operation.LogDebug($"Loading list {name}");

            var web  = operation.DecideWeb();
            var list = web.Lists.GetByTitle(name);

            operation.LoadListRequired(list);

            if (listLoader != null)
            {
                listLoader(operation.Context, list);
            }
            else
            {
                operation.Context.Load(list);
            }

            operation.SetLevel(OperationLevels.List, list);
            operation.ActionQueue.Enqueue(new DeferredAction {
                ClientObject = operation.LastList, Action = DeferredActions.Load
            });

            return(operation);
        }
Beispiel #3
0
        public static CSOMOperation SelectList(this CSOMOperation operation, string name)
        {
            if (operation.LoadedLists.ContainsKey(name))
            {
                operation.SetLevel(OperationLevels.List, operation.LoadedLists[name]);
            }
            else
            {
                throw new ArgumentException($"List ${name} doesn't exist");
            }

            return(operation);
        }
        public static CSOMOperation SelectContentType(this CSOMOperation operation, string name)
        {
            throw new NotImplementedException();

            var contentTypes = DecideContentTypes(operation);

            if (contentTypes != null)
            {
                operation.SetLevel(OperationLevels.ContentType, contentTypes.First(ct => ct.Name.Equals(name)));
            }

            return(operation);
        }
Beispiel #5
0
        public static CSOMOperation SelectWeb(this CSOMOperation operation, string url)
        {
            var key = url.ToLower();

            operation.LogDebug($"Selecting web with url: {key}");
            if (operation.LoadedWebs.ContainsKey(key))
            {
                operation.SetLevel(OperationLevels.Web, operation.LoadedWebs[key]);
            }
            else
            {
                throw new ArgumentException($"Web with URL {key} doesn't exists");
            }

            return(operation);
        }
Beispiel #6
0
        public static CSOMOperation LoadWeb(this CSOMOperation operation, Web web,
                                            params Expression <Func <Web, object> >[] retrievals)
        {
            operation.LogDebug($"Loading web");

            operation.Context.Load(web, retrievals.Length > 0
                                        ? retrievals
                                        : CSOMOperation.DefaultRetrievals.Web);

            operation.SetLevel(OperationLevels.Web, web);
            operation.ActionQueue.Enqueue(new DeferredAction {
                ClientObject = web, Action = DeferredActions.Load
            });

            return(operation);
        }
        public static CSOMOperation CreateList(this CSOMOperation operation, string name, string template = null)
        {
            operation.LogInfo($"Creating list {name}");

            ListCreationInformation listInformation = new ListCreationInformation
            {
                Title        = name,
                ListTemplate = String.IsNullOrEmpty(template)
                                        ? operation.LastWeb.ListTemplates.GetByName("Custom List")
                                        : operation.LastWeb.ListTemplates.GetByName(template)
            };

            var list = operation.LastWeb.Lists.Add(listInformation);

            operation.LastWeb.Context.Load(list);
            operation.SetLevel(OperationLevels.List, list);
            operation.ActionQueue.Enqueue(new DeferredAction {
                ClientObject = list, Action = DeferredActions.Load
            });

            return(operation);
        }