public override void Execute(INotification notification) { DebugLogger.Log("RequestReloadApplicationDataCommand::Execute"); // Register a command that will respond to the DataSystem DATA_LOADED notification Facade.RegisterCommand(DataLoaderNote.DATA_LOADED, typeof(ApplicationDataReloadedCommand)); // Register a command tha will respond to data load error Facade.RegisterCommand(DataLoaderNote.REQUEST_LOAD_DATA_ERROR, typeof(ApplicationDataFailedCommand)); // Retrieve the applicationDataProxy to get API and store details ApplicationDataProxy applicationDataProxy = Facade.RetrieveProxy(ApplicationDataProxy.NAME) as ApplicationDataProxy; // Set local strings string API_BASE_URI = applicationDataProxy.APIBaseURL; string API_DATA_ENDPOINT = applicationDataProxy.applicationSettingsVO.api_data_endpoint; // Send the request for applicationData based on store_id from settings SendNotification(DataLoaderNote.REQUEST_LOAD_DATA, new RequestLoadDataVO { requestType = RequestLoadDataType.WWW, path = Path.Combine(API_BASE_URI, API_DATA_ENDPOINT), dataType = typeof(ApplicationDataVO), cache = true, forceCacheRefresh = true }); }
public override void Execute(INotification notification) { DebugLogger.Log("ApplicationDataReloadedCommand::Execute"); ApplicationDataProxy applicationDataProxy = Facade.RetrieveProxy(ApplicationDataProxy.NAME) as ApplicationDataProxy; // Check data type if ((notification.Body as ApplicationDataVO) != null) { // Maintain Session when updating application data Session session = applicationDataProxy.Session; applicationDataProxy.Data = notification.Body as ApplicationDataVO; applicationDataProxy.Session = session; } else { // Report an error SendNotification(DataLoaderNote.REQUEST_LOAD_DATA_ERROR); return; } // Clean up Facade.RemoveCommand(DataLoaderNote.DATA_LOADED); Facade.RemoveCommand(DataLoaderNote.REQUEST_LOAD_DATA_ERROR); // Notify System that application is ready SendNotification(ApplicationNote.APPLICATION_DATA_RELOADED); }
public override void Execute(INotification notification) { DebugLogger.Log("RequestCheckApplicationDataUpdateCommand::Execute"); // We will handle the response in an onComplete Callback instead of passing to a Result command //Facade.RegisterCommand(DataSystemNote.DATA_LOADED, typeof(ApplicationDataReloadedCommand)); // Register a command tha will respond to data load error // Silently fail data reloads // Facade.RegisterCommand(DataSystemNote.REQUEST_LOAD_DATA_ERROR, typeof(ApplicationDataFailedCommand)); // Retrieve the applicationDataProxy to get API details applicationDataProxy = Facade.RetrieveProxy(ApplicationDataProxy.NAME) as ApplicationDataProxy; // Set local strings string API_BASE_URI = applicationDataProxy.APIBaseURL; string API_DATA_ENDPOINT = applicationDataProxy.applicationSettingsVO.api_data_endpoint; // Send the request for application Data SendNotification(DataLoaderNote.REQUEST_LOAD_DATA, new RequestLoadDataVO { requestType = RequestLoadDataType.WWW, path = Path.Combine(API_BASE_URI, API_DATA_ENDPOINT), dataType = typeof(ApplicationDataVO), cache = false, forceCacheRefresh = true, onComplete = DataReceived }); }
/// <summary> /// Called once application data has been loaded /// </summary> protected virtual void OnApplicationReady() { DebugLogger.Log(NAME + "::OnApplicationReady"); // Example of how to reference data and state proxies // Register Proxies in Application.Controller.Commands.Prepare.ApplicationModelPrepareCommand // Then they are available in any Mediator or Command class like this... applicationDataProxy = Facade.RetrieveProxy(ApplicationDataProxy.NAME) as ApplicationDataProxy; applicationStateProxy = Facade.RetrieveProxy(ApplicationStateProxy.NAME) as ApplicationStateProxy; InitializeViewComponent(); }
public override void Execute(INotification notification) { DebugLogger.Log("ApplicationDataLoadedCommand::Execute"); ApplicationDataProxy applicationDataProxy = Facade.RetrieveProxy(ApplicationDataProxy.NAME) as ApplicationDataProxy; // Check data type if ((notification.Body as ApplicationSettingsVO) != null) { applicationDataProxy.applicationSettingsVO = notification.Body as ApplicationSettingsVO; } else if ((notification.Body as ApplicationDataVO) != null) { applicationDataProxy.Data = notification.Body as ApplicationDataVO; PlayerPrefs.SetString("last_updated", applicationDataProxy.LastUpdatedDate.ToString()); } else { SendNotification(DataLoaderNote.REQUEST_LOAD_DATA_ERROR); } // Check if all data is loaded // And we can declare application ready if (applicationDataProxy.applicationSettingsVO != null && applicationDataProxy.ApplicationDataVO != null) { DebugLogger.Log("All Application data loaded!"); // Clean up Facade.RemoveCommand(DataLoaderNote.DATA_LOADED); Facade.RemoveCommand(DataLoaderNote.REQUEST_LOAD_DATA_ERROR); // Notify System application is ready SendNotification(ApplicationNote.APPLICATION_READY); // Set up coroutine to check for updates SendNotification(CoreNote.REQUEST_START_COROUTINE, new RequestStartCoroutineVO() { coroutine = CheckForUpdates() }); } }