Exemple #1
0
        public CommandResult Execute(ICommandInfo commandInfo)
        {
            var readInfo = commandInfo as ReadCommandInfo;

            if (readInfo == null)
            {
                return(CommandResult.Fail("CommandInfo does not implement ReadCommandInfo"));
            }

            if (readInfo.DataSource == null)
            {
                throw new ClientException("Invalid ReadCommand argument: Data source is not set.");
            }

            var genericRepository    = _repositories.GetGenericRepository(readInfo.DataSource);
            ReadCommandResult result = _serverCommandsUtility.ExecuteReadCommand(readInfo, genericRepository);

            if (result.Records != null && !AlreadyFilteredByRowPermissions(readInfo))
            {
                var valid = _serverCommandsUtility.CheckAllItemsWithinFilter(result.Records, RowPermissionsReadInfo.FilterName, genericRepository);
                if (!valid)
                {
                    throw new UserException("You are not authorized to access some or all of the data requested.", "DataStructure:" + readInfo.DataSource + ".");
                }
            }

            return(new CommandResult
            {
                Data = _dataTypeProvider.CreateBasicData(result),
                Message = (result.Records != null ? result.Records.Length.ToString() : result.TotalCount.ToString()) + " row(s) found",
                Success = true
            });
        }
        public CommandResult Execute(ICommandInfo commandInfo)
        {
            var info = (QueryDataSourceCommandInfo)commandInfo;

            var genericRepository = _repositories.GetGenericRepository(info.DataSource);
            var readCommandInfo   = info.ToReadCommandInfo();
            ReadCommandResult readCommandResult = _serverCommandsUtility.ExecuteReadCommand(readCommandInfo, genericRepository);

            var result = QueryDataSourceCommandResult.FromReadCommandResult(readCommandResult);

            return(new CommandResult
            {
                Data = _dataTypeProvider.CreateBasicData(result),
                Message = (result.Records != null ? result.Records.Length.ToString() : result.TotalRecords.ToString()) + " row(s) found",
                Success = true
            });
        }