Axaptapedia is now maintained by AgileCadence For more information please click here.

Job Template (for running database maintenance script etc)

From Axaptapedia
Revision as of 07:53, 16 March 2010 by Fredand (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Handy script with some failsafe stuff built into it.

I woulnd'nt give users access to it, you still need to know what you are doing.

<xpp> static void _TestJobTemplate(Args _args) {

   Dialog      dialog          = new Dialog("Heading of the dialog.");
   Dialog      dlgAreYouSure   = new Dialog("Are you sure?");
   DialogField                 dfAreYouSure;
   DialogField                 dfDryRun;
   str                         sDryRun     = "Dry Run(not modf. data)?";
   str                         sAreYouSure = "Are you sure?";
   str                         sUserAbort  = "User aborted operation.";
   // Setting vars
   boolean                     UseTTS = NoYes::No; // Use tts on (live operation)
   ;
   dfDryRun = dialog.addField(typeId(NoYes),sDryRun);
   if (dialog.run())
   {
       // Fetch values from optional dialog fields
       /*
       // Check that those values has been submitted
       if(!VAR)
       throw error("You need to supply XY");
       */
       if(dfDryRun.value())
       {
           // Dry Run logic goes here.


       } else {
           dfAreYouSure = dlgAreYouSure.addField(typeId(NoYes),sAreYouSure);
       if(dlgAreYouSure.run())
       {
           if(dfAreYouSure.value())
           {
               if(UseTTS)
                   ttsbegin;
               // Live run logic goes here
               if(UseTTS)
                   ttscommit;
               }  else
                   throw error(sUserAbort);
           } else
               throw error(sUserAbort);
       }
   }

}

</xpp>