public SPOWeb GetRootWeb(bool detailed)
        {
            if (_rootWebDetailed != null)
            {
                return(_rootWebDetailed);
            }
            if (_rootWeb != null && !detailed)
            {
                return(_rootWeb);
            }

            var ctx     = SPOSiteContext.CurrentSiteContext.Context;
            var rootWeb = this.Site.RootWeb;

            SPOWeb.LoadWeb(ctx, rootWeb, detailed);
            ctx.ExecuteQuery();

            var spoWeb = new SPOWeb(rootWeb);

            if (detailed)
            {
                _rootWebDetailed = spoWeb;
            }
            else
            {
                _rootWeb = spoWeb;
            }

            return(spoWeb);
        }
Beispiel #2
0
        public List <SPOWeb> GetWebs(bool detailed, bool includeAppWebs)
        {
            if (_detailedSubWebs != null)
            {
                return(_detailedSubWebs);
            }
            if (!detailed && _subWebs != null)
            {
                return(_subWebs);
            }

            var ctx     = SPOSiteContext.CurrentSiteContext.Context;
            var subWebs = _web.Webs;

            ctx.Load(subWebs);
            ctx.ExecuteQuery();
            var webs = new List <SPOWeb>();

            foreach (Web childWeb in subWebs)
            {
                SPOWeb.LoadWeb(ctx, childWeb, detailed);
                webs.Add(new SPOWeb(childWeb));
            }
            _subWebs = webs;
            if (detailed)
            {
                _detailedSubWebs = webs;
            }

            if (includeAppWebs)
            {
                return(webs);
            }
            return(webs.Where(w => w.WebTemplate != "APP").ToList());
        }
        public SPOFile Read(SPOWeb spoWeb)
        {
            if (string.IsNullOrEmpty(_serverRelativeUrl))
                throw new ArgumentNullException("The server relative URL was not provided.");

            return spoWeb.GetFileByServerRelativeUrl(_serverRelativeUrl);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;

            SPOWeb web = new SPOWeb(ctx.Site.OpenWeb(Web.Read()));
            WriteObject(web.GetFolderByServerRelativeUrl(Url));
        }
Beispiel #5
0
        private void IterateWebs(Web parentWeb, List <SPOWeb> webs, bool detailed)
        {
            var ctx       = SPOSiteContext.CurrentSiteContext.Context;
            var childWebs = parentWeb.Webs;

            ctx.Load(childWebs);
            ctx.ExecuteQuery();
            foreach (Web childWeb in childWebs)
            {
                SPOWeb.LoadWeb(ctx, childWeb, detailed);
                webs.Add(new SPOWeb(childWeb));
                IterateWebs(childWeb, webs, detailed);
            }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;

            ctx.Load(ctx.Site, s => s.ServerRelativeUrl);
            ctx.ExecuteQuery();

            FileInfo file = new FileInfo(LiteralPath);
            string leafName = file.Name;
            string url = ctx.Site.ServerRelativeUrl.TrimEnd('/') + "/_catalogs/solutions/" + leafName;
            using (FileStream stream = new FileStream(LiteralPath, FileMode.Open))
            {
                Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx,
                    url, stream, Overwrite);
            }
            SPOWeb web = new SPOWeb(ctx.Site.RootWeb);
            WriteObject(web.GetFileByServerRelativeUrl(url));
        }
 private void IterateWebs(CmdletContext ctx, Web parentWeb, bool detailed)
 {
     var childWebs = parentWeb.Webs;
     ctx.Load(childWebs);
     ctx.ExecuteQuery();
     foreach (Web childWeb in childWebs)
     {
         SPOWeb.LoadWeb(ctx, childWeb, detailed);
         SPOWeb web = new SPOWeb(childWeb);
         if (web.WebTemplate != "APP" || (web.WebTemplate == "APP" && IncludeAppWebs))
             WriteObject(web);
         IterateWebs(ctx, childWeb, detailed);
     }
 }
 public void AddFieldLinks(SPOWeb web, params string[] fieldsToAdd)
 {
     AddFieldLinks(web.Web.AvailableFields, false, fieldsToAdd);
 }
 public SPOPropertyBag(SPOWeb web, PropertyValues properties)
 {
     _web = web;
     _pb = properties;
 }
 public static SPOWikiPage AddWikiPage(SPOWeb web, string wikiPageLibraryUrlOrTitle, string wikiPageName)
 {
     return AddWikiPage(web, wikiPageLibraryUrlOrTitle, wikiPageName, false);
 }
 internal static SPOWikiPage AddWikiPage(SPOWeb web, string wikiPageLibraryUrlOrTitle, string wikiPageName, bool throwIfExists)
 {
     SPOList list = web.GetList(wikiPageLibraryUrlOrTitle, false);
     return AddWikiPage(list, wikiPageName, throwIfExists);
 }
 public SPOFile Read(Web web)
 {
     SPOWeb spoWeb = new SPOWeb(web);
     return Read(spoWeb);
 }
 public SPOPropertyBag(SPOWeb web, PropertyValues properties)
 {
     _web = web;
     _pb  = properties;
 }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            var ctx = base.Context;
            string surl = Identity.Read();

            if (!base.ShouldProcess(Identity.ToString()))
                return;

            SPOWeb web = new SPOWeb(ctx.Site.OpenWeb(surl));
            web.ApplyTheme(ColorPaletteUrl, FontSchemeUrl, BackgroundImageUrl, ShareGenerated);
        }
Beispiel #15
0
        public SPOWeb GetWeb(bool detailed)
        {
            if (_webDetailed != null) return _webDetailed;
            if (_web != null && !detailed) return _web;

            var ctx = SPOSiteContext.CurrentSiteContext.Context;
            var web = ctx.Web;
            SPOWeb.LoadWeb(ctx, web, detailed);
            ctx.ExecuteQuery();

            var spoWeb = new SPOWeb(web);
            if (detailed)
                _webDetailed = spoWeb;
            else
                _web = spoWeb;

            return spoWeb;
        }
Beispiel #16
0
        public SPOWeb GetRootWeb(bool detailed)
        {
            if (_rootWebDetailed != null) return _rootWebDetailed;
            if (_rootWeb != null && !detailed) return _rootWeb;

            var ctx = SPOSiteContext.CurrentSiteContext.Context;
            var rootWeb = this.Site.RootWeb;
            SPOWeb.LoadWeb(ctx, rootWeb, detailed);
            ctx.ExecuteQuery();

            var spoWeb = new SPOWeb(rootWeb);
            if (detailed)
                _rootWebDetailed = spoWeb;
            else
                _rootWeb = spoWeb;

            return spoWeb;
        }