on 07-24-2014 9:03 AM
Hi, guy
I am working on Offline Data SMP 3.0, i am saved Service Document and MetaData in cache already but, when turn off internet connection, I will read service document and metadata in cache but i can not get service document schema and metadata schema because entityType in service document and metadata are null, Please suggest me how to read service document and metadata in Cache on Offline Mode or give me some example.
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have to leverage cache library to store the service document and metadata document. My expert area is not IOS, I have a sample code for Android. Given below is an example :
IODataServiceDocument serviceDocument = null;
try {
//Getting Service Document from the cache
serviceDocument =
(IODataServiceDocument)mApplication.getCache().readDocument(
DocumentType.ServiceDocument,
FlightModelConstants.FLIGHT_MODEL_SERVICE_DOCUMENT);
} catch (CacheException e) {
Log.v(TAG, e.getLocalizedMessage());
}
//Checking if Service Document was not found in cache,
if (serviceDocument == null) {
mProgress =
ProgressDialog.show(this,
(CharSequence) "",
(CharSequence)
getString(R.string.serviceDocumentProgress),
true);
mRequestTag = REQUEST_SERVICE_DOCUMENT;
//Preparing request to retrieve Service Document from the server
IRequest request =
RequestBuilder.getInstance().buildServiceDocumentRequest(this,
REQUEST_SERVICE_DOCUMENT);
//Sending the request
mApplication.getRequestManager().makeRequest(request);
} else {
Toast.makeText(this, R.string.msgServiceDocumentCache,
Toast.LENGTH_LONG).show();
//Service Document was in the cache, now we are going to retrieve the
Schema
this.getServiceSchema();
}
The APIs are given in bold letters. Hope that helps.
Code to be added in onSuccess callback method to store the document:
IODataServiceDocument serviceDocument = parser
.parseODataServiceDocument(responseString);
mApplication.getCache().storeDocument(serviceDocument,
DocumentType.ServiceDocument,
FlightModelConstants.FLIGHT_MODEL_SERVICE_DOCUMENT);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.