Пример #1
0
        /// <summary>
        /// Stored Procedure Call to begin Api Session, passing the pkSystemUser obtained from ValidatePassword method
        /// </summary>
        /// <param name="context"></param>
        /// <param name="pkSystemUser"></param>
        /// <returns>ApiSession</returns>
        public static ApiSession Execute(ApiContext context, long?pkSystemUser)
        {
            try
            {
                var sp     = new BeginApiSession(pkSystemUser);
                var reader = context.GetReader(sp);
                if (reader.Read())
                {
                    var user = new ApiSession();
                    user.PKSystemUser  = reader.GetInt64(0);
                    user.UserId        = reader.GetString(1);
                    user.UserName      = reader.GetString(2);
                    user.UserCode      = reader.GetString(3);
                    user.AccessGranted = reader.GetDateTime(4);
                    user.AccessToken   = reader.GetGuid(5);
                    user.RefreshToken  = reader.GetGuid(6);
                    user.TokenExpiry   = reader.GetDateTime(7);
                    return(user);
                }
            }
            catch (Exception e)
            {
                return(null);
            }

            return(null);
        }
Пример #2
0
 /// <summary>
 /// Get a new ApiSession by calling the stored procedure, with defined parameters
 /// </summary>
 /// <param name="context"></param>
 /// <param name="pkSystemUser"></param>
 /// <param name="accessToken"></param>
 /// <param name="refreshToken"></param>
 /// <returns></returns>
 public static ApiSession Execute(ApiContext context, long?pkSystemUser, string accessToken, string refreshToken)
 {
     try
     {
         var sp     = new RefreshApiSession(pkSystemUser, accessToken, refreshToken);
         var reader = context.GetReader(sp);
         if (reader.Read())
         {
             var user = new ApiSession();
             user.PKSystemUser  = reader.GetInt64(0);
             user.UserId        = reader.GetString(1);
             user.UserName      = reader.GetString(2);
             user.AccessGranted = reader.GetDateTime(3);
             user.AccessToken   = reader.GetGuid(4);
             user.RefreshToken  = reader.GetGuid(5);
             user.TokenExpiry   = reader.GetDateTime(6);
             return(user);
         }
     }
     catch
     {
         throw;
     }
     return(null);
 }
Пример #3
0
 /// <summary>
 /// Update ApiSession by calling the Stored Procedure with PKSystemUser in session
 /// This is called after a user successfully log in and begin ApiSession
 /// </summary>
 /// <param name="context"></param>
 /// <param name="session"></param>
 public static void Execute(ApiContext context, ApiSession session)
 {
     try
     {
         var sp     = new GetTenant(session.PKSystemUser);
         var reader = context.GetReader(sp);
         while (reader.Read())
         {
             var tu = new TenantUserInfo();
             tu.PKTenant     = reader.GetInt64(0);
             tu.TenantCode   = reader.GetNullableString(1);
             tu.TenantName   = reader.GetNullableString(2);
             tu.PKTenantUser = reader.GetInt64(3);
             tu.PKParty      = reader.GetNullableInt64(4);
             tu.PartyCode    = reader.GetNullableString(5);
             tu.PartyName    = reader.GetNullableString(6);
             session.Tenants.Add(tu);
         }
     }
     catch
     {
         throw;
     }
 }