Patch level : 10.0

Files correlati     : bacnv.exe
Ricompilazione Demo : [ ]
Commento            :
Aggiunta conversione profile e maschere delle vendite in modo da aggiornare la gestione di commessa/fase


git-svn-id: svn://10.65.10.50/trunk@17123 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-08-28 11:22:25 +00:00
parent 3cd820072d
commit 34bbc4d456

View File

@ -1,23 +1,15 @@
#include <applicat.h> #include <applicat.h>
#include <assoc.h>
#include <mailbox.h> #include <mailbox.h>
#include <progind.h> #include <progind.h>
#include <prefix.h>
#include <relation.h> #include <relation.h>
#include <reputils.h>
#include <scanner.h> #include <scanner.h>
#include <sheet.h>
#include <tabutil.h> #include <tabutil.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <extcdecl.h> #include <extcdecl.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
#include <direct.h>
#define RMDIR _rmdir
#else
#define RMDIR rmdir
#endif
#include <causali.h> #include <causali.h>
#include <clifo.h> #include <clifo.h>
#include <mov.h> #include <mov.h>
@ -140,13 +132,10 @@ void TConversione_xbase::update()
end_wait(); end_wait();
} }
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// Applicazione di conversione archivi // Applicazione di conversione archivi
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
class TConversione_archivi : public TApplication class TConversione_archivi : public TApplication
{ {
int _nconv; int _nconv;
@ -159,6 +148,12 @@ protected: // TApplication
virtual bool destroy() ; virtual bool destroy() ;
virtual bool menu(MENU_TAG); virtual bool menu(MENU_TAG);
// Metodi per convert_profile
bool backup_text_file(TFilename& name, TLog_report& log) const;
bool rinumera_paragrafo(const TFilename& ini, const char* paragrafo,
const char* contatore, const char* variabile, TLog_report& log) const;
bool rinumera_maschera(const TFilename& msk, TLog_report& log) const;
public: public:
bool convert_rmov(TLocalisamfile & rmov, TArray & recs, int nrecs); bool convert_rmov(TLocalisamfile & rmov, TArray & recs, int nrecs);
void contropartita_rmov(); void contropartita_rmov();
@ -209,7 +204,7 @@ bool TConversione_archivi::create()
TApplication::create(); TApplication::create();
const int args = argc(); const int args = argc();
_nconv = atoi(argv(1)); _nconv = args > 1 ? abs(atoi(argv(1))) : 0;
if (_nconv > 1) if (_nconv > 1)
{ {
_oldditta = get_firm(); _oldditta = get_firm();
@ -362,8 +357,10 @@ bool TConversione_archivi::menu(MENU_TAG)
break; break;
case 22: case 22:
convert_pcon_ivd(); convert_pcon_ivd();
break;
case 23: case 23:
convert_profile(argv(2)); convert_profile(argv(2));
break;
default: default:
break; break;
} }
@ -540,7 +537,7 @@ void TConversione_archivi::zero_770()
for (int i = list.items()-1; i >= 0; i--) for (int i = list.items()-1; i >= 0; i--)
remove(list.row(i)); remove(list.row(i));
list.destroy(); list.destroy();
RMDIR(format("%scom/770", __ptprf)); xvt_fsys_rmdir(format("%scom/770", __ptprf));
} }
if (fexist(format("%s770", __ptprf))) if (fexist(format("%s770", __ptprf)))
{ {
@ -549,7 +546,7 @@ void TConversione_archivi::zero_770()
for (int i = list.items()-1; i >= 0; i--) for (int i = list.items()-1; i >= 0; i--)
remove(list.row(i)); remove(list.row(i));
list.destroy(); list.destroy();
RMDIR(format("%s770", __ptprf)); xvt_fsys_rmdir(format("%s770", __ptprf));
} }
} }
@ -667,9 +664,6 @@ if (d.eod() > 0L)
if (tpd == "NA") mov.put("TIPODOC","NC"); if (tpd == "NA") mov.put("TIPODOC","NC");
mov.rewrite(); mov.rewrite();
} }
}
{
} }
if (_codditta == 0) if (_codditta == 0)
{ {
@ -1934,55 +1928,213 @@ void TConversione_archivi::convert_pcon_ivd()
prefix().set(pref); prefix().set(pref);
} }
bool TConversione_archivi::backup_text_file(TFilename& name, TLog_report& log) const
{
TString msg;
msg << TR("Elaborazione ") << name;
log.log(0, "");
log.log(0, msg);
if (!name.custom_path())
{
log.log_error(TR("Il file non esiste!"));
return false;
}
if (name.find("custom") < 0)
{
log.log_error(TR("Il file non e' in una cartella custom!"));
return false;
}
TFilename bakname(name);
bakname << ".bak";
if (!bakname.exist())
{
msg.cut(0) << TR("Copia ") << name << TR(" in ") << bakname;
log.log(0, msg);
fcopy(name, bakname);
}
return true;
}
bool TConversione_archivi::rinumera_paragrafo(const TFilename& ininame, const char*paragrafo,
const char* contatore, const char* variabile,
TLog_report& log) const
{
TConfig p(ininame, paragrafo);
TString val = p.get( contatore, paragrafo );
if (val == "*")
return true; // Lascia stare tutto!
const int ncols = atoi(val);
const bool ok = p.remove(contatore) || ncols <= 0;
if (!ok)
{
log.log(1, TR("Il file risulta essere gia' stato convertito"));
return ok;
}
TString4 str;
for (int i = 1; i <= ncols; i++)
{
str.format("%d", i);
val = p.get(str);
p.remove(str);
p.set(variabile, val, NULL, true, i - 1);
}
return ok;
}
bool TConversione_archivi::rinumera_maschera(const TFilename& mskname, TLog_report& log) const
{
TFilename temp; temp.temp("msk");
if (mskname.exist()) // Dummy test
{
TString msg;
TScanner scan(mskname);
ofstream output(temp);
if (mskname.find("verig") > 0) // Maschera di riga
{
bool killing = false;
while (!scan.eof())
{
TString& line = scan.line();
if (!killing)
{
// Controllo per ammazzare i campi delle vecchie commesse 140,141,260,261
if (line.match("?? 14[0,1] [1,2]0*") || line.match("?? 26[0,1] *"))
{
msg.cut(0) << TR("Eliminazione campo ") << line;
log.log(1, msg);
killing = true; // Comincio a saltar righe fino ad EN
}
else
{
// Controllo se devo rinumerare i vecchi CODAGG da 142,143 a 152,153
if (line.match("?? 14[2,3] *")) // ST 142 12 -> ST 152 12
{
msg.cut(0) << TR("Rinumerazione campo ") << line;
log.log(1, msg);
line.overwrite("5", 4);
} else
if (line.match("IN * 14[2,3]")) // IN CODART 142 -> IN CODART 152
{
msg.cut(0) << TR("Rinumerazione campo ") << line;
log.log(1, msg);
line.overwrite("5", line.len()-2);
}
output << line << endl;
}
}
else
{
// Finisco di ammazzare quando raggiungo il token EN
if (line == "EN")
killing = false;
}
}
}
else // Maschera di testa
{
bool killing = false;
while (!scan.eof())
{
TString& line = scan.line();
if (!killing)
{
// Controllo per ammazzare i campi delle vecchie commesse 188,189,190,191
if (line.match("?? 18[8,9] *") || line.match("?? 19[0,1] *"))
{
msg.cut(0) << TR("Eliminazione campo ") << line;
log.log(1, msg);
killing = true; // Comincio a saltar righe fino ad EN
}
else
output << line << endl;
}
else
{
// Finisco di ammazzare quando raggiungo il token EN
if (line == "EN")
killing = false;
}
}
}
}
fcopy(temp, mskname);
temp.fremove();
return true;
}
void TConversione_archivi::convert_profile(const char* profile_name) void TConversione_archivi::convert_profile(const char* profile_name)
{ {
TConfig p(profile_name); TArray_sheet elenco(-1, -1, -4, -4,
TString16 str; TR("Profili da convertire"), TR("@1|Profilo@40|Maschera@40"));
int i;
int ncols = p.get_int( "NCOLS", "SHEET" ); TFilename name = profile_name;
p.remove("NCOLS"); name.ext("ini");
for (i = 1; i <= ncols; i++) if (name.custom_path()) // Esiste il profilo indicato?
{ {
str.format( "%d", i ); TToken_string row;
const TString16 val(p.get(str)); row = "X"; // preselezionato!
p.remove(str); row.add(name);
p.set("Col", val, NULL, true, i - 1); name.ext("msk");
if (name.exist()) // Esiste la maschera corrispondente?
{
row.add(name);
elenco.add(row);
}
} }
const int numtr = p.get_int( "NTIPIRIGA", "RIGHE" ); if (elenco.items() == 0) // Nessun nome valido specificato sulla riga di comando
p.remove( "NTIPIRIGA");
for (i = 1; i <= numtr; i ++ )
{ {
str.format("%d", i); name = prefix().get_studio();
const TString16 tiporiga(p.get(str)); name.add("custom");
p.remove(str); name.add("*.ini");
p.set("Tipo", tiporiga, NULL, true, i - 1); TString_array inis; list_files(name, inis);
FOR_EACH_ARRAY_ROW(inis, i, row)
{
TToken_string r;
r = "X"; // preselezionato
r.add(*row);
name = *row; name.ext("msk");
if (name.exist()) // Esiste la maschera corrispondente?
{
r.add(name);
elenco.add(r);
}
}
} }
const int hitems = p.get_int("NHANDLER", "HANDLERS"); if (elenco.run() == K_ENTER && elenco.one_checked())
p.remove("NHANDLER");
for (i = 1; i <= hitems; i++)
{ {
str.format("%d", i); TLog_report log(TR("Conversione maschere documenti"));
const TToken_string h(p.get(str));
p.remove(str); for (int r = 0; r < elenco.items(); r++) if (elenco.checked(r))
p.set("Handler", h, NULL, true, i - 1); {
name = elenco.row(r).get(1);
if (!backup_text_file(name, log))
continue;
const bool ok = rinumera_paragrafo(name, "SHEET", "NCOLS", "Col", log);
if (!ok)
continue; // Gia' elaborato!
rinumera_paragrafo(name, "RIGHE", "NTIPIRIGA", "Tipo", log);
rinumera_paragrafo(name, "HANDLERS", "NHANDLER", "Handler", log);
rinumera_paragrafo(name, "DEFAULT", "NDEFAULTS", "Default", log);
name = elenco.row(r).get(2);
if (backup_text_file(name, log))
rinumera_maschera(name, log);
} }
const int ditems = p.get_int("NDEFAULTS", "DEFAULT"); log.preview();
p.remove("NDEFAULTS");
for (i = 1; i <= ditems; i++)
{
str.format("%d", i);
const TToken_string h(p.get(str));
p.remove(str);
p.set("Default", h, NULL, true, i - 1);
} }
} }
@ -2003,12 +2155,12 @@ int main(int argc,char** argv)
if (r==0) if (r==0)
{ {
TConversione_xbase a; TConversione_xbase a;
a.run(argc,argv, "Conversione archivi di xBase"); a.run(argc,argv, TR("Conversione archivi di xBase"));
} }
else else
{ {
TConversione_archivi a ; TConversione_archivi a ;
a.run(argc, argv, "Conversione archivi"); a.run(argc, argv, TR("Conversione archivi"));
} }
return 0; return 0;