sc3100.cpp Aggiunta gestione della mailbox (copiata dalla relapp)

sc3100a.uml Specificati i campi chiave e field in modo da simulare relapp


git-svn-id: svn://10.65.10.50/trunk@4371 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-05-22 08:53:34 +00:00
parent 07c3de37c9
commit 7ef9201c1c
2 changed files with 149 additions and 65 deletions

View File

@ -8,6 +8,8 @@
#include <printer.h>
#endif
#include <mailbox.h>
#include "sc3.h"
#include "sc3100a.h"
#include "sc3100b.h"
@ -31,6 +33,7 @@ class TForm_EC : public TForm
protected:
virtual void pre_edit_checks(TMask& m, TPrint_section* sec);
virtual bool post_edit_checks(TMask& m, TPrint_section* sec);
public:
virtual const char* section_mask() { return "sc3100s" ;}
virtual void change_number_format(int w, int dec, const char* p);
@ -79,8 +82,8 @@ bool TForm_EC::post_edit_checks(TMask& m, TPrint_section* sec)
void TForm_EC::change_number_format(int w, int dec, const char* p)
{
char secs[] = { "FB" };
char ptyp[] = { "LOEF" };
const char* const secs = "FB";
const char* const ptyp = "LOEF";
TPrint_section* ps;
for (int sc = 0; sc < 4; sc++)
@ -93,6 +96,7 @@ class TForm_EC_editor : public TForm_editor
{
s_data _prm;
TMask * _msk; // maschera di selezione sezione
protected:
static bool cpy_handler(TMask_field& f, KEY k);
static bool font_handler(TMask_field& f, KEY k);
@ -111,11 +115,16 @@ protected:
void hide_body_items(TPrint_section* b);
void show_body_items(TPrint_section* b);
void remove_form(TLocalisamfile& frm, TLocalisamfile& rfr,const TString& t,const TString& c);
virtual const char* selection_mask() const { return "sc3100a"; }
virtual bool ask_profile();
virtual bool edit(char s, pagetype p);
virtual void print();
bool check_mailbox(TMask& m);
public:
TForm_EC_editor() {_msk = NULL;}
virtual ~TForm_EC_editor() {}
};
@ -402,7 +411,7 @@ bool TForm_EC_editor::recalculate_positions(const char* name, int size)
xvt_print_start_thread (wprms, (long)&_prm);
xvt_print_close();
const char sechar[4] = { 'B', 'F', 'G', 'H' };
const char* const sechar = "BFGH";
for (int sn = 0; sn < 4 ; sn++)
{
const char sc = sechar[sn];
@ -415,10 +424,10 @@ bool TForm_EC_editor::recalculate_positions(const char* name, int size)
void TForm_EC_editor::remove_temp_items(char sec, pagetype p)
{
TPrint_section* s = form().exist(sec,p);
if (s!=NULL)
if (s != NULL)
{
const word items = s->fields();
for (word j=0;j<items; j++)
for (word j=0; j < items; j++)
{
if (s->field(j).temp())
s->destroy_field(j,FALSE);
@ -830,20 +839,24 @@ void TForm_EC_editor::remove_form(TLocalisamfile& frm, TLocalisamfile& rfr,const
bool TForm_EC_editor::ask_profile()
{
KEY k;
mask().set_handler(DLG_COPY,cpy_handler);
mask().set_handler(F_CODE,code_handler);
mask().set_handler(F_CODEL,lng_handler);
mask().set(F_BASE,BASE_EC_PROFILE);
TMask& m = mask();
m.set_handler(DLG_COPY,cpy_handler);
m.set_handler(F_CODE,code_handler);
m.set_handler(F_CODEL,lng_handler);
m.set(F_BASE,BASE_EC_PROFILE);
disable_menu_item(M_FILE_PRINT);
while ((k = mask().run()) != K_QUIT)
check_mailbox(m);
while ((k = m.run()) != K_QUIT)
{
TLocalisamfile frm(LF_FORM);
TLocalisamfile rfr(LF_RFORM);
TString fform = mask().get(F_BASE);
TString fdesc = mask().get(F_DESC);
long fcode = mask().get_long(F_CODE);
char flng = mask().get(F_CODEL)[0];
TString fform = m.get(F_BASE);
TString fdesc = m.get(F_DESC);
long fcode = m.get_long(F_CODE);
char flng = m.get(F_CODEL)[0];
TString cod;
cod.format("%04ld%c",fcode,flng);
if (!extra() && fcode == 0 && flng=='\0')
@ -892,6 +905,68 @@ bool TForm_EC_editor::ask_profile()
return FALSE;
}
bool TForm_EC_editor::check_mailbox(TMask& m)
{
TMailbox mail;
TMessage* msg = mail.next_s(MSG_ED);
if (msg)
{
TToken_string body(msg->body());
const int key = body.get_int();
TAssoc_array field_values;
const char * s;
TString80 t;
while((s = body.get()) != NULL)
{
t = s;
const int u = t.find('=');
CHECKS(u > 0, "Invalid edit message ", (const char *) body);
if (u > 0)
{
const TString v(t.mid(u + 1));
t.cut(u);
field_values.add(t, v);
}
}
TString val;
for (TEditable_field* e = m.get_key_field(key, TRUE); e; e = m.get_key_field(key, FALSE))
{
const TFieldref* field = e->field();
if (field)
{
TString16 field_name(field->name());
const int from = field->from();
const int to = field->to();
if (to >= 0)
field_name << "[" << (from + 1);
const TString * v = (const TString *) field_values.objptr(field_name);
if (v == NULL && to >= 0)
{
v = (const TString *)field_values.objptr(field->name());
if (v)
val = v->sub(from, to);
}
else
if (v) val = *v;
if (v)
e->set(val);
}
}
m.send_key(K_AUTO_ENTER, 0);
}
return TRUE;
}
int sc3100(int argc, char** argv)
{
TForm_EC_editor a;

View File

@ -6,81 +6,90 @@ PAGE "Scelta profilo" -1 -1 75 6
STRING F_BASE 8
BEGIN
PROMPT 2 1 "Profilo base "
FLAGS "DP"
PROMPT 2 1 "Profilo base "
FLAGS "DP"
END
NUMBER F_CODE 4
BEGIN
PROMPT 2 2 "Codice profilo "
FLAGS "Z"
HELP "Codice del profilo"
USE LF_FORM
JOIN %LNG TO LF_FORM ALIAS 200 INTO CODTAB==CODPROF[5,5]
INPUT TIPOPROF F_BASE SELECT
INPUT CODPROF[1,4] F_CODE
INPUT CODPROF[5,5] F_CODEL
DISPLAY "Profilo base" TIPOPROF
DISPLAY "Codice" CODPROF[1,4]
DISPLAY "Lingua" CODPROF[5,5]
DISPLAY "Descrizione@50" DESC
DISPLAY "Desc. Lingua@50" -200->S0
OUTPUT F_BASE TIPOPROF
OUTPUT F_CODE CODPROF[1,4]
OUTPUT F_CODEL CODPROF[5,5]
OUTPUT F_DESC DESC
PROMPT 2 2 "Codice profilo "
FLAGS "Z"
HELP "Codice del profilo"
USE LF_FORM
JOIN %LNG TO LF_FORM ALIAS 200 INTO CODTAB==CODPROF[5,5]
INPUT TIPOPROF F_BASE SELECT
INPUT CODPROF[1,4] F_CODE
INPUT CODPROF[5,5] F_CODEL
DISPLAY "Profilo base" TIPOPROF
DISPLAY "Codice" CODPROF[1,4]
DISPLAY "Lingua" CODPROF[5,5]
DISPLAY "Descrizione@50" DESC
DISPLAY "Desc. Lingua@50" -200->S0
OUTPUT F_BASE TIPOPROF
OUTPUT F_CODE CODPROF[1,4]
OUTPUT F_CODEL CODPROF[5,5]
OUTPUT F_DESC DESC
// Simula relapp
KEY 1
FIELD CODPROF[1,4]
END
STRING F_CODEL 1
BEGIN
PROMPT 40 2 "Codice lingua "
FLAGS "U"
HELP "Codice lingua del profilo"
USE %LNG
INPUT CODTAB F_CODEL
DISPLAY "Codice lingua" CODTAB
DISPLAY "Decrizione@50" S0
OUTPUT F_CODEL CODTAB
CHECKTYPE NORMAL
PROMPT 40 2 "Codice lingua "
FLAGS "U"
HELP "Codice lingua del profilo"
USE %LNG
INPUT CODTAB F_CODEL
DISPLAY "Codice lingua" CODTAB
DISPLAY "Decrizione@50" S0
OUTPUT F_CODEL CODTAB
CHECKTYPE NORMAL
// Simula relapp
KEY 1
FIELD CODPROF[5,5]
END
STRING F_DESC 50
BEGIN
PROMPT 2 3 "Descrizione "
HELP "Descrizione profilo utente"
USE LF_FORM KEY 2
JOIN %LNG TO LF_FORM ALIAS 200 INTO CODTAB==CODPROF[5,5]
INPUT TIPOPROF F_BASE SELECT
INPUT DESC F_DESC
DISPLAY "Descrizione@50" DESC
DISPLAY "Profilo base" TIPOPROF
DISPLAY "Codice" CODPROF[1,4]
DISPLAY "Lingua" CODPROF[5,5]
DISPLAY "Desc. Lingua@50" -200->S0
COPY OUTPUT F_CODE
VALIDATE NOT_EMPTY_FUNC
WARNING "La descrizione e' obbligatoria"
PROMPT 2 3 "Descrizione "
HELP "Descrizione profilo utente"
USE LF_FORM KEY 2
JOIN %LNG TO LF_FORM ALIAS 200 INTO CODTAB==CODPROF[5,5]
INPUT TIPOPROF F_BASE SELECT
INPUT DESC F_DESC
DISPLAY "Descrizione@50" DESC
DISPLAY "Profilo base" TIPOPROF
DISPLAY "Codice" CODPROF[1,4]
DISPLAY "Lingua" CODPROF[5,5]
DISPLAY "Desc. Lingua@50" -200->S0
COPY OUTPUT F_CODE
VALIDATE NOT_EMPTY_FUNC
WARNING "La descrizione e' obbligatoria"
// Simula relapp
KEY 2
FIELD S0
END
BUTTON DLG_OK 9 2
BUTTON DLG_OK 10 2
BEGIN
PROMPT -14 -1 ""
PROMPT -14 -1 ""
END
BUTTON DLG_DELREC 9 2
BUTTON DLG_DELREC 10 2
BEGIN
PROMPT -24 -1 ""
MESSAGE EXIT,K_DEL
PROMPT -24 -1 ""
MESSAGE EXIT,K_DEL
END
BUTTON DLG_COPY 9 2
BUTTON DLG_COPY 10 2
BEGIN
PROMPT -34 -1 "C~opia..."
PROMPT -34 -1 "C~opia..."
END
BUTTON DLG_QUIT 9 2
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -44 -1 ""
PROMPT -44 -1 ""
END
ENDPAGE