Patch level :
Files correlati : ha1.exe Ricompilazione Demo : [ ] Commento : Corretta creazione file di testo per concentratore: ora viene creato un file .tmp che viene rinominato in .txt solo alla fine della scrittura in modo da evitare problemi di sincronizzazione. git-svn-id: svn://10.65.10.50/branches/R_10_00@22437 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									4ff9f8ecf0
								
							
						
					
					
						commit
						c4376d1cab
					
				
							
								
								
									
										114
									
								
								ha/ha1200.cpp
									
									
									
									
									
								
							
							
						
						
									
										114
									
								
								ha/ha1200.cpp
									
									
									
									
									
								
							@ -88,23 +88,30 @@ protected:
 | 
			
		||||
 | 
			
		||||
  void fill_anagrafica_cliente(const TISAM_recordset& archivio_clienti, 
 | 
			
		||||
                               TEsporta_clienti_recordset& clienti, const bool is_fatt = false);
 | 
			
		||||
  TFilename genera_path(const TString& prefisso);
 | 
			
		||||
 | 
			
		||||
  bool salva_recordset(TRecordset& recset, const char* nome) const;
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TFilename TFile2Txt::genera_path(const TString& prefisso)
 | 
			
		||||
bool TFile2Txt::salva_recordset(TRecordset& recset, const char* nome) const
 | 
			
		||||
{
 | 
			
		||||
  TFilename output_path;
 | 
			
		||||
  output_path = _output_path;
 | 
			
		||||
  output_path.add(prefisso);
 | 
			
		||||
  output_path.ext(".txt");
 | 
			
		||||
  return output_path;
 | 
			
		||||
  output_path.add(nome);
 | 
			
		||||
  output_path.ext(".tmp");
 | 
			
		||||
  output_path.lower();
 | 
			
		||||
  bool ok = recset.save_as(output_path, fmt_text);
 | 
			
		||||
  if (ok)
 | 
			
		||||
  {
 | 
			
		||||
    TFilename txt_path = output_path;
 | 
			
		||||
    txt_path.ext("txt");
 | 
			
		||||
    txt_path.fremove();              // Cancello nome.txt (potrebbe esistere)
 | 
			
		||||
    ::rename(output_path, txt_path); // rinomino nome.tmp in nome.txt
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
    cantwrite_box(output_path);
 | 
			
		||||
  return ok;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool TFile2Txt::genera_agenti_txt()
 | 
			
		||||
{
 | 
			
		||||
  //AS400 recordset da riempire (da lui nascerà il .txt)
 | 
			
		||||
@ -129,20 +136,13 @@ bool TFile2Txt::genera_agenti_txt()
 | 
			
		||||
    agenti.set(AGE_RAGSOC, archivio_agenti.get(AGE_RAGSOC));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //prepara il nome corretto del file .txt e lo genera
 | 
			
		||||
  TFilename output_path = genera_path("agenti");
 | 
			
		||||
  //..e alla fine della fiera salva il file di testo nell directory selezionata
 | 
			
		||||
  if (!agenti.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(agenti, "agenti");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void TFile2Txt::fill_anagrafica_cliente(const TISAM_recordset& archivio_clienti,
 | 
			
		||||
                                        TEsporta_clienti_recordset& clienti, const bool is_fatt)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    clienti.set_fatt("RagioneSociale", archivio_clienti.get(CLI_RAGSOC), is_fatt);
 | 
			
		||||
 | 
			
		||||
    TString80 indcf = archivio_clienti.get(CLI_INDCF).as_string();
 | 
			
		||||
@ -300,11 +300,7 @@ bool TFile2Txt::genera_clienti_txt(const long da_codcli)
 | 
			
		||||
 | 
			
		||||
  } //for (bool ok = archivio_clienti.move_first()...
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("clienti");
 | 
			
		||||
  if (!clienti.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(clienti, "clienti");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -370,11 +366,7 @@ bool TFile2Txt::genera_sospesi_txt(const long da_codcli)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("sospesi");
 | 
			
		||||
  if (!sospesi.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(sospesi, "sospesi");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//listini: i commenti del metodo sono nella genera_listino_txt() della ha1100
 | 
			
		||||
@ -427,11 +419,7 @@ bool TFile2Txt::genera_righelistini_txt()
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("listini");
 | 
			
		||||
  if (!righe_listini.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(righe_listini, "listini");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -477,11 +465,7 @@ bool TFile2Txt::genera_contratti_txt()
 | 
			
		||||
    righe_contratti.set(CONDV_VALFIN, hd_format_date8(datafine));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("particolari");
 | 
			
		||||
  if (!righe_contratti.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(righe_contratti, "particolari");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TFile2Txt::genera_promozioni_txt()
 | 
			
		||||
@ -506,11 +490,7 @@ bool TFile2Txt::genera_promozioni_txt()
 | 
			
		||||
    //non si sa quali campi trasferire!
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("promo");
 | 
			
		||||
  if (!righe_offerte.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(righe_offerte, "promo");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//prodotti: i commenti del metodo sono nella genera_prodotto_txt() della ha1100
 | 
			
		||||
@ -553,11 +533,7 @@ bool TFile2Txt::genera_prodotti_txt()
 | 
			
		||||
    prodotti.set("Fascia", archivio_anamag.get(ANAMAG_USER4).as_string().left(1));  
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("prodotti");
 | 
			
		||||
  if (!prodotti.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(prodotti, "prodotti");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TFile2Txt::genera_barcode_txt()
 | 
			
		||||
@ -587,11 +563,7 @@ bool TFile2Txt::genera_barcode_txt()
 | 
			
		||||
    barcode.set(CODCORR_CODART, codice_art);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("barcode");
 | 
			
		||||
  if (!barcode.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(barcode, "barcode");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -619,11 +591,7 @@ bool TFile2Txt::genera_decodart_txt()
 | 
			
		||||
    decodart.set(CODCORR_CODARTALT, archivio_codcorr.get(CODCORR_CODARTALT));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("decodart");
 | 
			
		||||
  if (!decodart.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(decodart, "decodart");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -663,9 +631,7 @@ bool TFile2Txt::genera_attrezzature_txt()
 | 
			
		||||
    attrezzature.set("DataFabbricazione", hd_format_date8(data_fabb));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path_att = genera_path("attrezzature");
 | 
			
		||||
  if (!attrezzature.save_as(output_path_att, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path_att);
 | 
			
		||||
  salva_recordset(attrezzature, "attrezzature");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  //esporta lo storico attrezzature (tabella &HAHIS)
 | 
			
		||||
@ -710,11 +676,7 @@ bool TFile2Txt::genera_attrezzature_txt()
 | 
			
		||||
    storico.set("ChiusuraComodato", archivio_storico.get("B0"));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path_sto = genera_path("storico");
 | 
			
		||||
  if (!storico.save_as(output_path_sto, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path_sto);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(storico, "storico");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TFile2Txt::genera_tabpag_txt()
 | 
			
		||||
@ -744,11 +706,7 @@ bool TFile2Txt::genera_tabpag_txt()
 | 
			
		||||
    tabpag.set("GiorniScadenza", giorni);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("tabpag");
 | 
			
		||||
  if (!tabpag.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(tabpag, "tabpag");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TFile2Txt::genera_carico_txt(const TMask& mask)
 | 
			
		||||
@ -802,11 +760,7 @@ bool TFile2Txt::genera_carico_txt(const TMask& mask)
 | 
			
		||||
    carico.set("CodiceLotto", archivio_rdoc.get(RDOC_LIVELLO));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("carico");
 | 
			
		||||
  if (!carico.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(carico, "carico");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TFile2Txt::genera_ripristino_txt(const TMask& mask)
 | 
			
		||||
@ -851,11 +805,7 @@ bool TFile2Txt::genera_ripristino_txt(const TMask& mask)
 | 
			
		||||
    ripristino.set("CodiceLotto", archivio_mag.get(MAG_LIVELLO));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  TFilename output_path = genera_path("carico");
 | 
			
		||||
  if (!ripristino.save_as(output_path, fmt_text))
 | 
			
		||||
    return cantwrite_box(output_path);
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
  return salva_recordset(ripristino, "carico");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//metodo di alto livello per la gestione delle chiamate
 | 
			
		||||
@ -926,8 +876,8 @@ TMask* TFile2Txt::create_mask() const
 | 
			
		||||
{
 | 
			
		||||
  TMask* mask = new TFile2Txt_mask;
 | 
			
		||||
  mask->set(F_OUTPUT_PATH, _output_path);
 | 
			
		||||
  mask->set(F_CONC_PATH, _conc_path);
 | 
			
		||||
  mask->set(F_TRANS_PATH, _trans_path);
 | 
			
		||||
  //mask->set(F_CONC_PATH, _conc_path);
 | 
			
		||||
  //mask->set(F_TRANS_PATH, _trans_path);
 | 
			
		||||
  return mask;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -56,6 +56,7 @@ bool THardy_transaction::wait_for_file(const TFilename& filename) const
 | 
			
		||||
  return last_size > 0L;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
void THardy_transaction::chiudi_concentratore()
 | 
			
		||||
{
 | 
			
		||||
  TFilename bat_chiudi = _conc_path;
 | 
			
		||||
@ -97,7 +98,7 @@ void THardy_transaction::trasmetti_concentratore()
 | 
			
		||||
  TExternal_app app_trasm(bat_trasm);
 | 
			
		||||
  app_trasm.run();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
void THardy_transaction::main_loop()
 | 
			
		||||
{
 | 
			
		||||
@ -152,12 +153,14 @@ void THardy_transaction::main_loop()
 | 
			
		||||
    while (mask->run() == K_ENTER)
 | 
			
		||||
    {
 | 
			
		||||
      //se è il server -> esegue le operazioni di elaborazione, viene fatta la preview diretta del log
 | 
			
		||||
      if (i_am_server)
 | 
			
		||||
      
 | 
			
		||||
      // if (i_am_server)  // Non c'è più distinzione tra server e client
 | 
			
		||||
      {
 | 
			
		||||
        log.reset();
 | 
			
		||||
        elabora(*mask, log);
 | 
			
		||||
        log.preview();
 | 
			
		||||
      }
 | 
			
		||||
      /*
 | 
			
		||||
      else  //senno' prepara il .ini per l'elaborazione postinica
 | 
			
		||||
      {
 | 
			
		||||
        TFilename trans = _trans_path;
 | 
			
		||||
@ -185,6 +188,7 @@ void THardy_transaction::main_loop()
 | 
			
		||||
          trans.fremove();
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      */
 | 
			
		||||
    }
 | 
			
		||||
  } //if(by_postino(...
 | 
			
		||||
 | 
			
		||||
@ -198,8 +202,6 @@ bool THardy_transaction::create()
 | 
			
		||||
  _output_path = config.get("OutputPath");
 | 
			
		||||
  _input_path = config.get("InputPath");
 | 
			
		||||
  _archive_path = config.get("ArchivePath");
 | 
			
		||||
  _conc_path = config.get("ConcentratorePath");
 | 
			
		||||
  _trans_path = config.get("TransactionPath");
 | 
			
		||||
 | 
			
		||||
  if (!_output_path.exist())
 | 
			
		||||
    return error_box(FR("Non esiste la cartella di destinazione %s!"), (const char*)_output_path);
 | 
			
		||||
@ -211,12 +213,14 @@ bool THardy_transaction::create()
 | 
			
		||||
    return error_box(FR("Non esiste la cartella di archiviazione dei files processati %s!"), (const char*)_archive_path);
 | 
			
		||||
 | 
			
		||||
  /* Controllo inutile
 | 
			
		||||
  _conc_path = config.get("ConcentratorePath");
 | 
			
		||||
  if (!_conc_path.exist())
 | 
			
		||||
    return error_box(FR("Non esiste la cartella del concentratore %s!"), (const char*)_conc_path);
 | 
			
		||||
  TFilename conc_prog_path = _conc_path;
 | 
			
		||||
  conc_prog_path.add("ProgettoConcentratore.exe");
 | 
			
		||||
  if (!conc_prog_path.exist())
 | 
			
		||||
    return error_box(FR("Il programma concentratore non si trova nella cartella %s!"), (const char*)_conc_path);
 | 
			
		||||
  _trans_path = config.get("TransactionPath");
 | 
			
		||||
  if (!_trans_path.exist())
 | 
			
		||||
    return error_box(FR("Non esiste la cartella di transazione %s!"), (const char*)_trans_path);
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,8 @@
 | 
			
		||||
class THardy_transaction : public TSkeleton_application
 | 
			
		||||
{
 | 
			
		||||
protected:
 | 
			
		||||
  TFilename _output_path, _input_path, _archive_path, _conc_path, _trans_path;
 | 
			
		||||
  TFilename _output_path, _input_path, _archive_path;
 | 
			
		||||
  //TFilename _conc_path, _trans_path;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  virtual void elabora(const TMask& mask, TLog_report& log) pure;
 | 
			
		||||
 | 
			
		||||
@ -1450,8 +1450,8 @@ TMask* TUpload2Campo::create_mask() const
 | 
			
		||||
  TMask* mask = new TUpload2Campo_mask;
 | 
			
		||||
  mask->set(F_INPUT_PATH, _input_path);
 | 
			
		||||
  mask->set(F_ARCHIVE_PATH, _archive_path);
 | 
			
		||||
  mask->set(F_CONC_PATH, _conc_path);
 | 
			
		||||
  mask->set(F_TRANS_PATH, _trans_path);
 | 
			
		||||
  //mask->set(F_CONC_PATH, _conc_path);
 | 
			
		||||
  //mask->set(F_TRANS_PATH, _trans_path);
 | 
			
		||||
  return mask;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user