Files correlati : Ricompilazione Demo : [ ] Commento : Riportate le modifiche dalla versione 2.1 222 Si puo cominciare a fare il primo CD git-svn-id: svn://10.65.10.50/trunk@12708 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			186 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			186 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						|
#include <automask.h>
 | 
						|
#include <config.h>
 | 
						|
#include <defmask.h>
 | 
						|
#include <execp.h>
 | 
						|
#include <prefix.h>
 | 
						|
#include <sheet.h>
 | 
						|
 | 
						|
#include "mr2500.h"
 | 
						|
 | 
						|
class TMultiplan_mask : public TAutomask
 | 
						|
{
 | 
						|
protected:
 | 
						|
  bool build_profile_name(const TString& code, TFilename& profname) const;
 | 
						|
 | 
						|
  static int get_profile_desc(TConfig& cfg, void* jolly);
 | 
						|
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						|
 | 
						|
  static int set_profile(TConfig& cfg, void* jolly);
 | 
						|
  void loop();
 | 
						|
 | 
						|
public:
 | 
						|
  TMultiplan_mask() : TAutomask("mr2500") { }
 | 
						|
  virtual ~TMultiplan_mask() { }
 | 
						|
};
 | 
						|
 | 
						|
int TMultiplan_mask::get_profile_desc(TConfig& cfg, void* jolly)
 | 
						|
{
 | 
						|
  const int num = atoi(cfg.get_paragraph());
 | 
						|
  if (num > 0)
 | 
						|
  {
 | 
						|
    TString_array& p = *(TString_array*)jolly;
 | 
						|
    p.add(cfg.get("Description"));
 | 
						|
  }
 | 
						|
  return false;
 | 
						|
}
 | 
						|
 | 
						|
struct TProfile_info
 | 
						|
{
 | 
						|
  TString80 _desc;
 | 
						|
  TString8 _code;
 | 
						|
};
 | 
						|
 | 
						|
int TMultiplan_mask::set_profile(TConfig& cfg, void* jolly)
 | 
						|
{
 | 
						|
  const TString para = cfg.get_paragraph();
 | 
						|
  const int num = atoi(para);
 | 
						|
  if (num > 0)
 | 
						|
  {
 | 
						|
    TProfile_info* pi = (TProfile_info*)jolly;
 | 
						|
    const TString& d1 = pi->_desc;
 | 
						|
    const TString& d2 = cfg.get("Description");
 | 
						|
    if (d1 == d2)
 | 
						|
    {
 | 
						|
      pi->_code = para;
 | 
						|
      return true;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return false;
 | 
						|
}
 | 
						|
 | 
						|
void TMultiplan_mask::loop()
 | 
						|
{
 | 
						|
  TMask msk(TR("Elaborazione"), 1, 64, 5);
 | 
						|
  msk.add_string(101, 0, TR("Programma "), 1, 1, 50, "D");
 | 
						|
  msk.add_string(102, 0, TR("Profilo   "), 1, 2, 70, "D", 50);
 | 
						|
  msk.add_button(DLG_OK, 0, "", -12, -1, 12, 2);
 | 
						|
  msk.add_button(DLG_CANCEL, 0, "", -22, -1, 12, 2);
 | 
						|
 
 | 
						|
  TString cmd;
 | 
						|
  TFilename prof;
 | 
						|
  TSheet_field& sheet = sfield(F_SHEET);
 | 
						|
  FOR_EACH_SHEET_ROW(sheet, i, row)
 | 
						|
  {
 | 
						|
    const TString8 prg = row->get(0);
 | 
						|
    if (prg == "MRP")
 | 
						|
    {
 | 
						|
      msk.set(101, "M.R.P."); 
 | 
						|
      cmd = "mr2 -0";
 | 
						|
    } else
 | 
						|
    if (prg == "MSP")
 | 
						|
    {
 | 
						|
      msk.set(101, "M.S.P."); 
 | 
						|
      cmd = "mr2 -2";
 | 
						|
    } else
 | 
						|
    if (prg == "PIA")
 | 
						|
    {
 | 
						|
      msk.set(101, TR("Pianificazione Ordini"));
 | 
						|
      cmd = "mr2 -1";
 | 
						|
    }
 | 
						|
    msk.set(102, row->get(2));
 | 
						|
 | 
						|
    if (msk.run() == K_ESC)
 | 
						|
      break;
 | 
						|
    
 | 
						|
    if (build_profile_name(prg, prof))
 | 
						|
    {
 | 
						|
      TConfig cfg(prof);
 | 
						|
      TProfile_info pi;
 | 
						|
      pi._desc = row->get(2);
 | 
						|
      cfg.for_each_paragraph(set_profile, (void*)&pi);
 | 
						|
      if (pi._code.not_empty())
 | 
						|
        cfg.set(user(), pi._code, "Main");
 | 
						|
    }
 | 
						|
 | 
						|
    const char mode = row->get_char(1);
 | 
						|
    if (mode > ' ')
 | 
						|
      cmd << " /AUTO" << mode;
 | 
						|
 | 
						|
    TExternal_app app(cmd);
 | 
						|
    app.run();
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
bool TMultiplan_mask::build_profile_name(const TString& code, TFilename& profname) const
 | 
						|
{
 | 
						|
  profname = ::firm2dir(-1);    // Directory dati
 | 
						|
  profname.add("config");       // Directory config
 | 
						|
  
 | 
						|
  if (code == "MRP")
 | 
						|
    profname.add("mr2100a"); else
 | 
						|
  if (code == "MSP")
 | 
						|
    profname.add("mr2300a"); else
 | 
						|
  if (code == "PIA")
 | 
						|
    profname.add("mr2200a");
 | 
						|
 | 
						|
  profname.ext("ini");
 | 
						|
  return profname.exist();
 | 
						|
}
 | 
						|
          
 | 
						|
bool TMultiplan_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						|
{
 | 
						|
  switch (o.dlg())
 | 
						|
  {
 | 
						|
  case 103:
 | 
						|
    if (e == fe_button)
 | 
						|
    {
 | 
						|
      TArray_sheet p(3, 3, -3, -3, "Profili", "Descrizione@60");
 | 
						|
 | 
						|
      TString_array& a = p.rows_array(); 
 | 
						|
 
 | 
						|
      const TString& code = o.mask().get(101);
 | 
						|
      TFilename profname;
 | 
						|
      if (build_profile_name(code, profname))
 | 
						|
      {
 | 
						|
        TConfig prof(profname);
 | 
						|
        a.destroy();
 | 
						|
        prof.for_each_paragraph(get_profile_desc, &a);
 | 
						|
        a.sort();
 | 
						|
        const int sel = a.find(o.get());
 | 
						|
        if (sel > 0)
 | 
						|
          p.select(sel);
 | 
						|
      }  
 | 
						|
      if (p.run() == K_ENTER)
 | 
						|
        o.set(p.row(-1));
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case DLG_ELABORA:
 | 
						|
    if (e == fe_button)
 | 
						|
      loop();
 | 
						|
    break;
 | 
						|
  default: break;
 | 
						|
  }
 | 
						|
  return true;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
class TMultiplan : public TSkeleton_application
 | 
						|
{
 | 
						|
protected:
 | 
						|
  virtual void main_loop();
 | 
						|
};
 | 
						|
 | 
						|
void TMultiplan::main_loop()
 | 
						|
{
 | 
						|
  TMultiplan_mask msk;
 | 
						|
  msk.run();
 | 
						|
}
 | 
						|
 | 
						|
int mr2500(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TMultiplan a;
 | 
						|
  a.run(argc, argv, TR("Pianificazione automatica"));
 | 
						|
  return 0;
 | 
						|
}
 |