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;
}