Ejemplo n.º 1
0
        /// <summary>
        ///     Exports the tenant.
        /// </summary>
        /// <remarks>
        /// This is the entry point for export requests that come via PlatformConfigure. c.f. EntityXmlExporter.GenerateXml.
        /// </remarks>
        /// <param name="tenantName">Name of the tenant.</param>
        /// <param name="entityId">Root entity to export.</param>
        /// <param name="packagePath">The package path.</param>
        /// <param name="exportSettings">Export settings.</param>
        /// <param name="context">The context.</param>
        public static void ExportEntity(string tenantName, long entityId, string packagePath, IProcessingContext context = null)
        {
            if (string.IsNullOrEmpty(tenantName))
            {
                throw new ArgumentNullException(nameof(tenantName));
            }
            if (string.IsNullOrEmpty(packagePath))
            {
                throw new ArgumentNullException(nameof(packagePath));
            }

            if (context == null)
            {
                context = new ProcessingContext( );
            }

            context.Report.StartTime = DateTime.Now;

            long tenantId = TenantHelper.GetTenantId(tenantName, true);

            /////
            // Create source to load app data from tenant
            /////
            using (IDataTarget target = FileManager.CreateDataTarget(Format.XmlVer2, packagePath))
            {
                var exporter = ( EntityXmlExporter )Factory.EntityXmlExporter;
                exporter.ExportEntity(tenantId, new[] { entityId }, target, context, false);
            }

            context.Report.EndTime = DateTime.Now;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Interface for providing XML export.
        /// </summary>
        /// <remarks>
        /// This is the entry point for export requests that come via the console. c.f. EntityManager.ExportEntity.
        /// </remarks>
        /// <param name="entityIds">ID of entity to export.</param>
        /// <param name="xmlWriter">Xml Writer to write the exported entity to.</param>
        /// <param name="settings">Export settings.</param>
        public void GenerateXml(IEnumerable <long> entityIds, XmlWriter xmlWriter, EntityXmlExportSettings settings)
        {
            if (xmlWriter == null)
            {
                throw new ArgumentNullException(nameof(xmlWriter));
            }
            if (settings == null)
            {
                settings = EntityXmlExportSettings.Default;
            }

            var context = new ProcessingContext( );

            context.Report.StartTime = DateTime.Now;

            long tenantId = RequestContext.TenantId;

            /////
            // Create source to load app data from tenant
            /////
            using (IDataTarget target = CreateDataTarget(xmlWriter, settings))
            {
                ExportEntity(tenantId, entityIds, target, context, true);
            }

            context.Report.EndTime = DateTime.Now;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a source with initial stream to attach...
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="inStream"></param>
        /// <returns></returns>
        public T CreateSource <T>(IDataStream inStream)
        {
            // if it has a source, then use this, otherwise it's null and that works too. Reason: some sources like DataTable or SQL won't have an upstream source
            T src = CreateSource <T>(inStream.Source);

            IDataTarget srcDs = (IDataTarget)src;

            srcDs.In.Clear();
            srcDs.In.Add(DataSource.DefaultStreamName, inStream);
            return(src);
        }
Ejemplo n.º 4
0
        public StreamInfo(IDataStream strm, IDataTarget target, string inName)
        {
            try
            {
                Target = (target as IDataSource).DataSourceGuid;
                Source = strm.Source.DataSourceGuid;
                TargetIn = inName;
                foreach (var outStm in strm.Source.Out)
                    if (outStm.Value == strm)
                        SourceOut = outStm.Key;

                Count = strm.LightList.Count();
            }
            catch
            {
                Error = true;
            }
        }
Ejemplo n.º 5
0
        private static IService CreateService(string domain,
                                              string imageStore,
                                              ILogger logger,
                                              ICacheManager cacheManager,
                                              IFileSystemAbstraction fileSystem)
        {
            var dataProvider = new DataProvider(logger, domain, cacheManager, new NetworkAbstraction(logger));

            var translationProvider = new TranslationProvider(dataProvider, logger);
            var parser = new Parser(logger, dataProvider, fileSystem, imageStore);

            var targets = new IDataTarget[]
            {
                new TemplateManagerTarget(logger),
                new TextFileTarget(logger, "skills.txt")
            };

            return(new Service(logger, parser, targets, translationProvider, 1, 3500));
        }
Ejemplo n.º 6
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( );
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataOperation"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        public DataOperation(IDataSource source, IDataTarget target)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.source        = source;
            this.source.Parent = this;

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            this.target        = target;
            this.target.Parent = this;

            this.timer = new Stopwatch();
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="DumpInformationRepository" /> class.
 /// </summary>
 /// <param name="dataTarget">The data target.</param>
 /// <param name="runtime">The runtime.</param>
 /// <param name="dumpFile">The dump file.</param>
 /// <exception cref="ArgumentNullException">dataTarget</exception>
 /// <exception cref="System.ArgumentNullException">dataTarget</exception>
 public DumpInformationRepository(IDataTarget dataTarget, IClrRuntime runtime, FileInfo dumpFile)
 {
     CpuUtilization = runtime.ThreadPool.CpuUtilization;
     DumpFile       = dumpFile;
     HeapCount      = runtime.HeapCount;
     IsMiniDump     = dataTarget?.IsMinidump ?? throw new ArgumentNullException(nameof(dataTarget));
     IsServerGc     = runtime.IsServerGc;
     MaxNumberFreeIoCompletionPorts = runtime.ThreadPool.MaxFreeCompletionPorts;
     MaxNumberIoCompletionPorts     = runtime.ThreadPool.MaxCompletionPorts;
     MaxThreads = runtime.ThreadPool.MaxThreads;
     MinNumberIoCompletionPorts = runtime.ThreadPool.MinCompletionPorts;
     MinThreads = runtime.ThreadPool.MinThreads;
     NumberFreeIoCompletionPorts = runtime.ThreadPool.FreeCompletionPortCount;
     NumberIdleThreads           = runtime.ThreadPool.IdleThreads;
     NumRunningThreads           = runtime.ThreadPool.RunningThreads;
     ModuleInfosInternal         = dataTarget?.EnumerateModules().ToList();
     SymbolCache   = dataTarget.SymbolLocator.SymbolCache;
     SymbolPath    = dataTarget.SymbolLocator.SymbolPath;
     TotalHeapSize = runtime.Heap.TotalHeapSize;
     TotalThreads  = runtime.ThreadPool.TotalThreads;
     StartTimeUtc  = DateTime.UtcNow;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates the data operation.
        /// </summary>
        /// <param name="connections">The connections.</param>
        /// <param name="operationElement">The operation element.</param>
        /// <returns>A DataOperation instance.</returns>
        private DataOperation CreateDataOperation(IEnumerable <DataConnection> connections, XElement operationElement)
        {
            var sourceElement = operationElement.Element("Source");

            if (sourceElement == null)
            {
                throw new DataScriptException("Source element missing");
            }

            var source = CreateSource(sourceElement, connections);

            var targetElement = operationElement.Element("Target");

            if (targetElement == null)
            {
                throw new DataScriptException("Target element missing");
            }

            IDataTarget target = this.CreateTarget(targetElement, connections);

            return(new DataOperation(source, target));
        }
Ejemplo n.º 10
0
 public SyncTask(
     string syncTaskId,
     IDataSource <TEntityA> dataSource,
     IDataTarget <TEntityA, TEntityB> dataTarget,
     ISyncStateStorage syncStateStorage,
     ISyncKeyMapStorage syncKeyMapStorage,
     Action <string, string, TEntityA, TEntityB, StateChange <TEntityA, TEntityB> > executeNestedTasks = null,
     string parentContextKey = null,
     bool failOnError        = false,
     Action <TEntityA, TEntityB, Exception> failedCallback = null,
     Action <TEntityA, TEntityB> successCallback           = null
     )
 {
     SyncTaskId         = syncTaskId;
     DataSource         = dataSource;
     DataTarget         = dataTarget;
     SyncStateStorage   = syncStateStorage;
     SyncKeyMapStorage  = syncKeyMapStorage;
     ExecuteNestedTasks = executeNestedTasks;
     ParentContextKey   = parentContextKey;
     FailOnError        = failOnError;
     _failedCallback    = failedCallback;
     _successCallback   = successCallback;
 }
        public void SavePodcastAsXml(IPodcast podcast)
        {
            IDataTarget fileTarget = Factory.CreateFileTarget();

            fileTarget.SavePodcast(podcast);
        }
Ejemplo n.º 12
0
 public UsersController(IDataSource dataSource, IDataTarget dataTarget)
 {
     _dataSource = dataSource;
     _dataTarget = dataTarget;
 }
Ejemplo n.º 13
0
		/// <summary>
		/// List with static properties and Test-Values
		/// </summary>

		/// <summary>
		/// The class constructor
		/// </summary>
		public DataTargetValueProvider(IDataTarget dataTarget)
		{
		    _dataTarget = dataTarget;
			Name = "In";
		}
Ejemplo n.º 14
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 /// <param name="context">The context.</param>
 public CopyProcessor(IDataSource source, IDataTarget target, IProcessingContext context)
 {
     DataSource = source;
     DataTarget = target;
     Context    = context;
 }
Ejemplo n.º 15
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="CopyProcessor" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 public CopyProcessor(IDataSource source, IDataTarget target)
     : this(source, target, null)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataTarget"/> class.
 /// </summary>
 /// <param name="target">
 /// The target.
 /// </param>
 public DataTarget(IDataTarget target)
 {
     this.target = target;
 }