コード例 #1
0
        public OperationResult Subscribe(long slaveId, long masterId, SubscriptionSettings settings)
        {
            return(InvokeOperations.InvokeOperation(() =>
            {
                var statuses = accService.GetAccountStatuses(slaveId);
                if (!statuses.IsSuccess)
                {
                    throw new OperationException(statuses.Error, statuses.Code);
                }
                if (statuses.Result.Has(AccountStatuses.IsPropTrading))
                {
                    throw new OperationException("Not available", ResultCode.SiteOperationNotAvailable);
                }

                Logger.Trace("Subscribe, slave id - {0}, master id - {1}", slaveId, masterId);
                var accountInformation = accService.ChangeAccountRole(slaveId, AccountRole.SignalSubscriber);
                if (!accountInformation.IsSuccess)
                {
                    throw new OperationException(accountInformation.Error, accountInformation.Code);
                }

                signalServiceRepository.SignalSubscription((short)SubscriptionStatus.On, slaveId, masterId, settings,
                                                           accountInformation.Result);
            }));
        }