AxPromptDBSync

From Axaptapedia
Jump to: navigation, search

A simple project that allows to choose whether to synchronize the AOT with the database at the moment or not.

This should be used with extreme caution and only by experienced developers (people, who know what they are doing)

See My Blog for details about how it works.


Download[edit]

Download the project here It contains the system table SysUserInfo - 2 fields to control syncronization were added to it - and the SysUserInfo form, which contains the FieldGroup so that you can modify these two fields.

Modify Application Class[edit]

Method dbSynchronize - here is the modified version - you have to insert the code in comments where it belongs (in case your method is already modified)

boolean dbSynchronize(tableId tableId         = 0,   // 0 = all tables, non-zero is a valid table handle
                     boolean syncAsNeeded    = true,  // true = objects touched in the AOT, false = unconditional synchronize
                     boolean continueOnError = true,
                     boolean showProgress    = true ) // true = report all problems, but throw only after all tables are synchronized, false = stop synchronize after first error/problem
{
   SqlSyncPending  sqlSyncPending = new SqlSyncPending();
   boolean         ok;
   //<AxPromptDBSync date=2006-12-12 description='Sync database on demand only'>
   ObjectIdent     lastActivatedForm;
   object          formRun;
   NoYes           doPrompt;
   SysUserInfo     sysUserInfo;    ;
   sysUserInfo = SysUserInfo::find(curUserId());
   if (sysUserInfo.skipDBSync)
       return NoYes::No;
   doPrompt = sysUserInfo.promptDBSync;
   if (doPrompt)
   {
       lastActivatedForm = Infolog.setLastActivatedForm();
       if (lastActivatedForm) formRun = lastActivatedForm.object();
       if (formRun && SysDictClass::isEqualOrSuperclass(classIdGet(formRun), classNum(FormRun)))
       {
           if (formRun.name() == formStr(SysCompilerOutput) ||
               formRun.name() == formStr(SysImportDialog))
           {
               doPrompt = NoYes::No;
           }
       }
   }
   if (doPrompt && box::yesNo("Do you really want to syncronize?", DialogButton::Yes) == DialogButton::No)
       return NoYes::No;
   //</DevExtensions>
   setPrefix("@SYS22807");
   ok = super(tableId, syncAsNeeded, continueOnError, showProgress);
   if (ok && this.isRunningMode())
   {
       SysApplicationSetup::saveApplicationVersion(SysApplicationSetupMode::Synhronize);
   }
   return ok;
}