예제 #1
0
        public void SaveLastRequest(int userID)
        {
            try
            {
                if (!IsUserTrackAllowed())
                {
                    return;
                }

                ActiveUser activeUser = GetActiveUserByUserID(userID);

                if (activeUser != null)
                {
                    activeUser.LastRequestTS = DateTime.Now;
                    activeUser.RequestCount += 1;

                    activeUser.Save();
                }
            }
            catch (Exception ex)
            {
                string error = "";
                CommonMethods.getError(ex, ref error);
                throw new Exception(CommonMethods.ConcatenateErrorIN_DB(DB_Exception.res_23, error, CommonMethods.GetCurrentMethodName()));
            }
        }
예제 #2
0
        public int SaveUserLoggedInActivity(bool active, int userID, int sessionExpiresMin = 0)
        {
            try
            {
                if (!IsUserTrackAllowed())
                {
                    return(-1);
                }

                ActiveUser activeUser = GetActiveUserByUserID(userID);

                if (activeUser != null)
                {
                    //če v trenutnem dnevu še ni zabeležene prijave se doda nova drugače se posodobijo vrednosti na obstoječi prijavi
                    if (activeUser.LoginDate.Date == DateTime.Today.Date)
                    {
                        activeUser.LoginDate        = DateTime.Now;
                        activeUser.IsActive         = active;
                        activeUser.LastRequestTS    = DateTime.Now;
                        activeUser.RequestCount    += 1;
                        activeUser.SessionExpireMin = active ? sessionExpiresMin : activeUser.SessionExpireMin;

                        activeUser.Save();
                        return(activeUser.ActiveUserID);
                    }
                    else
                    {
                        activeUser = CreateModel(userID, active, sessionExpiresMin);
                        activeUser.Save();
                        return(activeUser.ActiveUserID);
                    }
                }
                else
                {
                    activeUser = CreateModel(userID, active, sessionExpiresMin);
                    activeUser.Save();
                    return(activeUser.ActiveUserID);
                }
            }
            catch (Exception ex)
            {
                string error = "";
                CommonMethods.getError(ex, ref error);
                throw new Exception(CommonMethods.ConcatenateErrorIN_DB(DB_Exception.res_23, error, CommonMethods.GetCurrentMethodName()));
            }
        }