Пример #1
0
void Service::Execute(const std::string& host, int port, Command& cmd)
{
  cmd.status() = Command::EXECUTING;

  Connection *con = new TCPConnection(host, port);

  if (!con->Open())
  {
    delete con;
    throw "Could not connect to " + host;
  }

  con->Send(&cmd.Msg());

  Message *rsp = con->Recv();
  cmd.ReadMessage(*rsp);
  delete rsp;
}
Пример #2
0
int omain(int argc, oarg* argv[])
{
    ostring home;
    ostring dbs;
    ostring usr;
    ostring pwd;

    size_t i;

    /* CHECK COMMAND LINE --------------------------------------------------- */

    if (argc < (ArgCount - 1))
    {
        return EXIT_FAILURE;
    }

    /* GET ARGUMENTS ---------------------------------------------------------*/

    dbs = GetArg(argv[ArgDatabase]);
    usr = GetArg(argv[ArgUser]);
    pwd = GetArg(argv[ArgPassword]);

    if (argc == ArgCount)
    {
        home = GetArg(argv[ArgHome]);
    }

    try
    {
        Environment::Initialize(Environment::Default | Environment::Threaded, home);

        Environment::EnableWarnings(true);

        ocout << otext("Connecting to ") << usr << otext("/") << pwd << otext("@") << dbs << oendl << oendl;

        con.Open(dbs, usr, pwd, Environment::SessionDefault);

        print_version();
        create_tables();

        /* execute tests */

        for (i = 0; i < ARRAY_COUNT(tab_test); i++)
        {
            if (tab_test[i].execute)
                tab_test[i].proc();
        }

        drop_tables();
        con.Close();
    }
    catch (std::exception &ex)
    {
        ocout << ex.what() << oendl;
    }

    if (con)
    {
        drop_tables();
        con.Close();
    }

    Environment::Cleanup();

    ocout << otext("\nPress any key to exit...");

    getchar();

    return EXIT_SUCCESS;
}