Beispiel #1
0
 public Response ValidateUserSession(Request request)
 {
     if (request == null || string.IsNullOrEmpty(request.SessionId))
         return new Response() {IsSucess = false, ErrorMessage = "Invalide session request!"};
     Response response = new Response() { IsSucess = true };
     try
     {
         ICacheProvider cache = CacheProviderFactory.GetCacheProvider();
         var session = cache.GetValue(request.SessionId);
         if (session == null)
         {
             response.IsSucess = false;
             response.ErrorMessage = "Session expired! Please sign in again.";
         }
     }
     catch (Exception ex)
     {
         response.IsSucess = false;
         response.ErrorMessage = "Session expired! Please sign in again.";
         LoggingDataProviderFactory.GetLoggingDataProvider().LogException(ex, Source, "ValidateUserSession", Model.Severity.Critical);
     }
     return response;
 }
Beispiel #2
0
 private static Model.UserSession GetSession(string sessionId, Response response)
 {
     ICacheProvider cacheProvider = CacheProviderFactory.GetCacheProvider();
     var session = cacheProvider.GetValue(sessionId) as Model.UserSession;
     if (session == null)
     {
         response.IsSucess = false;
         response.Code = 4004;
         response.ErrorMessage = "Session Expired! Please login again.";
     }
     return session;
 }
Beispiel #3
0
 public Response Logout(Request request)
 {
     if (request == null || string.IsNullOrEmpty(request.SessionId))
         return new Response() { IsSucess = false, ErrorMessage = "Invalide logout request!" };
     Response response = new Response() { IsSucess = true };
     try
     {
         ICacheProvider cache = CacheProviderFactory.GetCacheProvider();
         cache.Remove(request.SessionId);
     }
     catch (Exception ex)
     {
         response.IsSucess = false;
         response.ErrorMessage = "Logout failed!";
         LoggingDataProviderFactory.GetLoggingDataProvider().LogException(ex, Source, "Logout", Model.Severity.Critical);
     }
     return response;
 }