示例#1
0
void CDatabaseReader::ReadCoordinate(CCoordinate& coord, const sql::ResultSet& rs)
{
  coord._lat = getDecimal(rs, "latitude", CCoordinate::KDigitsAfterComma);
  coord._long = getDecimal(rs, "longitude", CCoordinate::KDigitsAfterComma);
  if (!coord.IsValid())
  {
    std::string latStr = rs.getString("latitude");
    std::string longStr = rs.getString("longitude");
    throw new CDBReaderException("read a bad coordinate: (" + latStr + ", " + longStr + ")");
  }
}
      void SqlTableModel::load(sql::ResultSet result) {
        sql::ResultSetMetaData * rsmd = result.getResultSetMetaData();
        int fieldCount = rsmd->getColumnCount();
        //      insertColumns(0,fieldCount);
        //      for(int a=0;a<fieldCount;a++){
        /*
         * for locale support 
         * if(!setHeaderData(a,Wt::WString::tr(rsmd->getColumnName(a).c_str()))){ 
         */
        /*
          if(!setHeaderData(a,rsmd->getColumnName(a))){
            std::cout<<"Failed"<<std::endl;
          }
        }
         */
        for (int a = 0; result.next(); a++) {
          if (rowCount() <= a)
            insertRow(rowCount());
          for (int b = 0; b < fieldCount; b++)
            if (!setData(a, b, result.getString(b))) {
              std::cout << "set data Failed" << std::endl;
            }
        }

      }
      SqlTableModel::SqlTableModel(sql::ResultSet result, Wt::WContainerWidget* parent) : Wt::WStandardItemModel(0, 0, parent) {
        sql::ResultSetMetaData * rsmd = result.getResultSetMetaData();
        int fieldCount = rsmd->getColumnCount();
        insertColumns(0, fieldCount);
        for (int a = 0; a < fieldCount; a++) {
          /*
           * for locale support 
           * if(!setHeaderData(a,Wt::WString::tr(rsmd->getColumnName(a).c_str()))){ 
           */
          if (!setHeaderData(a, rsmd->getColumnName(a))) {
            //        if(!setHeaderData(a,boost::any(rsmd->getColumnName(a)))){
            //        if(!setHeaderData(a,boost::any(string("test")))){
            std::cout << "Failed" << std::endl;
          }
        }

        for (int a = 0; result.next(); a++) {
          if (rowCount() <= a)
            insertRow(rowCount());

          for (int b = 0; b < fieldCount; b++)
            if (!setData(a, b, result.getString(b))) {
              //          if(!setData(a,b,boost::any(result.getString(b)))){
              //          if(!setData(a,b,boost::any(new string("test")))){
              std::cout << "set data Failed" << std::endl;
            }else {
            }
        }

        //      load(result);
      }
示例#4
0
void CDatabaseReader::ReadCargoRow(CCargo& cargo, const sql::ResultSet& rs)
{
  cargo._weightKg = rs.getUInt("weightKg");
  cargo._liter = getDecimal(rs, "volumeM3", 3);   // volume
  cargo._units = rs.getUInt("volumeUnits");       // paletten;
  cargo._cargoType = rs.getString("cargoType");
}
示例#5
0
void CDatabaseReader::ReadTimePeriod(boost::posix_time::time_period& aTimePeriod,
                                     const sql::ResultSet& rs)
{
  using namespace boost::posix_time;
  using namespace boost::gregorian;

  std::string startStr = rs.getString("timeFrom");
  std::string endStr = rs.getString("timeUntil");
  ptime timeFrom = time_from_string(startStr);
  ptime timeUntil = time_from_string(endStr);

  if (timeFrom > timeUntil)
  {
    throw new CDBReaderException("reading bad time interval: timeFrom (" + startStr + ") is behind the timeUntil (" + endStr + ")");
  }

  aTimePeriod = time_period(timeFrom, timeUntil);
}
示例#6
0
CShipmentStation::EKind CDatabaseReader::ReadShipmentStationKind(const sql::ResultSet& rs)
{
  std::string kindStr = rs.getString("kind");
  boost::algorithm::to_lower(kindStr);
  if (kindStr == "load")
  {
    return CShipmentStation::KLoad;
  }
  else if (kindStr == "unload")
  {
    return CShipmentStation::KUnload;
  }
  else if (kindStr == "driveby")
  {
    return CShipmentStation::KDriveby;
  }
  else throw new CDBReaderException("Unknown kind of Shipment Station '" + kindStr + "' ??");
}