Web page "metadata"?

I haven’t worked with websites for sharepoint before, but you need to make changes to the web page, which should be distributed to some 700 websites. This is a change to one of the properties of the web part; the value needs to be changed. Is there a way to get the metadata for the web part and modify it directly in the database (I assume where it is stored.)?

Here is the scenario: Webpart contains a list of document types (internal type) with comma-delimited ones that it should display. Now there is a new document. types to add to all 700 websites. I need a way to list sites, get metadata for web parts, and add these new types of documents to a web page. Currently, they go manually to each site, click on edit, enter a new type of document and save it.

+3
source share
3 answers

, , , . , , .

, Title ListViewWebPart. , . , .

private static void ProcessSiteCollection(string url)
{
    using (SPSite siteCollection = new SPSite(url))
    {
        SPWeb rootWeb = siteCollection.RootWeb;
        ProcessWebs(rootWeb);
    }
}

private static void ProcessWebs(SPWeb parentWeb)
{
    foreach (SPWeb web in parentWeb.Webs)
    {
        try
        {
            UpdateWebPart(web); // Set web part properties
            ProcessWebs(web);   // Recursively loop through children
        }
        finally
        {
            web.Dispose();
        }
    }
}

private static void UpdateWebPart(SPWeb web)
{
    using (SPLimitedWebPartManager webPartManager =
        web.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared))
    {
        try
        {
            foreach (WebPart webPart in webPartManager.WebParts)
            {
                    if (webPart.Title == "My Web Part")
                    {
                            ListViewWebPart listViewWebPart = (ListViewWebPart)webPart;
                            listViewWebPart.Title = "Updated Web Part";
                            webPartManager.SaveChanges(listViewWebPart);
                            web.Update();
                            break;
                    }
            }
        }
        finally
        {
            webPartManager.Web.Dispose();
        }
    }
}
+3

sharepoint - "". .:)

, - .

, -, (). ( , .)... , ; , , , / , .

!

+3

DO NOT

, . , , - , Microsoft ( , ).

API - , :

-

+3
source

Source: https://habr.com/ru/post/1715010/


All Articles