Changeset 25929 for trunk/ippTools/src
- Timestamp:
- Oct 22, 2009, 4:51:58 PM (17 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pubtool.c
r25256 r25929 32 32 33 33 static bool defineclientMode(pxConfig *config); 34 static bool updateclientMode(pxConfig *config); 34 35 static bool definerunMode(pxConfig *config); 35 36 static bool pendingMode(pxConfig *config); … … 57 58 switch (config->mode) { 58 59 MODECASE(PUBTOOL_MODE_DEFINECLIENT, defineclientMode); 60 MODECASE(PUBTOOL_MODE_UPDATECLIENT, updateclientMode); 59 61 MODECASE(PUBTOOL_MODE_DEFINERUN, definerunMode); 60 62 MODECASE(PUBTOOL_MODE_PENDING, pendingMode); … … 94 96 PXOPT_LOOKUP_STR(comment, config->args, "-comment", false, false); 95 97 96 if (!publishClientInsert(config->dbh, 0, product, stage, workdir, comment)) { 97 psError(PS_ERR_UNKNOWN, false, "Database error"); 98 return false; 99 } 98 if (!publishClientInsert(config->dbh, 0, 0, product, stage, workdir, comment)) { 99 psError(PS_ERR_UNKNOWN, false, "Database error"); 100 return false; 101 } 102 103 return true; 104 } 105 106 static bool updateclientMode(pxConfig *config) 107 { 108 PS_ASSERT_PTR_NON_NULL(config, false); 109 110 psMetadata *where = psMetadataAlloc(); // WHERE conditions 111 PXOPT_COPY_S64(config->args, where, "-client_id", "client_id", "=="); 112 PXOPT_COPY_STR(config->args, where, "-product", "product", "=="); 113 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 114 PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE"); 115 116 PXOPT_LOOKUP_BOOL(active, config->args, "-active", false); 117 PXOPT_LOOKUP_BOOL(inactive, config->args, "-inactive", false); 118 119 if ((!active && !inactive) || (active && inactive)) { 120 psError(PS_ERR_UNKNOWN, false, "Must specify one, and only one, of -active and -inactive."); 121 psFree(where); 122 return false; 123 } 124 125 psString query = NULL; // Query to run 126 psStringAppend(&query, "UPDATE publishRun SET active = %d", active ? 1 : 0); 127 128 if (psListLength(where->list)) { 129 psString clause = psDBGenerateWhereConditionSQL(where, NULL); 130 psStringAppend(&query, "\n AND %s", clause); 131 psFree(clause); 132 } 133 psFree(where); 134 135 if (!p_psDBRunQuery(config->dbh, query)) { 136 psError(PS_ERR_UNKNOWN, false, "Database error"); 137 psFree(query); 138 return false; 139 } 140 psFree(query); 141 142 long numUpdated = psDBAffectedRows(config->dbh); 143 psLogMsg("pubtool", PS_LOG_INFO, "%ld rows updated.", numUpdated); 100 144 101 145 return true; -
trunk/ippTools/src/pubtool.h
r24512 r25929 26 26 PUBTOOL_MODE_NONE = 0x0, 27 27 PUBTOOL_MODE_DEFINECLIENT, 28 PUBTOOL_MODE_UPDATECLIENT, 28 29 PUBTOOL_MODE_DEFINERUN, 29 30 PUBTOOL_MODE_PENDING, -
trunk/ippTools/src/pubtoolConfig.c
r25256 r25929 50 50 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-comment", 0, "define comment", NULL); 51 51 52 // -updateclient 53 psMetadata *updateclientArgs = psMetadataAlloc(); 54 psMetadataAddStr(updateclientArgs, PS_LIST_TAIL, "-client_id", 0, "search by client_id", NULL); 55 psMetadataAddStr(updateclientArgs, PS_LIST_TAIL, "-stage", 0, "search by stage", NULL); 56 psMetadataAddStr(updateclientArgs, PS_LIST_TAIL, "-product", 0, "search by product", NULL); 57 psMetadataAddStr(updateclientArgs, PS_LIST_TAIL, "-comment", 0, "search by comment (LIKE)", NULL); 58 psMetadataAddBool(updateclientArgs, PS_LIST_TAIL, "-active", 0, "set to active state", NULL); 59 psMetadataAddBool(updateclientArgs, PS_LIST_TAIL, "-inactive", 0, "set to inactive state", NULL); 60 52 61 // -definerun 53 62 psMetadata *definerunArgs = psMetadataAlloc(); … … 85 94 86 95 PXOPT_ADD_MODE("-defineclient", "", PUBTOOL_MODE_DEFINECLIENT, defineclientArgs); 96 PXOPT_ADD_MODE("-updateclient", "", PUBTOOL_MODE_UPDATECLIENT, updateclientArgs); 87 97 PXOPT_ADD_MODE("-definerun", "", PUBTOOL_MODE_DEFINERUN, definerunArgs); 88 98 PXOPT_ADD_MODE("-pending", "", PUBTOOL_MODE_PENDING, pendingArgs);
Note:
See TracChangeset
for help on using the changeset viewer.
