[68] | 1 | #include <stdio.h> |
---|
| 2 | #include <string.h> |
---|
| 3 | #include <dirent.h> |
---|
| 4 | #include <sys/types.h> |
---|
| 5 | #include <sys/stat.h> |
---|
| 6 | #include <iterator> |
---|
| 7 | #include <time.h> |
---|
| 8 | #include <iostream> |
---|
| 9 | #include <cmath> |
---|
| 10 | using namespace std; |
---|
| 11 | |
---|
| 12 | #include "Produit.h" |
---|
| 13 | |
---|
| 14 | static char tampon [2048]; |
---|
| 15 | |
---|
| 16 | Produit::Produit() |
---|
| 17 | { |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | Produit::~Produit() |
---|
| 21 | { |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | //Mise ᅵ jour d'un produit |
---|
| 25 | void Produit::majProduit() |
---|
| 26 | { |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | //Insertion d'un nouveau produit |
---|
| 30 | void Produit::nvProduit() |
---|
| 31 | { |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | //Fonction de calcul des surfaces de pixels |
---|
| 35 | long double Produit::createAreaVincenty(Point point) |
---|
| 36 | { |
---|
| 37 | |
---|
| 38 | ////cout<< "point.lat, point.lon + pas/2 "<<point.lat<<" "<< point.lon + pas/2<<endl; |
---|
| 39 | |
---|
| 40 | Point* pBas = new Point(point.lat, point.lon + pas/2); |
---|
| 41 | //pBas->lat = point.lat; |
---|
| 42 | //pBas->lon =point.lon + pas/2; |
---|
| 43 | ////cout<<"lon pas/2 "<< pBas->lon <<endl; |
---|
| 44 | ////cout<<"pas/2 "<< pas/2 <<endl; |
---|
| 45 | Point* pHaut = new Point(point.lat+pas, point.lon + pas/2); |
---|
| 46 | //pHaut->lat = point.lat+pas; |
---|
| 47 | //pHaut->lon = point.lon + pas/2; |
---|
| 48 | ////cout<<"lon pas/2 "<< pHaut->lon <<endl; |
---|
| 49 | |
---|
| 50 | Point* pGauche = new Point(point.lat+pas/2, point.lon); |
---|
| 51 | //pGauche->lat = point.lat+pas/2; |
---|
| 52 | //pGauche->lon = point.lon; |
---|
| 53 | |
---|
| 54 | Point* pDroit = new Point(point.lat+pas/2, point.lon+pas); |
---|
| 55 | //pDroit->lat = point.lat+pas/2; |
---|
| 56 | //pDroit->lon = point.lon+pas; |
---|
| 57 | |
---|
| 58 | double distancePhautPbas = distance(pHaut, pBas)/1000; |
---|
| 59 | double distancePgauchePdroit = distance(pGauche, pDroit)/1000; |
---|
| 60 | |
---|
| 61 | delete pBas; |
---|
| 62 | delete pHaut; |
---|
| 63 | delete pGauche; |
---|
| 64 | delete pDroit; |
---|
| 65 | ////cout << "distancePhautPbas * distancePgauchePdroit "<<distancePhautPbas * distancePgauchePdroit <<endl; |
---|
| 66 | return ( (distancePhautPbas * distancePgauchePdroit) ); |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | long double Produit::distance(Point* p1, Point* p2) |
---|
| 72 | { |
---|
| 73 | ////cout<<"lon p1 "<<p1->lon<<" lat p2 "<<p2->lon<<endl; |
---|
| 74 | p1->lonRad = p1->lon * ((2*3.14159265)/360) ; |
---|
| 75 | p2->lonRad = p2->lon * ((2*3.14159265)/360) ; |
---|
| 76 | p1->latRad = p1->lat * ((2*3.14159265)/360) ; |
---|
| 77 | p2->latRad = p2->lat * ((2*3.14159265)/360) ; |
---|
| 78 | |
---|
| 79 | ////cout<<"lonrad p2 "<<p2->lonRad<<" lonrad p1 "<<p1->lonRad<<endl; |
---|
| 80 | long double L = p2->lonRad - p1->lonRad; |
---|
| 81 | ////cout<<"L "<<L<<endl; |
---|
| 82 | long double U1 = atan((1 - f) * tan(p1->latRad)); |
---|
| 83 | long double U2 = atan((1 - f) * tan(p2->latRad)); |
---|
| 84 | |
---|
| 85 | long double sinU1 = sin(U1); |
---|
| 86 | long double cosU1 = cos(U1); |
---|
| 87 | |
---|
| 88 | long double sinU2 = sin(U2); |
---|
| 89 | long double cosU2 = cos(U2); |
---|
| 90 | |
---|
| 91 | long double sinLambda = 0, cosLambda = 0, sinSigma = 0, cosSigma = 0, sigma = 0, sinAlpha = 0, cosSqAlpha = 0, cos2SigmaM = 0; |
---|
| 92 | long double lambda = L, lambdaP = 2* 3.14159265; |
---|
| 93 | long double iterLimit = 20; |
---|
| 94 | |
---|
| 95 | while( fabs(lambda-lambdaP) > 1e-12 && --iterLimit>0 ) |
---|
| 96 | { |
---|
| 97 | sinLambda = sin(lambda); |
---|
| 98 | cosLambda = cos(lambda); |
---|
| 99 | sinSigma = sqrt((cosU2*sinLambda) * (cosU2*sinLambda) + (cosU1*sinU2-sinU1*cosU2*cosLambda) * (cosU1*sinU2-sinU1*cosU2*cosLambda)); |
---|
| 100 | if (sinSigma==0) return 0; // co-incident points |
---|
| 101 | cosSigma = sinU1*sinU2 + cosU1*cosU2*cosLambda; |
---|
| 102 | sigma = atan2(sinSigma, cosSigma); |
---|
| 103 | sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma; |
---|
| 104 | cosSqAlpha = 1 - sinAlpha*sinAlpha; |
---|
| 105 | cos2SigmaM = cosSigma - 2*sinU1*sinU2/cosSqAlpha; |
---|
| 106 | if (isnan(cos2SigmaM)) cos2SigmaM = 0; // equatorial line: cosSqAlpha=0 (6) |
---|
| 107 | long double C = f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha)); |
---|
| 108 | lambdaP = lambda; |
---|
| 109 | lambda = L + (1-C) * f * sinAlpha * (sigma + C*sinSigma*(cos2SigmaM+C*cosSigma*(-1+2*cos2SigmaM*cos2SigmaM))); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | if (iterLimit == 0) return NAN; // formula failed to converge |
---|
| 113 | |
---|
| 114 | long double uSq = cosSqAlpha * (a*a - b*b) / (b*b); |
---|
| 115 | long double A = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq))); |
---|
| 116 | long double B = uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq))); |
---|
| 117 | long double deltaSigma = B*sinSigma*(cos2SigmaM+B/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)-B/6*cos2SigmaM*(-3+4*sinSigma*sinSigma)*(-3+4*cos2SigmaM*cos2SigmaM))); |
---|
| 118 | long double s = b*A*(sigma-deltaSigma); |
---|
| 119 | ////cout<<"s "<<s<<endl; |
---|
| 120 | return s; |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | long double Produit::distanceHaversine(Point* p1, Point* p2) |
---|
| 127 | { |
---|
| 128 | |
---|
| 129 | long double a = pow( sin((p2->lat-p1->lat)/2) ,2)+ cos(p2->lat) * pow( sin((p2->lon-p1->lon)/2) ,2); |
---|
| 130 | long double c = 2*atan2(sqrt(a), sqrt(1-a)); |
---|
| 131 | return R*c; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | long double Produit::createAreaHaversine(Point point) |
---|
| 135 | { |
---|
| 136 | Point* pBas = new Point(); |
---|
| 137 | pBas->lat = point.lat; |
---|
| 138 | pBas->lon =point.lon + pas/2; |
---|
| 139 | ////cout<<"lon pas/2 "<< pBas->lon <<endl; |
---|
| 140 | ////cout<<"pas/2 "<< pas/2 <<endl; |
---|
| 141 | Point* pHaut = new Point(); |
---|
| 142 | pHaut->lat = point.lat+pas; |
---|
| 143 | pHaut->lon = point.lon + pas/2; |
---|
| 144 | ////cout<<"lon pas/2 "<< pHaut->lon <<endl; |
---|
| 145 | |
---|
| 146 | Point* pGauche = new Point(); |
---|
| 147 | pGauche->lat = point.lat+pas/2; |
---|
| 148 | pGauche->lon = point.lon; |
---|
| 149 | |
---|
| 150 | Point* pDroit = new Point(); |
---|
| 151 | pDroit->lat = point.lat+pas/2; |
---|
| 152 | pDroit->lon = point.lon+pas; |
---|
| 153 | |
---|
| 154 | double distancePhautPbas = distanceHaversine(pHaut, pBas)/1000; |
---|
| 155 | double distancePgauchePdroit = distanceHaversine(pGauche, pDroit)/1000; |
---|
| 156 | |
---|
| 157 | delete pBas; |
---|
| 158 | delete pHaut; |
---|
| 159 | delete pGauche; |
---|
| 160 | delete pDroit; |
---|
| 161 | return ( distancePhautPbas * distancePgauchePdroit ); |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | char* Produit::getExtensionFileRead(char* fichier) |
---|
| 167 | { |
---|
| 168 | |
---|
| 169 | string fichierStr = fichier; |
---|
| 170 | |
---|
| 171 | string nomFich = SplitFilename(fichier); |
---|
| 172 | size_t found = (nomFich).find_last_of(".") ; |
---|
| 173 | |
---|
| 174 | //if ((nomFich).substr(found+1, nomFich.length() ) != NULL ) |
---|
| 175 | fichierStr=(nomFich).substr(found+1, nomFich.length()); |
---|
| 176 | //else |
---|
| 177 | //fichierStr=""; |
---|
| 178 | |
---|
| 179 | return (char*)fichierStr.c_str(); |
---|
| 180 | /* |
---|
| 181 | char* fich = fichier; |
---|
| 182 | while (strchr(fich, '/') != NULL) |
---|
| 183 | { |
---|
| 184 | fich = strchr(fich, '/')+1; |
---|
| 185 | } |
---|
| 186 | if ( strchr(fich, '.') != NULL ) |
---|
| 187 | fich = strchr(fich, '.')+1; |
---|
| 188 | else fich = ""; |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | return fich;*/ |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | //------------------------------------Fonctions de lecture des donnï¿œes brutes-------------------------------------------// |
---|
| 198 | |
---|
| 199 | //Scan d'un repertoire : determiner les sous repertoires et les fichiers |
---|
| 200 | |
---|
| 201 | Repertoire Produit::scanRep(Repertoire rep) |
---|
| 202 | { |
---|
| 203 | struct dirent *item; |
---|
| 204 | static struct stat stat_item; |
---|
| 205 | DIR *dirp; |
---|
| 206 | char *addr; |
---|
| 207 | ////cout<<"-----------------------------------------ScanRep------------------------------------"<<endl; |
---|
| 208 | if ((dirp = opendir(rep.chemin)) != NULL) |
---|
| 209 | { |
---|
| 210 | strcpy(tampon, rep.chemin); |
---|
| 211 | strcat(tampon, "/"); |
---|
| 212 | addr= &tampon[strlen(tampon)]; |
---|
| 213 | |
---|
| 214 | |
---|
| 215 | while ((item=readdir(dirp)) != NULL) |
---|
| 216 | { |
---|
| 217 | strcpy(addr, item->d_name); |
---|
| 218 | if (!stat(tampon, &stat_item)) |
---|
| 219 | { |
---|
| 220 | if (S_ISDIR(stat_item.st_mode)) |
---|
| 221 | { |
---|
| 222 | if (strcmp(item->d_name, ".") && strcmp(item->d_name, "..")) |
---|
| 223 | { |
---|
| 224 | Repertoire child; |
---|
| 225 | child.allouRep(stat_item,item->d_name, tampon, rep.level); |
---|
| 226 | rep.children.push_back(child); |
---|
| 227 | |
---|
| 228 | } |
---|
| 229 | } |
---|
| 230 | else |
---|
| 231 | { |
---|
| 232 | Feuille fich = Feuille(stat_item, item->d_name,tampon, rep.level); |
---|
| 233 | rep.fichier.push_back(fich); |
---|
| 234 | ////cout<<item->d_name<<" "<<tampon<<endl; |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | } |
---|
| 238 | ////cout<<"-----------------------------------------ScanRep------------------------------------"<<endl; |
---|
| 239 | |
---|
| 240 | } |
---|
| 241 | else |
---|
| 242 | { |
---|
| 243 | //logger->addReadersMessagesErrors("Impossible d'ouvrir le perertoire : "+rep.chemin); |
---|
| 244 | //cout << " ---> Impossible d'ouvrir le repertoire : " << rep.chemin << endl; |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | return(rep); |
---|
| 248 | |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | //iterer sur toute l'arborescence |
---|
| 252 | void Produit::scanParcour(Repertoire rep) |
---|
| 253 | { |
---|
| 254 | rep = scanRep(rep); |
---|
| 255 | parcourRep(rep); |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | //--------------------------------------------------------------------------------------------------------------------// |
---|
| 259 | |
---|
| 260 | void Produit::parcourRep(Repertoire rep) |
---|
| 261 | { |
---|
| 262 | if (!rep.children.empty()) |
---|
| 263 | { |
---|
| 264 | list<Repertoire>::iterator it; |
---|
| 265 | for (it = rep.children.begin(); it != rep.children.end(); it++) |
---|
| 266 | { |
---|
| 267 | scanParcour((*it)); |
---|
| 268 | } |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | if (!rep.fichier.empty()) |
---|
| 272 | { |
---|
| 273 | base.readBD(logger); |
---|
| 274 | //cout << " traitement des fichiers du repertoire : "<< rep.nom << endl; |
---|
| 275 | |
---|
| 276 | bool verifExt; |
---|
| 277 | |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | list<Feuille>::iterator itt; |
---|
| 281 | for (itt = rep.fichier.begin(); itt != rep.fichier.end(); itt++) |
---|
| 282 | { |
---|
| 283 | |
---|
| 284 | if(!strcmp("NULL", extension)) |
---|
| 285 | verifExt=true; |
---|
| 286 | else |
---|
| 287 | verifExt=!strcmp(getExtensionFileRead((*itt).chemin),extension); |
---|
| 288 | |
---|
| 289 | ////cout << (*itt).chemin <<" "<< (*itt).nom <<" "<<ctime(&((*itt).stt.st_ctime))<<" ++++ " <<endl; |
---|
| 290 | |
---|
| 291 | ////cout << (*itt).chemin <<" "<< (*itt).nom <<" "<<" ++++ "<<endl; |
---|
| 292 | |
---|
| 293 | ////cout<<"id"<<base.produit.getTuple(NomProduit)->id<<endl; |
---|
| 294 | //cout<<strcmp(getExtensionFileRead((*itt).chemin), extension)<<"--"<< (*itt).chemin <<"--"<<extension<<endl; |
---|
| 295 | ////cout<< rep.fichier.size()<<" ////////////////"<<endl; |
---|
| 296 | if ( ( verifExt && base.fichier.verifDate(ctime(&((*itt).stt.st_ctime)), base.produit.getTuple(NomProduit)->id, (*itt).nom) ) || ( !strcmp("", extension) && base.fichier.verifDate(ctime(&((*itt).stt.st_ctime)), base.produit.getTuple(NomProduit)->id, (*itt).nom) ) ) |
---|
| 297 | { |
---|
| 298 | ////cout<<"-----------verifDate------------"<< base.fichier.verifDate(ctime(&((*itt).stt.st_ctime)), base.produit.getTuple(NomProduit)->id, (*itt).nom) <<(*itt).chemin <<endl; |
---|
| 299 | |
---|
| 300 | ////cout<< !strcmp(strchr((*itt).chemin , '.')+1, extension)<<"//////8888//////////"<<endl; |
---|
| 301 | ////cout << ".......... Traitement du fichier "<<(*itt).chemin<<" "<< (*itt).nom <<endl; |
---|
| 302 | // //cout << ".......... Traitement du fichier : "<<" "<< (*itt).nom <<endl; |
---|
| 303 | readFile((*itt)); |
---|
| 304 | ////cout << ".......... fin Traitement du fichier : "<<endl; |
---|
| 305 | } |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | ////cout<< rep.fichier.size()<<" ////////////////"<<endl; |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | if (rep.children.empty() && rep.fichier.empty()) |
---|
| 312 | { |
---|
| 313 | //logger->addReadersMessagesErrors("Le repertoire : "+rep.chemin+"est vide"); |
---|
| 314 | printf("--- Le repertoire : %s est vide \n", rep.chemin); |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | void Produit::deleteProduct(string idProduct) |
---|
| 319 | { |
---|
| 320 | PGconn* conn = base.connectBD(logger); |
---|
| 321 | string sql = "delete from grille where id_produit ="+idProduct+";"; |
---|
| 322 | ////cout << sql << endl; |
---|
| 323 | |
---|
| 324 | PGresult* res = PQexec(conn, sql.c_str()); |
---|
| 325 | if ( PQresultStatus(res) != PGRES_TUPLES_OK) |
---|
| 326 | { |
---|
| 327 | logger->traitementBaseMessages(" DELETE GRILLE " , res); |
---|
| 328 | ////cout<<"delete"<<endl; |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | sql = "delete from fichier where id_produit ="+idProduct+";"; |
---|
| 332 | ////cout << sql << endl; |
---|
| 333 | |
---|
| 334 | res = PQexec(conn, sql.c_str()); |
---|
| 335 | if ( PQresultStatus(res) != PGRES_TUPLES_OK) |
---|
| 336 | { |
---|
| 337 | logger->traitementBaseMessages(" DELETE FICHIER " , res); |
---|
| 338 | ////cout<<"delete fichier"<<endl; |
---|
| 339 | } |
---|
| 340 | PQfinish(conn); |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | bool Produit::chercheFichierRep(Rowfichier fichier, Repertoire rep) |
---|
| 344 | { |
---|
| 345 | rep = scanRep(rep); |
---|
| 346 | ////cout<<"repchercheFichierRep "<<rep.nom<<endl; |
---|
| 347 | bool trouve = false; |
---|
| 348 | if (!rep.children.empty()) |
---|
| 349 | { |
---|
| 350 | ////cout<<"children"<<endl; |
---|
| 351 | list<Repertoire>::iterator itRep; |
---|
| 352 | for (itRep = rep.children.begin(); itRep != rep.children.end(); itRep++) |
---|
| 353 | { |
---|
| 354 | Repertoire reper = scanRep((*itRep)); |
---|
| 355 | trouve = chercheFichierRep(fichier, reper); |
---|
| 356 | } |
---|
| 357 | } |
---|
| 358 | if (trouve) return trouve; |
---|
| 359 | else |
---|
| 360 | { |
---|
| 361 | list<Feuille>::iterator itt; |
---|
| 362 | ////cout<<"taille "<<rep.fichier.size()<<endl; |
---|
| 363 | ////cout<<"nom rep "<<rep.chemin<<endl; |
---|
| 364 | //if (rep.fichier.empty()) return trouve; |
---|
| 365 | for (itt = rep.fichier.begin(); itt != rep.fichier.end(); itt++) |
---|
| 366 | { |
---|
| 367 | /*if (fichier.idProduit == base.produit.getTuple(NomProduit)->id) |
---|
| 368 | {*/ |
---|
| 369 | ////cout <<(*itt).nom<<" "<<fichier.name<<endl; |
---|
| 370 | if( ( fichier.idProduit == base.produit.getTuple(NomProduit)->id ) && ( !strcmp((*itt).nom, (fichier.name).c_str()) ) ) |
---|
| 371 | { |
---|
| 372 | ////cout <<(*itt).nom<<" ** "<<fichier.name<<endl; |
---|
| 373 | trouve = true; |
---|
| 374 | return trouve; |
---|
| 375 | break; |
---|
| 376 | } |
---|
| 377 | //} |
---|
| 378 | } |
---|
| 379 | } |
---|
| 380 | return trouve; |
---|
| 381 | |
---|
| 382 | } |
---|
| 383 | |
---|
| 384 | |
---|
| 385 | |
---|
| 386 | bool Produit::fichierAbst(Tabfichier tabFichier, Repertoire rep) |
---|
| 387 | { |
---|
| 388 | |
---|
| 389 | ////cout << "fonction fichierAbst " <<rep.nom <<endl; |
---|
| 390 | bool absent; |
---|
| 391 | ////cout<<"tabFichier"<<tabFichier.tuples.size()<<endl; |
---|
| 392 | ////cout<<"rep"<<rep.fichier.size()<<endl; |
---|
| 393 | if ( !tabFichier.tuples.empty() ) |
---|
| 394 | { |
---|
| 395 | absent = false; |
---|
| 396 | rep = scanRep(rep); |
---|
| 397 | |
---|
| 398 | list<Rowfichier>::iterator it; |
---|
| 399 | |
---|
| 400 | for (it = tabFichier.tuples.begin() ; it != tabFichier.tuples.end(); it++) |
---|
| 401 | { |
---|
| 402 | if ((*it).idProduit == base.produit.getTuple(NomProduit)->id) |
---|
| 403 | { |
---|
| 404 | if(!chercheFichierRep((*it), rep)) |
---|
| 405 | { |
---|
| 406 | ////cout<<"absent boucle"<<endl; |
---|
| 407 | absent = true; |
---|
| 408 | break; |
---|
| 409 | } |
---|
| 410 | } |
---|
| 411 | } |
---|
| 412 | } |
---|
| 413 | else absent=false; |
---|
| 414 | |
---|
| 415 | ////cout<<"absent "<<absent<<endl; |
---|
| 416 | return absent; |
---|
| 417 | |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | void Produit::readFile(Feuille f) |
---|
| 421 | { |
---|
| 422 | } |
---|
| 423 | |
---|
| 424 | void Produit::verifMinMax(float min, float max) |
---|
| 425 | { |
---|
| 426 | Base baseVerif; |
---|
| 427 | baseVerif.readBD(logger); |
---|
| 428 | |
---|
| 429 | float minBase = atof( (baseVerif.parametre.getTuple(NomParametre)->minCalculate).c_str() ); |
---|
| 430 | float maxBase = atof( (baseVerif.parametre.getTuple(NomParametre)->maxCalculate).c_str() ); |
---|
| 431 | |
---|
| 432 | if (min < minBase) |
---|
| 433 | { |
---|
| 434 | PGconn* conn = base.connectBD(logger); |
---|
| 435 | string sql = "update parametre set min_param_calculate ="+ ftoa(min) +" where id_param="+ base.parametre.getTuple(NomParametre)->id +";"; |
---|
| 436 | ////cout<<"sql "<<sql<<endl; |
---|
| 437 | ////cout<<"minBase "<<minBase<<endl; |
---|
| 438 | PGresult* res = PQexec(conn, sql.c_str()); |
---|
| 439 | PQfinish(conn); |
---|
| 440 | |
---|
| 441 | |
---|
| 442 | |
---|
| 443 | /*if ( PQresultStatus(res) != PGRES_TUPLES_OK) |
---|
| 444 | { |
---|
| 445 | logger->traitementBaseMessages(" UPDATE PARAM MIN " , res); |
---|
| 446 | }*/ |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | |
---|
| 450 | |
---|
| 451 | |
---|
| 452 | if (max > maxBase) |
---|
| 453 | { |
---|
| 454 | PGconn* conn = base.connectBD(logger); |
---|
| 455 | string sql = "update parametre set max_param_calculate ="+ ftoa(max) +" where id_param="+ base.parametre.getTuple(NomParametre)->id +";"; |
---|
| 456 | ////cout<<"sql "<<sql<<endl; |
---|
| 457 | ////cout<<"maxBase "<<maxBase<<endl; |
---|
| 458 | PGresult* res = PQexec(conn, sql.c_str()); |
---|
| 459 | ////cout<<"ok"<<endl; |
---|
| 460 | PQfinish(conn); |
---|
| 461 | |
---|
| 462 | /*if ( PQresultStatus(res) != PGRES_TUPLES_OK) |
---|
| 463 | { |
---|
| 464 | logger->traitementBaseMessages(" UPDATE PARAM MAX " , res); |
---|
| 465 | }*/ |
---|
| 466 | } |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | |
---|
| 470 | |
---|
| 471 | |
---|