StreetFoo.Client.StreetFooRuntime.LogonAsync C# (CSharp) Method

LogonAsync() static private method

static private LogonAsync ( string username, string token ) : System.Threading.Tasks.Task
username string
token string
return System.Threading.Tasks.Task
        internal static async Task LogonAsync(string username, string token)
        {
            // set the database to be a user specific one... (assumes the username doesn't have evil chars in it
            // - for production you may prefer to use a hash)...
            UserDatabaseConnectionString = string.Format("StreetFoo-user-{0}.db", username);

            // store the logon token...
            LogonToken = token;

            // initialize the database - has to be done async...
            var conn = GetUserDatabase();
            await conn.CreateTableAsync<ReportItem>();
        }

Usage Example

        public async Task <bool> RestorePersistentLogonAsync()
        {
            var token = await SettingItem.GetValueAsync(LogonTokenKey);

            if (!(string.IsNullOrEmpty(token)))
            {
                var username = await SettingItem.GetValueAsync(LastUsernameKey);

                if (!(string.IsNullOrEmpty(username)))
                {
                    // logon...
                    await StreetFooRuntime.LogonAsync(username, token);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
All Usage Examples Of StreetFoo.Client.StreetFooRuntime::LogonAsync