Example #1
0
        private Tuple <int, int> Process()
        {
            //userid,offlineTime
            Dictionary <int, string> infos = UserStore.GetUserSessionOfflineInfos();

            if (infos == null || infos.Count <= 0)
            {
                return(new Tuple <int, int>(0, 0));
            }

            int      handleCount = 0;
            DateTime offlineTime;

            foreach (var item in infos)
            {
                if (!string.IsNullOrEmpty(item.Value) &&
                    DateTime.TryParse(item.Value, out offlineTime) &&
                    offlineTime.AddHours(2) <= DateTime.Now &&
                    UserStore.DeleteSessionOfflineUserInfo(item.Key, item.Value))
                {
                    //Get near group guid recently used by the user and then remove the user from the group according to near group guid
                    string nearGrouGuid = GroupStore.GetRecentUserInNearGroupGuid(item.Key);
                    GroupStore.DeleteGroupUsers(nearGrouGuid, item.Key);
                    handleCount++;
                }
            }
            return(new Tuple <int, int>(infos.Count, handleCount));
        }