/// <summary>
    /// Gets the contact targets.
    /// </summary>
    /// <returns></returns>
    private IList GetContactTargets()
    {
        IList              contactList;
        IQueryable         query       = (IQueryable)EntityFactory.GetRepository <IContact>();
        IExpressionFactory expressions = query.GetExpressionFactory();
        IProjections       projections = query.GetProjectionsFactory();
        ICriteria          criteria    = query.CreateCriteria("a1")
                                         .CreateCriteria("Account", "account")
                                         .CreateCriteria("a1.Addresses", "address")
                                         .SetProjection(projections.ProjectionList()
                                                        .Add(projections.Distinct(projections.Property("Id")))
                                                        .Add(projections.Property("FirstName"))
                                                        .Add(projections.Property("LastName"))
                                                        .Add(projections.Property("AccountName"))
                                                        .Add(projections.Property("Email"))
                                                        .Add(projections.Property("address.City"))
                                                        .Add(projections.Property("address.State"))
                                                        .Add(projections.Property("address.PostalCode"))
                                                        .Add(projections.Property("WorkPhone"))

                                                        );

        AddExpressionsCriteria(criteria, expressions);
        contactList = criteria.List();
        // NOTE: The generic exception handler was removed since the exception was rethrown; this exception would be logged twice otherwise.
        // We may want to throw a UserObservableApplicationException in the future.
        return(contactList);
    }
Example #2
0
    /// <summary>
    /// Gets the contact targets.
    /// </summary>
    /// <returns></returns>
    private IList GetContactTargets()
    {
        IList contactList;

        try
        {
            IQueryable         query       = (IQueryable)EntityFactory.GetRepository <IContact>();
            IExpressionFactory expressions = query.GetExpressionFactory();
            IProjections       projections = query.GetProjectionsFactory();
            ICriteria          criteria    = query.CreateCriteria("a1")
                                             .CreateCriteria("Account", "account")
                                             .CreateCriteria("a1.Addresses", "address")
                                             .SetProjection(projections.ProjectionList()
                                                            .Add(projections.Distinct(projections.Property("Id")))
                                                            .Add(projections.Property("FirstName"))
                                                            .Add(projections.Property("LastName"))
                                                            .Add(projections.Property("Account"))
                                                            .Add(projections.Property("Email"))
                                                            .Add(projections.Property("address.City"))
                                                            .Add(projections.Property("address.State"))
                                                            .Add(projections.Property("address.PostalCode"))
                                                            .Add(projections.Property("WorkPhone"))
                                                            );
            AddExpressionsCriteria(criteria, expressions);
            contactList = criteria.List();
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            throw;
        }
        return(contactList);
    }
Example #3
0
    /// <summary>
    /// Gets the contact targets via a join through Account.
    /// </summary>
    /// <returns></returns>
    private IList GetAccountTargets()
    {
        IList contactList;

        try
        {
            IQueryable         query       = (IQueryable)EntityFactory.GetRepository <IContact>();
            IExpressionFactory expressions = query.GetExpressionFactory();
            IProjections       projections = query.GetProjectionsFactory();
            ICriteria          criteria    = query.CreateCriteria("a1")
                                             .CreateCriteria("Account", "account")
                                             .CreateCriteria("Addresses", "address")
                                             .SetProjection(projections.ProjectionList()
                                                            .Add(projections.Distinct(projections.Property("Id")))
                                                            .Add(projections.Property("FirstName"))
                                                            .Add(projections.Property("LastName"))
                                                            .Add(projections.Property("Account"))
                                                            .Add(projections.Property("Email"))
                                                            .Add(projections.Property("address.City"))
                                                            .Add(projections.Property("address.State"))
                                                            .Add(projections.Property("address.PostalCode"))
                                                            .Add(projections.Property("WorkPhone"))
                                                            );
            AddExpressionsCriteria(criteria, expressions);
            contactList = criteria.List();
        }
        catch (NHibernate.QueryException nex)
        {
            log.Error(nex.Message);
            string message = GetLocalResourceObject("QueryError").ToString();
            if (nex.Message.Contains("could not resolve property"))
            {
                message += "  " + GetLocalResourceObject("QueryErrorInvalidParameter");
            }

            throw new ValidationException(message);
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            throw;
        }
        return(contactList);
    }
    /// <summary>
    /// Gets the contact targets via a join through Account.
    /// </summary>
    /// <returns></returns>
    private IList GetAccountTargets()
    {
        IList contactList;

        try
        {
            IQueryable         query       = (IQueryable)EntityFactory.GetRepository <IContact>();
            IExpressionFactory expressions = query.GetExpressionFactory();
            IProjections       projections = query.GetProjectionsFactory();
            ICriteria          criteria    = query.CreateCriteria("a1")
                                             .CreateCriteria("Account", "account")
                                             .CreateCriteria("Addresses", "address")
                                             .SetProjection(projections.ProjectionList()
                                                            .Add(projections.Distinct(projections.Property("Id")))
                                                            .Add(projections.Property("FirstName"))
                                                            .Add(projections.Property("LastName"))
                                                            .Add(projections.Property("AccountName"))
                                                            .Add(projections.Property("Email"))
                                                            .Add(projections.Property("address.City"))
                                                            .Add(projections.Property("address.State"))
                                                            .Add(projections.Property("address.PostalCode"))
                                                            .Add(projections.Property("WorkPhone"))
                                                            );
            AddExpressionsCriteria(criteria, expressions);
            contactList = criteria.List();
        }
        catch (NHibernate.QueryException nex)
        {
            log.Error("The call to ManageTargets.GetAccountTargets() failed", nex);
            string message = GetLocalResourceObject("QueryError").ToString();
            if (nex.Message.Contains("could not resolve property"))
            {
                message += "  " + GetLocalResourceObject("QueryErrorInvalidParameter");
            }

            throw new ValidationException(message);
        }
        // NOTE: The generic exception handler was removed since the exception was rethrown; this exception would be logged twice otherwise.
        // We may want to throw a UserObservableApplicationException in the future.
        return(contactList);
    }
Example #5
0
    /// <summary>
    /// Gets the Lead targets.
    /// </summary>
    /// <returns></returns>
    private IList GetLeadTargets()
    {
        IList leadList = null;

        try
        {
            IQueryable         query       = (IQueryable)EntityFactory.GetRepository <ILead>();
            IExpressionFactory expressions = query.GetExpressionFactory();
            IProjections       projections = query.GetProjectionsFactory();
            ICriteria          criteria    = query.CreateCriteria("lead")
                                             .SetCacheable(true)
                                             .CreateCriteria("CampaignTargets", "target")
                                             .Add(expressions.Eq("Campaign.Id", EntityContext.EntityID))
                                             .CreateCriteria("TargetResponses", "response")
                                             .SetProjection(projections.ProjectionList()
                                                            .Add(projections.Property("response.LeadSource"))
                                                            .Add(projections.Property("LeadNameLastFirst"))
                                                            .Add(projections.Property("target.TargetType"))
                                                            .Add(projections.Property("response.ResponseDate"))
                                                            .Add(projections.Property("response.ResponseMethod"))
                                                            .Add(projections.Property("response.Stage"))
                                                            .Add(projections.Property("response.Comments"))
                                                            .Add(projections.Property("target.Id"))
                                                            .Add(projections.Property("response.Id"))
                                                            .Add(projections.Property("lead.LastName"))
                                                            );
            criteria = GetExpressions(criteria, expressions);
            if (chkName.Checked)
            {
                criteria.Add(expressions.InsensitiveLike("lead.LastName", txtName.Text, LikeMatchMode.BeginsWith));
            }
            leadList = criteria.List();
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            throw;
        }
        return(leadList);
    }