本文整理汇总了C#中Blog.CopyExistingBlogFolderToNewBlogFolder方法的典型用法代码示例。如果您正苦于以下问题:C# Blog.CopyExistingBlogFolderToNewBlogFolder方法的具体用法?C# Blog.CopyExistingBlogFolderToNewBlogFolder怎么用?C# Blog.CopyExistingBlogFolderToNewBlogFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blog
的用法示例。
在下文中一共展示了Blog.CopyExistingBlogFolderToNewBlogFolder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupBlogFromExistingBlog
/// <summary>
/// Sets up the required storage files/tables for a new Blog instance, from an existing blog instance.
/// </summary>
/// <param name="existingBlog">
/// The existing blog to copy from.
/// </param>
/// <param name="newBlog">
/// The new blog to copy to.
/// </param>
public override bool SetupBlogFromExistingBlog(Blog existingBlog, Blog newBlog)
{
bool copyResult = newBlog.CopyExistingBlogFolderToNewBlogFolder(existingBlog);
// All we need to do for the XmlBlogProvider is to copy the folders, as done above.
return copyResult;
}
示例2: SetupBlogFromExistingBlog
/// <summary>
/// Sets up the required storage files/tables for a new Blog instance, from an existing blog instance.
/// </summary>
/// <param name="existingBlog">
/// The existing blog to copy from.
/// </param>
/// <param name="newBlog">
/// The new blog to copy to.
/// </param>
public override bool SetupBlogFromExistingBlog(Blog existingBlog, Blog newBlog)
{
// Even for the DbBlogProvider, we call newBlog.CopyExistingBlogFolderToNewBlogFolder().
// The reasons are that a small number of extensions/widgets use App_Data even if
// the DbBlogProvider is being used (Newsletter widget, Logger extension, and any
// other custom components written by other people). Also, even if the
// DbBlogProvider is being used, the XmlMembershipProvider and XmlRoleProvider could
// also be used, which stores data in App_Data.
// So as a rule of thumb, whenever a new blog instance is created, we will create
// a new folder in App_Data for that new instance, and copy all the files/folders in.
bool copyResult = newBlog.CopyExistingBlogFolderToNewBlogFolder(existingBlog);
if (!copyResult)
{
Utils.Log("DbBlogProvider.SetupBlogFromExistingBlog", new Exception("Unsuccessful result from newBlog.CopyExistingBlogFolderToNewBlogFolder."));
return false;
}
using (var conn = this.CreateConnection())
{
if (conn.HasConnection)
{
//
// For SQL CE compatibility, all the "newblogid" parameters below need to have their DBType set to DBType.String.
// This is done with the CreateParameter() overload that accepts a DBType.
//
// be_BlogRollItems
using (var cmd = conn.CreateTextCommand(string.Format(
" INSERT INTO {0}BlogRollItems ( BlogId, BlogRollId, Title, Description, BlogUrl, FeedUrl, Xfn, SortIndex ) " +
" SELECT {1}newblogid, BlogRollId, Title, Description, BlogUrl, FeedUrl, Xfn, SortIndex " +
" FROM {0}BlogRollItems " +
" WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
{
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
cmd.ExecuteNonQuery();
}
// be_Categories
using (var cmd = conn.CreateTextCommand(string.Format(
" INSERT INTO {0}Categories ( BlogID, CategoryID, CategoryName, Description, ParentID ) " +
" SELECT {1}newblogid, CategoryID, CategoryName, Description, ParentID " +
" FROM {0}Categories " +
" WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
{
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
cmd.ExecuteNonQuery();
}
// be_DataStoreSettings
using (var cmd = conn.CreateTextCommand(string.Format(
" INSERT INTO {0}DataStoreSettings ( BlogId, ExtensionType, ExtensionId, Settings ) " +
" SELECT {1}newblogid, ExtensionType, ExtensionId, Settings " +
" FROM {0}DataStoreSettings " +
" WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
{
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
cmd.ExecuteNonQuery();
}
// be_Pages
using (var cmd = conn.CreateTextCommand(string.Format(
" INSERT INTO {0}Pages ( BlogID, PageID, Title, Description, PageContent, Keywords, DateCreated, DateModified, IsPublished, IsFrontPage, Parent, ShowInList, Slug, IsDeleted ) " +
" SELECT {1}newblogid, PageID, Title, Description, PageContent, Keywords, DateCreated, DateModified, IsPublished, IsFrontPage, Parent, ShowInList, Slug, IsDeleted " +
" FROM {0}Pages " +
" WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
{
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
cmd.ExecuteNonQuery();
}
// be_PingService
using (var cmd = conn.CreateTextCommand(string.Format(
" INSERT INTO {0}PingService ( BlogID, Link ) " +
" SELECT {1}newblogid, Link " +
" FROM {0}PingService " +
" WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
{
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
cmd.ExecuteNonQuery();
}
// be_Profiles
using (var cmd = conn.CreateTextCommand(string.Format(
" INSERT INTO {0}Profiles ( BlogID, UserName, SettingName, SettingValue ) " +
//.........这里部分代码省略.........