Ejemplo n.º 1
0
        private async Task Initialize()
        {
            _presenterService          = ServiceProxy.Create <IPresenterService>(new Uri(_presenterServiceUri));
            _exComService              = ServiceProxy.Create <IExternalCommunicationService>(new Uri(_exComServiceUri));
            _securityService           = ServiceProxy.Create <ISecurityService>(new Uri(_securityServiceUri));
            _currentKpuPackageRequests = new Dictionary <string, List <string> >();
            logger.Trace($"Initializing Presenter service");
            _presenterService.Initialize().Wait();
            logger.Trace($"Initializing Presenter service complete");
            try
            {
                _configuration               = new ConfigurationBuilder().AddXmlFile("App.config").Build();
                _amqRoutes                   = new Dictionary <string, string>();
                _amqEndpoint                 = _configuration["Connection:Endpoint"];
                _amqUser                     = _configuration["Connection:User"];
                _amqPassword                 = _configuration["Connection:Password"];
                _amqRoutes["ToBlackboard"]   = _configuration["Routes:ToBlackboard"];
                _amqRoutes["FromBlackboard"] = _configuration["Routes:FromBlackboard"];
                await SetupActiveMq();
            }
            catch (Exception e)
            {
                logger.Error($"Exception while reading app.config and getting amq routes: {e.ToString()}");
                return;
            }

            try
            {
                var         proxy2  = ActorProxy.Create <IBlackboardActor>(new ActorId(42), "fabric:/Assistant");
                Task <bool> ret2    = proxy2.InitBlackboard();
                bool        retVal3 = ret2.Result;

                Task rett;
                rett = proxy2.StartProcessing();
            }
            catch (Exception e)
            {
                logger.Error(e.ToString());
            }
            logger.Trace($"Initializing Blackboard Actor complete");

            InitializeTransformerActor();


            var registerForMessagesAtBlackboardRequest = new RoutingRequest()
            {
                Id           = "Core",
                Path         = _amqRoutes["FromBlackboard"],
                ContentTypes = new string[]
                {
                    BrokerCommands.PACKAGE,
                    BrokerCommands.KPU_REGISTRATION,
                    BrokerCommands.MODEL_UPDATE
                },
            };
            var registerPackage = BreanosConnectors.SerializationHelper.Pack(registerForMessagesAtBlackboardRequest);
            await _activeMqConnector.SendAsync(registerPackage, _amqRoutes["ToBlackboard"], BrokerCommands.CONFIGURE_ROUTES);

            logger.Trace($"Registration with Blackboard complete.");
        }
Ejemplo n.º 2
0
 public async Task SendAddToMasterlist(string connectionId, string viewTitle, string viewId)
 {
     logger.Trace($"connectionId = {connectionId}, viewTitle = {viewTitle}, viewId={viewId}");
     try
     {
         await _hub.Clients.Client(connectionId).SendAsync("OnAddToMasterList", viewTitle, viewId);
     }
     catch (Exception E)
     {
         logger.Error(E.ToString());
     }
     logger.Trace($"connectionId = {connectionId}, viewTitle = {viewTitle}, viewId={viewId} completed");
 }
Ejemplo n.º 3
0
        public async Task Login(string user, string password)
        {
            logger.Trace($"user ={user}; password={password}");
            try
            {
                if (await _service?.Login(Context.ConnectionId, user, password))
                {
                    logger.Trace($"Sending OnReceiveGoodLogin to {Context.ConnectionId}");
                    await Clients.Client(Context.ConnectionId).OnReceiveGoodLogin();

                    var menu = await _service?.GetUserMenu(Context.ConnectionId);

                    if (!string.IsNullOrEmpty(menu))
                    {
                        await Clients.Client(Context.ConnectionId).OnMenuReceived(menu);
                    }
                    logger.Trace($"Sent OnReceiveGoodLogin to {Context.ConnectionId}");
                }
                else
                {
                    logger.Trace($"Sending OnReceiveBadLogin to {Context.ConnectionId}");
                    await Clients.Client(Context.ConnectionId).OnReceiveBadLogin();

                    logger.Trace($"Sent OnReceiveBadLogin to {Context.ConnectionId}");
                }
            }
            catch (Exception e)
            {
                logger.Error($"Exception on sending login-state information to client {Context.ConnectionId}. {e.ToString()}");
            }
        }
Ejemplo n.º 4
0
        private void Sbc_Log(object sender, string message, ServiceBusConnectorLogLevel level)
        {
            switch (level)
            {
            case ServiceBusConnectorLogLevel.Error:
                logger.Error(sender.ToString() + message.ToString());
                break;

            case ServiceBusConnectorLogLevel.Info:
                logger.Info(sender.ToString() + message.ToString());
                break;

            case ServiceBusConnectorLogLevel.Trace:
                logger.Trace(sender.ToString() + message.ToString());
                break;

            default:
                logger.Trace(sender.ToString() + message.ToString());
                break;
            }
        }
Ejemplo n.º 5
0
 public void OldRouterCode(string content, string contentType)
 {
     try
     {
         if (contentType.CompareTo("MU1") == 0)
         {
             logger.Trace($"Sending message to {TOPIC_FOR_STATUS_UPDATE}");
             _amqc.SendAsync(content, TOPIC_FOR_STATUS_UPDATE, contentType, null).Wait();
         }
         else if (contentType.CompareTo("DU1") == 0)
         {
             logger.Trace($"Sending message to {TOPIC_FOR_ANSWER}");
             _amqc.SendAsync(content, TOPIC_FOR_ANSWER, contentType, null).Wait();
         }
         else
         {
             logger.Trace("Type not valid!: " + contentType);
         }
     }
     catch (Exception ex)
     {
         logger.Error("Error:" + ex.ToString());
     }
 }
Ejemplo n.º 6
0
 public async Task <bool> CheckPermission(string connectionId, string actionId)
 {
     try
     {
         logger.Trace($"called with connectionId = {connectionId}, actionId = {actionId}");
         var user = GetUserFromConnectionId(connectionId);
         logger.Trace($"session {connectionId} resolved to user {user}");
         if (_sessionUsers[connectionId] == null)
         {
             return((await _accessControlService.IsUserHasPermission("nullUser", actionId)).Result);
         }
         var hasPermission = _accessControlService.IsUserHasPermission(user, actionId);
         logger.Trace($"User {user} has permission for {actionId} : {hasPermission}");
         return((await hasPermission).Result);
     }
     catch (Exception e)
     {
         logger.Error($"exception was caused: {e.ToString()}");
         return(false);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="ex"></param>
 public void LogErrors(object sender, ExceptionReceivedEventArgs ex)
 {
     logger.Error(sender.ToString(), ex.ToString());
 }