Ejemplo n.º 1
0
        private ExecutableRuntimeTask GetRuntimeTask()
        {
            var factory = new RuntimeTaskFactory(Activator.RepositoryLocator.CatalogueRepository);

            var lmd            = _processTask.LoadMetadata;
            var argsDictionary = new LoadArgsDictionary(lmd, new HICDatabaseConfiguration(lmd).DeployInfo);

            //populate the UI with the args
            _runtimeTask      = (ExecutableRuntimeTask)factory.Create(_processTask, argsDictionary.LoadArgs[_processTask.LoadStage]);
            tbExeCommand.Text = _runtimeTask.ExeFilepath + " " + _runtimeTask.CreateArgString();

            return(_runtimeTask);
        }
Ejemplo n.º 2
0
        public CompositeDataLoadComponent CreateCompositeDataLoadComponentFor(LoadStage loadStage, string descriptionForComponent)
        {
            RuntimeTaskFactory factory = new RuntimeTaskFactory(_repository);

            var tasks = new List <IDataLoadComponent>();

            foreach (var task in GetRuntimeTasksForStage(loadStage))
            {
                tasks.Add(factory.Create(task.ProcessTask, _loadArgsDictionary[loadStage]));
            }

            return(new CompositeDataLoadComponent(tasks)
            {
                Description = descriptionForComponent
            });
        }
Ejemplo n.º 3
0
        private void CheckComponent()
        {
            try
            {
                var factory = new RuntimeTaskFactory(Activator.RepositoryLocator.CatalogueRepository);

                var lmd            = _processTask.LoadMetadata;
                var argsDictionary = new LoadArgsDictionary(lmd, new HICDatabaseConfiguration(lmd).DeployInfo);
                var mefTask        = (IMEFRuntimeTask)factory.Create(_processTask, argsDictionary.LoadArgs[_processTask.LoadStage]);

                _ragSmiley.StartChecking(mefTask.MEFPluginClassInstance);
            }
            catch (Exception e)
            {
                _ragSmiley.Fatal(e);
            }
        }
Ejemplo n.º 4
0
        public void GatherAndShare_LoadMetadata_WithReferenceProcessTaskArgument()
        {
            //create an object
            LoadMetadata lmd1 = WhenIHaveA <LoadMetadata>();

            //setup Reflection / MEF
            SetupMEF();
            RuntimeTaskFactory f = new RuntimeTaskFactory(Repository);
            var stg = Mock.Of <IStageArgs>(x =>
                                           x.LoadStage == LoadStage.Mounting &&
                                           x.DbInfo == new DiscoveredServer(new SqlConnectionStringBuilder()).ExpectDatabase("d"));

            //create a single process task for the load
            var pt1 = new ProcessTask(Repository, lmd1, LoadStage.Mounting);

            pt1.ProcessTaskType = ProcessTaskType.MutilateDataTable;
            pt1.LoadStage       = LoadStage.AdjustRaw;
            pt1.Path            = typeof(SafePrimaryKeyCollisionResolverMutilation).FullName;
            pt1.SaveToDatabase();

            //give it a reference to an (unshared) object (ColumnInfo)
            pt1.CreateArgumentsForClassIfNotExists(typeof(SafePrimaryKeyCollisionResolverMutilation));
            var pta = pt1.ProcessTaskArguments.Single(pt => pt.Name == "ColumnToResolveOn");

            pta.SetValue(WhenIHaveA <ColumnInfo>());
            pta.SaveToDatabase();

            //check that reflection can assemble the master ProcessTask
            MutilateDataTablesRuntimeTask t = (MutilateDataTablesRuntimeTask)f.Create(pt1, stg);

            Assert.IsNotNull(((SafePrimaryKeyCollisionResolverMutilation)t.MEFPluginClassInstance).ColumnToResolveOn);

            //share to the second repository (which won't have that ColumnInfo)
            var lmd2 = ShareToNewRepository(lmd1);

            //create a new reflection factory for the new repo
            RuntimeTaskFactory f2 = new RuntimeTaskFactory(lmd2.CatalogueRepository);

            lmd2.CatalogueRepository.MEF = MEF;

            //when we create the shared instance it should not have a valid value for ColumnInfo (since it wasn't - and shouldn't be shared)
            MutilateDataTablesRuntimeTask t2 = (MutilateDataTablesRuntimeTask)f2.Create(lmd2.ProcessTasks.Single(), stg);

            Assert.IsNull(((SafePrimaryKeyCollisionResolverMutilation)t2.MEFPluginClassInstance).ColumnToResolveOn);
        }
Ejemplo n.º 5
0
        public void GatherAndShare_LoadMetadata_WithRealProcessTask()
        {
            //create an object
            LoadMetadata lmd1 = WhenIHaveA <LoadMetadata>();

            SetupMEF();

            var pt1 = new ProcessTask(Repository, lmd1, LoadStage.Mounting);

            pt1.ProcessTaskType = ProcessTaskType.Attacher;
            pt1.LoadStage       = LoadStage.Mounting;
            pt1.Path            = typeof(AnySeparatorFileAttacher).FullName;
            pt1.SaveToDatabase();

            pt1.CreateArgumentsForClassIfNotExists(typeof(AnySeparatorFileAttacher));
            var pta = pt1.ProcessTaskArguments.Single(pt => pt.Name == "Separator");

            pta.SetValue(",");
            pta.SaveToDatabase();


            var lmd2 = ShareToNewRepository(lmd1);

            //different repos so not identical
            Assert.IsFalse(ReferenceEquals(lmd1, lmd2));
            AssertAreEqual(lmd1, lmd2);

            var pt2 = lmd2.ProcessTasks.Single();

            Assert.IsFalse(ReferenceEquals(pt1, pt2));
            AssertAreEqual(pt1, pt2);

            AssertAreEqual(pt1.GetAllArguments(), pt2.GetAllArguments());

            RuntimeTaskFactory f = new RuntimeTaskFactory(Repository);

            var stg = Mock.Of <IStageArgs>(x => x.LoadStage == LoadStage.Mounting);

            f.Create(pt1, stg);
        }
Ejemplo n.º 6
0
        public void RuntimeTaskFactoryTest(string className)
        {
            var lmd  = new LoadMetadata(CatalogueRepository);
            var task = new ProcessTask(CatalogueRepository, lmd, LoadStage.GetFiles);

            var f = new RuntimeTaskFactory(CatalogueRepository);

            task.Path            = className;
            task.ProcessTaskType = ProcessTaskType.DataProvider;
            task.SaveToDatabase();

            try
            {
                var ex = Assert.Throws <Exception>(() => f.Create(task, new StageArgs(LoadStage.AdjustRaw, GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer), Mock.Of <ILoadDirectory>())));
                Assert.IsTrue(ex.InnerException.Message.Contains("marked with DemandsInitialization but no corresponding argument was provided in ArgumentCollection"));
            }
            finally
            {
                task.DeleteInDatabase();
                lmd.DeleteInDatabase();
            }
        }
Ejemplo n.º 7
0
        public void Check(ProcessTask processTask, ICheckNotifier notifier)
        {
            if (dictionary == null)
            {
                try
                {
                    dictionary = new LoadArgsDictionary(_loadMetadata, new HICDatabaseConfiguration(_loadMetadata).DeployInfo);
                }
                catch (Exception e)
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs("Could not assemble LoadArgsDictionary, see inner exception for specifics",
                                           CheckResult.Fail, e));
                    return;
                }
            }


            var factory = new RuntimeTaskFactory(_loadMetadata.CatalogueRepository);
            var created = factory.Create(processTask, dictionary.LoadArgs[processTask.LoadStage]);

            created.Check(notifier);
        }