コード例 #1
0
        public static bool SwitchState <TState>(this OperationDataBase <TState> data, TState expectedState, TState nextState)
            where TState : struct, IConvertible
        {
            if (data == null)
            {
                throw new InvalidOperationException("Operation execution data was not properly initialized.");
            }

            if (Convert.ToInt32(data.State) < Convert.ToInt32(expectedState))
            {
                // Throws to retry and wait until the operation will be in the required state
                throw new InvalidOperationException(
                          $"Operation execution state can't be switched: {data.State} -> {nextState}. Waiting for the {expectedState} state.");
            }

            if (Convert.ToInt32(data.State) > Convert.ToInt32(expectedState))
            {
                // Already in the next state, so this event can be just ignored
                return(false);
            }

            data.State = nextState;

            return(true);
        }
コード例 #2
0
ファイル: SagaExtensions.cs プロジェクト: LykkeBusiness/MT
        public static bool SwitchState(this OperationDataBase <SpecialLiquidationOperationState> data,
                                       SpecialLiquidationOperationState expectedState, SpecialLiquidationOperationState nextState)
        {
            if (data == null)
            {
                throw new InvalidOperationException("Operation execution data was not properly initialized.");
            }

            if (Convert.ToInt32(data.State) < Convert.ToInt32(expectedState))
            {
                // Throws to retry and wait until the operation will be in the required state
                throw new InvalidOperationException(
                          $"Operation execution state can't be switched: {data.State} -> {nextState}. Waiting for the {expectedState} state.");
            }

            if (Convert.ToInt32(data.State) > Convert.ToInt32(expectedState))
            {
                LogLocator.CommonLog.WriteWarning(nameof(SagaExtensions), nameof(SwitchState),
                                                  $"Operation is already in the next state, so this event is ignored, {new {data, expectedState, nextState}.ToJson()}.");
                return(false);
            }

            if (data.State == SpecialLiquidationOperationState.Failed &&
                nextState == SpecialLiquidationOperationState.Cancelled)
            {
                LogLocator.CommonLog.WriteWarning(nameof(SagaExtensions), nameof(SwitchState),
                                                  $"Cannot switch from Failed to Cancelled state (both states are final), so this event is ignored, {new {data, expectedState, nextState}.ToJson()}.");
                return(false);
            }

            data.State = nextState;

            return(true);
        }
コード例 #3
0
ファイル: SagaExtensions.cs プロジェクト: LykkeBusiness/MT
        public static bool SwitchState <TState>(this OperationDataBase <TState> data, TState expectedState,
                                                TState nextState)
            where TState : struct, IConvertible
        {
            if (data == null)
            {
                throw new InvalidOperationException("Operation execution data was not properly initialized.");
            }

            if (Convert.ToInt32(data.State) < Convert.ToInt32(expectedState))
            {
                // Throws to retry and wait until the operation will be in the required state
                throw new InvalidOperationException(
                          $"Operation execution state can't be switched: {data.State} -> {nextState}. Waiting for the {expectedState} state.");
            }

            if (Convert.ToInt32(data.State) > Convert.ToInt32(expectedState))
            {
                LogLocator.CommonLog.WriteWarning(nameof(SagaExtensions), nameof(SwitchState),
                                                  $"Operation is already in the next state, so this event is ignored, {new {data, expectedState, nextState}.ToJson()}.");
                return(false);
            }

            data.State = nextState;

            return(true);
        }
コード例 #4
0
        public MainWindowViewModel()
        {
            _operationDataBase = OperationDataBase.GetInstance();

            CurrentContent = Content.GetInstance();

            CurrentContent.Catalogs = UpdaterRss.UpdateTreeViewChannels(CurrentContent.User.Login);
        }
コード例 #5
0
        public SettingPageViewModel()
        {
            _operationDataBase = OperationDataBase.GetInstance();
            CurrentContent     = Content.GetInstance();

            Login    = CurrentContent.User.Login;
            Password = CurrentContent.User.Password;
            Email    = CurrentContent.User.Email;
        }
コード例 #6
0
        public RssItemPageViewModel()
        {
            CurrentContent     = Content.GetInstance();
            _operationDataBase = OperationDataBase.GetInstance();

            PrintRssItems();

            Favorite_Checked = _operationDataBase.CheckedFavoriteItem(CurrentContent.User.Login, CurrentContent.RssItem.Title);
        }
コード例 #7
0
 static UpdaterRss()
 {
     _operationDataBase = OperationDataBase.GetInstance();
 }
コード例 #8
0
 public RegistrationPageViewModel()
 {
     _operationDataBase  = OperationDataBase.GetInstance();
     _currentRegistrUser = new User();
 }
コード例 #9
0
 public LoginPageViewModel()
 {
     CurrentContent     = Content.GetInstance();
     _operationDataBase = OperationDataBase.GetInstance();
 }