Beispiel #1
0
        public async void regAndSync()
        {
            //// Obtaining a handle to the data service
            updateBaseUrl();
            IDataAgent agent = MEAData.Agent(
                username: "******",
                baseUrl: baseUrl
                );

            //// Registering a resource in the service

            agent.Register(
                name: resourceUrl,
                url: resourceUrl,          // the url of the resource
                registree: "MiCoTestApp",  // a string identifying who's requesting this resource
                poll: 12                   // the desired frequency to poll the resource for changes, in hours
                );

            var cache = agent.Cache(resourceUrl);

            if (cache == null)
            {
                // no such resource has been registered
            }
            else
            {
                // request that a resource be synced right now
                var response = await cache.Sync();

                if (!response.Status.IsError())
                {
                    // sync succeeded
                }
                else
                {
                    // sync failed, perhaps b/c we're offline
                }

                // perform an SQLite query against the data
                using (var conn = cache.GetDbConnection()) {
                    //var results = conn.Query<dynamic>("SELECT * FROM sqlite_master WHERE type='table'");
                    SampleData = conn.Query <SampleData>("SELECT * FROM [Entity 1]");
                }

                // fetch a resource's metainformation
                if (DateTime.UtcNow - cache.LastSyncDate > new TimeSpan(36, 0, 0))
                {        // time since last successful sync
                    //WarnUserCacheIsStale();
                }

                if (DateTime.UtcNow - cache.LastModifiedDate > new TimeSpan(120, 0, 0))
                {        // time since data last updated on server. Always >= CacheAge.
                    //WarnUserServerDataIsOld();
                }
            }
        }
Beispiel #2
0
        public async void getData()
        {
            //// Obtaining a handle to the data service
            updateBaseUrl();
            IDataAgent agent = MEAData.Agent(
                username: "******",
                baseUrl: baseUrl
                );

            //// Registering a resource in the service
            if (string.IsNullOrEmpty(updateResourceUrl()))
            {
                messages.Text = PLEASE_ENTER_CONFIG_INFO;
                return;
            }
            else
            {
                messages.Text = string.Empty;
                agent.Register(
                    name: resourceUrl,
                    url: resourceUrl,                // the url of the resource
                    registree: "TestAdventureWorks", // a string identifying who's requesting this resource
                    poll: 1,                         // the desired frequency to poll the resource for changes, in hours
                    auth: AuthType.MiCo,             // The authentication method type
                    user: MEASUsername.Text,         // The MEAS User username
                    pass: MEASPassword.Text          // The MEAS User password
                    );

                var cache = agent.Cache(resourceUrl);

                if (cache == null)
                {
                    // no such resource has been registered
                }
                else
                {
                    // request that a resource be synced right now
                    var response = await cache.Sync();

                    if (!response.Status.IsError())
                    {
                        // sync succeeded
                        messages.Text = SYNC_COMPLETE;
                    }
                    else
                    {
                        // sync failed, perhaps b/c we're offline
                        messages.Text = SYNC_FAILED;
                    }
                }
            }
        }
Beispiel #3
0
        public async void register()
        {
            //// Obtaining a handle to the data service
            updateBaseUrl();
            IDataAgent agent = MEAData.Agent(
                username: "******",
                baseUrl: baseUrl
                );

            //// Registering a resource in the service
            if (string.IsNullOrEmpty(updateResourceUrl()))
            {
                messages.Text = PLEASE_ENTER_CONFIG_INFO;
                return;
            }
            else
            {
                messages.Text = string.Empty;
                agent.Register(
                    name: resourceUrl,
                    url: resourceUrl,                // the url of the resource
                    registree: "TestAdventureWorks", // a string identifying who's requesting this resource
                    poll: 1,                         // the desired frequency to poll the resource for changes, in hours
                    auth: AuthType.MiCo,             // The authentication method type
                    user: MEASUsername.Text,         // The MEAS User username
                    pass: MEASPassword.Text          // The MEAS User password
                    );

                var cache = agent.Cache(resourceUrl);

                if (cache == null)
                {
                    // no such resource has been registered
                    messages.Text = REGISTRATION_FAILED;
                }
                else
                {
                    messages.Text = REGISTRATION_COMPLETE;
                }
            }
        }