36 if (connDb ==
nullptr)
42 "values ($1, $2, $3)");
46 stmt->
SetInt(0, record_id);
47 stmt->
SetInt(1, attachment_number);
52 cout <<
"ERROR: inserting new attachment to the Database has been failed" << endl;
61 tmp_record_id = record_id;
62 int tmp_attachment_number;
63 tmp_attachment_number = attachment_number;
65 tmp_file_path = file_path;
67 return new ElogAttachment(connDb, tmp_record_id, tmp_attachment_number, tmp_file_path);
74 if (connDb ==
nullptr)
81 "where record_id = %d and attachment_number = %d",
82 record_id, attachment_number);
87 cout <<
"ERROR: getting attachment from the database has been failed" << endl;
99 cout <<
"ERROR: attachment was not found in the database" << endl;
107 tmp_record_id = stmt->
GetInt(0);
108 int tmp_attachment_number;
109 tmp_attachment_number = stmt->
GetInt(1);
115 return new ElogAttachment(connDb, tmp_record_id, tmp_attachment_number, tmp_file_path);
122 if (connDb ==
nullptr)
129 "where lower(file_path) = lower('%s')",
135 cout <<
"ERROR: getting attachment from the database has been failed" << endl;
147 cout <<
"ERROR: attachment was not found in the database" << endl;
155 tmp_record_id = stmt->
GetInt(0);
156 int tmp_attachment_number;
157 tmp_attachment_number = stmt->
GetInt(1);
163 return new ElogAttachment(connDb, tmp_record_id, tmp_attachment_number, tmp_file_path);
170 if (connDb ==
nullptr)
177 "where record_id = %d and attachment_number = %d",
178 record_id, attachment_number);
183 cout <<
"ERROR: getting attachment from the database has been failed" << endl;
210 if (connDb ==
nullptr)
217 "where lower(file_path) = lower('%s')",
223 cout <<
"ERROR: getting attachment from the database has been failed" << endl;
250 if (connDb ==
nullptr)
256 "where record_id = $1 and attachment_number = $2");
260 stmt->
SetInt(0, record_id);
261 stmt->
SetInt(1, attachment_number);
265 cout <<
"ERROR: deleting attachment from the dataBase has been failed" << endl;
281 if (connDb ==
nullptr)
287 "where lower(file_path) = lower($1)");
295 cout <<
"ERROR: deleting attachment from the DataBase has been failed" << endl;
311 if (connDb ==
nullptr)
322 cout <<
"ERROR: getting all 'attachments' from the dataBase has been failed" << endl;
333 cout <<
"Table 'attachment_':" << endl;
335 cout <<
"record_id: ";
336 cout << (stmt->
GetInt(0));
337 cout <<
", attachment_number: ";
338 cout << (stmt->
GetInt(1));
339 cout <<
", file_path: ";
354 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
361 "set record_id = $1 "
362 "where record_id = $2 and attachment_number = $3");
366 stmt->
SetInt(0, record_id);
372 cout <<
"ERROR: updating information about attachment has been failed" << endl;
387 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
394 "set attachment_number = $1 "
395 "where record_id = $2 and attachment_number = $3");
399 stmt->
SetInt(0, attachment_number);
405 cout <<
"ERROR: updating information about attachment has been failed" << endl;
420 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
427 "set file_path = $1 "
428 "where record_id = $2 and attachment_number = $3");
438 cout <<
"ERROR: updating information about attachment has been failed" << endl;
453 cout <<
"Table 'attachment_'";
static ElogAttachment * GetAttachment(int record_id, int attachment_number)
get attachment from the database
void Print()
print information about current attachment
static int PrintAll()
print all attachments
TString str_file_path
file path
static int DeleteAttachment(int record_id, int attachment_number)
delete attachment from the database
static ElogAttachment * CreateAttachment(int record_id, int attachment_number, TString file_path)
add new attachment to the database
ElogConnection * connectionDB
connection to the database
int i_attachment_number
attachment number
int SetRecordId(int record_id)
set record id of the current attachment
ElogAttachment(ElogConnection *db_connect, int record_id, int attachment_number, TString file_path)
virtual ~ElogAttachment()
int SetFilePath(TString file_path)
set file path of the current attachment
int SetAttachmentNumber(int attachment_number)
set attachment number of the current attachment
static int CheckAttachmentExists(int record_id, int attachment_number)
check attachment exists in the database: 1- true, 0 - false, <0 - database operation error
static ElogConnection * Open()
TSQLServer * GetSQLServer()
virtual TSQLStatement * Statement(const char *, Int_t=100)
virtual const char * GetString(Int_t)
virtual Bool_t NextIteration()=0
virtual Bool_t NextResultRow()=0
virtual Bool_t SetString(Int_t, const char *, Int_t=256)
virtual Int_t GetInt(Int_t)
virtual Bool_t Process()=0
virtual Bool_t SetInt(Int_t, Int_t)
virtual Bool_t StoreResult()=0
const char * Data() const
static TString Format(const char *fmt,...)