0% found this document useful (0 votes)
91 views36 pages

Outline 2 How To 3

This document outlines steps to modify the OSMDb Mobile application to work offline. It describes: 1. Checking roles offline using JavaScript instead of server-side data actions. 2. Preventing edits to movies and people offline, except for user movie ratings. 3. Detecting online/offline status changes using the NetworkStatusChanged block. 4. Calculating average movie ratings only when online. 5. Saving user ratings locally offline and synchronizing when back online.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views36 pages

Outline 2 How To 3

This document outlines steps to modify the OSMDb Mobile application to work offline. It describes: 1. Checking roles offline using JavaScript instead of server-side data actions. 2. Preventing edits to movies and people offline, except for user movie ratings. 3. Detecting online/offline status changes using the NetworkStatusChanged block. 4. Calculating average movie ratings only when online. 5. Saving user ratings locally offline and synchronizing when back online.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

 

Table of Contents 
Outline 2 

How to 3 
Offline Interaction and Role Checking 3 
Changing the Network Status 14 
Average Rating 19 
User Rating - Synchronization Revisited 28 

   


 

Outline 
In this exercise, we will prepare the OSMDb Mobile application to properly work offline. So far, 
we created the local storage data model and the synchronization algorithm, but there are still 
some situations in the app that only work when the device is online: 

● Check Roles 
● Calculate the Average Rating 
● AddCastAndCrew Screen 

When the device becomes offline, the application throws communication errors, since all the 
Screens have Data Actions used to check roles and the MovieDetail Screen has the average 
rating.  

First, we will use the J​ avaScript API​ to check the OSMDbAdmin Role offline (client-side) on 
Screens, instead of the Data Actions. This guarantees that the role is verified either when the 
app is online or offline.  

Then, we want to make sure that despite the Role, the movie and person information cannot be 
edited while offline, with the exception of the user movie rating in the MovieDetail Screen. Also, 
the access to the AddCastAndCrew Screen can only be done when the application is online. 

To support that, it is important that the application distinguishes when the app gets offline or 
online, on the application Screens. That can be done using the NetworkStatusChanged Block of 
the OutSystems UI Framework. This Block has an Event that is triggered when the network 
status changes.  

Then, on the MovieDetail Screen, we have a Database Aggregate that calculates the Average 
Rating for the movie. Since that functionality will only continue to work online, we need to make 
sure that the average rating only appears, and is calculated, when the app is online.  

Finally, the user will be able to rate movies, even when offline. This means that when the app is 
offline, the ratings will only be saved locally. However, when the network gets back online, the 
new ratings should be synchronized with the server and the information should be updated in 
the Database as well. 

   


 

How to 
In this section, we’ll describe, step by step, the exercise 5.​4 - Offline​. 

Offline Interaction and Role Checking 


Up to this point of the application, every Screen that requires some role-based verification, 
either to hide a widget or to disable an input field, is using Data Actions. These Actions are 
server-side only, so they do not work while offline.  

In the first part of this exercise, we will replace the Data Actions by a different way of role 
checking, which works client-side, using a J​ avaScript API​. However, it is important to mention 
that this API should only be used to help designing the UI. Being a client-side only verification, it 
does not provide the same security strength as a server-side verification, since the device can 
be more easily tampered. With that in mind, all business validations should be done on 
server-side, right before a critical operation is done, on Server Actions. In the 
OSMDb_Core_Mobile module, we have a couple of Server Actions that do exactly that, before 
any operation in the database is made. 

Then, besides the role restrictions, we want to make sure that no information from movies or 
people are modified when the user is offline, except for the movie rating. 

1. Create a Client Action, ​CheckOSMDbAdminRole​. This Action will check if the logged in user 
has the OSMDbAdmin Role. This Action should use the JavaScript API to accomplish this. 


 

a. In the ​OSMDb_Mobile​ module, switch to the Logic tab, right-click the C


​ lient 
Actions​ folder and select ​Add Client Action​. 

b. Set the ​Name o


​ f the Action to be ​CheckOSMDbAdminRole​. 

c. Drag a ​JavaScript n
​ ode and drop it on the Action flow. Set its N
​ ame t​ o 
CheckOSMDbAdminJS​. 


 

d. Double-click the JavaScript node to open it. Here, we will check if a user has the 
OSMDbAdmin Role. So, let’s first add an Output Parameter to the JavaScript node 
by right-clicking on the ​Parameters f​ older and selecting the respective option. 

e. Set the ​Name o


​ f the Parameter to ​HasRole a
​ nd set its D
​ ata Type​ to ​Boolean​. 

f. Add an Output Parameter to the Client Action, set its ​Name t​ o ​HasRole a
​ nd its 
Data Type​ to ​Boolean​. 

g. Add the following JavaScript code to the JavaScript node. 

$parameters.HasRole = $public.Security.checkIfCurrentUserHasRole($roles.OSMDbAdmin); 

This JavaScript code uses the checkIfCurrentUserHasRole function from the 


JavaScript API, which returns a Boolean value, indicating if the currently logged in 
user has the Role passed as parameter. You can find more information about this 
function h
​ ere​. Click Done to close the editor. 


 

h. Drag an ​Assign n
​ ode and drop it after the JavaScript. Set the Assignment to be: 

HasRole = CheckOSMDbAdminJS.HasRole 

2. In the ​Movies S
​ creen, the Data Action is used to help us display the option to create a 
new movie only when the user has the OSMDbAdmin Role. Let’s delete the Data Action 
and use the​ CheckOSMDbAdminRole A
​ ction to control that behavior. The 
CheckOSMDbAdmin Action should be used on the O
​ n Initialize ​Event, to check the Role 
before the Screen is rendered. Also, a user should only be able to create a new movie if 
the application is online. 

a. In the OSMDb_Mobile module, switch to the Interface tab and expand the M
​ ovies 
Screen. 

b. Delete the C
​ heckAdminRole ​Data Action. 


 

This should lead to an error, since the Data Action was used in an If widget, to 
hide the Create New Movie option on the top right corner of the Screen. 

c. Select the Movies Screen, expand the Event area and select the​ On Initialize 
Event. 

This creates a new O


​ nInitialize C
​ lient Action on the Movies Screen, which will 
execute when the On Initialize Event is triggered.  


 

d. Switch to the Logic tab and drag the ​CheckOSMDbAdminRole ​Action to the 
OnInitialize Action flow. 

 
e. Now, we need to save the value of the Output Parameter from the 
CheckOSMDbAdminRole in a Local Variable. Right-click on the Movies Screen and 
select​ Add Local Variable​. 

f. Set the ​Name o


​ f the Variable to ​HasAdminRole ​and the D
​ ata Type​ to ​Boolean​. 

g. Drag an ​Assign a
​ nd drop it after the CheckOSMDbAdminRole Action call in the 
OnInitialize Action flow. 


 

h. Set the Assignment to  

HasAdminRole = CheckOSMDbAdminRole.HasRole 

i. Now we need to consider the online scenario. Add a new L


​ ocal Variable ​to the 
Movies Screen, set its name to I​ sOnline ​and make sure its​ Data Type ​is set to 
Boolean​. 

j. Open the Movies Screen, select the If that is causing the error and set its 
Condition ​to  

IsOnline and HasAdminRole 

This guarantees that the icon only appears when the two scenarios are true. 
However, there’s still some logic necessary to control the online / offline scenario, 
which will be done later in this exercise. 

k. Publish the module to save the latest changes in the server. 

3. In the ​People S
​ creen, the Data Action is also used to help us display the option to create 
a new person in the database only when the user has the OSMDbAdmin Role. Let’s apply 
in this Screen the same logic used in the Movies Screen. 

4. In the ​MovieDetail S
​ creen, we have two Data Actions, one to check the OSMDbAdmin 
Role and another one to check the Registered Role. To replace the one about the 
OSMDbAdmin Role, we can use the same strategy used in the previous two Screens. For 
the Registered Role, we can just check if the User Identifier is different from 
NullIdentifier(),​ using the ​GetUserId()​ system function. Finally, we want to make sure that 


 

besides the existing Role verifications, we only want to be able to edit and save the 
movie information if we are online, except for the movie rating. 

a. Expand the ​MovieDetail ​Screen and delete the two existing Data Actions. This 
will raise several errors in the application. 

b. Add two L
​ ocal Variables​ to the MovieDetail Screen: ​HasAdminRole ​(Boolean) and 
IsOnline ​(Boolean). 

c. Select the MovieDetail Screen and under ​Event​, select O


​ n Initialize​ to create the 
Action handler. 

d. Define the O
​ nInitialize ​Action just like in the previous Screens 

10 
 

e. Open the ​MovieDetail S


​ creen, select the I​ f ​enclosing the Add Cast and Crew Link 
and set the C
​ ondition ​to 

IsOnline and HasAdminRole 

f. Notice that all the input fields in the Form have an error. Fix those errors by 
setting their ​Enabled p
​ roperty to 

IsOnline and HasAdminRole 

g. Select the ​Save b


​ utton and set the ​Visible p
​ roperty to  

IsOnline and HasAdminRole 

11 
 

h. Select the ​StarDisplay B


​ lock in the MovieDetail Screen under the Y
​ our Rating 
Label. Since we do not have the CheckRegisteredRole Data Action anymore, we 
need to check if the user is Registered anyway. To do that, we can use the 
GetUserId()​ Action. This Action returns the identifier of the user currently logged 
in, so if the ​GetUserId()​ Action returns N
​ ullIdentifier() ​it means that the user is n
​ ot 
logged in. Set the A
​ llowClicking ​Input Parameter to  

GetUserId() <> NullIdentifier() 

i. Publish the module to save the changes in the server. 

5. Apply the same logic as in the above scenarios to the ​PersonDetail ​Screen. 

6. Go back to the ​MovieDetail S


​ creen and to the ​StarClickedHandler ​Action. On the 
MovieDetail Screen, a user will be able to rate a movie while online or offline, if the user 
has the Registered Role. For that reason, we need to add some additional logic to the 
StarClickedHandler Action to make sure that rating is only saved in the server when the 
app is online, using the recently created I​ sOnline L
​ ocal Variable. 

a. Open the StarClickedHandler Action, drag an ​If ​node and drop it before the 
UserMovieRatingCreateOrUpdate Action call. 

12 
 

b. Set the ​Condition t​ o ​IsOnline​. 

c. Drag an ​Assign a
​ nd drop it to the right of the If. Create the T
​ rue b
​ ranch between 
the If and the Assign. 

d. Set the following assignment to save the movie rating 

GetMovieById.List.Current.LocalMovie.Rating = SelectedStar 

NOTE:​ The rating was already being saved in the Assign that already existed in 
the Action flow (the one right after the Server Action). The problem is that Assign 
will only run now when the app is online, so we need to make sure that the rating 
is still saved when the app is offline.  

e. Right-click on the If and select​ Swap Connectors​ to make sure that the Server 
Action is called only when the app is online. 

13 
 

f. Connect the new Assign with the ​LocalMovieCreateOrUpdate C


​ lient Action. 

7. Publish the module to save the changes. 

Changing the Network Status 


In the first part of the exercise, we defined some conditions based on a Local Variable, 
IsOnline​. However, the logic to properly set the value of the IsOnline variable has not been 
done yet. In this section of the exercise, we will leverage the ​NetworkStatusChanged B
​ lock to 
identify when the app becomes online or offline and set the value of each IsOnline Variable, in 
its own Screen appropriately. Also, when the Screens are being initialized, it is important to 
check if the app is online or offline, and also set the IsOnline Variables accordingly. 

1. Use the ​GetNetworkStatus A


​ ction and the N
​ etworkStatusChanged B
​ lock in the 
Movies Screen, to check if the app is online when the Screen is being initialized and to 

14 
 

know when the network status changes, while the user is interacting with the Screen. 
The I​ sOnline L
​ ocal Variable will save the current status of the network. 

a. Open the ​OnInitialize A


​ ction on the ​Movies ​Screen.  

b. Drag a ​Run Client Action​ node to the flow and drop it before the 
CheckOSMDbAdminRole Action. 

c. In the new dialog, search for ​getnetwork a


​ nd select the ​GetNetworkStatus 
Action. 

15 
 

d. Select the existing ​Assign n


​ ode and define a new assignment:  

IsOnline = GetNetworkStatus.IsOnline 

e. Open the Movies Screen. Now we want to drag the ​NetworkStatusChanged 


Block, from the OutSystemsUI Framework, to the Screen. Since it’s not a Block 
with UI, we can add it anywhere on the Screen. Let’s add it to the top. 

16 
 

f. The NetworkStatusChanged Block has an Event that is triggered when the 


network changes from online to offline or vice-versa. Select the 
NetworkStatusChanged B
​ lock on the Screen and set the ​Handler p
​ roperty to 
(New Client Action)​. 

g. Rename the recently created Action to ​NetworkStatusChangedHandler​. Change the 


name of the Input Parameter of the Action to ​IsNetworkOnline. T
​ his Input 
Parameter was automatically created, since it is a parameter of the Event 
triggered in the NetworkStatusChanged Block. 

h. Drag an ​Assign n
​ ode and drop it on the NetworkStatusChangedHandler Action 
flow. Set the Assignment to 

IsOnline = IsNetworkOnline 

17 
 

i. Publish the module to save the latest changes. 

2. Use the same strategy on the remaining Screens: MovieDetail, People and PersonDetail. 

3. Publish the module to save the latest changes. 

4. Open the application on the device. Login with a user with the OSMDbAdmin Role.  

5. Confirm that in the Movies Screen, the option to create a new movie appears. 

6. Turn off the network connection to make the application work offline. Notice that the 
option to create a new movie disappears. 

7. Open the People Screen and notice that no error is thrown and the Screen works as 
expected. 

8. Turn on the network connection again and confirm that the option to add a new person 
appears on the top of the Screen. 

9. Now turn off the network connection again and go back to the Movies Screen. Select any 
movie on the list to navigate to the MovieDetail Screen. An error is thrown indicating 
that there was a request failed with an error. This happens because the 
GetAverageRating ​is a Database Aggregate, which is trying to be executed when the 
Screen is initializing. In the next section of the exercise, we will fix this problem. 

18 
 

Average Rating 
To solve the problem that was identified in the previous section, we need to define a new Block. 
This Block will have the G
​ etAverageRating ​in it, as well as the S
​ tarDisplay ​Block as the only 
element in its UI.  

On the MovieDetail Screen, the new Block should only be displayed when the Screen is online, 
which can be controlled by the Local Variable ​IsOnline​. When a user rates a movie, the average 
rating should be calculated again, if the app is online. The same applies when the network 
status changes from offline to online, while we are interacting with the Screen. 

1. Create a new Block called ​AverageRating​, with the GetAverageRating Aggregate and the 
StarDisplay Block in its UI. 

a. Right-click on the MainFlow and select​ Add Block 

b. Set the name of the Block to A


​ verageRating​. 

c. Expand the MovieDetail Screen, cut the G


​ etAverageRating ​and paste it in the 
AverageRating B
​ lock. 

19 
 

d. The GetAverageRating Block uses a M


​ ovieId ​in the Filters. So, we need to add 
that information to the scope of the Block. Add an I​ nput Parameter​ called 
MovieId​, with ​Data Type​ set to ​Movie Identifier​. 

e. Drag the ​StarDisplay B


​ lock to the Content of the Screen.  

f. Set the values for the Input Parameters of the StarDisplay Block to be: 

Rating:​ GetAverageRating.List.Current.RatingAvg 

AllowClicking:​ False 

20 
 

g. Drag a ​Label a
​ nd drop it before the StarDisplay Block. Set the T
​ ext ​to ​Average 
Rating​. 

2. Replace the ​StarDisplay B


​ lock on the Screen with the ​AverageRating B
​ lock. Enclose the 
AverageRating Block in an ​If ​to display the Block only when the app is online. 

a. Open the ​MovieDetail S


​ creen and delete the StarDisplay Block of the Screen. 
Also, delete the L
​ abel r​ ight above it. 

21 
 

b. Drag the ​AverageRating B


​ lock and drop it on the same location where the Block 
in the previous step was. 

c. Set the ​MovieId ​Input Parameter value to ​MovieId (​ the Input Parameter of the 
MovieDetail Screen). 

d. Right-click on the AverageRating on the Screen and select E


​ nclose in If​. 

e. Set the ​Condition t​ o ​IsOnline​. 

22 
 

3. At this point, Service Studio has an error. When the user rates a movie, the 
GetAverageRating Aggregate is re-executed (in the ​StarClickedHandler ​Action). Since 
the Aggregate is not available on the Screen that Refresh Data node should be deleted. 

 
4. Publish the module and access the MovieDetail Screen offline. No error should be 
thrown at this point. 

5. Rate a movie. Did the Average Rating change? It shouldn’t! This means that we are not 
done yet! The reason behind this is that the Average Rating is now inside a Block, 
including the Aggregate. So, since the only Input Parameter is the MovieId, and since 
that does not change with a new rating, we need to somehow trigger the rendering of 
the Block, which will in turn run the Aggregate again to calculate the average rating.  

6. Add an ​Input Parameter​ to the ​AverageRating ​Block, called ​UserRated​, which is 
controlled by a L
​ ocal Variable​ on the MovieDetail Screen with the same name. 
Whenever the user rated a movie, that variable changes the value, thus changing the 
Input Parameter of the Block.  

a. Add a new L
​ ocal Variable​ to the MovieDetail Screen, called U
​ serRated​, with D
​ ata 
Type​ set to B
​ oolean​. 

23 
 

b. On the S
​ tarClickedHandler A
​ ction, drag an ​Assign ​node and drop it right after 
the LocalMovieCreateOrUpdate Action call 

c. Define the Assignment to be:  

UserRated = not UserRated 

This guarantees that the value of the variable changes every time the user rates 
the movie, which is what will cause the Block’s Input Parameter to change as well. 

24 
 

d. Add a new I​ nput Parameter​ to the ​AverageRating B


​ lock. Call it ​UserRated a
​ nd 
set the D
​ ata Type​ to Boolean. This should throw an error in Service Studio. The 
error appears on the Block instance in the MovieDetail Screen, because we added 
a new mandatory Input Parameter and we are not passing a value to it. 

e. Set the ​UserRated v


​ alue to be the U
​ serRated ​Local Variable. 

7. Set the ​On Parameters Changed E


​ vent in the A
​ verageRating ​Block to a Client Action 
that refreshes the ​GetAverageRating A
​ ggregate, only when the user is online. 

25 
 

a. Select the AverageRating Block and under the E


​ vents ​select the O
​ n Parameters 
Changed 

b. Drag the ​Refresh Data​ node and drop it on the Action flow 

c. Select the ​GetAverageRating A


​ ggregate in the new dialog. 

d. This re-execution of the GetAverageRating should be done only when the app is 
online. Since the Block does not have access to the scope of the Screen, add a 
new​ Input Parameter​ to the Block, call it ​IsOnline a
​ nd set the D
​ ata Type​ is set to 
Boolean​. This will create an error that will be solved in the next steps. 

e. Drag an ​If n
​ ode and drop it above the Refresh Data node. Set the C
​ ondition ​to 
IsOnline​. Drag an E
​ nd ​node and drop it to the right of the If and connect the two 

26 
 

nodes to create the True branch. Then, right-click on the If and S


​ wap 
Connectors​. 

NOTE:​ Despite not being used, the ​UserRated ​Input Parameter triggers the On 
Parameters Changed event, every time a user rates a movie, due to the last 
Assign we added in the StarClickedHandler Action. This is enough to trigger the 
Event, run the Action Handler and re-execute the Aggregate if the app is online. 
The Block itself will also render on the Screen. 

f. In the MovieDetail Screen, select the instance of the AverageRating Block and set 
the value of the ​IsOnline I​ nput Parameter to the Local Variable I​ sOnline​. This will 
solve the error caused two steps ago. 

27 
 

8. Publish the module and test the app. The average rating should work properly at this 
point. 

User Rating - Synchronization Revisited 


The final section of this exercise will focus on the user rating. Every single Registered user 
should be able to rate a movie, even when offline. Then, whenever the app gets online, the 
added ratings should be synchronized with the server, where the UserMovieRating Entity 
should be updated with the data coming from the device. This leads us to a second 
synchronization moment, where only the movie rating information is synchronized, when the 
app gets online. 

This requires several steps: 

● Set the Local Storage to save which ratings were modified, since the last time the app 
was online. That can be done with the help of an extra attribute, that is set to T​ rue 
whenever a new rating is added while offline. 
● Modify the synchronization logic to send to the server the movie ratings changed since 
the last time the app was online. 
● Define a new SyncUnit to define this new synchronization moment, leveraging the 
existing Static Entity. 
● Trigger the synchronization, with the new SyncUnit, whenever the app gets back online. 

1. In the ​OSMDb_Core_Mobile​ module, create an additional attribute in the ​LocalMovie 


Entity, ​IsModified​, of ​Boolean D
​ ata Type​ and ​non-mandatory​. The first attribute will 
indicate if the movie record was modified since the last time the app was online. 

28 
 

2. In the synchronization logic for the movies and local movies, make sure that we send to 
the server the movies that were modified with new ratings, and update that information 
in the database.  

a. Switch to the OSMDb_Core_Mobile module and open the ​SyncLocalMovies 


Client Action. 

b. Drag an ​Aggregate a
​ nd drop it right before the SyncMovies Action call. 

c. Set the ​Source o


​ f the Aggregate to be the L
​ ocalMovie ​Entity. 

d. In the ​Filters t​ ab, set the following condition 

LocalMovie.IsModified = True 

e. Set the ​Name o


​ f the Aggregate to ​GetModifiedLocalMovies​. 

29 
 

f. Now, we need to send this list to the server. Add an I​ nput Parameter​ to the 
SyncMovies Server Action, set its ​Name t​ o ​ModifiedLocalMovies ​and its D
​ ata Type 
to ​LocalMovie List​. 

This creates an error, since now the SyncMovies Action expects a value for the 
new Input Parameter in the SyncLocalMovies Action. 

g. Select the ​SyncMovies ​Action node in the SyncLocalMovies Action flow and set 
the ​ModifiedLocalMovies v
​ alue to G
​ etModifiedLocalMovies.List​. 

h. Open the ​SyncMovies A


​ ction flow. Now we need to add to the Database the 
changes done locally. Drag a F
​ or Each​ and drop it before the GetMovies 
Aggregate. 

30 
 

i. Drag a ​Run Server Action​ and drop it to the right of the For Each. 

j. Select the ​CreateOrUpdateUserMovieRating E


​ ntity Action 

k. Connect the For Each with the CreateOrUpdateUserMovieRating Action and the 
Action to the For Each to create a loop. 

l. Select the For Each and set the R


​ ecord List​ to ​ModifiedLocalMovies​. 

31 
 

m. Set the ​Source o


​ f the CreateOrUpdateUserMovieRating Action call to 
ModifiedLocalMovies.Current​. Since the ModifiedLocalMovies List is of type 
LocalMovies List, we need to do a mapping to the UserMovieRating. Set the 
following mappings: 

Id = RatingId  
UserId = GetUserId() 
MovieId = Id 
Rating = Rating 

 
The I​ d ​of the UserMovieRating record is stored in the R
​ atingId ​attribute of the 
LocalMovie, as well as the ​Rating​. The ​UserId c​ an be easily set with the user 
function G
​ etUserId(). ​The M
​ ovieId ​attribute is set to the I​ d ​of the LocalMovie 
record. 

n. Select the ​LocalMovie A


​ ssign, to the right of the GetRatingByUserId Aggregate. 
Set the ​IsModified v
​ alue in the mapping to F​ alse​. 

32 
 

Every Local Movie record will have the ​IsModified a


​ ttribute set to ​False​, since 
after the synchronization we will not have modified records in the local storage 
that are not synced with the server. 

3. Publish the OSMDb_Core_Mobile module to save the latest changes. 

4. In the OSMDb_Mobile module, refresh the dependencies to include the latest changes 
published in the Core module. 

5. In the MovieDetail Screen, we can rate a movie while offline. So, we need to mark the 
movie that was rated as modified, while offline, using the IsModified attribute. Select the 
Assign node to the right of the IsOnline? If and add the following assignment 

GetMovieById.List.Current.LocalMovie.IsModified = True 

By setting this ​IsModified a


​ ttribute to T​ rue​, we are indicating that this LocalMovie was 
updated while the app was offline. 

6. To finish, we just need to trigger the synchronization procedure when the app gets 
online. Make sure that the only data synchronized at this point should be the movie 
ratings. 

33 
 

a. Under the Data tab, find the S


​ yncUnit ​Static Entity and add a new record. Set the 
Identifier t​ o ​Offline ​and the U
​ nit ​to ​“Offline”​. 

b. Under the Logic tab, open the O


​ fflineDataSync ​Client Action 

c. Drag an ​If n
​ ode and drop it to the right of the existing If. 

d. Set the ​Condition t​ o ​SyncUnit = Entities.SyncUnit.Offline 

e. Drag a ​Run Client Action​ and drop it below the most recently added If 

34 
 

f. In the new dialog, select the ​SyncLocalMovies C


​ lient Action. Set the ​Name t​ o 
SyncRatings 

g. Connect the If to the Action to create the True branch. 

h. Drag an ​End n
​ ode and drop it below the SyncRatings Action. Connect the two 
nodes. 

7. To trigger the synchronization of the movie ratings properly, we need to go to the 


Movies​, ​People​, ​MovieDetail ​and ​PersonDetail S
​ creens and trigger the 
synchronization procedure, with the appropriate S
​ yncUnit​, when the app gets online. 

a. In the Movies Screen, open the ​NetworkStatusChangedHandler ​Action. Drag an 


If node and drop it right after the existing Assign. 

35 
 

b. Set the ​Condition t​ o ​GetNetworkStatus() 

c. Drag a ​Run Client Action​ and drop it to the right of the If node.  

d. Select the ​TriggerOfflineDataSync ​Action. Set the S


​ yncUnit ​value to 
Entities.SyncUnit.Offline 

This guarantees that only the ratings are synchronized. 

e. Connect the If to the Action to create the True branch and then the Action to the 
End node. 

f. Repeat the exact same process for the People, MovieDetail and PersonDetail 
Screens. 

g. Publish the module to save the latest changes. 

8. Test the application in the device and guarantee that it works as expected. 

36 

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy