Patch level : 10.0 272
Files correlati : ca2.exe Ricompilazione Demo : [ ] Commento : Aggiunto esecuzione ripetuta dell' invio a Board. La linea di comando è ca2 -4 -M -uADMIN git-svn-id: svn://10.65.10.50/branches/R_10_00@23208 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8494445c99
commit
a379b353fe
545
ca/ca2500.cpp
545
ca/ca2500.cpp
@ -1,250 +1,295 @@
|
|||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <automask.h>
|
#include <automask.h>
|
||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
#include <odbcrset.h>
|
#include <odbcrset.h>
|
||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
|
||||||
#include "ca2500a.h"
|
#include "ca2500a.h"
|
||||||
|
|
||||||
class TBoard_msk : public TAutomask
|
class TBoard_msk : public TAutomask
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
virtual long handler(WINDOW task, EVENT* ep);
|
||||||
void update_sheet();
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||||
public:
|
void update_sheet();
|
||||||
TBoard_msk();
|
public:
|
||||||
};
|
TBoard_msk();
|
||||||
|
};
|
||||||
void TBoard_msk::update_sheet()
|
|
||||||
{
|
void TBoard_msk::update_sheet()
|
||||||
TSheet_field& s = sfield(F_FILES);
|
{
|
||||||
|
TSheet_field& s = sfield(F_FILES);
|
||||||
if (s.empty())
|
|
||||||
{
|
if (s.empty())
|
||||||
const TPrefix& prf = prefix();
|
{
|
||||||
const TIsam_handle ff[] = { LF_CLIFO, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA,
|
const TPrefix& prf = prefix();
|
||||||
LF_PCONANA, LF_MOVANA, LF_RMOVANA, LF_RMOVANAC,
|
const TIsam_handle ff[] = { LF_CLIFO, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA,
|
||||||
LF_COMMESSE, LF_CDC, LF_FASI, 0 };
|
LF_PCONANA, LF_MOVANA, LF_RMOVANA, LF_RMOVANAC,
|
||||||
for (int i = 0; ff[i]; i++)
|
LF_COMMESSE, LF_CDC, LF_FASI, 0 };
|
||||||
{
|
for (int i = 0; ff[i]; i++)
|
||||||
const TIsam_handle lf = ff[i];
|
{
|
||||||
const TFilename fn = prf.get_filename(lf);
|
const TIsam_handle lf = ff[i];
|
||||||
TToken_string& row = s.row(-1);
|
const TFilename fn = prf.get_filename(lf);
|
||||||
row.format(" |%d", lf);
|
TToken_string& row = s.row(-1);
|
||||||
row.add(fn.name_only());
|
row.format(" |%d", lf);
|
||||||
}
|
row.add(fn.name_only());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
TString query;
|
|
||||||
FOR_EACH_SHEET_ROW(s, r, row)
|
TString query;
|
||||||
{
|
FOR_EACH_SHEET_ROW(s, r, row)
|
||||||
query.format("USE %d", row->get_int(1));
|
{
|
||||||
TISAM_recordset c(query);
|
query.format("USE %d", row->get_int(1));
|
||||||
row->add(c.items(), 3);
|
TISAM_recordset c(query);
|
||||||
}
|
row->add(c.items(), 3);
|
||||||
s.force_update();
|
}
|
||||||
}
|
s.force_update();
|
||||||
|
}
|
||||||
bool TBoard_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
||||||
{
|
long TBoard_msk::handler(WINDOW task, EVENT* ep)
|
||||||
switch (o.dlg())
|
{
|
||||||
{
|
if (ep->type == E_TIMER)
|
||||||
case F_DATA_INI:
|
{
|
||||||
case F_DATA_FIN:
|
if (is_running())
|
||||||
if (e == fe_modify)
|
stop_run(K_ENTER);
|
||||||
update_sheet();
|
}
|
||||||
break;
|
return TAutomask::handler(task, ep);
|
||||||
case F_FILES:
|
}
|
||||||
if (e == se_query_add || e == se_query_del)
|
|
||||||
return false;
|
bool TBoard_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
default:
|
{
|
||||||
break;
|
switch (o.dlg())
|
||||||
}
|
{
|
||||||
return true;
|
case F_DATA_INI:
|
||||||
}
|
case F_DATA_FIN:
|
||||||
|
if (e == fe_modify)
|
||||||
TBoard_msk::TBoard_msk() : TAutomask("ca2500a")
|
update_sheet();
|
||||||
{
|
break;
|
||||||
TDate d(TODAY);
|
case F_FILES:
|
||||||
set(F_DATA_FIN, d);
|
if (e == se_query_add || e == se_query_del)
|
||||||
d.set_day(1);
|
return false;
|
||||||
set(F_DATA_INI, d, true);
|
default:
|
||||||
update_sheet();
|
break;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
class TBoard_app : public TSkeleton_application
|
}
|
||||||
{
|
|
||||||
protected:
|
TBoard_msk::TBoard_msk() : TAutomask("ca2500a")
|
||||||
bool create_table(const TString& DSN, TIsam_handle lf) const;
|
{
|
||||||
bool esporta(const TString& DSN, TIsam_handle lf, const TDate& datef, const TDate& datet) const;
|
TDate d(TODAY);
|
||||||
|
set(F_DATA_FIN, d);
|
||||||
public:
|
d.set_day(1);
|
||||||
virtual void main_loop();
|
set(F_DATA_INI, d, true);
|
||||||
};
|
update_sheet();
|
||||||
|
}
|
||||||
bool TBoard_app::create_table(const TString& DSN, TIsam_handle lf) const
|
|
||||||
{
|
class TBoard_app : public TSkeleton_application
|
||||||
TString query(1024);
|
{
|
||||||
TString table = prefix().get_filename(lf).name_only(); table.upper();
|
protected:
|
||||||
TODBC_recordset set("");
|
bool create_table(const TString& DSN, TIsam_handle lf) const;
|
||||||
|
bool esporta(const TString& DSN, TIsam_handle lf, const TDate& datef, const TDate& datet) const;
|
||||||
if (!set.connect(DSN))
|
|
||||||
return false;
|
public:
|
||||||
|
virtual void main_loop();
|
||||||
// query.format("SELECT * FROM %s.INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='%s'",
|
};
|
||||||
// (const char*)recset.dsn(), (const char*)table);
|
|
||||||
query.format("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='%s'",
|
bool TBoard_app::create_table(const TString& DSN, TIsam_handle lf) const
|
||||||
(const char*)table);
|
{
|
||||||
set.set(query);
|
TString query(1024);
|
||||||
if (set.items())
|
TString table = prefix().get_filename(lf).name_only(); table.upper();
|
||||||
return true;
|
TODBC_recordset set("");
|
||||||
|
|
||||||
query.cut(0) << "CREATE TABLE " << table << " (\n";
|
if (!set.connect(DSN))
|
||||||
const RecDes& rd = prefix().get_recdes(lf);
|
return false;
|
||||||
const bool access = set.driver() == ODBC_access;
|
|
||||||
|
// query.format("SELECT * FROM %s.INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='%s'",
|
||||||
for (int f = 0; f < rd.NFields; f++)
|
// (const char*)recset.dsn(), (const char*)table);
|
||||||
{
|
query.format("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='%s'",
|
||||||
const RecFieldDes& fd = rd.Fd[f];
|
(const char*)table);
|
||||||
if (f) query << ',';
|
set.set(query);
|
||||||
query << fd.Name << " ";
|
if (set.items())
|
||||||
switch (fd.TypeF)
|
return true;
|
||||||
{
|
|
||||||
case _alfafld: query << "varchar(" << fd.Len << ')'; break;
|
query.cut(0) << "CREATE TABLE " << table << " (\n";
|
||||||
case _realfld:
|
const RecDes& rd = prefix().get_recdes(lf);
|
||||||
{
|
const bool access = set.driver() == ODBC_access;
|
||||||
if (access)
|
|
||||||
query << "currency";
|
for (int f = 0; f < rd.NFields; f++)
|
||||||
else
|
{
|
||||||
query << "decimal(" << fd.Len << ',' << fd.Dec << ')';
|
const RecFieldDes& fd = rd.Fd[f];
|
||||||
break;
|
if (f) query << ',';
|
||||||
}
|
query << fd.Name << " ";
|
||||||
case _datefld: query << "date"; break;
|
switch (fd.TypeF)
|
||||||
case _boolfld: query << "bit"; break;
|
{
|
||||||
case _memofld:
|
case _alfafld: query << "varchar(" << fd.Len << ')'; break;
|
||||||
{
|
case _realfld:
|
||||||
if (access)
|
{
|
||||||
query << "longtext";
|
if (access)
|
||||||
else
|
query << "currency";
|
||||||
query << "varchar(max)";
|
else
|
||||||
break;
|
query << "decimal(" << fd.Len << ',' << fd.Dec << ')';
|
||||||
}
|
break;
|
||||||
default : query << "int"; break;
|
}
|
||||||
}
|
case _datefld: query << "date"; break;
|
||||||
}
|
case _boolfld: query << "bit"; break;
|
||||||
//query << ", CONSTRAINT Key0 PRIMARY KEY (";
|
case _memofld:
|
||||||
query << ", PRIMARY KEY (";
|
{
|
||||||
for (int i = 0; i < rd.Ky[0].NkFields; i++)
|
if (access)
|
||||||
{
|
query << "longtext";
|
||||||
const RecFieldDes& fd = rd.Fd[rd.Ky[0].FieldSeq[i] % 100];
|
else
|
||||||
|
query << "varchar(max)";
|
||||||
if (i > 0)
|
break;
|
||||||
query << ", ";
|
}
|
||||||
query << " " << fd.Name;
|
default : query << "int"; break;
|
||||||
}
|
}
|
||||||
query << "));";
|
}
|
||||||
set.exec(query);
|
//query << ", CONSTRAINT Key0 PRIMARY KEY (";
|
||||||
set.exec("COMMIT;");
|
query << ", PRIMARY KEY (";
|
||||||
return true;
|
for (int i = 0; i < rd.Ky[0].NkFields; i++)
|
||||||
}
|
{
|
||||||
|
const RecFieldDes& fd = rd.Fd[rd.Ky[0].FieldSeq[i] % 100];
|
||||||
|
|
||||||
bool TBoard_app::esporta(const TString& DSN, TIsam_handle lf, const TDate& datef, const TDate& datet) const
|
if (i > 0)
|
||||||
{
|
query << ", ";
|
||||||
TString sqlquery, dbfquery;
|
query << " " << fd.Name;
|
||||||
TToken_string keyexpr;
|
}
|
||||||
TODBC_recordset sqlset("", true);
|
query << "));";
|
||||||
|
set.exec(query);
|
||||||
if (!sqlset.connect(DSN))
|
set.exec("COMMIT;");
|
||||||
return false;
|
return true;
|
||||||
if (!create_table(DSN, lf))
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
TString table = prefix().get_filename(lf).name_only(); table.upper();
|
bool TBoard_app::esporta(const TString& DSN, TIsam_handle lf, const TDate& datef, const TDate& datet) const
|
||||||
|
{
|
||||||
sqlquery.cut(0) << "SELECT * FROM " << table;
|
TString sqlquery, dbfquery;
|
||||||
dbfquery << "USE " << lf;
|
TToken_string keyexpr;
|
||||||
|
TODBC_recordset sqlset("", true);
|
||||||
|
|
||||||
sqlset.begin();
|
if (!sqlset.connect(DSN))
|
||||||
|
return false;
|
||||||
sqlset.set(sqlquery);
|
if (!create_table(DSN, lf))
|
||||||
sqlset.move_first();
|
return false;
|
||||||
|
|
||||||
TISAM_recordset dbfset(dbfquery);
|
TString table = prefix().get_filename(lf).name_only(); table.upper();
|
||||||
TString msg("Esportazione tabella "); msg << table;
|
|
||||||
TProgind p(dbfset.items(), msg);
|
sqlquery.cut(0) << "SELECT * FROM " << table;
|
||||||
|
dbfquery << "USE " << lf;
|
||||||
if (dbfset.items() == 0)
|
|
||||||
{
|
|
||||||
if (sqlset.items() > 0L)
|
sqlset.begin();
|
||||||
{
|
|
||||||
TString table = prefix().get_filename(lf).name_only(); table.upper();
|
sqlset.set(sqlquery);
|
||||||
|
sqlset.move_first();
|
||||||
TString query("DELETE FROM "); query << table << ";";
|
|
||||||
sqlset.exec(query);
|
TISAM_recordset dbfset(dbfquery);
|
||||||
}
|
TString msg("Esportazione tabella "); msg << table;
|
||||||
}
|
TProgind p(dbfset.items(), msg);
|
||||||
else
|
|
||||||
if (sqlset.items() == 0L)
|
if (dbfset.items() == 0)
|
||||||
{
|
{
|
||||||
for (bool go = dbfset.move_first(); go&& !p.iscancelled(); go = dbfset.move_next())
|
if (sqlset.items() > 0L)
|
||||||
{
|
{
|
||||||
p.addstatus(1L);
|
TString table = prefix().get_filename(lf).name_only(); table.upper();
|
||||||
sqlset.create_rec(dbfset);
|
|
||||||
}
|
TString query("DELETE FROM "); query << table << ";";
|
||||||
}
|
sqlset.exec(query);
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
for (bool go = dbfset.move_first(); go && !p.iscancelled(); go = dbfset.move_next())
|
else
|
||||||
{
|
if (sqlset.items() == 0L)
|
||||||
int cmp = 1;
|
{
|
||||||
|
for (bool go = dbfset.move_first(); go&& !p.iscancelled(); go = dbfset.move_next())
|
||||||
p.addstatus(1L);
|
{
|
||||||
if (!sqlset.eof())
|
p.addstatus(1L);
|
||||||
{
|
sqlset.create_rec(dbfset);
|
||||||
cmp = sqlset.compare_key(dbfset);
|
}
|
||||||
while (!sqlset.eof() && cmp > 0)
|
}
|
||||||
{
|
else
|
||||||
sqlset.remove_rec(dbfset);
|
{
|
||||||
sqlset.move_next();
|
for (bool go = dbfset.move_first(); go && !p.iscancelled(); go = dbfset.move_next())
|
||||||
cmp = sqlset.compare_key(dbfset);
|
{
|
||||||
}
|
int cmp = 1;
|
||||||
}
|
|
||||||
|
p.addstatus(1L);
|
||||||
if (cmp == 0)
|
if (!sqlset.eof())
|
||||||
{
|
{
|
||||||
if (sqlset.compare_rec(dbfset)) // record modificato
|
cmp = sqlset.compare_key(dbfset);
|
||||||
sqlset.update_rec(dbfset);
|
while (!sqlset.eof() && cmp > 0)
|
||||||
sqlset.move_next();
|
{
|
||||||
}
|
sqlset.remove_rec(dbfset);
|
||||||
else
|
sqlset.move_next();
|
||||||
sqlset.create_rec(dbfset);
|
cmp = sqlset.compare_key(dbfset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlset.commit();
|
|
||||||
return true;
|
if (cmp == 0)
|
||||||
}
|
{
|
||||||
|
if (sqlset.compare_rec(dbfset)) // record modificato
|
||||||
void TBoard_app::main_loop()
|
sqlset.update_rec(dbfset);
|
||||||
{
|
sqlset.move_next();
|
||||||
TBoard_msk m;
|
}
|
||||||
while (m.run() == K_ENTER)
|
else
|
||||||
{
|
sqlset.create_rec(dbfset);
|
||||||
TSheet_field& s = m.sfield(F_FILES);
|
}
|
||||||
const TString& DSN = m.get(F_DSN);
|
}
|
||||||
const TDate datef = m.get(F_DATA_INI);
|
sqlset.commit();
|
||||||
const TDate datet = m.get(F_DATA_FIN);
|
return true;
|
||||||
FOR_EACH_SHEET_ROW(s, r, row) if (row->get_char(0) > ' ')
|
}
|
||||||
esporta(DSN, row->get_int(1), datef, datet);
|
|
||||||
}
|
void TBoard_app::main_loop()
|
||||||
}
|
{
|
||||||
|
TBoard_msk m;
|
||||||
|
bool batch = false;
|
||||||
int ca2500(int argc, char* argv[])
|
|
||||||
{
|
if (argc() > 2)
|
||||||
TBoard_app app;
|
{
|
||||||
app.run(argc, argv, TR("Invio a Board"));
|
const TFixed_string a(argv(2));
|
||||||
return 0;
|
|
||||||
}
|
batch = toupper(a[1]) == 'M';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (batch)
|
||||||
|
{
|
||||||
|
const WINDOW task =TASK_WIN;
|
||||||
|
WINDOW tray = xvt_trayicon_create(task, 10212, name()); // Washing machine
|
||||||
|
|
||||||
|
if (tray != NULL_WIN)
|
||||||
|
xvt_vobj_set_visible(task, FALSE);
|
||||||
|
xvt_timer_create(m.win(), 60 * 1000L);
|
||||||
|
while (m.run() == K_ENTER)
|
||||||
|
{
|
||||||
|
TSheet_field& s = m.sfield(F_FILES);
|
||||||
|
const TString& DSN = m.get(F_DSN);
|
||||||
|
const TDate datef = m.get(F_DATA_INI);
|
||||||
|
const TDate datet = m.get(F_DATA_FIN);
|
||||||
|
|
||||||
|
xvt_vobj_set_visible(task, TRUE);
|
||||||
|
FOR_EACH_SHEET_ROW(s, r, row) if (row->get_char(0) > ' ')
|
||||||
|
esporta(DSN, row->get_int(1), datef, datet);
|
||||||
|
xvt_vobj_set_visible(task, FALSE);
|
||||||
|
}
|
||||||
|
xvt_trayicon_destroy(tray);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (m.run() == K_ENTER)
|
||||||
|
{
|
||||||
|
TSheet_field& s = m.sfield(F_FILES);
|
||||||
|
const TString& DSN = m.get(F_DSN);
|
||||||
|
const TDate datef = m.get(F_DATA_INI);
|
||||||
|
const TDate datet = m.get(F_DATA_FIN);
|
||||||
|
FOR_EACH_SHEET_ROW(s, r, row) if (row->get_char(0) > ' ')
|
||||||
|
esporta(DSN, row->get_int(1), datef, datet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ca2500(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
TBoard_app app;
|
||||||
|
app.run(argc, argv, TR("Invio a Board"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user