Beispiel #1
0
        public override void ConsumeTransactionFeature(CommitItems commitItems, Commit commit, Transaction transaction, FeatureAccount featureAccount, FeatureData featureData)
        {
            var group   = featureData as Group;
            var groupId = group.GroupId;

            var groupAdministrationInfo = GroupAdministrationChainHandler.GetGroupInfo(groupId);

            if (groupAdministrationInfo != null)
            {
                if (groupAdministrationInfo.IsGroupAccount(transaction.AccountId))
                {
                    var groupInfo = GetGroupInfo(groupId);
                    groupInfo.ConsumeGroup(transaction, group);
                    commit.DirtyIds.Add(groupId);
                }
            }
        }
        public override void PreProcess(IFeatureChain featureChain, FeatureAccount featureAccount, Transaction transaction, FeatureData featureData)
        {
            if (_chainHandler == null)
            {
                _chainHandler = featureChain.GetFeatureChainHandler <GroupAdministrationChainHandler>(featureData.FeatureId);
                _nextGroupId  = _chainHandler.LastGroupId + 1;
            }

            if (transaction.GetFeatureRequest <GroupAdministrationRequest>(out var request))
            {
                var groupId = request.GroupId;
                var group   = _chainHandler.GetGroupInfo(groupId);
                _lastTransactionIdLookup.Set(groupId, group.AdministrationLastTransactionInfo.TransactionId);
            }
        }
Beispiel #3
0
        public override (bool, int) Validate(Transaction transaction, FeatureData featureData)
        {
            var group     = featureData as Group;
            var groupInfo = _chainHandler.GetGroupInfo(group.GroupId);

            if (groupInfo == null)
            {
                return(false, (int)GroupError.InvalidGroup);
            }

            if (!groupInfo.IsGroupAccount(transaction.AccountId))
            {
                return(false, (int)GroupError.InvalidAccount);
            }

            return(true, 0);
        }
        public override Result QueryFeature(FeatureQuery query)
        {
            var action = query.Action;

            if (action == GroupsAction)
            {
                return(GetAccountData <GroupAdministrationContainer>(query, 0, (container) =>
                {
                    if (container != null)
                    {
                        return new LongArrayResult(container.GetGroups());
                    }

                    return Result.DataNotFound;
                }));
            }
            else if (query.GetLong(0, out var groupId))
            {
                var groupInfo = _handler.GetGroupInfo(groupId);
                if (groupInfo == null)
                {
                    return(Result.DataNotFound);
                }

                if (action == AccountsAction)
                {
                    return(new GroupUsersResult(groupInfo.GetAccounts()));
                }
                else if (action == PendingAccountsAction)
                {
                    return(new GroupUsersResult(groupInfo.GetPendingAccounts()));
                }
                else if (action == AdministrationLastTransactionInfoAction)
                {
                    return(new PackableResult(groupInfo.AdministrationLastTransactionInfo));
                }
            }

            return(Result.InvalidQuery);
        }