Exemple #1
0
        public HttpResponseMessage Get(string sessionId)
        {
            SessionMinDetails retVal = new SessionMinDetails();

            try
            {
                SessionController sessionController = new SessionController();

                Session session = sessionController.GetSessionWithId(new SessionId(sessionId));

                retVal.Description       = session.Description;
                retVal.SessionId         = session.SessionId.ToString();
                retVal.StartTime         = session.StartTime.ToString("yyyy-MM-dd HH:mm:ss");
                retVal.EndTime           = session.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
                retVal.Status            = session.Status;
                retVal.DiagnoserSessions = new List <string>(session.GetDiagnoserSessions().Select(p => p.Diagnoser.Name));
                retVal.HasBlobSasUri     = !string.IsNullOrWhiteSpace(session.BlobSasUri);
            }
            catch (FileNotFoundException fex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, fex.Message));
            }
            catch (Exception ex)
            {
                Logger.LogSessionErrorEvent("Encountered exception while getting session", ex, sessionId);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, retVal));
        }
        public HttpResponseMessage Get(string type)
        {
            List <SessionMinDetails> retVal = new List <SessionMinDetails>();

            try
            {
                SessionController     sessionController = new SessionController();
                IEnumerable <Session> sessions;

                switch (type.ToLowerInvariant())
                {
                case "all":
                    sessions = sessionController.GetAllSessions();
                    break;

                case "pending":
                    sessions = sessionController.GetAllActiveSessions();
                    break;

                case "needanalysis":
                    sessions = sessionController.GetAllUnanalyzedSessions();
                    break;

                case "complete":
                    sessions = sessionController.GetAllCompletedSessions();
                    break;

                default:
                    sessions = sessionController.GetAllSessions();
                    break;
                }

                IEnumerable <Session> sortedSessions = sessions.OrderByDescending(p => p.StartTime);

                foreach (Session session in sortedSessions)
                {
                    SessionMinDetails sessionDetails = new SessionMinDetails
                    {
                        Description       = session.Description,
                        SessionId         = session.SessionId.ToString(),
                        StartTime         = session.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        EndTime           = session.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Status            = session.Status,
                        DiagnoserSessions = new List <String>(session.GetDiagnoserSessions().Select(p => p.Diagnoser.Name)),
                        HasBlobSasUri     = !string.IsNullOrWhiteSpace(session.BlobSasUri)
                    };

                    retVal.Add(sessionDetails);
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorEvent("Encountered exception while getting sessions from file", ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, $"Encountered exception {ex.Message} while getting sessions from file"));
            }


            return(Request.CreateResponse(HttpStatusCode.OK, retVal));
        }
        public List <SessionMinDetails> Get(string type)
        {
            SessionController sessionController = new SessionController();

            IEnumerable <ISession> sessions;

            switch (type)
            {
            case "all":
                sessions = sessionController.GetAllSessions();
                break;

            case "pending":
                sessions = sessionController.GetAllActiveSessions();
                break;

            case "needanalysis":
                sessions = sessionController.GetAllUnanalyzedSessions();
                break;

            case "complete":
                sessions = sessionController.GetAllCompletedSessions();
                break;

            default:
                sessions = sessionController.GetAllSessions();
                break;
            }

            List <SessionMinDetails> retVal = new List <SessionMinDetails>();

            foreach (ISession session in sessions)
            {
                SessionMinDetails sessionDetails = new SessionMinDetails
                {
                    Description       = session.Description,
                    SessionId         = session.SessionId.ToString(),
                    StartTime         = session.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    EndTime           = session.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    Status            = session.Status,
                    DiagnoserSessions = new List <String>(session.GetDiagnoserSessions().Select(p => p.Diagnoser.Name))
                };

                retVal.Add(sessionDetails);
            }

            return(retVal);
        }
        public SessionMinDetails Get(string sessionId)
        {
            SessionController sessionController = new SessionController();

            ISession session = sessionController.GetSessionWithId(new SessionId(sessionId)).Result;

            SessionMinDetails retval = new SessionMinDetails
            {
                Description       = session.Description,
                SessionId         = session.SessionId.ToString(),
                StartTime         = session.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                EndTime           = session.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                Status            = session.Status,
                DiagnoserSessions = new List <string>(session.GetDiagnoserSessions().Select(p => p.Diagnoser.Name))
            };

            return(retval);
        }