Ejemplo n.º 1
0
        /// <summary>
        /// Executes a pipeline component to process the input message and returns the result message.
        /// </summary>
        /// <param name="pContext">A reference to <see cref="Microsoft.BizTalk.Component.Interop.IPipelineContext"/> object that contains the current pipeline context.</param>
        /// <param name="pInMsg">A reference to <see cref="Microsoft.BizTalk.Message.Interop.IBaseMessage"/> object that contains the message to process.</param>
        /// <returns>A reference to the returned <see cref="Microsoft.BizTalk.Message.Interop.IBaseMessage"/> object which will contain the output message.</returns>
        public override IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            if (pContext != null && pInMsg != null)
            {
                PolicyExecutionInfo policyExecInfo = !String.IsNullOrEmpty(PolicyVersion) ? new PolicyExecutionInfo(PolicyName, System.Version.Parse(PolicyVersion)) : new PolicyExecutionInfo(PolicyName);

                string ctxPropName, ctxPropNamespace;

                for (int i = 0; i < pInMsg.Context.CountProperties; i++)
                {
                    ctxPropName      = null;
                    ctxPropNamespace = null;

                    object ctxPropValue = pInMsg.Context.ReadAt(i, out ctxPropName, out ctxPropNamespace);
                    policyExecInfo.AddParameter(String.Format("{0}{1}{2}", ctxPropNamespace, BizTalkUtility.ContextPropertyNameSeparator, ctxPropName), ctxPropValue);
#if DEBUG
                    TraceManager.PipelineComponent.TraceDetails("DETAIL: Context property added: {0}{1}{2} = {3}", ctxPropNamespace, BizTalkUtility.ContextPropertyNameSeparator, ctxPropName, ctxPropValue);
#endif
                }

                using (RuntimeTaskExecutionContext taskExecContext = new RuntimeTaskExecutionContext(pContext, pInMsg))
                {
                    IList <IMessagingRuntimeExtenderTask> registeredTasks = RuntimeTaskFactory.GetRegisteredTasks(taskExecContext);

                    try
                    {
                        PolicyExecutionResult policyExecResult = PolicyHelper.Execute(policyExecInfo, registeredTasks);

                        if (policyExecResult.Success)
                        {
                            foreach (IMessagingRuntimeExtenderTask task in taskExecContext.Extensions.FindAll <IMessagingRuntimeExtenderTask>())
                            {
                                if (task.CanRun)
                                {
                                    task.Run(taskExecContext);
                                }
                            }

                            return(taskExecContext.Message);
                        }
                    }
                    finally
                    {
                        policyExecInfo.ClearParameters();

                        registeredTasks.Clear();
                        registeredTasks = null;
                    }
                }
            }
            return(pInMsg);
        }
Ejemplo n.º 2
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.º 3
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.º 4
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.º 5
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.º 6
0
        public void ValidateHandleGetConfigurationSectionRequestPolicy()
        {
            PolicyExecutionInfo policyExecInfo = new PolicyExecutionInfo("Contoso.Cloud.Integration.GenericCloudRequestHandling");

            policyExecInfo.AddParameter("http://schemas.microsoft.com/BizTalk/2003/soap-properties#MethodName", "Contoso.Cloud.Integration.ServiceContracts/IOnPremiseConfigurationService/GetConfigurationSection");

            IList <IMessagingRuntimeExtenderTask> registeredTasks = RuntimeTaskFactory.GetRegisteredTasks();
            PolicyExecutionResult policyExecResult = PolicyHelper.Execute(policyExecInfo, registeredTasks);

            IEnumerable <ExternalComponentInvokeTask> execTasks = registeredTasks.OfType <ExternalComponentInvokeTask>();

            Assert.IsTrue(policyExecResult.Success, "Policy execution was not successful");
            Assert.IsFalse(execTasks.Count() == 0, "No ExternalComponentInvokeTask was found in task collection");

            ExternalComponentInvokeTask execTask = execTasks.ElementAt <ExternalComponentInvokeTask>(0);

            Assert.IsNotNull(execTask, "execTask instance has not been found");
            Assert.IsFalse(String.IsNullOrEmpty(execTask.AssemblyName), "AssemblyName is null or empty");
            Assert.IsFalse(String.IsNullOrEmpty(execTask.TypeName), "TypeName is null or empty");
        }
Ejemplo n.º 7
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.º 8
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.º 9
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);
        }