38 if (connDb ==
nullptr)
44 "values ($1, $2, $3)");
48 stmt->
SetInt(0, period_number);
50 if (end_datetime ==
nullptr)
57 cout <<
"ERROR: inserting new run period to the Database has been failed" << endl;
65 int tmp_period_number;
66 tmp_period_number = period_number;
68 tmp_start_datetime = start_datetime;
70 if (end_datetime ==
nullptr)
71 tmp_end_datetime =
nullptr;
73 tmp_end_datetime =
new TDatime(*end_datetime);
75 return new UniRunPeriod(connDb, tmp_period_number, tmp_start_datetime, tmp_end_datetime);
82 if (connDb ==
nullptr)
89 "where period_number = %d",
95 cout <<
"ERROR: getting run period from the database has been failed" << endl;
107 cout <<
"ERROR: run period was not found in the database" << endl;
114 int tmp_period_number;
115 tmp_period_number = stmt->
GetInt(0);
120 tmp_end_datetime =
nullptr;
126 return new UniRunPeriod(connDb, tmp_period_number, tmp_start_datetime, tmp_end_datetime);
133 if (connDb ==
nullptr)
140 "where period_number = %d",
146 cout <<
"ERROR: getting run period from the database has been failed" << endl;
173 if (connDb ==
nullptr)
179 "where period_number = $1");
183 stmt->
SetInt(0, period_number);
187 cout <<
"ERROR: deleting run period from the dataBase has been failed" << endl;
203 if (connDb ==
nullptr)
214 cout <<
"ERROR: getting all 'run periods' from the dataBase has been failed" << endl;
225 cout <<
"Table 'run_period':" << endl;
227 cout <<
"period_number: ";
228 cout << (stmt->
GetInt(0));
229 cout <<
", start_datetime: ";
230 cout << (stmt->
GetDatime(1)).AsSQLString();
231 cout <<
", end_datetime: ";
249 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
256 "set period_number = $1 "
257 "where period_number = $2");
261 stmt->
SetInt(0, period_number);
266 cout <<
"ERROR: updating information about run period has been failed" << endl;
281 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
288 "set start_datetime = $1 "
289 "where period_number = $2");
298 cout <<
"ERROR: updating information about run period has been failed" << endl;
313 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
320 "set end_datetime = $1 "
321 "where period_number = $2");
325 if (end_datetime ==
nullptr)
333 cout <<
"ERROR: updating information about run period has been failed" << endl;
341 if (end_datetime ==
nullptr)
353 cout <<
"Table 'run_period'";
355 <<
". end_datetime: " << (
ts_end_datetime ==
nullptr ?
"nullptr" : (*ts_end_datetime).AsSQLString()) << endl;
365 if (connDb ==
nullptr) {
366 cout <<
"ERROR: connection to the database was failed" << endl;
374 "where period_number = %d "
375 "order by run_number",
381 cout <<
"ERROR: getting run numbers from the database failed" << endl;
392 vecRuns.push_back(stmt->
GetInt(0));
397 int run_count = vecRuns.size();
399 for (
int i = 0;
i < run_count;
i++) {
411 if (connDb ==
nullptr) {
412 cout <<
"ERROR: connection to the database was failed" << endl;
420 "where period_number = %d ",
426 cout <<
"ERROR: getting run numbers from the database failed" << endl;
437 min_number = stmt->
GetInt(0);
449 if (connDb ==
nullptr) {
450 cout <<
"ERROR: connection to the database was failed" << endl;
458 "where period_number = %d ",
464 cout <<
"ERROR: getting run numbers from the database failed" << endl;
475 max_number = stmt->
GetInt(0);
493 if (connDb ==
nullptr) {
494 cout <<
"ERROR: connection to the database was failed" << endl;
502 "where '%s' <= end_datetime and '%s' >= start_datetime",
503 pcdatetime, pcdatetime);
508 cout <<
"ERROR: getting period number for specified datetim from the database failed" << endl;
518 cout <<
"WARNING: any period for the given datetime was not found" << endl;
523 int period_number = stmt->
GetInt(0);
528 return period_number;
const char * AsSQLString() const
virtual TSQLStatement * Statement(const char *, Int_t=100)
virtual Bool_t NextIteration()=0
virtual Bool_t NextResultRow()=0
Bool_t SetDatime(Int_t, const TDatime &)
virtual Int_t GetInt(Int_t)
virtual Bool_t IsNull(Int_t)
virtual Bool_t Process()=0
virtual Bool_t SetInt(Int_t, Int_t)
virtual Bool_t SetNull(Int_t)
virtual Bool_t StoreResult()=0
static TString Format(const char *fmt,...)
static UniConnection * Open()
TSQLServer * GetSQLServer()
int GetPeriodNumber()
get period number of the current run period
void Print()
print information about current run period
static UniRunPeriod * GetRunPeriod(int period_number)
get run period from the database
int SetEndDatetime(TDatime *end_datetime)
set end datetime of the current run period
int SetPeriodNumber(int period_number)
set period number of the current run period
TDatime ts_start_datetime
start datetime
TDatime * ts_end_datetime
end datetime
static int GetFirstRunNumber(int period_number)
get first run number for a selected period
int i_period_number
period number
UniConnection * connectionDB
connection to the database
static int CheckRunPeriodExists(int period_number)
check run period exists in the database: 1- true, 0 - false, <0 - database operation error
int SetStartDatetime(TDatime start_datetime)
set start datetime of the current run period
static int DeleteRunPeriod(int period_number)
delete run period from the database
static int GetLastRunNumber(int period_number)
get last run number for a selected period
static UniRunPeriod * CreateRunPeriod(int period_number, TDatime start_datetime, TDatime *end_datetime)
add new run period to the database
static int GetRunNumbers(UniqueRunNumber *&run_numbers, int period_number)
get numbers of runs existing in the Database for a selected period
static int PrintAll()
print all run periods
UniRunPeriod(UniConnection *db_connect, int period_number, TDatime start_datetime, TDatime *end_datetime)