diff --git a/apdUnitCreator.cpp b/apdUnitCreator.cpp index e2274b8ee5efca3f7cbfc777b8d72cd7522cba88..735e553bd6413d71eec6e22e0068ce7b76a78f7d 100644 --- a/apdUnitCreator.cpp +++ b/apdUnitCreator.cpp @@ -30,24 +30,29 @@ void processArgumentsAndQueryMissing(int m_argc, char* m_argv[]); void loadSerialsFromFileName(string m_fileName, bool m_debug = false); int main(int argc, char* argv[]) { - ProductionDatabaseClient *proddb = new ProductionDatabaseClient(); processArgumentsAndQueryMissing(argc, argv); + ProductionDatabaseClient *proddb = new ProductionDatabaseClient(); if (debug) cout << "Intitialized apdBoxSetter with version " << proddb->getVersion() << " of the database access libraries." << endl << endl << "Now trying to set Batch number " << boxNo << " for ADPs from serial file " << fileName << endl; loadSerialsFromFileName(fileName); -// if (username == "" || password == "") proddb->queryCredentials(); -// else proddb->setCredentials(username, password); -// DatabaseClientResponse response = proddb->checkConnectivityAndCredentials(); -// if (response != Successful ) { -// cerr << "Connection to database failed because of error: " << response << endl; -// return response; -// } -// if (debug) cout << "Connection successful!" << endl; - + if (username == "" || password == "") proddb->queryCredentials(); + else proddb->setCredentials(username, password); + DatabaseClientResponse response = proddb->checkConnectivityAndCredentials(); + if (response != Successful ) { + cerr << "Connection to database failed because of error: " << response << endl; + return response; + } + if (debug) cout << "Connection successful!" << endl; + for (auto newUnit = newUnits.begin(); newUnit < newUnits.end(); newUnit++) { + //proddb->createApdCapsule(newUnit->redSerial, newUnit->blueSerial); + std::string capsuleSerial = newUnit->redSerial + "/" + newUnit->blueSerial; + std::cerr << "Capsule serial should be " << capsuleSerial << std::endl; + //proddb->createApdUnit(capsuleSerial, newUnit->crystalSerial, newUnit->barCode); + } // cout << "\nBox " << boxNo << " was successfully assigned to APDs from serial file " << fileName << ". At least I hope so. In any case, something happened for " << apdSerials.size() << " APDs." // << "\nThank you for using apdBoxSetter! :)" << endl << endl;