/// <summary> /// Obtaions a dictionary of all contact forms that fall under the included criteria, grouping them by their source form name. /// </summary> private IList <ContactForm> GetRequestedContactForms(string businessArea, List <string> formTypes, string startingDateValue, string endingDateValue, string contactType) { DateTime?startingDate; DateTime?endingDate; var contactForms = new List <ContactForm>(); try { for (int i = 0; i < formTypes.Count; i++) // Check FormTypes { formTypes[i] = GetValidFormType(formTypes[i]); } // Check Starting Date startingDate = GetValidStartDate(startingDateValue); endingDate = GetValidEndDate(endingDateValue); if (!endingDate.HasValue || endingDate.Value == DateTime.MinValue) { endingDate = DateTime.Now; } endingDate = endingDate.Value.Date.AddDays(1).AddMilliseconds(-1); // Get the highest possible time for the date. if (!startingDate.HasValue) { startingDate = endingDate.Value.AddDays(-7); } var forms = ContactFormDao.GetContactsByCriteria(businessArea, formTypes, startingDate.Value, endingDate.Value); foreach (var form in forms) { if (string.IsNullOrEmpty(form.FormData)) // Skip items that dont' have any form data. . . { continue; } if (!string.IsNullOrEmpty(contactType) && // Filter by 'contactType,' if necessary. . . !form.ContactTypes.Trim().Equals(contactType.Trim(), StringComparison.CurrentCultureIgnoreCase)) { continue; } contactForms.Add(form); // Add the form to the list. . . } } catch (Exception ex) { return(null); } return(contactForms); }
private IList <ContactForm> GetRequestedContactForms() { List <string> formTypes = new List <string>(); DateTime? startingDate; DateTime? endingDate; try { // Add FormTypes //formType = GetValidFormType(wf_FormTypes.SelectedValue); formTypes = GetFormTypes(); // Check Starting Date startingDate = GetValidStartDate(wf_StartingFrom); if (!startingDate.HasValue) { return(null); } endingDate = GetValidEndDate(wf_EndingOn); if (!endingDate.HasValue) { return(null); } else { if (endingDate < MaxDateTime.AddDays(-1)) { endingDate = ((DateTime)endingDate).AddDays(1).AddMilliseconds(-1); } } UpdatePreviewDescription(formTypes, startingDate, endingDate); return(ContactFormDao.GetContactsByCriteria(formTypes, startingDate.Value, endingDate.Value)); } catch (ArgumentOutOfRangeException outOfRangeException) { wf_Status.Text = outOfRangeException.Message; wf_Status.Visible = true; return(null); } catch (ArgumentException ex) { wf_Status.Text = ex.Message; wf_Status.Visible = true; return(null); } }
private IList <ContactForm> GetRequestedContactForms() { string formType; DateTime?startingDate; DateTime?endingDate; try { var formTypes = new List <string>(); // Grab the business area var businessArea = GetValidBusinessArea(wf_BusinessTypes.SelectedValue); // Check FormType formType = GetValidFormType(wf_FormTypes.SelectedValue); if (!string.IsNullOrEmpty(formType)) { formTypes.Add(formType); } else { formTypes.AddRange(ContactFormDao.GetContactFormTypes(businessArea).Select(x => x.SourceFormName)); } // Check Starting Date startingDate = GetValidStartDate(wf_StartingFrom); if (!startingDate.HasValue) { return(null); } endingDate = GetValidEndDate(wf_EndingOn); if (!endingDate.HasValue) { return(null); } else { if (endingDate < MaxDateTime.AddDays(-1)) { endingDate = ((DateTime)endingDate).AddDays(1).AddMilliseconds(-1); } } UpdatePreviewDescription(businessArea, formType, startingDate, endingDate); return(ContactFormDao.GetContactsByCriteria(businessArea, formTypes, startingDate.Value, endingDate.Value)); } catch (ArgumentOutOfRangeException outOfRangeException) { wf_Status.Text = outOfRangeException.Message; wf_Status.Visible = true; return(null); } catch (ArgumentException ex) { wf_Status.Text = ex.Message; wf_Status.Visible = true; return(null); } }