Ejemplo n.º 1
0
        public void Distribute(int publicationItemID)
        {
            BLL.DistributionHub.IDistributionHub distributionHub = InProcFactory.CreateInstance <BLL.DistributionHub.DistributionHub, BLL.DistributionHub.IDistributionHub>();

            try
            {
                Entities.PublicationEntities.PublicationItem publicationItem = distributionHub.PopulatePublicationItem(publicationItemID);

                HelperClasses.Output.ThrowIfFailed(publicationItem != null, string.Format("Could not load item {0}", publicationItemID.ToString()));

                bool isItemPublishable = distributionHub.IsItemPublishable(publicationItem);

                if (isItemPublishable)
                {
                    publicationItem.Status = 1;
                    HelperClasses.Output.ThrowIfFailed(distributionHub.SaveItem(publicationItem), string.Format("Could not set queued status for item {0} published status.", publicationItemID.ToString()));

                    HelperClasses.Output.ThrowIfFailed(PublishIt(publicationItemID), string.Format("Could not stream to destination: {0}", publicationItemID.ToString()));

                    publicationItem.Status = 2;
                    HelperClasses.Output.ThrowIfFailed(distributionHub.SaveItem(publicationItem), string.Format("Could not set item {0} published status.", publicationItemID.ToString()));
                }
            }
            catch (Exception ex)
            {
                HelperClasses.Output.ThrowIfFailed(false, ex.Message);
            }
            finally
            {
                InProcFactory.CloseProxy(distributionHub);
            }

            //Life is good, so let the transaction commit and be published.
        }
Ejemplo n.º 2
0
 public void Cleanup()
 {
     FabricRuntime.Actors.Clear();
     FabricRuntime.Services.Clear();
     //TEST ONLY...
     InProcFactory.CloseHosts();
 }
Ejemplo n.º 3
0
        // Note how the DataFeedManager service composes other services. The Engine and DataAccessor
        // services are hosted and run "in process" to this DataFeedManager service via
        // the ServiceModelEx InProcFactory. Please see "Programming WCF Services", 3rd Edition
        // by Juval Lowy, pp 71-74 for more information.

        void IDataFeeds.IngestTestData(TestMessage msg)
        {
            DateTime msgReceivedTime = DateTime.Now;

            Debug.Assert(msg != null);

            //string displayMsg = string.Format("{0}.IngestTestData(): Entered:", m_ThisName);
            //ConsoleNTraceHelpers.DisplayInfoToConsoleNTrace(displayMsg);

            // Check validity.
            InProcessFeedMsg    checkedMsg       = null;
            IFeedValidityEngine validityEngProxy = InProcFactory.CreateInstance <ValidityEngine, IFeedValidityEngine>();

            checkedMsg = validityEngProxy.IsTestMessageValid(msg, msgReceivedTime);
            InProcFactory.CloseProxy(validityEngProxy);

            Debug.Assert(checkedMsg != null);
            if (checkedMsg.IsValid)
            {
                // Used only with a test client.
                DisplayMsgAndQueueLength(msg, checkedMsg);

                // Save data.
                IIngestedDataDA ingestDataDaProxy = InProcFactory.CreateInstance <IngestedDataDA, IIngestedDataDA>();
                ingestDataDaProxy.SaveTestData(checkedMsg);
                InProcFactory.CloseProxy(ingestDataDaProxy);
            }
            else
            {
                Debug.Assert(checkedMsg.IsValid);
                LogInvalidMessageError(checkedMsg);
            }
        }
        IngestedDataAnalysisResult ISomeServiceContract.AnalyzeIngestedData()
        {
            // Get the ingested data from the DB.
            ISomeDataAnalysisEngine dataAnalysisEngineProxy =
                InProcFactory.CreateInstance <SomeDataAnalysisEngine, ISomeDataAnalysisEngine>();
            IngestedDataAnalysisResult analysisResult = dataAnalysisEngineProxy.DoIngestedDataAnalysis();

            return(analysisResult);
        }
Ejemplo n.º 5
0
        public ApplicationTenantsResult GetApplicationTenants(ApplicationTenantsQuery query)
        {
            var repositoryService = InProcFactory.CreateInstance <ApplicationRepositoryService, IApplicationRepository>();

            try
            {
                return(repositoryService.GetApplicationTenants(query));
            }
            finally
            {
                InProcFactory.CloseProxy(repositoryService);
            }
        }
Ejemplo n.º 6
0
        protected void Setup(FeatureConfigurationContext context)
        {
            var scope = context.Settings.GetOrDefault <ILifetimeScope>("ExistingLifetimeScope");

            if (scope == null)
            {
                return;
            }
            InProcFactory.Scope = scope;
            InProcFactory.SetGenericResolver(scope.ComponentRegistry.Registrations.Select(r => r.Activator.LimitType).ToArray());
            InProcFactory.SetDefaultServiceBehaviour(new AuditInterceptorServiceBehavior(), new ErrorHandlerServiceBehaviour());
            Start();
        }
Ejemplo n.º 7
0
        private void UseRepository(Action <IApplicationRepository> action)
        {
            var repositoryService = InProcFactory.CreateInstance <ApplicationRepositoryService, IApplicationRepository>();

            try
            {
                action(repositoryService);
            }
            finally
            {
                InProcFactory.CloseProxy(repositoryService);
            }
        }
Ejemplo n.º 8
0
        public ApplicationInfo[] GetApplications()
        {
            var repositoryService = InProcFactory.CreateInstance <ApplicationRepositoryService, IApplicationRepository>();

            try
            {
                return(repositoryService.GetApplications());
            }
            finally
            {
                InProcFactory.CloseProxy(repositoryService);
            }
        }
Ejemplo n.º 9
0
        private static void DisplayMsgAndQueueLength(TestMessage msg, InProcessFeedMsg checkedMsg)
        {
            // For test client only.
            IFeedAdminDA feedAdminDaProxy = InProcFactory.CreateInstance <AdminDA, IFeedAdminDA>();
            long         queueLength      = feedAdminDaProxy.GetQueueLength(iFX.Common.ConstantsNEnums.IngestionQueueName);

            InProcFactory.CloseProxy(feedAdminDaProxy);
            checkedMsg.QueueLength = queueLength;
            string queueLengthMsg = string.Format("{0} count = {1}",
                                                  iFX.Common.ConstantsNEnums.IngestionQueueName,
                                                  queueLength);

            ConsoleNTraceHelpers.DisplayInfoToConsoleNTrace(queueLengthMsg);
            ConsoleNTraceHelpers.DisplayTestMessage(msg);
            ConsoleNTraceHelpers.TraceTestMessage(msg);
        }
Ejemplo n.º 10
0
        IngestedDataAnalysisResult ISomeDataAnalysisEngine.DoIngestedDataAnalysis()
        {
            // Get the ingested data from the DB.
            IIngestedDataDA ingestDataDaProxy    = InProcFactory.CreateInstance <IngestedDataDA, IIngestedDataDA>();
            string          dummyDataForAnalysis = ingestDataDaProxy.GetDummyDataForAnalysis();

            // Do the analysis.
            IngestedDataAnalysisResult result = new IngestedDataAnalysisResult();

            InProcFactory.CloseProxy(ingestDataDaProxy);
            result.ResultPart1 = dummyDataForAnalysis;
            int analysisResult = dummyDataForAnalysis.Length;

            result.ResultPart2 =
                string.Format("The analysis of the dummy data reveals it contains {0} characters", analysisResult);
            return(result);
        }
        DataFeedStatistics IFeedAdmin.PresentFeedComponentInfo(string componentName)
        {
            ConsoleNTraceHelpers.DisplayInfoToConsoleNTrace(m_ThisName + ".PresentFeedComponentInfo(): Entered:");

            // Check validity of all requests.
            IAdminValidityEngine validityEngProxy = InProcFactory.CreateInstance <ValidityEngine, IAdminValidityEngine>();

            validityEngProxy.IsPresentFeedComponentInfoRequestValid(componentName);
            InProcFactory.CloseProxy(validityEngProxy);

            // Retrieve Feed Component info
            DataFeedStatistics stats            = null;
            IFeedAdminDA       feedAdminDaProxy = InProcFactory.CreateInstance <AdminDA, IFeedAdminDA>();

            stats = feedAdminDaProxy.GetFeedStatistics(componentName);
            InProcFactory.CloseProxy(feedAdminDaProxy);

            return(stats);
        }
Ejemplo n.º 12
0
    protected WcfStreamWrapper()
    {
        NetNamedPipeBinding binding;

        try
        {
            binding = new NetNamedPipeContextBinding("InProcFactory");
        }
        catch
        {
            binding = new NetNamedPipeContextBinding();
        }

        binding.TransferMode           = TransferMode.Streamed;
        binding.MaxReceivedMessageSize = 524288;

        InProcFactory.SetBinding(binding);
        Proxy = InProcFactory.CreateInstance <S, I>(binding);
    }
Ejemplo n.º 13
0
        protected void UpdateTenant(string applicationName, string tenantName, Action <ApplicationTenantHeaderUpdateInfo> updateInfo)
        {
            if (string.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentNullException("applicationName");
            }
            if (string.IsNullOrEmpty(tenantName))
            {
                throw new ArgumentNullException("tenantName");
            }

            var repositoryService = InProcFactory.CreateInstance <ApplicationRepositoryService, IApplicationRepository>();

            try
            {
                var tenant = repositoryService.GetTenantHeaderInfo(applicationName, tenantName);
                if (tenant == null)
                {
                    throw new ArgumentException(string.Format("Tenant {0} from application {1} could not be found.", tenantName, applicationName));
                }

                var tenantUpdateInfo = new ApplicationTenantHeaderUpdateInfo()
                {
                    ApplicationName   = applicationName,
                    Name              = tenantName,
                    IsActive          = tenant.IsActive,
                    ContractStartTime = tenant.ContractStartedAt,
                    Url = tenant.Url
                };

                updateInfo(tenantUpdateInfo);

                repositoryService.UpdateTenantHeaderInfo(tenantUpdateInfo);
            }
            finally
            {
                InProcFactory.CloseProxy(repositoryService);
            }
        }
Ejemplo n.º 14
0
 void IDisposable.Dispose()
 {
     InProcFactory.CloseProxy(Proxy);
 }
Ejemplo n.º 15
0
        private static async Task DoEverything()
        {
            var           useWcf = true;
            IHumanService humanService;
            IDogService   dogService;

            if (useWcf)
            {
                humanService = InProcFactory.CreateInstance <HumanService, IHumanService>();
                dogService   = InProcFactory.CreateInstance <DogService, IDogService>();
            }
            else
            {
                humanService = new HumanService();
                dogService   = new DogService();
            }

            var humanRecord = new List <Human>();
            var dogRecord   = new List <Dog>();

            var numberOfIterations = 100;

            var humanAddTasks = Enumerable.Range(0, numberOfIterations)
                                .Select(async i =>
            {
                var newHuman = new Human
                {
                    DateOfBirth = DateTime.Today.AddYears(_random.Next(20, 50) * -1),
                    Forename    = _forenames[_random.Next(0, _forenames.Length)],
                    Surname     = _surnames[_random.Next(0, _surnames.Length)]
                };

                newHuman.Id = await humanService.AddHumanAsync(newHuman);
                humanRecord.Add(newHuman);
            });
            await Task.WhenAll(humanAddTasks);

            var dogAddTasks = Enumerable.Range(0, numberOfIterations)
                              .Select(async i =>
            {
                var newDog = new Dog
                {
                    Breed       = (DogBreed)_random.Next(1, 3),
                    DateOfBirth = DateTime.Today.AddYears(_random.Next(3, 12) * -1),
                    Name        = _dognames[_random.Next(0, _dognames.Length)]
                };

                newDog.Id = await dogService.AddDogAsync(newDog);
                dogRecord.Add(newDog);
            });
            await Task.WhenAll(dogAddTasks);

            var dogFriendTasks = Enumerable.Range(0, numberOfIterations)
                                 .Select(async i =>
            {
                var firstFriendId = _random.Next(0, numberOfIterations - 1);
                await dogService.MakeFriendAsync(dogRecord[i], dogRecord[firstFriendId]);

                var secondFriendId = _random.Next(0, numberOfIterations - 1);
                while (secondFriendId == firstFriendId)
                {
                    secondFriendId = _random.Next(0, numberOfIterations - 1);
                }

                await dogService.MakeFriendAsync(new Dog {
                    Id = i
                }, new Dog {
                    Id = secondFriendId
                });
            });
            await Task.WhenAll(dogFriendTasks);

            var adoptDogTasks = Enumerable.Range(0, numberOfIterations)
                                .Select(async i =>
            {
                await humanService.AdoptDogAsync(humanRecord[i], dogRecord[i]);
            });
            await Task.WhenAll(adoptDogTasks);

            using (var context = EntityFunDbContext.Create())
            {
                var dogCount = context.Dogs.Count();
                Console.WriteLine("There are {0} dogs in the system", dogCount);

                var humanCount = context.Humans.Count();
                Console.WriteLine("There are {0} humans in the system", humanCount);

                var dogFriends = context.Dogs.SelectMany(x => x.Friends).Count();
                Console.WriteLine("There are {0} dog friend combos", dogFriends);

                var dogsWithManyFriends = context.Dogs.Count(x => x.Friends.Count > 2);
                Console.WriteLine("{0} dogs have more than 2 friends", dogsWithManyFriends);

                Console.WriteLine("{0} dogs have 0 friends", context.Dogs.Count(x => x.Friends.Count == 0));
            }
        }
Ejemplo n.º 16
0
        private static void DoEverythingSync()
        {
            var           useWcf = true;
            IHumanService humanService;
            IDogService   dogService;

            if (useWcf)
            {
                humanService = InProcFactory.CreateInstance <HumanService, IHumanService>();
                dogService   = InProcFactory.CreateInstance <DogService, IDogService>();
            }
            else
            {
                humanService = new HumanService();
                dogService   = new DogService();
            }

            var humanRecord = new List <Human>();
            var dogRecord   = new List <Dog>();

            for (int i = 0; i < 1000; i++)
            {
                var newHuman = new Human
                {
                    DateOfBirth = DateTime.Today.AddYears(_random.Next(20, 50) * -1),
                    Forename    = _forenames[_random.Next(0, _forenames.Length)],
                    Surname     = _surnames[_random.Next(0, _surnames.Length)]
                };

                newHuman.Id = humanService.AddHumanSync(newHuman);
                humanRecord.Add(newHuman);
            }

            for (int i = 0; i < 1000; i++)
            {
                var newDog = new Dog
                {
                    Breed       = (DogBreed)_random.Next(1, 3),
                    DateOfBirth = DateTime.Today.AddYears(_random.Next(3, 12) * -1),
                    Name        = _dognames[_random.Next(0, _dognames.Length)]
                };

                newDog.Id = dogService.AddDogSync(newDog);
                dogRecord.Add(newDog);
            }

            for (int i = 0; i < 1000; i++)
            {
                var firstFriendId = _random.Next(0, 999);
                dogService.MakeFriendSync(dogRecord[i], dogRecord[firstFriendId]);

                var secondFriendId = _random.Next(0, 999);
                while (secondFriendId == firstFriendId)
                {
                    secondFriendId = _random.Next(0, 999);
                }
                dogService.MakeFriendSync(dogRecord[i], dogRecord[secondFriendId]);
            }

            for (int i = 0; i < 1000; i++)
            {
                humanService.AdoptDogSync(humanRecord[i], dogRecord[i]);
            }

            using (var context = EntityFunDbContext.Create())
            {
                var dogCount = context.Dogs.Count();
                Console.WriteLine("There are {0} dogs in the system", dogCount);

                var humanCount = context.Humans.Count();
                Console.WriteLine("There are {0} humans in the system", humanCount);

                var dogFriends = context.Dogs.SelectMany(x => x.Friends).Count();
                Console.WriteLine(dogFriends);

                var dogsWithManyFriends = context.Dogs.Count(x => x.Friends.Count > 2);
                Console.WriteLine("{0} dogs have more than 2 friends", dogsWithManyFriends);

                Console.WriteLine("{0} dogs have 0 friends", context.Dogs.Count(x => x.Friends.Count == 0));
            }
        }
 public static ITasksDao CreateTasksInstance()
 {
     return(InProcFactory.CreateInstance <TasksDao, ITasksDao>());
 }
Ejemplo n.º 18
0
 public void Close()
 {
     InProcFactory.CloseProxy(Proxy);
 }
Ejemplo n.º 19
0
 protected WcfWrapper(S singleton)
 {
     InProcFactory.SetSingleton(singleton);
     Proxy = InProcFactory.CreateInstance <S, I>();
 }
Ejemplo n.º 20
0
 protected WcfWrapper()
 {
     Proxy = InProcFactory.CreateInstance <S, I>();
 }
Ejemplo n.º 21
0
 public UserAccountEngine()
 {
     _UserAccountAccessor = new Lazy <IUserAccountAccessor>(() => InProcFactory.CreateInstance <UserAccountAccessor, IUserAccountAccessor>());
 }