コード例 #1
0
        private static void ImportObject(string packagePath, string userName)
        {
            string objectType = "";
            int    objectID   = 0;

            SiteImportSettings settings = new SiteImportSettings(UserInfoProvider.GetUserInfo(userName));

            settings.UseAutomaticSiteForTranslation = true;
            settings.LogSynchronization             = true;
            settings.WebsitePath    = SystemContext.WebApplicationPhysicalPath;
            settings.SourceFilePath = packagePath;

            var obj = ObjectSelections(objectType);

            var importObj = SingleObjectSelection(objectID, obj);

            if (importObj.ObjectSiteID > 0)
            {
                settings.SiteId            = importObj.ObjectSiteID;
                settings.ExistingSite      = true;
                settings.SiteIsContentOnly = settings.SiteInfo.SiteIsContentOnly;

                // Do not update site definition when restoring a single object
                settings.SetSettings(ImportExportHelper.SETTINGS_UPDATE_SITE_DEFINITION, false);
            }

            ImportProvider.CreateTemporaryFiles(settings);

            settings.LoadDefaultSelection();

            ImportProvider.ImportObjectsData(settings);
        }
コード例 #2
0
    /// <summary>
    /// Imports user object. Called when the "Import object" button is pressed.
    /// </summary>
    private bool ImportObject()
    {
        // Create site import settings
        SiteImportSettings settings = new SiteImportSettings(MembershipContext.AuthenticatedUser);

        // Initialize the settings
        settings.WebsitePath    = Server.MapPath("~/");
        settings.SourceFilePath = settings.WebsitePath + "CMSAPIExamples\\Code\\Tools\\ImportExport\\Packages\\APIExample_User.zip";
        settings.ImportType     = ImportTypeEnum.AllNonConflicting;
        settings.LoadDefaultSelection();

        // Import
        ImportProvider.ImportObjectsData(settings);

        // Delete temporary data
        ImportProvider.DeleteTemporaryFiles(settings, false);

        return(true);
    }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: v-jli/jean0407large
    /// <summary>
    /// Imports user object. Called when the "Import object" button is pressed.
    /// </summary>
    private bool ImportObject()
    {
        // Create site import settings
        SiteImportSettings settings = new SiteImportSettings(CMSContext.CurrentUser);

        // Initialize the settings
        settings.WebsitePath = Server.MapPath("~/");
        settings.SourceFilePath = settings.WebsitePath + "\\CMSAPIExamples\\Code\\Tools\\ImportExport\\Packages\\APIExample_User.zip";
        settings.ImportType = ImportTypeEnum.All;
        settings.LoadDefaultSelection();

        // Import
        ImportProvider.ImportObjectsData(settings);

        // Delete temporary data
        ImportProvider.DeleteTemporaryFiles(settings, false);

        return true;
    }