Beispiel #1
0
        public IHttpActionResult GetOnlineSessionByUserID(string id)
        {
            List <SessionHistoryEntity> sessionEntityList = new List <SessionHistoryEntity>();

            ResultEntity result = new ResultEntity();

            try
            {
                List <SessionHistory> temp = dal.FindAllOnlineSessions();
                foreach (var sessionHistory in temp)
                {
                    SessionHistoryEntity item = sessionHistory.ToSessionHistoryEntity();
                    item.GGAHistories = sessionHistory.GGAHistories.ToList <GGAHistory>().ConvertAll <GGAHistoryEntity>(g => g.ToGGAHistoryEntity());
                    List <string> accountNameList = this.getAccountNameListByUserID(id);
                    if (accountNameList.Contains(item.AccountName))
                    {
                        sessionEntityList.Add(item);
                    }
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                NtripProxyLogger.LogExceptionIntoFile("调用接口api/SessionHistory/GetOnlineSessionByUserID异常,异常信息为:" + e.Message);
            }
            result.IsSuccess = result.Message == null;
            result.Data      = sessionEntityList;
            return(Json <ResultEntity>(result));
        }
        /// <summary>
        /// SessionHistory,转换基础信息到SessionHistoryEntity
        /// </summary>
        /// <param name="session">DAL层会话</param>
        /// <returns>WebApi层会话实体</returns>
        public static SessionHistoryEntity ToSessionHistoryEntity(this SessionHistory session)
        {
            SessionHistoryEntity sessionHistoryEntity = new SessionHistoryEntity
            {
                ID              = session.ID,
                AccountName     = session.AccountName,
                AccountType     = session.AccountType,
                AccountSYSName  = session.AccountSYSName,
                MountPoint      = session.MountPoint,
                Client          = session.Client,
                ClientAddress   = session.ClientAddress,
                ConnectionStart = session.ConnectionStart,
                ConnectionEnd   = session.ConnectionEnd,
                GGACount        = (int)session.GGACount,
                FixedCount      = (int)session.FixedCount,
                ErrorInfo       = session.ErrorInfo
            };

            return(sessionHistoryEntity);
        }