Ejemplo n.º 1
0
    void wf_BusinessTypes_SelectedIndexChanged(object sender, EventArgs e)
    {
        var businessArea = GetValidBusinessArea(wf_BusinessTypes.SelectedValue);
        IList <ContactFormType> formTypes;

        if (string.IsNullOrEmpty(businessArea)) // If 'All Areas' or an invalid value is selected, fill with all items. . .
        {
            formTypes = ContactFormDao.GetContactFormTypes();
        }
        else // Fill with business Area items. . .
        {
            formTypes = ContactFormDao.GetContactFormTypes(businessArea);
        }

        ResetFormTypes(formTypes);
    }
Ejemplo n.º 2
0
    private void BindData()
    {
        // Populate Business Area drop down. . .
        wf_BusinessTypes.DataSource = ContactFormDao.GetContactFormBusinessAreas();
        wf_BusinessTypes.DataBind();
        wf_BusinessTypes.AutoPostBack = true;
        wf_BusinessTypes.Items.Insert(0, ALLAREAS_DESC);

        // Populate Form Types so that admin can filter down what site/form
        ResetFormTypes(ContactFormDao.GetContactFormTypes());

        // lets prepopulate starting date to 7 days ago
        wf_StartingFrom.Text = DateTime.Now.AddDays(-7).ToShortDateString();

        wf_Contacts.DataSource = ContactFormDao.GetLast100Contacts();
        wf_Contacts.DataBind();

        wf_PreviewDesc.Text    = "Viewing Last 100 Contacts";
        wf_PreviewDesc.Visible = true;
    }
Ejemplo n.º 3
0
    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);
        }
    }