/// <summary>
 /// Controller for Staged Receive endpoints
 /// </summary>
 /// <param name="commonBusiness"></param>
 public StagedReceiveController(IReceiveBusiness receiveBusiness, ICommonBusiness commonBusiness)
 {
     receiveBusiness.ThrowIfNull(nameof(receiveBusiness));
     commonBusiness.ThrowIfNull(nameof(commonBusiness));
     _receiveBusiness = receiveBusiness;
     _commonBusiness  = commonBusiness;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Controller for Receive endpoints
        /// </summary>
        /// <param name="receiveBusiness"></param>
        /// <param name="commonBusiness"></param>
        /// <param name="lookupBusiness"></param>
        public ReceiveController(IReceiveBusiness receiveBusiness, ICommonBusiness commonBusiness, ILookupBusiness lookupBusiness)
        {
            receiveBusiness.ThrowIfNull(nameof(receiveBusiness));
            commonBusiness.ThrowIfNull(nameof(commonBusiness));
            lookupBusiness.ThrowIfNull(nameof(lookupBusiness));

            _receiveBusiness = receiveBusiness;
            _commonBusiness  = commonBusiness;
            _lookupBusiness  = lookupBusiness;
        }
Exemplo n.º 3
0
        public static void ManageMessages()
        {
            Message message = null;

            while (messages.Count > 0)
            {
                lock (messages)
                {
                    if (messages.Count > 0)
                    {
                        message = messages.Dequeue();
                    }
                }

                if (message == null || !message.sessionState.driver.IsConnected())
                {
                    ThreadController.manageMessagesQueueSignalEvent.Reset();

                    return;
                }

                using (var dbContext = Database.For <ThePalaceEntities>())
                {
                    dbContext.Database.ExecuteSqlCommand("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");

                    IReceiveBusiness business = null;

                    try
                    {
                        var mnemonic = Regex.Replace(message.header.eventType, @"[^\w\d]+", string.Empty);
                        var type     = PluginManager.GetType($"ThePalace.Server.Plugins.Business.{mnemonic}");

                        if (type == null)
                        {
                            type = Type.GetType($"ThePalace.Server.Business.{message.header.eventType}");
                        }

                        var parameters = new object[] {
                            new Dictionary <string, object> {
                                { "UserID", message.sessionState.UserID },
                            }
                        };
                        var value = true;

                        value &= type.AttributeWrapper(typeof(SuccessfullyConnectedProtocolAttribute), "OnBeforeProtocolExecute", parameters);
                        value &= type.AttributeWrapper(typeof(AdminOnlyProtocolAttribute), "OnBeforeProtocolExecute", parameters);

                        if (!value)
                        {
                            return;
                        }

                        if (type != null)
                        {
                            business = (IReceiveBusiness)Activator.CreateInstance(type);
                        }

                        if (business != null)
                        {
                            business.Receive(dbContext, message);
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.DebugLog();
                    }
                }
            }
        }