Esempio n. 1
0
        //Delete/Clear Session details for user
        public JsonResult ClearSessionDetails(string userId)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _UserSessionLogBusinessLogic = new UserSessionLogBusinessLogic();
                _EncryptionModule            = new EncryptionModule();

                int decryptedUserId = Convert.ToInt32(_EncryptionModule.Decrypt(userId));

                var result = _UserSessionLogBusinessLogic.ClearSessionDetails(decryptedUserId);

                return(Json(result));
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);
                return(Json(false));
            }
        }
Esempio n. 2
0
        //Get all user log details
        public JsonResult GetAllLoggedInSessions(string userId)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _UserSessionLogBusinessLogic = new UserSessionLogBusinessLogic();
                _EncryptionModule            = new EncryptionModule();

                HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

                int decryptedUserId = userId == "0" ? 0 : Convert.ToInt32(_EncryptionModule.Decrypt(userId));

                if (authCookie != null)
                {
                    ticket = FormsAuthentication.Decrypt(authCookie.Value);



                    var userLogDetails = _UserSessionLogBusinessLogic.GetAllLoggedInSessions(decryptedUserId);

                    var userLogDetailsEncrypted = userLogDetails
                                                  .Select(ul => new
                    {
                        UserSessionLogId   = _EncryptionModule.Encrypt(ul.UserSessionLogId.ToString()),
                        UserId             = _EncryptionModule.Encrypt(ul.UserId.ToString()),
                        ProfilePicURL      = ul.ProfilePicURL,
                        Username           = ul.Username,
                        UserGroupName      = ul.UserGroupName,
                        UserFullName       = ul.UserFullName,
                        UserCallingName    = ul.UserCallingName,
                        IPAddress          = ul.IPAddress,
                        CountryCode        = ul.CountryCode,
                        Country            = ul.Country,
                        City               = ul.City,
                        Region             = ul.Region,
                        LoggedInTimestamp  = ul.LoggedInTimestamp,
                        LoggedOffTimestamp = ul.LoggedOffTimestamp
                    }).ToList();



                    return(Json(userLogDetailsEncrypted));
                }
                else
                {
                    return(Json(null));
                }
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);
                return(Json(null));
            }
        }