Exemple #1
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;
        }
Exemple #2
0
 /// <summary>
 /// Using the configured SQL connection string, opens a connection to the database and attempts
 /// to wrtie a record from the ApplicationSessions table 
 /// </summary>
 /// <returns>BoolTO with true value if read was successful, FaultTO otherwise</returns>
 public BoolTO canWrite()
 {
     UsageDao dao = new UsageDao(_connectionString);
     string sessionId = gov.va.medora.utils.StringUtils.getNCharRandom(24);
     ApplicationSession session = new ApplicationSession(sessionId, System.Net.IPAddress.Loopback.ToString(), DateTime.Now);
     session.End = DateTime.Now;
     session.LocalhostName = System.Net.IPAddress.Loopback.ToString();
     ApplicationRequest request = new ApplicationRequest(sessionId, new Uri("http://mdws.va.gov/getSomething"), DateTime.Now, DateTime.Now, "<Soap>...</Soap>", "<Soap>...</Soap>");
     session.Requests.Add(request);
     dao.saveSession(session);
     return dao.deleteSession(sessionId);
 }