Exemplo n.º 1
0
            void format_and_print_result(const std::string& command, const fc::variant& result)
            {
              std::string method_name = command;
              try
              {
                // command could be alias, so get the real name of the method.
                auto method_data = _rpc_server->get_method_data(command);
                method_name = method_data.name;
              }
              catch( const fc::key_not_found_exception& )
              {
                 elog( " KEY NOT FOUND " );
              }
              catch( ... )
              {
                 elog( " unexpected exception " );
              }
              
              if (method_name == "help")
              {
                std::string help_string = result.as<std::string>();
                std::cout << help_string << "\n";
              }
              else if (method_name == "wallet_get_transaction_history_summary")
              {
                  auto tx_history_summary = result.as<std::vector<pretty_transaction>>();
                  print_transaction_history(tx_history_summary);
              }
              else
              {
                // there was no custom handler for this particular command, see if the return type
                // is one we know how to pretty-print
                std::string result_type;
                try
                {
                  const rpc_server::method_data& method_data = _rpc_server->get_method_data(method_name);
                  result_type = method_data.return_type;

                  if (result_type == "asset")
                    std::cout << (std::string)result.as<bts::blockchain::asset>() << "\n";
                  else if (result_type == "address")
                    std::cout << (std::string)result.as<bts::blockchain::address>() << "\n";
                  else if (result_type == "null" || result_type == "void")
                    std::cout << "OK\n";
                  else
                    std::cout << fc::json::to_pretty_string(result) << "\n";
                }
                catch( const fc::key_not_found_exception& )
                {
                   elog( " KEY NOT FOUND " );
                   std::cout << "key not found \n";
                }
                catch( ... )
                {
                   std::cout << "unexpected exception \n";
                }
              }
            }
Exemplo n.º 2
0
bool DisplayCustomerHistory::ExecuteAction(std::istream& input)
{
  CustomerCollection& customers = store_.customers();

  int customer_id;
  input >> customer_id;

  StoreCustomer* customer = customers.GetCustomer(customer_id);

  if(customer == NULL) // customer does not exist
    return false;

  print_customer_information(*customer);
  print_transaction_history(*customer);
  std::cout << std::endl;

  return false;
}