コード例 #1
0
        public ApplicationSessionsTO getMdwsSessionsInMemory()
        {
            ApplicationSessionsTO result = new ApplicationSessionsTO();

            if (Application == null || Application.AllKeys == null || !Application.AllKeys.Contains("APPLICATION_SESSIONS"))
            {
                return(result);
            }
            ApplicationSessions sessions = (ApplicationSessions)Application["APPLICATION_SESSIONS"];

            if (sessions.Sessions == null || sessions.Sessions.Count == 0)
            {
                return(result);
            }

            result.sessions = new ApplicationSessionTO[sessions.Sessions.Count];
            int currentIndex = 0;

            foreach (string sessionId in sessions.Sessions.Keys)
            {
                result.sessions[currentIndex] = new ApplicationSessionTO(sessions.Sessions[sessionId]);
                currentIndex++;
            }
            return(result);
        }
コード例 #2
0
        public ApplicationSessionsTO getMdwsSessions(string startDate, string endDate)
        {
            ApplicationSessionsTO result = new ApplicationSessionsTO();
            UsageDao dao = null;

            try
            {
                dao = new UsageDao();
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
                return(result);
            }

            DateTime start = new DateTime();
            DateTime end   = new DateTime();

            if (String.IsNullOrEmpty(startDate) || String.IsNullOrEmpty(endDate))
            {
                result.fault = new FaultTO("Must supply a start and a stop date");
            }
            else if (!DateTime.TryParse(startDate, out start))
            {
                result.fault = new FaultTO("Unable to parse start date", "Try a different date format");
            }
            else if (!DateTime.TryParse(endDate, out end))
            {
                result.fault = new FaultTO("Unable to parse end date", "Try a different date format");
            }
            if (start.Year < 2010 || end.Year < 2010)
            {
                result.fault = new FaultTO("No records exist from before 2010");
            }
            else if (end.CompareTo(start) < 0)
            {
                result.fault = new FaultTO("The end date must be the same or later than the start date");
            }
            else if (end.Subtract(start).TotalDays > 30)
            {
                result.fault = new FaultTO("You are only allowed to retrieve a 30 day window of session data");
            }

            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                result = dao.getSessions(start, end);
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }
            return(result);
        }
コード例 #3
0
ファイル: UsageDao.cs プロジェクト: monkeyglasses/mdws
        /// <summary>
        /// Get all the MDWS sessions and the related requests for a given date range
        /// </summary>
        /// <param name="start">The start date</param>
        /// <param name="end">The end date</param>
        /// <returns>An ApplicationSessionsTO object - will have a FaultTO if an error occurs</returns>
        public ApplicationSessionsTO getSessions(DateTime start, DateTime end)
        {
            ApplicationSessionsTO result = new ApplicationSessionsTO();

            SqlConnection  conn = new SqlConnection();
            SqlTransaction tx   = null;

            try
            {
                conn = getConnection();

                tx = conn.BeginTransaction();
                SqlDataAdapter adapter      = buildSelectSessionsAdapter(start, end, conn, tx);
                DataSet        sessionData  = new DataSet();
                int            sessionCount = adapter.Fill(sessionData);

                tx.Commit();

                return(new ApplicationSessionsTO(getApplicationSessions(sessionData)));
            }
            catch (Exception exc)
            {
                if (tx != null && tx.Connection != null) // transaction connection should be null if completed
                {
                    tx.Rollback();
                }
                result.fault = new FaultTO(exc);
                return(result);
            }
            finally
            {
                conn.Close();
                if (tx != null)
                {
                    tx.Dispose();
                }
            }
        }
コード例 #4
0
ファイル: UsageDao.cs プロジェクト: ChristopherEdwards/mdws-1
        /// <summary>
        /// Get all the MDWS sessions and the related requests for a given date range
        /// </summary>
        /// <param name="start">The start date</param>
        /// <param name="end">The end date</param>
        /// <returns>An ApplicationSessionsTO object - will have a FaultTO if an error occurs</returns>
        public ApplicationSessionsTO getSessions(DateTime start, DateTime end)
        {
            ApplicationSessionsTO result = new ApplicationSessionsTO();

            SqlConnection conn = new SqlConnection();
            SqlTransaction tx = null;
            try
            {
                conn = getConnection();

                tx = conn.BeginTransaction();
                SqlDataAdapter adapter = buildSelectSessionsAdapter(start, end, conn, tx);
                DataSet sessionData = new DataSet();
                int sessionCount = adapter.Fill(sessionData);

                tx.Commit();

                return new ApplicationSessionsTO(getApplicationSessions(sessionData));
            }
            catch (Exception exc)
            {
                if (tx != null && tx.Connection != null) // transaction connection should be null if completed
                {
                    tx.Rollback();
                }
                result.fault = new FaultTO(exc);
                return result;
            }
            finally
            {
                conn.Close();
                if (tx != null)
                {
                    tx.Dispose();
                }
            }
        }