Correzioni su fascicolator e sfascicolator
git-svn-id: svn://10.65.10.50/trunk@6008 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c617d992bc
commit
e9327430fc
104
ba/ba1600.cpp
104
ba/ba1600.cpp
@ -87,6 +87,11 @@ int TInstall_ini::build_complete_list(const TString& module, TString_array& a,
|
||||
if (submodule.len() > 2)
|
||||
build_list(submodule, a, sommario, agg);
|
||||
}
|
||||
if (sommario && *sommario)
|
||||
{
|
||||
TConfig sum(sommario, "Main");
|
||||
sum.set("Demo", demo());
|
||||
}
|
||||
return a.items();
|
||||
}
|
||||
|
||||
@ -126,6 +131,19 @@ const TString& TInstall_ini::version(const char* module)
|
||||
return ver;
|
||||
}
|
||||
|
||||
long TInstall_ini::patch(const char* module)
|
||||
{
|
||||
CHECK(module && *module > ' ', "Can't get version of NULL module");
|
||||
long patch = get_long("Patch", module);
|
||||
if (patch == 0 && strlen(module) > 2)
|
||||
{
|
||||
TString16 str;
|
||||
str.strncpy(module, 2);
|
||||
patch = get_long("Patch", str);
|
||||
}
|
||||
return patch;
|
||||
}
|
||||
|
||||
bool TInstall_ini::update_prices(const char* from)
|
||||
{
|
||||
CHECK(fexist(from), "Can't find listino prezzi");
|
||||
@ -155,37 +173,25 @@ bool TInstall_ini::update_prices(const char* from)
|
||||
void TInstall_ini::prices(const char* module, word users,
|
||||
real& full, real& assist)
|
||||
{
|
||||
word min_user = 0;
|
||||
TAssoc_array& arr = list_variables(module);
|
||||
FOR_EACH_ASSOC_STRING(arr, obj, key, str)
|
||||
{
|
||||
const TFixed_string price(key);
|
||||
if (price.compare("Prezzo", 6, TRUE) == 0)
|
||||
real last_pac, last_ass;
|
||||
full = assist = 0.0;
|
||||
for (word u = 1; u <= users; u++)
|
||||
{
|
||||
TAuto_token_string prezzi = get("Prezzo", module, int(u));
|
||||
if (prezzi.not_empty())
|
||||
{
|
||||
const word user = atoi(key+7);
|
||||
if (user >= min_user && user <= users)
|
||||
{
|
||||
min_user = user;
|
||||
|
||||
TAuto_token_string tmp = str;
|
||||
full = tmp.get(0);
|
||||
if (full < 50000.0)
|
||||
full *= 1000.0;
|
||||
assist = tmp.get();
|
||||
if (assist < 50000.0)
|
||||
assist *= 1000.0;
|
||||
|
||||
if (user == 1 && users > 1)
|
||||
{
|
||||
full *= users;
|
||||
assist *= users;
|
||||
}
|
||||
|
||||
const int mese = TDate(TODAY).month();
|
||||
assist = assist * (12-mese) / 12;
|
||||
assist.round(-3);
|
||||
}
|
||||
last_pac = prezzi.get(0);
|
||||
if (last_pac < 50000.0)
|
||||
last_pac *= 1000.0;
|
||||
last_ass = prezzi.get();
|
||||
if (last_ass < 50000.0)
|
||||
last_ass *= 1000.0;
|
||||
const int mese = TDate(TODAY).month();
|
||||
last_ass = last_ass * (12-mese) / 12;
|
||||
last_ass.round(-3);
|
||||
}
|
||||
full += last_pac;
|
||||
assist += last_ass;
|
||||
}
|
||||
}
|
||||
|
||||
@ -605,6 +611,7 @@ void TModule_mask::save()
|
||||
|
||||
const TString module = get(F_MODULE);
|
||||
const TString version = ini.version(module);
|
||||
const long patch = ini.patch(module);
|
||||
|
||||
for (index = 0; index <= 9; index++)
|
||||
{
|
||||
@ -636,6 +643,7 @@ void TModule_mask::save()
|
||||
if (agg) tmp.add("X"); // Flag aggiornamento
|
||||
ini.set("File", tmp, sub, TRUE, index++);
|
||||
ini.set("Versione", version); // Aggiorna versione del sottomodulo
|
||||
ini.set("Patch", patch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -672,7 +680,7 @@ protected:
|
||||
bool zip_file(const char* archive, const char* file) const;
|
||||
int split_file(const TFilename& file, long size) const;
|
||||
bool move_file(const TFilename& file, const char* dir) const;
|
||||
bool zip_module(const TString& module, bool agg) const;
|
||||
bool zip_module(const TString& module, int patch_level, bool agg) const;
|
||||
|
||||
const TFilename& build_export_path(TFilename& path) const;
|
||||
|
||||
@ -719,14 +727,16 @@ bool TFascicolator_mask::save_handler(TMask_field& f, KEY k)
|
||||
TInstall_ini ini;
|
||||
ini.set_paragraph(module);
|
||||
ini.set("Versione", m.get(S_VERSION));
|
||||
ini.set("Patch", m.get(S_PATCHLEVEL));
|
||||
ini.set("Data", m.get(S_DATE));
|
||||
ini.set("Moduli", m.get(S_EXTERN));
|
||||
ini.set("PreProcess", m.get(S_PREPROCESS));
|
||||
ini.set("PostProcess", m.get(S_POSTPROCESS));
|
||||
}
|
||||
const int patch_level = m.get_int(S_PATCHLEVEL);
|
||||
const bool agg = f.dlg() == S_SAVEAGG;
|
||||
TFascicolator_mask& fm = (TFascicolator_mask&)m.get_sheet()->mask();
|
||||
fm.zip_module(module, agg);
|
||||
fm.zip_module(module, patch_level, agg);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -844,6 +854,9 @@ void TFascicolator_mask::load()
|
||||
tmp = ini.get("Versione");
|
||||
row.add(tmp);
|
||||
|
||||
tmp = ini.get("Patch");
|
||||
row.add(tmp);
|
||||
|
||||
tmp = ini.get("Data");
|
||||
row.add(tmp);
|
||||
|
||||
@ -886,6 +899,9 @@ void TFascicolator_mask::save()
|
||||
tmp = row->get(2);
|
||||
ini.set("Versione", tmp);
|
||||
|
||||
tmp = row->get();
|
||||
ini.set("Patch", tmp);
|
||||
|
||||
tmp = row->get();
|
||||
ini.set("Data", tmp);
|
||||
|
||||
@ -993,7 +1009,7 @@ int TFascicolator_mask::split_file(const TFilename& archive, long size) const
|
||||
TFilename cmd;
|
||||
xvt_fsys_convert_dir_to_str(&curdir, cmd.get_buffer(), cmd.size());
|
||||
cmd.add("zipsplit.pif");
|
||||
cmd << " -n " << size << " " << " -b " << archive.path() << " " << archive;
|
||||
cmd << " -n " << size << " -b " << archive.path() << " " << archive;
|
||||
|
||||
// Salta alla directory temporanea
|
||||
xvt_fsys_convert_str_to_dir((char*)archive.path(), &tmpdir);
|
||||
@ -1035,14 +1051,21 @@ int TFascicolator_mask::split_file(const TFilename& archive, long size) const
|
||||
return disks;
|
||||
}
|
||||
|
||||
bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
|
||||
bool TFascicolator_mask::zip_module(const TString& main_module, int patch_level, bool agg) const
|
||||
{
|
||||
TString_array arr;
|
||||
TInstall_ini ini;
|
||||
|
||||
TFilename sommario; sommario.tempdir();
|
||||
sommario.add(main_module);
|
||||
sommario << "inst.ini"; // Nome del file sommario completo
|
||||
if (agg)
|
||||
{
|
||||
TString16 name;
|
||||
name.format("%03da.ini", patch_level);
|
||||
sommario << name; // Nome del file sommario aggiornamento
|
||||
}
|
||||
else
|
||||
sommario << "inst.ini"; // Nome del file sommario completo
|
||||
|
||||
ini.build_complete_list(main_module, arr, sommario, agg);
|
||||
if (arr.items() == 0)
|
||||
@ -1063,7 +1086,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
|
||||
FILE * fileh=fopen((const char *)filelist,"w");
|
||||
TProgind pi(arr.items(), msg, TRUE, TRUE);
|
||||
TString cmd(120);
|
||||
|
||||
|
||||
FOR_EACH_ARRAY_ROW_BACK(arr, i, row)
|
||||
{
|
||||
pi.addstatus(1);
|
||||
@ -1072,12 +1095,12 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
|
||||
aborted = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = row->get(0);
|
||||
// Se non trovo anche uno solo dei files nella lista, è un casino
|
||||
if (_access(row->get(0),0))
|
||||
if (!fexist(cmd))
|
||||
{
|
||||
TString msg(128);
|
||||
msg << "Impossibile aprire il file " << row->get(0) << ". Interrompo ?";
|
||||
msg << "Impossibile aprire il file " << cmd << ". Interrompere?";
|
||||
if (yesno_box(msg))
|
||||
{
|
||||
aborted = TRUE;
|
||||
@ -1086,9 +1109,9 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
|
||||
}
|
||||
|
||||
// Aggiungo il nome corrente alla lista dei files da compattare
|
||||
cmd=row->get(0);
|
||||
cmd << '\n';
|
||||
fwrite(cmd, sizeof(char), cmd.len(),fileh);
|
||||
// fwrite(cmd, sizeof(char), cmd.len(),fileh);
|
||||
fputs(cmd, fileh);
|
||||
}
|
||||
fclose(fileh);
|
||||
|
||||
@ -1098,7 +1121,6 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
|
||||
// elimna il file lista-file
|
||||
fileh = fopen((const char *)filelist,"w");
|
||||
fclose(fileh);
|
||||
|
||||
|
||||
msg.cut(0);
|
||||
msg << "Separazione del file " << archivio << " ...";
|
||||
|
@ -18,6 +18,7 @@ public:
|
||||
|
||||
bool demo() { return get_bool("Demo", "Main"); }
|
||||
const TString& version(const char* module);
|
||||
long patch(const char* module);
|
||||
|
||||
bool update_prices(const char* src_ini);
|
||||
void prices(const char* module, word users, real& full, real& manut);
|
||||
|
@ -11,10 +11,11 @@
|
||||
#define S_FILE 101
|
||||
#define S_MODULE 102
|
||||
#define S_VERSION 103
|
||||
#define S_DATE 104
|
||||
#define S_EXTERN 105
|
||||
#define S_PREPROCESS 106
|
||||
#define S_POSTPROCESS 107
|
||||
#define S_PATCHLEVEL 104
|
||||
#define S_DATE 105
|
||||
#define S_EXTERN 106
|
||||
#define S_PREPROCESS 107
|
||||
#define S_POSTPROCESS 108
|
||||
|
||||
#define S_LIST 100
|
||||
#define S_SAVE 151
|
||||
|
@ -37,6 +37,7 @@ BEGIN
|
||||
ITEM "Modulo@30"
|
||||
ITEM "Cod."
|
||||
ITEM "Versione"
|
||||
ITEM "Patch"
|
||||
ITEM "Rilascio"
|
||||
ITEM "Moduli esterni@30"
|
||||
ITEM "Pre-processing@25"
|
||||
@ -61,11 +62,16 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING S_VERSION 6
|
||||
STRING S_VERSION 8
|
||||
BEGIN
|
||||
PROMPT 1 2 "Versione "
|
||||
END
|
||||
|
||||
STRING S_PATCHLEVEL 3
|
||||
BEGIN
|
||||
PROMPT 20 2 "Patch "
|
||||
END
|
||||
|
||||
DATE S_DATE
|
||||
BEGIN
|
||||
PROMPT 31 2 "Rilascio "
|
||||
|
119
ba/ba1700.cpp
119
ba/ba1700.cpp
@ -13,7 +13,7 @@
|
||||
#include "ba1600.h"
|
||||
#include "ba1700a.h"
|
||||
|
||||
HIDDEN int compare_version(const char* v1, const char* v2)
|
||||
HIDDEN int compare_version(const char* v1, long p1, const char* v2, long p2)
|
||||
{
|
||||
TString16 ver1(v1), ver2(v2);
|
||||
ver1.trim();
|
||||
@ -22,7 +22,14 @@ HIDDEN int compare_version(const char* v1, const char* v2)
|
||||
ver2.trim();
|
||||
if (ver2.len() == 4)
|
||||
ver2.insert((v2[0] == '9') ? "19" : "20", 0);
|
||||
return ver1.compare(ver2, -1, TRUE);
|
||||
|
||||
int res = ver1.compare(ver2, -1, TRUE);
|
||||
if (res == 0)
|
||||
{
|
||||
res = p1 == p2 ? 0 : (p1 > p2 ? +1 : -1);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
HIDDEN word version2year(const char* v)
|
||||
@ -52,6 +59,7 @@ protected:
|
||||
static bool install_handler(TMask_field& fld, KEY key);
|
||||
|
||||
bool add_module(TConfig& ini, const TString& module);
|
||||
int sort_modules();
|
||||
void update_version();
|
||||
|
||||
bool move_file(const TFilename& file, const char* dir) const;
|
||||
@ -66,7 +74,7 @@ protected:
|
||||
|
||||
public:
|
||||
bool autoload();
|
||||
bool install(const TString& module);
|
||||
bool install(const TString& module, long patch);
|
||||
|
||||
TInstaller_mask();
|
||||
virtual ~TInstaller_mask();
|
||||
@ -85,12 +93,52 @@ bool TInstaller_mask::add_module(TConfig& ini, const TString& module)
|
||||
row.add(ini.get("Descrizione"));
|
||||
row.add(module);
|
||||
row.add(ini.get("Versione"));
|
||||
row.add(ini.get("Patch"));
|
||||
row.add(ini.get("Data"));
|
||||
add(row);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int compare_modules(const TObject** o1, const TObject** o2)
|
||||
{
|
||||
TToken_string& ts1 = *(TToken_string*)(*o1);
|
||||
TToken_string& ts2 = *(TToken_string*)(*o2);
|
||||
|
||||
int res = 0;
|
||||
for (int i = 2; i < 5 && res == 0; i++)
|
||||
{
|
||||
TString16 s1 = ts1.get(i);
|
||||
const char* s2 = ts2.get(i);
|
||||
res = s1.compare(s2);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int TInstaller_mask::sort_modules()
|
||||
{
|
||||
rows_array().TArray::sort(compare_modules);
|
||||
|
||||
const int tot = int(items());
|
||||
TString16 dis, mod;
|
||||
for (int r = 0; r < tot; r++)
|
||||
{
|
||||
mod = row(r).get(2);
|
||||
if (dis == mod)
|
||||
{
|
||||
disable_row(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
long patch = row(r).get_long(4);
|
||||
if (patch == 0)
|
||||
dis = mod;
|
||||
}
|
||||
}
|
||||
return tot;
|
||||
}
|
||||
|
||||
void TInstaller_mask::update_version()
|
||||
{
|
||||
TInstall_ini ini;
|
||||
@ -103,8 +151,9 @@ void TInstaller_mask::update_version()
|
||||
|
||||
const TString16 newver = row->get(3);
|
||||
const TString16 oldver = ini.get("Versione");
|
||||
row->add(oldver, 5);
|
||||
row->add(ini.get("Data"), 6);
|
||||
row->add(oldver, 6);
|
||||
row->add(ini.get("Patch"), 7);
|
||||
row->add(ini.get("Data"), 8);
|
||||
}
|
||||
force_update();
|
||||
}
|
||||
@ -148,15 +197,29 @@ bool TInstaller_mask::autoload()
|
||||
TString& ininame = *row;
|
||||
ininame.lower();
|
||||
const int pos = ininame.find("inst.ini");
|
||||
CHECKS(pos > 2, "Invalid installation configuration: ", (const char*)ininame);
|
||||
CHECKS(pos >= 2, "Invalid installation configuration: ", (const char*)ininame);
|
||||
const TString16 module = ininame.mid(pos-2, 2);
|
||||
TConfig ini(ininame, module);
|
||||
add_module(ini, module);
|
||||
}
|
||||
|
||||
ininame = path;
|
||||
ininame.add("??0??a.ini");
|
||||
modules.destroy();
|
||||
list_files(ininame, modules);
|
||||
FOR_EACH_ARRAY_ROW(modules, am, arow)
|
||||
{
|
||||
TString& ininame = *arow;
|
||||
ininame.lower();
|
||||
const int pos = ininame.find("a.ini");
|
||||
CHECKS(pos >= 5, "Invalid installation configuration: ", (const char*)ininame);
|
||||
const TString16 module = ininame.mid(pos-5, 2);
|
||||
TConfig ini(ininame, module);
|
||||
add_module(ini, module);
|
||||
}
|
||||
}
|
||||
|
||||
rows_array().sort();
|
||||
const bool ok = items() > 0;
|
||||
const bool ok = sort_modules() > 0;
|
||||
if (ok)
|
||||
update_version();
|
||||
else
|
||||
@ -238,7 +301,7 @@ bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini)
|
||||
<< "':\nSi desidera procedere alla sua installazione?";
|
||||
ok = yesno_box(msg);
|
||||
if (ok)
|
||||
ok = install(submodule);
|
||||
ok = install(submodule, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,7 +354,7 @@ bool TInstaller_mask::move_file(const TFilename& file, const char* dir) const
|
||||
::remove(file);
|
||||
else
|
||||
{
|
||||
if (!yesno_box("Errore di copia del file %s.\nSi desidera riprovare?",
|
||||
if (!yesno_box("Errore di copia del file %s.\nSi desidera ritentare?",
|
||||
(const char*)file));
|
||||
user_abort = TRUE;
|
||||
}
|
||||
@ -329,14 +392,22 @@ bool TInstaller_mask::move_module(const TString& module, TInstall_ini& ini, bool
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TInstaller_mask::install(const TString& module)
|
||||
bool TInstaller_mask::install(const TString& module, long patchlevel)
|
||||
{
|
||||
bool ok = FALSE;
|
||||
|
||||
const TString& path = get(F_PATH);
|
||||
TFilename ininame = path;
|
||||
ininame.add(module);
|
||||
ininame << "inst.ini";
|
||||
|
||||
if (patchlevel > 0)
|
||||
{
|
||||
TString16 name;
|
||||
name.format("%03da.ini");
|
||||
ininame << name;
|
||||
}
|
||||
else
|
||||
ininame << "inst.ini";
|
||||
|
||||
if (fexist(ininame))
|
||||
{
|
||||
@ -422,8 +493,10 @@ bool TInstaller_mask::install(const TString& module)
|
||||
{
|
||||
TInstall_ini curini;
|
||||
const TString16 curver = curini.version(submod);
|
||||
const long curpatch = curini.patch(submod);
|
||||
const TString16 reqver = ini.version(submod);
|
||||
int distance =compare_version(reqver, curver) ;
|
||||
const long reqpatch = ini.patch(submod);
|
||||
int distance = compare_version(reqver, reqpatch, curver, curpatch);
|
||||
upd = distance> 0;
|
||||
if (!upd)
|
||||
{
|
||||
@ -526,7 +599,9 @@ void TInstaller_mask::install_selection()
|
||||
{
|
||||
const TString modulo = row->get(2);
|
||||
const TString newver = row->get(3);
|
||||
const TString oldver = row->get(5);
|
||||
const long newpatch = row->get_long(4);
|
||||
const TString oldver = row->get(6);
|
||||
const long oldpatch = row->get_long(7);
|
||||
|
||||
if (version2year(newver) < 1997)
|
||||
{
|
||||
@ -535,17 +610,19 @@ void TInstaller_mask::install_selection()
|
||||
}
|
||||
|
||||
bool ok = TRUE;
|
||||
const int cmp = compare_version(oldver, newver);
|
||||
const int cmp = compare_version(oldver, oldpatch, newver, newpatch);
|
||||
if (cmp < 0)
|
||||
ok = yesno_box("Si desidera installare la versione %s?", (const char*)newver);
|
||||
ok = yesno_box("Si desidera installare la versione %s.%ld?", (const char*)newver, newpatch);
|
||||
if (cmp == 0)
|
||||
ok = yesno_box("Si desidera reinstallare la versione %s?", (const char*)newver);
|
||||
ok = yesno_box("Si desidera reinstallare la versione %s.%ld?", (const char*)newver, newpatch);
|
||||
if (cmp > 0)
|
||||
ok = yesno_box("Si desidera ritornare alla versione %s?\n"
|
||||
ok = yesno_box("Si desidera ritornare alla versione %s.%ld?\n"
|
||||
"Attenzione: non e' garantito il corretto\n"
|
||||
"funzionamento di tutti i programmi!", (const char*)oldver);
|
||||
"funzionamento di tutti i programmi!", (const char*)newver, newpatch);
|
||||
if (ok)
|
||||
install(modulo);
|
||||
{
|
||||
install(modulo, newpatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,7 +652,7 @@ bool TInstaller_mask::on_key(KEY key)
|
||||
|
||||
TInstaller_mask::TInstaller_mask()
|
||||
: TArray_sheet(0, 0, 0, 0, "Installazione",
|
||||
"@1|Modulo@30|Cod.|Versione\nda installare@13|Data\nRilascio@10|Versione\nInstallata@10|Data\nInstallazione@13",
|
||||
"@1|Modulo@30|Cod.|Versione\nda installare@13|Livello\nPatch|Data\nRilascio@10|Versione\nInstallata@10|Livello\nPatch|Data\nInstallazione@13",
|
||||
0x18, 3)
|
||||
{
|
||||
_curr_mask = this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user