Patch level : 12.0 no patch
Files correlati : Commento : Aggiunto ai record il campo update_memo per verificare se un memo è stato mofificato
This commit is contained in:
		
							parent
							
								
									18284e3fb7
								
							
						
					
					
						commit
						4443d366f4
					
				@ -712,8 +712,7 @@ TBaseisamfile::TBaseisamfile(
 | 
			
		||||
 | 
			
		||||
TBaseisamfile::~TBaseisamfile()
 | 
			
		||||
{
 | 
			
		||||
  if (_current)
 | 
			
		||||
    delete _current;
 | 
			
		||||
	SAFE_DELETE(_current);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TCodeb_handle TBaseisamfile::handle(int key) const
 | 
			
		||||
@ -940,6 +939,8 @@ int TBaseisamfile::_write(const TRectype& rec)
 | 
			
		||||
  { 
 | 
			
		||||
		if (rec.has_memo())
 | 
			
		||||
      ((TRectype&)rec).write_memo(_isam_handle, _recno );
 | 
			
		||||
		rec_cache(_logicnum).notify_change();
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
    _lasterr = get_error(_lasterr);
 | 
			
		||||
@ -980,6 +981,7 @@ int TBaseisamfile::rewrite_write()
 | 
			
		||||
int TBaseisamfile::_rewrite(const TRectype& rec)
 | 
			
		||||
{
 | 
			
		||||
  CHECK(!rec.empty(), "Can't write an empty record");
 | 
			
		||||
	bool changed = false;
 | 
			
		||||
    
 | 
			
		||||
  TRectype save_rec(rec);
 | 
			
		||||
 | 
			
		||||
@ -1004,18 +1006,23 @@ int TBaseisamfile::_rewrite(const TRectype& rec)
 | 
			
		||||
			else
 | 
			
		||||
        _lasterr = get_error(_lasterr);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
 		DB_unlock(fhnd);  // non vale la pena farlo sempre ?
 | 
			
		||||
    _recno = DB_recno(fhnd);
 | 
			
		||||
    prefix().unlock_record(_isam_handle, _recno);
 | 
			
		||||
 | 
			
		||||
		if (_lasterr == NOERR)
 | 
			
		||||
		{
 | 
			
		||||
      if (curr().has_memo())
 | 
			
		||||
			if (rec.has_memo())
 | 
			
		||||
			{
 | 
			
		||||
				((TRectype&)rec).update_memo();
 | 
			
		||||
				changed |= rec.memo_dirty();
 | 
			
		||||
				if (changed)
 | 
			
		||||
					((TRectype&)rec).write_memo(_isam_handle, _recno);
 | 
			
		||||
			}
 | 
			
		||||
			if (changed)
 | 
			
		||||
				rec_cache(_logicnum).notify_change();
 | 
			
		||||
		}
 | 
			
		||||
  }    
 | 
			
		||||
 | 
			
		||||
  return _lasterr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1032,6 +1039,7 @@ int TBaseisamfile::rewrite()
 | 
			
		||||
int TBaseisamfile::rewriteat(const TRectype& rec, TRecnotype nrec)
 | 
			
		||||
{
 | 
			
		||||
  const int fhnd = handle();
 | 
			
		||||
	bool changed = false;
 | 
			
		||||
 | 
			
		||||
  if ((_lasterr=DB_go(fhnd,nrec))== NOERR)
 | 
			
		||||
  {           
 | 
			
		||||
@ -1046,11 +1054,16 @@ int TBaseisamfile::rewriteat(const TRectype& rec, TRecnotype nrec)
 | 
			
		||||
 | 
			
		||||
	if (_lasterr == NOERR)
 | 
			
		||||
	{
 | 
			
		||||
    if (curr().has_memo())
 | 
			
		||||
		if (rec.has_memo())
 | 
			
		||||
		{
 | 
			
		||||
			((TRectype&)rec).update_memo();
 | 
			
		||||
			changed |= rec.memo_dirty();
 | 
			
		||||
			if (changed)
 | 
			
		||||
				((TRectype&)rec).write_memo(_isam_handle, _recno);
 | 
			
		||||
		}
 | 
			
		||||
		if (changed)
 | 
			
		||||
			rec_cache(_logicnum).notify_change();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
  return _lasterr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1064,8 +1077,8 @@ int TBaseisamfile::_remove(const TRectype& rec)
 | 
			
		||||
  CHECK(!rec.empty(), "Can't remove an empty record");
 | 
			
		||||
 | 
			
		||||
  const int fhnd = handle(1); // Forza l'uso della chiave principale (per chiavi duplicate?)
 | 
			
		||||
 | 
			
		||||
  TRectype save_rec(rec);
 | 
			
		||||
  
 | 
			
		||||
  _lasterr = cisread(fhnd, 1, save_rec, _isequal + _nolock, _recno); // Si Posiziona per sicurezza...
 | 
			
		||||
 | 
			
		||||
  if (_lasterr == NOERR)
 | 
			
		||||
@ -1278,8 +1291,12 @@ int TBaseisamfile::is_valid(bool exclusive)
 | 
			
		||||
			  if (dbfreclen != trcreclen)
 | 
			
		||||
        {
 | 
			
		||||
				  err = _istrcerr;
 | 
			
		||||
          if (_logicnum == LF_CLIFO)
 | 
			
		||||
            error_box("Clifo trc=%d dbf=%d", trcreclen, dbfreclen);
 | 
			
		||||
 | 
			
		||||
					TString msg;
 | 
			
		||||
		
 | 
			
		||||
					msg.format("Lunghezza record incoerente sul file %d (%s): file=%d trc=%d",
 | 
			
		||||
											num(), (const char*)description(), dbfreclen, trcreclen);
 | 
			
		||||
					error_box(msg);
 | 
			
		||||
				}    
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -1459,7 +1476,6 @@ TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create, bool
 | 
			
		||||
  open(n, create, eod, eox);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TIsamtempfile::~TIsamtempfile()
 | 
			
		||||
{
 | 
			
		||||
  close();
 | 
			
		||||
@ -2738,7 +2754,7 @@ int TSystemisamfile::dump(
 | 
			
		||||
		SELECTIONFUNCTION select_func, // @parm funzione filtro 
 | 
			
		||||
		TObject * filter_obj) // @parm oggetto di filtro 
 | 
			
		||||
 | 
			
		||||
// @xref <mf TSystemisamfile::load>
 | 
			
		||||
// @xref <mf TSystemisamfile::dump>
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  FILE* f = NULL; fopen_s(&f, to, "w");
 | 
			
		||||
@ -2947,7 +2963,7 @@ int TSystemisamfile::dump(
 | 
			
		||||
		SELECTIONFUNCTION select_func, // @parm funzione filtro 
 | 
			
		||||
		TObject * filter_obj) // @parm oggetto di filtro 
 | 
			
		||||
 | 
			
		||||
// @xref <mf TSystemisamfile::load>
 | 
			
		||||
// @xref <mf TSystemisamfile::dump>
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  FILE* f = NULL; fopen_s(&f, to, "w");
 | 
			
		||||
 | 
			
		||||
@ -44,6 +44,7 @@ public:
 | 
			
		||||
  TIsam_handle file() const { return _isamfile; }
 | 
			
		||||
  void copy(const TMemo_data& m);
 | 
			
		||||
  bool is_dirty(int i) const { return _dirty[i]; }
 | 
			
		||||
	bool dirty() const { return _dirty.some_one(); }
 | 
			
		||||
  void set_dirty(int i, bool d = true) { _dirty.set(i, d); }
 | 
			
		||||
  
 | 
			
		||||
  TMemo_data& operator=(const TMemo_data& m) { copy(m); return *this; }
 | 
			
		||||
@ -260,8 +261,10 @@ public:
 | 
			
		||||
 | 
			
		||||
  virtual void init_memo(const TRecnotype recno  = RECORD_NON_FISICO, TIsam_handle file = 0);
 | 
			
		||||
  virtual void reset_memo() { _memo_data->init(RECORD_NON_FISICO, 0); }
 | 
			
		||||
	virtual void update_memo() {}
 | 
			
		||||
  virtual void write_memo(TIsam_handle file, const TRecnotype recno);
 | 
			
		||||
  bool has_memo() const { return _memo_data != NULL; } 
 | 
			
		||||
	bool memo_dirty() const { return has_memo() && _memo_data->dirty(); }
 | 
			
		||||
 | 
			
		||||
  // Gestione posta elettronica
 | 
			
		||||
  virtual void fill_transaction(TConfig& cfg, int row = 0) const;
 | 
			
		||||
 | 
			
		||||
@ -168,11 +168,12 @@ void TVariable_rectype::unknown_field(const char* name) const
 | 
			
		||||
    TRectype::unknown_field(name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TVariable_rectype::write_memo(TIsam_handle file, const TRecnotype recno)
 | 
			
		||||
void TVariable_rectype::update_memo()
 | 
			
		||||
{
 | 
			
		||||
	if (_memo_fld.full())
 | 
			
		||||
	{
 | 
			
		||||
		TToken_string t(256, '\n');
 | 
			
		||||
 | 
			
		||||
		FOR_EACH_ASSOC_OBJECT(_virtual_fields, h, key, o)
 | 
			
		||||
		{
 | 
			
		||||
			const TVariable_field* vf = (TVariable_field*)o;
 | 
			
		||||
@ -186,6 +187,11 @@ void TVariable_rectype::write_memo(TIsam_handle file, const TRecnotype recno)
 | 
			
		||||
		}
 | 
			
		||||
		put(_memo_fld, t);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TVariable_rectype::write_memo(TIsam_handle file, const TRecnotype recno)
 | 
			
		||||
{   
 | 
			
		||||
	update_memo();
 | 
			
		||||
  TRectype::write_memo(file, recno);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -139,6 +139,7 @@ public:
 | 
			
		||||
  void set_memo_fld(const char * fieldname);
 | 
			
		||||
  void reset_memo_fld() { set_memo_fld(NULL); }                                                              
 | 
			
		||||
  virtual void init_memo(const TRecnotype recno = RECORD_NON_FISICO, TIsam_handle file = 0);
 | 
			
		||||
	virtual void update_memo();
 | 
			
		||||
	virtual void write_memo(TIsam_handle file, const TRecnotype recno);
 | 
			
		||||
 | 
			
		||||
  virtual void add_field(TVariable_field * f);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user