Esempio n. 1
0
        /// <summary>
        /// Implementation of exporting an entity.
        /// </summary>
        /// <remarks>
        /// This has been split to try and capture the common code shared by a PlatformConfigure export and a console export.
        /// </remarks>
        /// <param name="tenantId">The tenant</param>
        /// <param name="entityIds">The entity</param>
        /// <param name="target">The target</param>
        /// <param name="context">Processing context.</param>
        /// <param name="demandReadPermission">If true, perform a read demand as the current user.</param>
        internal void ExportEntity(long tenantId, IEnumerable <long> entityIds, IDataTarget target, IProcessingContext context, bool demandReadPermission)
        {
            using (IDataSource source = new TenantGraphSource {
                TenantId = tenantId,
                RootEntities = entityIds.ToList( ),
                DemandReadPermission = demandReadPermission
            })
            {
                if (demandReadPermission)
                {
                    CheckExportSecurity(source, context);
                }

                /////
                // Copy the data
                /////
                var processor = new CopyProcessor(source, target, context);
                processor.MigrateData( );
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Create a baseline source for importing data into a tenant.
        /// </summary>
        /// <remarks>
        ///     Check the tenant to see if the root entity is present.
        ///     If it is, then perform an export to use the existing contents as a baseline, so it gets updated.
        ///     If it's not, then use an empty source so that everything gets added.
        /// </remarks>
        /// <param name="tenantId">Target tenant.</param>
        /// <param name="rootGuids">UpgradeID of entity to be targeted, if present.</param>
        /// <returns></returns>
        private IDataSource GetBaselineSourceForImport(long tenantId, IEnumerable <Guid> rootGuids)
        {
            IDataSource baseline;

            using (new TenantAdministratorContext(tenantId))
            {
                IDictionary <Guid, long> ids = UpgradeIdProvider.GetIdsFromUpgradeIds(rootGuids);

                if (ids.Count == 0)
                {
                    baseline = new EmptySource( );
                }
                else
                {
                    baseline = new TenantGraphSource
                    {
                        TenantId     = tenantId,
                        RootEntities = ids.Values.ToList( )
                    };
                }
            }
            return(baseline);
        }