예제 #1
0
        static void Main(string[] args)
        {
            System.Diagnostics.Debugger.Launch();
            Console.WriteLine("Create ContentType App [C]");
            Console.WriteLine("Check for links in WikiFields [W]");
            Console.WriteLine("Create Modern Pages [M]");
            Console.WriteLine("Publish All Pages [P]");
            var input = Console.ReadLine();

            if (input.ToLower().Equals("c"))
            {
                StartCreatingContentType();
            }
            else if (input.ToLower().Equals("m"))
            {
                StartCreatingModernPages();
            }
            else if (input.ToLower().Equals("w"))
            {
                string        targetSiteUrl = "https://lbforsikring.sharepoint.com/sites/skademanuals";
                ClientContext ctx           = SPOUtility.Authenticate(targetSiteUrl, "*****@*****.**", "MandM777");

                Ansvar.CheckForLinks(ctx);
                Console.WriteLine("Done searching for links");
                Console.ReadLine();
            }
            else if (input.ToLower().Equals("p"))
            {
                string        targetSiteUrl = "https://lbforsikring.sharepoint.com/sites/skade";
                ClientContext ctx           = SPOUtility.Authenticate(targetSiteUrl, "", "");
                SPOUtility.CheckInAllDocuments(ctx, "Webstedssider");
            }
        }
예제 #2
0
        private static void StartCreatingModernPages()
        {
            string        targetSiteUrl         = "https://lbforsikring.sharepoint.com/sites/skademanuals";
            ClientContext ctx                   = SPOUtility.Authenticate(targetSiteUrl, "*****@*****.**", "MandM777");
            string        sourceLibraryName     = "Ansvar";
            string        targetLibraryName     = "SitePages";
            string        targetContentTypeName = "SkadeManual";

            SitePages.CreateModernSitePages(ctx, sourceLibraryName, targetLibraryName, targetContentTypeName);
        }
예제 #3
0
        private static void CreatePages(ClientContext context, ErhvervManualProperies p, string targetContentTypeName)
        {
            var page = context.Web.AddClientSidePage(p.FileName, true);

            ClientSideText txt1 = new ClientSideText()
            {
                Text = p.WikiContent
            };

            page.AddControl(txt1, -1);

            Microsoft.SharePoint.Client.ContentType newContentType = context.Web.GetContentTypeByName(targetContentTypeName);
            context.Load(newContentType);
            context.ExecuteQuery();

            ListItem item = page.PageListItem;

            //item.Update();

            context.Load(item);
            context.ExecuteQuery();

            //item["ContentType"] = newContentType.Name;
            item.Properties["ContentTypeId"] = newContentType.Id.StringValue;
            item["ContentTypeId"]            = newContentType.Id;

            item.Update();
            //page.Save();

            //context.ExecuteQuery();



            //context.ExecuteQuery();

            if (!string.IsNullOrEmpty(p.ErhvervCategory))
            {
                SPOUtility.SetMetadataField(context, item, p.ErhvervCategory, "ErhvervCategory");
                item.Update();
            }
            if (!string.IsNullOrEmpty(p.ErhvervArea))
            {
                SPOUtility.SetMetadataField(context, item, p.ErhvervArea, "ErhvervArea");
                item.Update();
            }



            page.Save();


            context.ExecuteQuery();
        }
예제 #4
0
        private static void StartCreatingContentType()
        {
            string sourceSiteUrl = "https://lboffice365.sharepoint.com/sites/MigrateOne";
            string targetSiteUrl = "https://lboffice365.sharepoint.com/sites/Skade/";
            string siteUrl       = "https://lboffice365.sharepoint.com/sites/LbCommunicationSite/";


            string contentTypeHubSiteUrl = "https://lboffice365.sharepoint.com/sites/contentTypeHub";

            string        contentTypeName          = "IndboManual";
            string        categoryFieldName        = "IndboManualCategory";
            string        internalFieldName        = "IndboManualCategory";
            string        termSetName              = "Indbo";
            ClientContext ctxContentTypeHubSiteUrl = SPOUtility.Authenticate(contentTypeHubSiteUrl, "", "");

            ContentType.CreateSiteColumn(ctxContentTypeHubSiteUrl, "Indbo kategori", internalFieldName, termSetName);
            ContentType.CreateContentType(ctxContentTypeHubSiteUrl, contentTypeName, categoryFieldName);
        }
예제 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Create ContentType App [C]");
            Console.WriteLine("Create Modern Pages [M]");
            Console.WriteLine("Publish All Pages [P]");
            var input = Console.ReadLine();

            if (input.ToLower().Equals("c"))
            {
                StartCreatingContentType();
            }
            else if (input.ToLower().Equals("m"))
            {
                StartCreatingModernPages();
            }
            else if (input.ToLower().Equals("p"))
            {
                string        targetSiteUrl = "https://lboffice365.sharepoint.com/sites/Indbohaandbog/";
                ClientContext ctx           = SPOUtility.Authenticate(targetSiteUrl, "", "");
                SPOUtility.CheckInAllDocuments(ctx, "Site Pages");
            }


            // Update the below variables to use your tenant and account information



            //string userName = "******";
            //SecureString password = GetSecureString("Password");

            //AuthenticationManager am = new AuthenticationManager();

            //using (var cc = am.GetSharePointOnlineAuthenticatedContextTenant(contentTypeHubSiteUrl, userName, password))
            //{
            //    CreateTaxColumn(cc);

            //    CreateLBContentType(cc);

            //    List<pageSettings> pages= GetPages(sourceSiteUrl, cc);
            //    using (var ccc = am.GetSharePointOnlineAuthenticatedContextTenant(targetSiteUrl, userName, password))
            //    {
            //        foreach (var p in pages)
            //        {
            //            CreateModernSitePage(ccc, p);
            //        }
            //    }


            //    Web web = cc.Web;
            //    Microsoft.SharePoint.Client.ContentType newContentType = GetContentTypeByName(cc, web, "LBManual");



            //    pageSettings s = GetWikiPages();
            //    var page = cc.Web.AddClientSidePage("PnPRocks11.aspx", true);

            //    ClientSideText txt1 = new ClientSideText() { Text = s.Content };

            //    page.AddControl(txt1, -1);
            //    page.Save();

            //    ListItem item = page.PageListItem;
            //    item.Properties["ContentType"] = "LBManual";
            //    item["ContentTypeId"] = newContentType.StringId;

            //    item.Update();
            //    cc.ExecuteQuery();


            //    SetMetadataField(cc, item, s.ManualSetting);

            //    item.Update();

            //    cc.ExecuteQuery();



            //}
        }
예제 #6
0
        private static void StartCreatingModernPages()
        {
            string sourceLibraryName = "";
            string targetLibraryName = "SitePages";

            targetLibraryName = "Webstedssider";

            string        targetSiteUrl = "https://lbforsikring.sharepoint.com/sites/skade";
            ClientContext ctx           = SPOUtility.Authenticate(targetSiteUrl, "*****@*****.**", "MandM777");

            Console.WriteLine("Create Ansvar Manuals [A]");
            Console.WriteLine("Create Beredskab Manuals [B]");
            Console.WriteLine("Create Bil Manuals [C]");
            Console.WriteLine("Create BilskadePortalGuide Manuals [D]");
            Console.WriteLine("Create Bygning Manuals [E]");
            Console.WriteLine("Create Båd Manuals [F]");
            Console.WriteLine("Create Ejerskifte Manuals [G]");
            Console.WriteLine("Create Enterprise Manuals [H]");
            Console.WriteLine("Create Erhverv Manuals [I]");
            Console.WriteLine("Create Gerningsmand Manuals [J]");
            Console.WriteLine("Create Hund Manuals [K]");
            var input = Console.ReadLine();

            if (input.ToLower().Equals("a"))
            {
                sourceLibraryName = "Ansvar";

                List <AnsvarManualProperies> AnsvarManuals = Ansvar.GetSourceFiles(ctx, sourceLibraryName);
                Ansvar.CreateModernSitePages(ctx, AnsvarManuals);
            }
            else if (input.ToLower().Equals("b"))
            {
                sourceLibraryName = "Beredskab";

                List <BeredskabManualProperies> BeredskabManuals = Beredskab.GetSourceFiles(ctx, sourceLibraryName);
                Beredskab.CreateModernSitePages(ctx, BeredskabManuals);
            }
            else if (input.ToLower().Equals("c"))
            {
                sourceLibraryName = "Bil";

                List <BilManualProperies> BilManuals = Bil.GetSourceFiles(ctx, sourceLibraryName);
                Bil.CreateModernSitePages(ctx, BilManuals);
            }
            else if (input.ToLower().Equals("d"))
            {
                sourceLibraryName = "Bilskade Portal Guide";

                List <BilSkadePortalGuideManualProperies> BilSkadePortalGuideManuals = BilSkadePortalGuide.GetSourceFiles(ctx, sourceLibraryName);
                BilSkadePortalGuide.CreateModernSitePages(ctx, BilSkadePortalGuideManuals);
            }
            else if (input.ToLower().Equals("e"))
            {
                sourceLibraryName = "Bygning";

                List <BygningManualProperies> BygningManuals = Bygning.GetSourceFiles(ctx, sourceLibraryName);
                Bygning.CreateModernSitePages(ctx, BygningManuals);
            }
            else if (input.ToLower().Equals("f"))
            {
                sourceLibraryName = "Båd";

                List <BaadManualProperies> BaadManuals = Baad.GetSourceFiles(ctx, sourceLibraryName);
                Baad.CreateModernSitePages(ctx, BaadManuals);
            }
            else if (input.ToLower().Equals("g"))
            {
                sourceLibraryName = "Ejerskifte";

                List <EjerskifteManualProperies> EjerskifteManuals = Ejerskifte.GetSourceFiles(ctx, sourceLibraryName);
                Ejerskifte.CreateModernSitePages(ctx, EjerskifteManuals);
            }
            else if (input.ToLower().Equals("h"))
            {
                sourceLibraryName = "Enterprise";

                List <EnterpriseManualProperies> EnterpriseManuals = Enterprise.GetSourceFiles(ctx, sourceLibraryName);
                Enterprise.CreateModernSitePages(ctx, EnterpriseManuals);
            }
            else if (input.ToLower().Equals("i"))
            {
                sourceLibraryName = "Erhverv";

                List <ErhvervManualProperies> ErhvervManuals = Erhverv.GetSourceFiles(ctx, sourceLibraryName);
                Erhverv.CreateModernSitePages(ctx, ErhvervManuals);
            }
            else if (input.ToLower().Equals("j"))
            {
                sourceLibraryName = "Gerningsmand";

                List <GerningsmandManualProperies> GerningsmandManuals = Gerningsmand.GetSourceFiles(ctx, sourceLibraryName);
                Gerningsmand.CreateModernSitePages(ctx, GerningsmandManuals);
            }
            else if (input.ToLower().Equals("k"))
            {
                sourceLibraryName = "Hund";

                List <HundManualProperies> HundManuals = Hund.GetSourceFiles(ctx, sourceLibraryName);
                Hund.CreateModernSitePages(ctx, HundManuals);
            }



            //SitePages.CreateModernSitePages(ctx, sourceLibraryName,targetLibraryName, targetContentTypeName);
            //SitePages.CreateModernSitePages(ctx, sourceLibraryName, targetLibraryName, targetContentTypeName);
        }