示例#1
0
        public void SessionChange(int sessionId, SessionChangeReason evnt, SessionProperties properties)
        {
            if (evnt == SessionChangeReason.SessionLogon)
            {
                string username = ApiUtils.GetUserFromSession(sessionId).GetUsername();
                sessionTracker.UserLoggedOn(username, sessionId);
            }
            else if (evnt == SessionChangeReason.SessionLogoff)
            {
                SessionTracker.Information information = sessionTracker.GetInformation(sessionId);
                if (information == null)
                {
                    return;
                }

                try
                {
                    sessionTracker.StartedProfileUploading(information.Username);
                    using (var synchronizer = new SftpSynchronizer(information.Username, information.Password, information.Sid))
                    {
                        synchronizer.UploadProfile();
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    Log.Error(e.StackTrace);
                }
                finally
                {
                    sessionTracker.UserLoggedOff(information.Username, sessionId);
                }
            }
        }
示例#2
0
        public static SessionChangeReasonCode ToCode(this SessionChangeReason value)
        {
            switch (value)
            {
            case SessionChangeReason.ConsoleConnect: return(SessionChangeReasonCode.ConsoleConnect);

            case SessionChangeReason.ConsoleDisconnect: return(SessionChangeReasonCode.ConsoleDisconnect);

            case SessionChangeReason.RemoteConnect: return(SessionChangeReasonCode.RemoteConnect);

            case SessionChangeReason.RemoteDisconnect: return(SessionChangeReasonCode.RemoteDisconnect);

            case SessionChangeReason.SessionLock: return(SessionChangeReasonCode.SessionLock);

            case SessionChangeReason.SessionUnlock: return(SessionChangeReasonCode.SessionUnlock);

            case SessionChangeReason.SessionLogoff: return(SessionChangeReasonCode.SessionLogoff);

            case SessionChangeReason.SessionLogon: return(SessionChangeReasonCode.SessionLogon);

            case SessionChangeReason.SessionRemoteControl: return(SessionChangeReasonCode.SessionRemoteControl);

            default: return(default(SessionChangeReasonCode));
            }
        }
示例#3
0
        private void DoAction(SessionChangeReason reason)
        {
            switch (reason)
            {
            case SessionChangeReason.SessionLogon:
                Clockwork.Instance.Send("", "Greetings!");
                break;

            case SessionChangeReason.SessionLogoff:
                Clockwork.Instance.Send("", "Don't leeeeave meeee! :(");
                break;

            case SessionChangeReason.SessionLock:
                Clockwork.Instance.Send("", "Bye~");
                break;

            case SessionChangeReason.SessionUnlock:
                Clockwork.Instance.Send("", "Welcome back~");
                break;
            }

            using (var service = new MMPService())
            {
                service.AddUserEventByEventTypeId(string.Format("{0}/{1}", Environment.UserDomainName, Environment.UserName), (int)reason);
            }
        }
示例#4
0
        public static SessionChangeDescription CreateSessionChangeDescription(SessionChangeReason reason, int id)
        {
            SessionChangeDescriptionUnion u;

            u.Desc     = new SessionChangeDescription();
            u.DescCopy = new SessionChangeDescriptionCopy()
            {
                _id = id, _reason = reason
            };
            return(u.Desc);
        }
示例#5
0
 protected override void OnSessionChange(SessionChangeDescription changeDescription)
 {
     //if (e.Reason == SessionSwitchReason.SessionLock)
     //{
     //    m_SessionState = SessionSwitchReason.SessionLock;
     //    //I left my desk
     //}
     //else if (e.Reason == SessionSwitchReason.SessionUnlock)
     //{
     //    m_SessionState = SessionSwitchReason.SessionUnlock;
     //    //I returned to my desk
     //}
     if (changeDescription.Reason == SessionChangeReason.ConsoleConnect || changeDescription.Reason == SessionChangeReason.ConsoleDisconnect)
     {
         m_SessionState = changeDescription.Reason;
     }
     //Utils.WriteLog(changeDescription.Reason.ToString());
     //base.OnSessionChange(changeDescription);
 }
示例#6
0
 public void SessionChange(int sessionID, SessionChangeReason evnt)
 {
     m_logger.InfoFormat("SessionChange:{0} {1}", sessionID, (int)evnt);
     Thread rem_local = new Thread(() => SessionChangeThread(sessionID, evnt));
     rem_local.Start();
 }
示例#7
0
 private void SessionChangeThread(int sessionID, SessionChangeReason evnt)
 {
     m_logger.InfoFormat("SessionChange: {0} -> {1}", sessionID, evnt);
     try
     {
         lock (m_sessionPropertyCache)
         {
             if (evnt == SessionChangeReason.SessionLogon && m_sessionPropertyCache.Exists(sessionID))
             {
                 // if a user tried to logon but didnt pass the logonscreen (windows 8 and 10 lock screen bug) trash the info stored about that session
                 UserInformation uInfo = m_sessionPropertyCache.Get(sessionID).First().GetTrackedSingle<UserInformation>();
                 string sessionID_is = String.Format("{0}@{1}", Abstractions.WindowsApi.pInvokes.GetUserName(sessionID), Abstractions.WindowsApi.pInvokes.GetUserDomain(sessionID));
                 string sessionID_should = String.Format("{0}@{1}", uInfo.Username, uInfo.Domain);
                 if (!sessionID_is.Equals(sessionID_should, StringComparison.CurrentCultureIgnoreCase))
                 {
                     m_logger.InfoFormat("SessionLogon missmatch {0} != {1} removing SessionProperties", sessionID_is, sessionID_should);
                     m_sessionPropertyCache.Remove(sessionID);
                     return;
                 }
             }
             if (evnt == SessionChangeReason.SessionLogoff)
             {
                     CREDUIhelper(sessionID);
             }
             foreach (IPluginEventNotifications plugin in PluginLoader.GetOrderedPluginsOfType<IPluginEventNotifications>())
             {
                 if (m_sessionPropertyCache.Exists(sessionID))
                 {
                     foreach (SessionProperties props in m_sessionPropertyCache.Get(sessionID))
                     {
                         plugin.SessionChange(sessionID, evnt, props);
                     }
                 }
                 else
                 {
                     plugin.SessionChange(sessionID, evnt, null);
                 }
             }
             // If this is a logout, remove from our map
             if (evnt == SessionChangeReason.SessionLogoff && m_sessionPropertyCache.Exists(sessionID))
             {
                 //m_logger.InfoFormat("delete sessionInfos:{0} from sessionID:{1}", String.Join(" ", m_sessionPropertyCache.Get(sessionID).Select(l => l.Id).ToList()), sessionID);
                 m_sessionPropertyCache.Remove(sessionID);
             }
         }
     }
     catch (Exception e)
     {
         m_logger.ErrorFormat("Exception while handling SessionChange event: {0}", e);
     }
 }
示例#8
0
 // protected virtual void OnSessionChange(SessionChangeDescription changeDescription)
 protected virtual void OnSessionChange(SessionChangeReason reason, int sessionId)
 {
 }
 internal SessionChangeDescription(SessionChangeReason reason, int id)
 {
     this._reason = reason;
     this._id = id;
 }
示例#10
0
        public static void HandleSessionChanged(SessionChangeReason reason)
        {
            Log.Information("ServiceHelper HandleSessionChanged called");

            Refresh();
        }
示例#11
0
 internal SessionChangeEventArgs(SessionChangeReason reason, int sessionId)
 {
     Reason    = reason;
     SessionId = sessionId;
 }
示例#12
0
 public abstract void SessionChange(
     [NotNull] TextWriter writer,
     [SCP(typeof(ServiceResources), "Cmd_SessionChange_ChangeReason_Description")] SessionChangeReason
     changeReason,
     [SCP(typeof(ServiceResources), "Cmd_SessionChange_SessionID_Description")] int sessionId);
 internal SessionChangeDescription(SessionChangeReason reason, int id)
 {
     this.reason = reason;
     this.id     = id;
 }
 // protected virtual void OnSessionChange(SessionChangeDescription changeDescription)
 protected virtual void OnSessionChange(SessionChangeReason reason, int sessionId)
 {
 }
示例#15
0
 public void SessionChange(int sessionID, SessionChangeReason evnt)
 {
     m_service.SessionChange(sessionID, evnt);
 }
示例#16
0
 public static SessionChangeDescription CreateSessionChangeDescription(SessionChangeReason reason, int id)
 {
     SessionChangeDescriptionUnion u;
     u.Desc = new SessionChangeDescription();
     u.DescCopy = new SessionChangeDescriptionCopy() { _id = id, _reason = reason };
     return u.Desc;
 }
 internal SessionChangeDescription(SessionChangeReason reason, int id)
 {
     _reason = reason;
     _id     = id;
 }
示例#18
0
 public void SessionChange(int sessionID, SessionChangeReason evnt)
 {
     m_service.SessionChange(sessionID, evnt);
 }