简体   繁体   English

以编程方式创建带有新的内容数据库错误的新网站集。 对象相同的ID。 SP2013

[英]Programmatically create new site collecttion with new content database error. Object Same ID. SP2013

I need to create site collections automatically in a Timer Job. 我需要在“计时器作业”中自动创建网站集。 This functionality is working correctly when it comes to a single content database. 当涉及单个内容数据库时,此功能正常工作。

But a content database has its limitations and need time to create the site collection check the limit and in case of exceeding the specified limit have to create another content database and use it. 但是内容数据库有其局限性,需要时间来创建网站集,请检查该限制,如果超出指定限制,则必须创建另一个内容数据库并使用它。

The creation of this content dababase is working: 正在创建此内容dababase:

public static SPContentDatabase CriarContentDataBase(string server, string contentName, SPSite site)
{
    SPContentDatabase content = new SPContentDatabase();
    content = site.WebApplication.ContentDatabases.Add(server, contentName, null, null, 35, 40, 0);
    content.Update();
    site.WebApplication.Update();
    return content;
}

The problem is time to create the site collection, I am using the overload SPContentDataBase.Add(// parameters) method: 问题是创建网站集的时间,我在使用重载SPContentDataBase.Add(// parameters)方法:

SPContentDatabase currentContentDataBase = getCurrentContentDataBase(site);

using (SPSite newSite = currentContentDataBase.Sites.Add(siteCollectionURL, titulo, null, 1046, 15, TEMPLATE_NAME, loginUsuarioGestorConteudo, nomeUsuarioGestorConteudo, emailUsuarioGestorConteudo, "", "", "", currentContentDataBase.Server, currentContentDataBase.Name, null, null))
            {

                // more code
            }

This call returns me an exception of SPException type with the following message: 该调用向我返回SPException类型的异常,并显示以下消息:

The attach operation cannot continue because another object in this farm already contains the same ID. Each object in a farm must have a unique ID. In order to proceed with the attach operation you must assign a new ID to this database. To attach this database with a new ID, use the Mount-SPContentDatabase command with the -AssignNewDatabaseId parameter. Note that if this new database and an existing database contain the same site collections, attaching this database will likely result in orphaned site collections due to conflicts between the two databases.

Can someone tell me how to do it you have as to create the content database I modify this ID? 有人可以告诉我您要如何创建内容数据库(我修改此ID)吗?

Thank you. 谢谢。

Go to Central Admin > Application Management > Manage Content Database and see your how many content DB does your Web Application has. 转到中央管理>应用程序管理>管理内容数据库,然后查看您的Web应用程序具有多少个内容数据库。

If there are more than one, please check If the name or id is same with the new one you tried to create. 如果有多个,请检查名称或ID是否与您尝试创建的新名称相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM