Exemplo n.º 1
0
        public async Task LoginAsync(Logins l, ILoginCallback callback)
        {
            int count = -1;

            if (DBHandler.db == null)
            {
                DBHandler.DBConnection();
            }
            try
            {
                await DBHandler.db.InsertAsync(l);

                await DBHandler.db.CloseAsync();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Login DAO fail " + e.Message);
                return;
            }

            if (DBHandler.db == null)
            {
                DBHandler.DBConnection();
            }
            try
            {
                count = await DBHandler.db.ExecuteScalarAsync <int>("select count(*) from LOGINS where USER_ID=1");
            }
            catch (Exception e)
            {
                callback.GetLoginFail();
                return;
            }
            callback.GetLoginSuccess(count);
        }
 public bool Unregister(ILoginCallback callback)
 {
     lock (_callbacksLock)
     {
         KeepAliveManager.Instance.Register(callback.OnPing);
         return _callbacks.Remove(callback);
     }
 }
Exemplo n.º 3
0
 /// <summary>USE THIS from within Libation. It wraps the call with correct JSONPath</summary>
 public static Task <Api> GetApiAsync(ILoginCallback loginCallback, Account account)
 {
     Serilog.Log.Logger.Information("GetApiAsync. {@DebugInfo}", new
     {
         Account    = account?.MaskedLogEntry ?? "[null]",
         LocaleName = account?.Locale?.Name
     });
     return(EzApiCreator.GetApiAsync(
                account.Locale,
                AudibleApiStorage.AccountsSettingsFile,
                account.GetIdentityTokensJsonPath(),
                loginCallback));
 }
Exemplo n.º 4
0
 /// <summary>USE THIS from within Libation. It wraps the call with correct JSONPath</summary>
 public static Task <Api> GetApiAsync(string username, string localeName, ILoginCallback loginCallback = null)
 {
     Serilog.Log.Logger.Information("GetApiAsync. {@DebugInfo}", new
     {
         Username   = username.ToMask(),
         LocaleName = localeName,
     });
     return(EzApiCreator.GetApiAsync(
                Localization.Get(localeName),
                AudibleApiStorage.AccountsSettingsFile,
                AudibleApiStorage.GetIdentityTokensJsonPath(username, localeName),
                loginCallback));
 }
        public bool Register(ILoginCallback callback)
        {
            lock (_callbacksLock)
            {
                if (!_callbacks.Contains(callback))
                {
                    _callbacks.Add(callback);
                    KeepAliveManager.Instance.Register(callback.OnPing);
                    return true;
                }
            }

            return false;
        }