Example #1
0
        /// <summary>
        /// Создает команду из заголовка. Если данных недостаточно, то возвращает <code>null</code>.
        /// </summary>
        /// <param name="command_header"></param>
        /// <param name="not_ready_data"></param>
        /// <returns></returns>
        public Command CreateCommand(CommandHeader command_header, out Tuple <FunctionHeader, List <DataCellHeader> > not_ready_data)
        {
            not_ready_data = null;
            var input_data       = new List <DataCell>();
            var empty_input_data = new List <DataCellHeader>();

            foreach (var data_cell_header in command_header.InputDataHeaders)
            {
                var data = _dataCellRepository.Get(new[] { data_cell_header }).FirstOrDefault();

                if (data != null)
                {
                    input_data.Add(data);
                }
                else
                {
                    empty_input_data.Add(data_cell_header);
                }
            }

            var output_data = _dataCellRepository.Get(new[] { command_header.OutputDataHeader }).FirstOrDefault();

            if (output_data == null)
            {
                output_data = new DataCell()
                {
                    Header = command_header.OutputDataHeader,
                    //HasValue = false,
                    HasValue = null,
                    Data     = null
                };
            }

            var function = _functionRepository.Get(new[] { command_header.FunctionHeader }).FirstOrDefault();

            if (empty_input_data.Any() || function == null)
            {
                not_ready_data = new Tuple <FunctionHeader, List <DataCellHeader> >(function == null ? command_header.FunctionHeader : null, empty_input_data);
                return(null);
            }

            return(new Command()
            {
                Header = new InvokeHeader()
                {
                    CallStack = command_header.CallStack
                },
                Function = function,
                InputData = input_data,
                OutputData = output_data
            });
        }
Example #2
0
        private DataCell GetOutputData(DataCellHeader data_cell_header)
        {
            var output_data = _dataCellRepository.Get(new[] { data_cell_header }).FirstOrDefault();

            if (output_data == null)
            {
                output_data = new DataCell()
                {
                    Header   = data_cell_header,
                    HasValue = null,
                    Data     = null
                };
                _dataCellRepository.Add(new[] { output_data });
            }

            return(output_data);
        }
Example #3
0
 public virtual IEnumerable <DataCell> GetDataCell(IEnumerable <DataCellHeader> data_cell_headers)
 {
     return(_dataCellRepository.Get(data_cell_headers));
 }