on 07-10-2014 7:25 PM
HI Team
I Have created MBO with Oracle Database PL/SQL Function as Datasource. I can able to register the devices. After synchronization no new data available in local database. During MBO Creation In MBO Tool kit i get data in Preview.
My Code:
public class MainActivity extends Activity {
private static final String HOST = "IP";
// private static final int PORT = 5001;
private static final String USERNAME = "admin";
private static final String PASSWORD = "admin";
private static volatile boolean initializationDone = false;
private static int TIMEOUT = 600;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeApplication();
}
private void initializeApplication()
{
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setTitle("on boarding ...");
dialog.setMessage("Please wait while download initial data...");
dialog.setIndeterminate(false);
dialog.setProgress(100);
dialog.setCancelable(true);
dialog.show();
new Thread()
{
@Override
public void run()
{
try
{
int count = 0;
while (!initializationDone)
{
dialog.setProgress(++count);
Thread.sleep(500);
if (count == 100)
{
count = 0;
}
}
dialog.cancel();
}
catch (Exception e)
{
dialog.cancel();
}
}
}.start();
NWCversion2DB.registerCallbackHandler(new CustomerDBCallback());
Application app = Application.getInstance();
app.setApplicationIdentifier("NWCversion2");
app.setApplicationContext(MainActivity.this);
new Thread(new Runnable()
{
@Override
public void run()
{
try
{
Application app = Application.getInstance();
// ApplicationCallback appCallback = new MyApplicationCallback();
// app.setApplicationCallback(appCallback);
//NWCversion2DB.registerCallbackHandler(new CustomerDBCallback());
NWCversion2DB.setApplication(app);
NWCversion2DB.getSynchronizationProfile().setServerName(HOST); // Convenience only
ConnectionProperties connProps = app.getConnectionProperties();
LoginCredentials loginCredentials = new LoginCredentials(USERNAME, PASSWORD);
connProps.setLoginCredentials(loginCredentials);
connProps.setServerName(HOST);
connProps.setPortNumber(5001);
Log.i("SMP101","Starting Application Registration");
if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED)
{
try {
app.registerApplication(TIMEOUT);
}
catch (Exception e)
{
Log.e("SMP101","Cannot register " + e.getMessage());
}
}
else
{
app.startConnection(TIMEOUT);
}
Log.i("SMP101","Application REGISTERED");
if (!NWCversion2DB.isSynchronized("default"))
{
if(!NWCversion2DB.databaseExists())
{
NWCversion2DB.createDatabase();
}
Log.i("SMP101","Starting Initial Sync");
ConnectionProfile cp = NWCversion2DB.getSynchronizationProfile();
cp.setServerName(HOST);
cp.setPortNumber(2480);
NWCversion2DB.disableChangeLog();
NWCversion2DB.synchronize(); // Initial Synchronize
LogAuthSubscription sp = new LogAuthSubscription();
sp.setSp_userName("User1");
sp.setSp_password("1234567");
//LoginAuthentication.addSubscription(sp);
NWCversion2DB.synchronize("SG_LogAuth");
//NWCversion2DB.synchronize();
// NWCversion1DB.synchronize("SG_LoginAuthentication");
//String a=lS.getRTRN_STATUS()+" By Single";
//Log.v("By Single", ""+a);
//Log.v("NWC List", ""+s1.getRTRN_STATUS()+" By List");
//Log.i("SMP101",a);
}
NWCversion2DB.enableChangeLog();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
initializationDone = true;
}
MainActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
}
});
}
}).start();
}
private class CustomerDBCallback extends DefaultCallbackHandler
{
@Override
public int onSynchronize(GenericList<SynchronizationGroup> groups, SynchronizationContext context)
{
Log.i("SMP101","OnSynchronize() called with STATUS " + context.getStatus());
if (context.getStatus() == SynchronizationStatus.ERROR)
{
Log.e("SMP101","ERROR " +
"[Exception message = " + context.getException().getMessage() +
"\n" + context.getException().getStackTrace());
}
if (context.getStatus() == SynchronizationStatus.STARTING)
{
MainActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
//Toast.makeText(MainActivity.this, "Synchronizing ... ", Toast.LENGTH_SHORT);
System.out.println("Synchronizing");
}
});
}
else if (context.getStatus() == SynchronizationStatus.FINISHING || context.getStatus() == SynchronizationStatus.ASYNC_REPLAY_UPLOADED)
{
MainActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
Toast.makeText(MainActivity.this, "Synchronize done", Toast.LENGTH_SHORT);
System.out.println("Finished");
LogAuth log=new LogAuth();
System.out.println("NWCLog"+log.getRTRN_STATUS());
GenericList<LogAuth> s = LogAuth.findAll();
for (LogAuth s1 : s) {
Log.v("NWC List", ""+s1.getRTRN_STATUS()+" By List");
}
}
});
/*if (SMP101SampleActivity.this.adapter != null)
{
SMP101SampleActivity.this.adapter.refreshUI(false);
}*/
}
return SynchronizationAction.CONTINUE;
}
}
}
Have you resolved the issue ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is the cache group you are using ? If it is on demand cache group check the option "partition by requester and device ID" in the properties of cache group created. If there is any load parameter in the MBO map it with PK with "partition by requester and device ID" checked or map it with sync parameter.
You can check whether CDB is updated by following this blog,
The issue would be with the cache group you selected.
Midhun VP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.