Changeset 23885 for trunk/ippTools/src/receivetool.c
- Timestamp:
- Apr 16, 2009, 12:39:27 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/receivetool.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/receivetool.c
r23880 r23885 33 33 static bool definesourceMode(pxConfig *config); 34 34 static bool listMode(pxConfig *config); 35 static bool definerunMode(pxConfig *config);35 static bool addfilesetMode(pxConfig *config); 36 36 static bool updatelastMode(pxConfig *config); 37 static bool pendingrunMode(pxConfig *config); 37 static bool pendingfilesetMode(pxConfig *config); 38 static bool addfileMode(pxConfig *config); 39 static bool pendingfileMode(pxConfig *config); 38 40 static bool addresultMode(pxConfig *config); 39 41 static bool revertMode(pxConfig *config); … … 60 62 MODECASE(RECEIVETOOL_MODE_DEFINESOURCE, definesourceMode); 61 63 MODECASE(RECEIVETOOL_MODE_LIST, listMode); 62 MODECASE(RECEIVETOOL_MODE_ DEFINERUN, definerunMode);64 MODECASE(RECEIVETOOL_MODE_ADDFILESET, addfilesetMode); 63 65 MODECASE(RECEIVETOOL_MODE_UPDATELAST, updatelastMode); 64 MODECASE(RECEIVETOOL_MODE_PENDINGRUN, pendingrunMode); 66 MODECASE(RECEIVETOOL_MODE_PENDINGFILESET, pendingfilesetMode); 67 MODECASE(RECEIVETOOL_MODE_ADDFILE, addfileMode); 68 MODECASE(RECEIVETOOL_MODE_PENDINGFILE, pendingfileMode); 65 69 MODECASE(RECEIVETOOL_MODE_ADDRESULT, addresultMode); 66 70 MODECASE(RECEIVETOOL_MODE_REVERT, revertMode); … … 100 104 101 105 if (!receiveSourceInsert(config->dbh, 0, source, product, workdir, comment, last)) { 102 psError(PS_ERR_UNKNOWN, false, " database error");106 psError(PS_ERR_UNKNOWN, false, "Database error"); 103 107 return false; 104 108 } … … 159 163 } 160 164 161 static bool definerunMode(pxConfig *config)165 static bool addfilesetMode(pxConfig *config) 162 166 { 163 167 PS_ASSERT_PTR_NON_NULL(config, false); … … 167 171 PXOPT_LOOKUP_STR(fileset, config->args, "-fileset", true, false); 168 172 169 if (!receive RunInsert(config->dbh, 0, source_id, fileset)) {170 psError(PS_ERR_UNKNOWN, false, " database error");173 if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset)) { 174 psError(PS_ERR_UNKNOWN, false, "Database error"); 171 175 return false; 172 176 } … … 198 202 199 203 200 static bool pending runMode(pxConfig *config)204 static bool pendingfilesetMode(pxConfig *config) 201 205 { 202 206 PS_ASSERT_PTR_NON_NULL(config, false); … … 207 211 PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "=="); 208 212 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "=="); 209 PXOPT_COPY_S 64(config->args, where, "-comment", "receiveSource.comment", "LIKE");210 211 psString query = pxDataGet("receivetool_pending run.sql");213 PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 214 215 psString query = pxDataGet("receivetool_pendingfileset.sql"); 212 216 if (!query) { 213 217 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); … … 240 244 return true; 241 245 } 242 if (!ippdbPrintMetadatas(stdout, output, "receive Run", true)) {246 if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", true)) { 243 247 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 244 248 psFree(output); … … 250 254 } 251 255 256 static bool addfileMode(pxConfig *config) 257 { 258 PS_ASSERT_PTR_NON_NULL(config, false); 259 260 // required 261 PXOPT_LOOKUP_S64(fileset_id, config->args, "-fileset_id", true, false); 262 PXOPT_LOOKUP_STR(file, config->args, "-file", true, false); 263 264 if (!receiveFileInsert(config->dbh, 0, fileset_id, file)) { 265 psError(PS_ERR_UNKNOWN, false, "Database error"); 266 return false; 267 } 268 269 return true; 270 } 271 272 static bool pendingfileMode(pxConfig *config) 273 { 274 PS_ASSERT_PTR_NON_NULL(config, false); 275 276 psMetadata *where = psMetadataAlloc(); // WHERE conditions 277 278 // required 279 PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "=="); 280 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "=="); 281 PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 282 PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.file_id", "=="); 283 284 psString query = pxDataGet("receivetool_pendingfile.sql"); 285 if (!query) { 286 psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement"); 287 psFree(where); 288 return false; 289 } 290 291 if (psListLength(where->list)) { 292 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 293 psStringAppend(&query, " AND %s", whereClause); 294 psFree(whereClause); 295 } 296 psFree(where); 297 298 if (!p_psDBRunQueryF(config->dbh, query)) { 299 psError(PS_ERR_UNKNOWN, false, "Database error"); 300 psFree(query); 301 return false; 302 } 303 psFree(query); 304 305 psArray *output = p_psDBFetchResult(config->dbh); 306 if (!output) { 307 psError(PS_ERR_UNKNOWN, false, "Database error"); 308 return false; 309 } 310 if (!psArrayLength(output)) { 311 psTrace("receivetool", PS_LOG_INFO, "No rows found"); 312 psFree(output); 313 return true; 314 } 315 if (!ippdbPrintMetadatas(stdout, output, "receiveFile", true)) { 316 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 317 psFree(output); 318 return false; 319 } 320 psFree(output); 321 322 return true; 323 } 324 252 325 static bool addresultMode(pxConfig *config) 253 326 { … … 255 328 256 329 // required 257 PXOPT_LOOKUP_S64( receive_id, config->args, "-source_id", true, false);330 PXOPT_LOOKUP_S64(fileset_id, config->args, "-source_id", true, false); 258 331 259 332 // optional … … 262 335 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false); 263 336 264 if (!receiveResultInsert(config->dbh, receive_id, dtime_copy, dtime_extract, fault)) {337 if (!receiveResultInsert(config->dbh, fileset_id, dtime_copy, dtime_extract, fault)) { 265 338 psError(PS_ERR_UNKNOWN, false, "Database error"); 266 339 return false; … … 276 349 psMetadata *where = psMetadataAlloc(); // WHERE conditions 277 350 278 PXOPT_COPY_S64(config->args, where, "- receive_id", "receiveResult.receive_id", "==");351 PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveResult.fileset_id", "=="); 279 352 PXOPT_COPY_S32(config->args, where, "-fault", "receiveResult.fault", "=="); 280 353 PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "==");
Note:
See TracChangeset
for help on using the changeset viewer.
