Example #1
0
        public void Start(string serverEndPoint         = null, string serverActorSystemName   = null,
                          ActorSystem serverActorSystem = null, string serverActorSystemConfig = null)
        {
            try
            {
                ActorSystemFactory.CreateOrSetUpActorSystem(serverActorSystemName: serverActorSystemName, actorSystem: serverActorSystem, actorSystemConfig: serverActorSystemConfig);
                var inventoryNotificationActorAddress = ConfigurationManager.AppSettings["RemoteInventoryInventoryQueryActorAddress"];
                var RemoteInventoryActorAddress       = ConfigurationManager.AppSettings["RemoteInventoryActorAddress"];
                var signalRInventoryQueryActorRef     = ActorSystemFactory.InventoryServiceActorSystem.ActorOf(Props.Create(() => new SignalRInventoryQueryActor(inventoryNotificationActorAddress, RemoteInventoryActorAddress)).WithMailbox(nameof(GetAllInventoryListMailbox)), typeof(SignalRInventoryQueryActor).Name);

                const string message = "signalRInventoryQueryActor created !!!!";
                Log.Debug(message);
                Console.WriteLine(message);

                Log.Debug("Starting inventory service ...");
                serverEndPoint = serverEndPoint ?? ConfigurationManager.AppSettings["ServerEndPoint"];

                if (!string.IsNullOrEmpty(serverEndPoint))
                {
                    OwinRef = WebApp.Start(serverEndPoint, (appBuilder) =>
                    {
                        if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "/web"))
                        {
                            var builder = new ContainerBuilder();
                            builder.Register(c => signalRInventoryQueryActorRef).ExternallyOwned();
                            // Register your SignalR hubs.
                            builder.RegisterType <InventoryServiceHub>().ExternallyOwned();

                            var container = builder.Build();
                            //var config = new HubConfiguration {Resolver = new AutofacDependencyResolver(container)};
                            GlobalHost.DependencyResolver = new AutofacDependencyResolver(container);
                            appBuilder.UseAutofacMiddleware(container);

                            appBuilder.MapSignalR();

                            var fileSystem = new PhysicalFileSystem(AppDomain.CurrentDomain.BaseDirectory + "/web");
                            var options    = new FileServerOptions
                            {
                                EnableDirectoryBrowsing = true,
                                FileSystem         = fileSystem,
                                EnableDefaultFiles = true
                            };

                            appBuilder.UseFileServer(options);
                        }

                        //  InventoryServiceSignalRContext.Push();
                    });
                }

                Log.Debug("WebUIDeployment initialized successfully");
            }
            catch (Exception e)
            {
                Log.Error(e, "Unable to start inventory service UI");
                throw;
            }
        }
        public void Start(string serverEndPoint = null, string serverActorSystemName = null, ActorSystem serverActorSystem = null, string serverActorSystemConfig = null)
        {
            try
            {
                ActorSystemFactory.CreateOrSetUpActorSystem(serverActorSystemName: serverActorSystemName, actorSystem: serverActorSystem, actorSystemConfig: serverActorSystemConfig);

                var actorViewerActorRef = ActorSystemFactory.ActorViewerActorSystem.ActorOf(Props.Create(() => new ActorViewerActor(new SignalRNotificationService())), typeof(ActorViewerActor).Name);

                Log.Debug("Starting ActorViewer service ...");
                serverEndPoint = serverEndPoint ?? ConfigurationManager.AppSettings["ServerEndPoint"];

                if (!string.IsNullOrEmpty(serverEndPoint))
                {
                    OwinRef = WebApp.Start(serverEndPoint, (appBuilder) =>
                    {
                        if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "/site"))
                        {
                            return;
                        }
                        var builder = new ContainerBuilder();
                        builder.Register(c => actorViewerActorRef).ExternallyOwned();
                        // Register your SignalR hubs.
                        builder.RegisterType <ActorViewerHub>().ExternallyOwned();

                        var container = builder.Build();
                        GlobalHost.DependencyResolver = new AutofacDependencyResolver(container);
                        appBuilder.UseAutofacMiddleware(container);

                        appBuilder.MapSignalR();

                        var fileSystem = new PhysicalFileSystem(AppDomain.CurrentDomain.BaseDirectory + "/site");
                        var options    = new FileServerOptions
                        {
                            EnableDirectoryBrowsing = true,
                            FileSystem         = fileSystem,
                            EnableDefaultFiles = true
                        };

                        appBuilder.UseFileServer(options);
                    });
                }

                Log.Debug("WebUIDeployment initialized successfully");
            }
            catch (Exception e)
            {
                Log.Error(e, "Unable to start ActorViewer service UI");
                throw;
            }
        }
        public void StartServer(IPerformanceService performanceService, IBackUpService backUpService, Action <IActorRef, ActorSystem> onReady = null, Type storageType = null, string serverActorSystemName = null,
                                ActorSystem serverActorSystem = null, string serverActorSystemConfig = null)
        {
            Log.Debug("Initializing ...");
            IActorRef inventoryActor = null;

            if (storageType == null)
            {
                // var message = "Unable to initialize storage. No storage specified" ;
                // Log.Debug(message);
                var storageSettings = ConfigurationManager.AppSettings["Storage"];
                if (string.IsNullOrEmpty(storageSettings))
                {
                    const string message = "Could not find Storage setup in config";
                    Log.Debug(message);
                    throw new Exception(message);
                }
                else
                {
                    storageType = Type.GetType(storageSettings);
                }
            }
            if (storageType == null)
            {
                const string message = "Could not create storage type";
                Log.Debug(message);
                throw new Exception(message);
            }
            var inventoryStorage = (IInventoryStorage)Activator.CreateInstance(storageType);

            Log.Debug("Starting Server");

            ActorSystemFactory.CreateOrSetUpActorSystem(serverActorSystemName: serverActorSystemName,
                                                        actorSystem: serverActorSystem, actorSystemConfig: serverActorSystemConfig);

            inventoryActor =
                ActorSystemFactory.InventoryServiceActorSystem.ActorOf(
                    Props.Create(() => new InventoryActor(inventoryStorage, performanceService, backUpService, true)),
                    typeof(InventoryActor).Name);

            if (inventoryActor == null || inventoryActor.IsNobody())
            {
                const string message = "Unable to create actor";
                Log.Debug(message);
                throw new Exception(message);
            }
            ActorSystem = ActorSystemFactory.InventoryServiceActorSystem;

            onReady?.Invoke(inventoryActor, ActorSystem);
        }