예제 #1
0
    public static void UnpauseGame(PauseSource pauseSource)
    {
        switch (pauseSource)
        {
        case PauseSource.UI:
            bPauseUI = false;
            break;

        case PauseSource.FakeLoading:
            bPauseFakeLoading = false;
            break;
        }

        if (bPauseUI || bPauseFakeLoading)
        {
            bPauseGame = true;
        }
        else
        {
            bPauseGame = false;
        }

        if (!bPauseGame && pauseSource == PauseSource.FakeLoading && OnFLContinueGame != null)
        {
            OnFLContinueGame();
        }
        if (!bPauseGame && pauseSource == PauseSource.UI && OnUIContinueGame != null)
        {
            OnUIContinueGame();
        }
    }
예제 #2
0
        public async Task <RfqPauseErrorCode> AddAsync(string operationId, PauseSource source, Initiator initiator)
        {
            if (string.IsNullOrEmpty(operationId))
            {
                throw new ArgumentNullException(nameof(operationId));
            }

            var locker = _lock.GetOrAdd(operationId, new SemaphoreSlim(1, 1));

            await locker.WaitAsync();

            try
            {
                var existingPause = (await _pauseRepository.FindAsync(
                                         operationId,
                                         SpecialLiquidationSaga.OperationName,
                                         NotCancelledPredicate))
                                    .SingleOrDefault();

                if (existingPause != null)
                {
                    await _log.WriteWarningAsync(nameof(RfqPauseService), nameof(AddAsync), $"There is already pause with state [{existingPause.State}] for operation with id [{operationId}]");

                    return(RfqPauseErrorCode.AlreadyExists);
                }

                var executionInfo = await _executionInfoRepository
                                    .GetAsync <SpecialLiquidationOperationData>(SpecialLiquidationSaga.OperationName, operationId);

                if (executionInfo == null)
                {
                    return(RfqPauseErrorCode.NotFound);
                }

                if (!AllowedOperationStatesToPauseIn.Contains(executionInfo.Data.State))
                {
                    await _log.WriteWarningAsync(nameof(RfqPauseService), nameof(AddAsync),
                                                 $"There was an attempt to pause special liquidation with id {operationId} and state {executionInfo.Data.State}. Pause is possible in [{string.Join(',', AllowedOperationStatesToPauseIn)}] states only");

                    return(RfqPauseErrorCode.InvalidOperationState);
                }

                var pause = Pause.Create(
                    operationId,
                    SpecialLiquidationSaga.OperationName,
                    source,
                    initiator,
                    _dateService.Now());

                await _pauseRepository.AddAsync(pause);

                // todo: add audit log
            }
            finally
            {
                locker.Release();
            }

            return(RfqPauseErrorCode.None);
        }
예제 #3
0
파일: Pause.cs 프로젝트: LykkeBusiness/MT
 private Pause(long?oid,
               string operationId,
               string operationName,
               DateTime createdAt,
               DateTime?effectiveSince,
               PauseState state,
               PauseSource source,
               Initiator initiator,
               DateTime?cancelledAt,
               DateTime?cancellationEffectiveSince,
               [CanBeNull] Initiator cancellationInitiator,
               PauseCancellationSource?cancellationSource)
 {
     Oid                        = oid;
     OperationId                = operationId;
     OperationName              = operationName;
     CreatedAt                  = createdAt;
     EffectiveSince             = effectiveSince;
     State                      = state;
     Source                     = source;
     Initiator                  = initiator;
     CancelledAt                = cancelledAt;
     CancellationEffectiveSince = cancellationEffectiveSince;
     CancellationInitiator      = cancellationInitiator;
     CancellationSource         = cancellationSource;
 }
예제 #4
0
파일: Pause.cs 프로젝트: LykkeBusiness/MT
        public static Pause Initialize(long?oid,
                                       string operationId,
                                       string operationName,
                                       DateTime createdAt,
                                       DateTime?effectiveSince,
                                       PauseState state,
                                       PauseSource source,
                                       Initiator initiator,
                                       DateTime?cancelledAt,
                                       DateTime?cancellationEffectiveSince,
                                       Initiator cancellationInitiator,
                                       PauseCancellationSource?cancellationSource)
        {
            if (!oid.HasValue)
            {
                throw new InvalidOperationException("Pause initialization can be done for persisted object only");
            }

            return(new Pause(
                       oid,
                       operationId,
                       operationName,
                       createdAt,
                       effectiveSince,
                       state,
                       source,
                       initiator,
                       cancelledAt,
                       cancellationEffectiveSince,
                       cancellationInitiator,
                       cancellationSource));
        }
예제 #5
0
    public static void PauseGame(PauseSource pauseSource)
    {
        switch (pauseSource)
        {
        case PauseSource.UI:
            bPauseUI = true;
            break;

        case PauseSource.FakeLoading:
            bPauseFakeLoading = true;
            break;
        }

        if (!bPauseGame)
        {
            bPauseGame = true;
            if (OnPauseGame != null)
            {
                OnPauseGame();
            }
        }
    }
예제 #6
0
파일: Pause.cs 프로젝트: LykkeBusiness/MT
 public static Pause Create(string operationId,
                            string operationName,
                            PauseSource source,
                            Initiator initiator,
                            DateTime createdAt,
                            DateTime?effectiveSince                    = null,
                            PauseState state                           = PauseState.Pending,
                            DateTime?cancelledAt                       = null,
                            DateTime?cancellationEffectiveSince        = null,
                            Initiator cancellationInitiator            = null,
                            PauseCancellationSource?cancellationSource = null) =>
 new Pause(
     null,
     operationId,
     operationName,
     createdAt,
     effectiveSince,
     state,
     source,
     initiator,
     cancelledAt,
     cancellationEffectiveSince,
     cancellationInitiator,
     cancellationSource);