public ClaimMigratorOperations()
        {
            // Initialize Container
//            log4net.Config.XmlConfigurator.Configure(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", "log4net.config")));

            //try
            //{
            //    var section = (UnityConfigurationSection)ConfigurationManager.GetSection("xiap/core/unity");
            //    section.Configure(GlobalClaimWakeUp.Container);
            //    section = (UnityConfigurationSection)ConfigurationManager.GetSection("xiap/custom/unity");
            //    section.Configure(GlobalClaimWakeUp.Container);
            //    GlobalClaimWakeUp.Container.RegisterType<TransferToGenius>();
            //}
            //catch (Exception ex)
            //{
            //    Logger.ErrorFormat("Problem initialising the Unity container! \n[\n\tMessage={0}\n\tStack={1}\n]", ex.Message, ex.StackTrace);
            //    return;
            //}
            XmlConfigurator.Configure();
            Logger.Info("== Starting up ClaimProcessor ==");

            try
            {
                //var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
                // Instantiate the object using constructor injection
                _config = GlobalClaimWakeUp.Container.Resolve<ClaimProcessorConfiguration>();
                _migrator = GlobalClaimWakeUp.Container.Resolve<TransferToGenius>();
                _migrator.SetConcurency(1);
                GlobalClaimWakeUp.Container.RegisterInstance<IGeniusXGateway>(new GeniusXGateway(_config.GeniusXConnectionString));
                // Change to allow for two different Staging DBs.
                GlobalClaimWakeUp.Container.RegisterType<Func<string, IStagingGateway>>(new InjectionFactory(c => new Func<string, IStagingGateway>((cr) =>
                {
                    if (cr.EndsWith("MO"))
                    {
                        return new StagingGateway(_config.StagingMotorConnectionString);
                    }
                    else
                    {
                        return new StagingGateway(_config.StagingLiabConnectionString);
                    }
                })));
                GlobalClaimWakeUp.Container.RegisterInstance<IGeniusGateway>(new GeniusGateway(_config.GeniusConnectionString));

            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("Bogus! \n[\n\tMessage={0}\n\tStack={1}\n]", ex.Message, ex.StackTrace);
                throw;
            }

            Logger.Info("== Finished initialising ClaimProcessor ==");
        }
        public void InitializeDataflow()
        {
            _config = GlobalClaimWakeUp.Container.Resolve<ClaimProcessorConfiguration>();
            Logger.Info("======================Initializing Dataflow=================================");
            
            GlobalClaimWakeUp.PostedClaims.Clear();
            if (_config.ReopeningClaims)
            {
                GlobalClaimWakeUp.GeniusXPolicyState.Clear();
                GlobalClaimWakeUp.NameReferences.Clear();
                GlobalClaimWakeUp.PostedClaims.Clear();
            }
            

            _attachClaimToPolicy = new TransformBlock<Claim, Claim>(
                c => AttachClaimToPolicyBlock.Execute(c),
                    new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 });


            _executeExcessAndDeductibles = new TransformBlock<Claim, Claim>(
                    c => ExcessAndDeductiblesBlock.Execute(c),
                    new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 });

            _createTransferNameRequests = new TransformBlock<Claim, Claim>(
                    c => CreateNameTransferRequestsBlock.Execute(c),
                    new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 });

            // We don't need to create a review task for the service
            //_createClaimReviewTask = new TransformBlock<Claim, Claim>(
            //        c => CreateReviewTaskBlock.Execute(c),
            //        new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 });

            _createTransferClaimRequest = new TransformBlock<Claim, Claim>(
                    c => CreateClaimTransferRequestsBlock.Execute(c),
                    new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 });

            _clearLocks = new TransformBlock<Claim, Claim>(
                c => ClearLocksBlock.Execute(c),
                    new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 });

            _validateClaim = new TransformBlock<Claim, Claim>(
                    c => ValidateClaimBlock.Execute(c),
                    new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 });

            _setCustomCode18 = new TransformBlock<Claim, Claim>(
                    c =>
                        {
                            SetCustomCode18Block.Execute(c);
                            UpdateMigrationStatus(c);
                            return c;
                        },
                    new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 2 });

            _logClaimState = new ActionBlock<Claim>(
                c =>
                    {
                        Logger.InfoFormat("Claim status is\r\n{0}", JObject.FromObject(c));
                    });
            
            //_attachClaimToPolicy.LinkTo(_createClaimReviewTask, new DataflowLinkOptions { PropagateCompletion = true });
            //_createClaimReviewTask.LinkTo(_executeExcessAndDeductibles, new DataflowLinkOptions { PropagateCompletion = true });
            // Created next line to avoid the review task creation.
            _attachClaimToPolicy.LinkTo(_executeExcessAndDeductibles, new DataflowLinkOptions { PropagateCompletion = true });
            _executeExcessAndDeductibles.LinkTo(_createTransferClaimRequest, new DataflowLinkOptions { PropagateCompletion = true });
            _createTransferClaimRequest.LinkTo(_createTransferNameRequests, new DataflowLinkOptions { PropagateCompletion = true });
            _createTransferNameRequests.LinkTo(_validateClaim, new DataflowLinkOptions { PropagateCompletion = true });
            _validateClaim.LinkTo(_clearLocks, new DataflowLinkOptions { PropagateCompletion = true });
            _clearLocks.LinkTo(_setCustomCode18, new DataflowLinkOptions { PropagateCompletion = true });
            _setCustomCode18.LinkTo(_logClaimState, new DataflowLinkOptions {PropagateCompletion = true});
        }