Ejemplo n.º 1
0
        protected override void Receive(CancellationToken token, IConnection connection)
        {
            using (ISession session = connection.CreateSession(true, AcknowledgeMode.AutoAcknowledge))
            {
                CurrentSessions.SetSession(session);

                token.Register(() =>
                {
                    if (consumer != null)
                    {
                        consumer.Close();
                    }
                });

                using (consumer = createConsumer(session))
                {
                    while (!token.IsCancellationRequested)
                    {
                        IMessage message = consumer.Receive();

                        if (message != null)
                        {
                            Exception        exception        = null;
                            TransportMessage transportMessage = null;
                            try
                            {
                                transportMessage = ConvertMessage(message);

                                if (ProcessMessage(transportMessage))
                                {
                                    session.Commit();
                                }
                                else
                                {
                                    session.Rollback();
                                }
                            }
                            catch (Exception ex)
                            {
                                Logger.Error("Error processing message.", ex);

                                session.Rollback();

                                exception = ex;
                            }
                            finally
                            {
                                endProcessMessage(transportMessage, exception);
                            }
                        }
                    }

                    consumer.Close();
                }

                session.Close();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public override Session StartSession(RegisteredUser user)
        {
            var result = new Session()
            {
                User = user
            };

            CurrentSessions.Add(result);
            return(result);
        }
Ejemplo n.º 3
0
        public void UpdatedLocation(DateTime timestamp, CommanderTravelLocation location, string reason)
        {
            this.CurrentLocation = location;
            var travelSession = StartedTravelling(timestamp, reason);

            foreach (var currentSession in CurrentSessions.Where(p => p != null))
            {
                currentSession.UpdateLocation(this.CurrentLocation);
            }
        }
Ejemplo n.º 4
0
        void AssignCurrentTables()
        {
            current_session_macro_sessions = new CurrentSessionMacroSessions(schedule);
            current_session_pack_groups    = new CurrentSessionPackGroup(schedule);
            current_session_games          = new CurrentSessionGames2(schedule);
            //current_session_game_pack_groups = new CurrentSessionGamePackGroups( schedule );
            current_session_game_session_pack_groups = new CurrentSessionGameSessionPackGroups(schedule);

            current_session_bundle_packs = new CurrentSessionBundlePacks(schedule);
            current_session_bundles      = new CurrentSessionBundles(schedule);

            current_session_games                = new CurrentSessionGames2(schedule);
            current_sessions                     = new CurrentSessions(schedule);
            current_bundles                      = new CurrentBundles(schedule);
            current_all_sessions                 = new CurrentSessions(schedule);
            current_session_packs                = new CurrentSessionPack(schedule);
            current_pack_group_packs             = new CurrentPackGroupPacks(schedule);
            current_session_price_exception_sets = new CurrentSessionPriceExceptionSets(schedule);

            current_session_prize_exception_sets = new CurrentSessionPrizeExceptionSets(schedule);
            current_prize_data = new CurrentPrizeData(schedule);
            //current_session_pack_order = new CurrentSessionPackOrder( schedule );

            current_game_patterns = new CurrentGamePatterns(schedule);

            current_cardset_ranges      = schedule.Tables[CurrentCardsetRanges.TableName] as CurrentCardsetRanges;
            current_pack_cardset_ranges = new CurrentPackCardsetRanges(schedule);
            current_cardset_range_packs = schedule.Tables[CurrentCardsetRangePack.TableName] as CurrentCardsetRangePack;
            //current_session_packs = schedule.Tables[CurrentSessionPack.TableName] as CurrentSessionPack;
            //current_session_pack_groups = schedule.Tables[CurrentSessionPackGroup.TableName] as CurrentSessionPackGroup;
            current_pack_prize_level = schedule.Tables[CurrentPackPrizeLevel.TableName] as CurrentPackPrizeLevel;

            //current_pack_group_packs = schedule.Tables[CurrentPackGroupPacks.TableName] as CurrentPackGroupPacks;

            current_game_group_prizes = schedule.Tables[CurrentGameGroupPrizes.TableName] as CurrentGameGroupPrizes;

#if asdfasdf
            current_session_prize_level = schedule.Tables[CurrentSessionGamePackPrize.TableName] as CurrentSessionGamePackPrize;
#endif

            //current_session_prize_level_order = schedule.Tables[CurrentSessionPrizeOrder.TableName] as CurrentSessionPrizeOrder;
            current_pack_face_prize_level = schedule.Tables[CurrentPackFacePrizeLevel.TableName] as CurrentPackFacePrizeLevel;

            current_game_group_prize_packs = schedule.Tables[CurrentGameGroupPrizePacks.TableName] as CurrentGameGroupPrizePacks;

            //current_session_price_exception_sets = schedule.Tables[CurrentSessionPriceExceptionSets.TableName] as CurrentSessionPriceExceptionSets;
            current_price_data = schedule.Tables[CurrentPriceData.TableName] as CurrentPriceData;

            //current_session_prize_exception_sets = schedule.Tables[CurrentSessionPrizeExceptionSets.TableName] as CurrentSessionPrizeExceptionSets;
            //current_prize_data = schedule.Tables[CurrentPrizeData.TableName] as CurrentPrizeData;
        }
Ejemplo n.º 5
0
        internal void Shutdown(DateTime timestamp)
        {
            var reason = "Shutdown";

            foreach (var session in CurrentSessions.Where(p => p != null))
            {
                this.CompleteSession(session, timestamp, reason);
            }

            // Save all sessions?
            foreach (var session in sessionList)
            {
                // FIXME: Still Jank
                var baseline = ObjectMapper.Map <StatSessionSummary>(session);
                var summary  = session.SummariseSession(baseline);
                DisplaySummary(summary);
                SaveSession(session);
                SaveSessionSummary(summary);
            }
        }
        protected override void Receive(CancellationToken token, IConnection connection)
        {
            var backOff = new BackOff(MaximumDelay);

            using (ISession session = connection.CreateSession(true, AcknowledgeMode.AutoAcknowledge))
            {
                CurrentSessions.SetSession(session);

                using (IMessageConsumer consumer = createConsumer(session))
                {
                    while (!token.IsCancellationRequested)
                    {
                        IMessage message;

                        using (var lockReset = new ManualResetEventSlim(false))
                        {
                            using (var scope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
                            {
                                Transaction.Current.TransactionCompleted += (sender, args) => lockReset.Set();

                                message = consumer.ReceiveNoWait();

                                if (message != null)
                                {
                                    Exception        exception        = null;
                                    TransportMessage transportMessage = null;

                                    try
                                    {
                                        transportMessage = ConvertMessage(message);

                                        if (ProcessMessage(transportMessage))
                                        {
                                            scope.Complete();
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Logger.Error("Error processing message.", ex);

                                        exception = ex;
                                    }
                                    finally
                                    {
                                        endProcessMessage(transportMessage, exception);
                                    }
                                }
                            }

                            lockReset.Wait();
                        }

                        backOff.Wait(() => message == null);
                    }

                    consumer.Close();
                }

                session.Close();
            }
        }