/// <summary>
 /// Gets a collection of LeadQualfication entities based on the parameters.
 /// </summary>
 /// <param name="qualificationCategory">The QualificationCategory.</param>
 /// <param name="qualifications">The Qualifications.</param>
 /// <param name="lead">The Lead.</param>
 /// <returns></returns>
 protected static IList <ILeadQualification> GetLeadQualifications(IQualificationCategory qualificationCategory, IList <IQualification> qualifications, ILead lead)
 {
     using (new SessionScopeWrapper())
     {
         IRepository <ILeadQualification> rep = EntityFactory.GetRepository <ILeadQualification>();
         IQueryable         qry = (IQueryable)rep;
         IExpressionFactory ep  = qry.GetExpressionFactory();
         ICriteria          crt = qry.CreateCriteria();
         IJunction          all = ep.Conjunction();
         all.Add(ep.Eq("Lead", lead));
         all.Add(ep.In("Qualification", (System.Collections.ICollection)qualifications));
         crt.Add(all);
         IList <ILeadQualification> list = crt.List <ILeadQualification>();
         return(list);
     }
 }
 /// <summary>
 /// Gets the LeadQualification entity based on the parameters.
 /// </summary>
 /// <param name="lead">The Lead.</param>
 /// <param name="qualification">The Qualification.</param>
 /// <returns></returns>
 protected static ILeadQualification GetLeadQualification(ILead lead, IQualification qualification)
 {
     using (new SessionScopeWrapper())
     {
         IRepository <ILeadQualification> rep = EntityFactory.GetRepository <ILeadQualification>();
         IQueryable         qry = (IQueryable)rep;
         IExpressionFactory ep  = qry.GetExpressionFactory();
         ICriteria          crt = qry.CreateCriteria();
         IJunction          all = ep.Conjunction();
         all.Add(ep.Eq("Lead", lead));
         all.Add(ep.Eq("Qualification", qualification));
         crt.Add(all);
         ILeadQualification result = crt.UniqueResult <ILeadQualification>();
         return(result);
     }
 }
Exemple #3
0
        public override Criterion.IParameter GetParameter()
        {
            if (Builder == null)
            {
                return(null);
            }

            IJunction junction = (Type == JunctionType.Conjunction ? Builder.Conjunction() : Builder.Disjunction());

            foreach (var p in this)
            {
                var toAdd = p.GetParameter();
                if (toAdd != null)
                {
                    junction.Add(toAdd);
                }
            }

            if (junction.Count == 0)
            {
                return(null);
            }

            return(junction);
        }
        private void BuildAnd(IJunction or, IEnumerator <QueryMember> members, IEnumerator values)
        {
            var and = new Conjunction();

            while (members.MoveNext())
            {
                var criterion = BuildCriterion(members.Current, values);
                and.Add(criterion);
            }

            or.Add(and);
        }
 /// <summary>
 /// Adds the comma delimited strings to the expression factory.
 /// </summary>
 /// <param name="criteria">The criteria.</param>
 /// <param name="expressions">The expressions.</param>
 /// <param name="text">The text.</param>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="clause">The clause.</param>
 private static void AddCommaDelimitedStringsToExpression(ICriteria criteria, IExpressionFactory expressions, String text,
                                                          String propertyName, SearchParameter clause)
 {
     if (!string.IsNullOrEmpty(text))
     {
         string[]            values     = text.Split(',');
         IList <IExpression> expression = values.Select(value => GetExpression(expressions, clause, propertyName, value)).ToList();
         IJunction           junction   = expressions.Disjunction();
         foreach (IExpression e in expression)
         {
             junction.Add(e);
         }
         criteria.Add(junction);
     }
 }
        public override dbqf.Criterion.IParameter Restore(DTO.Criterion.ParameterDTO dto)
        {
            var j = dto as JunctionDTO;

            if (j == null)
            {
                return(base.Restore(dto));
            }

            IJunction result = j is ConjunctionDTO?_builder.Conjunction() : _builder.Disjunction();

            foreach (var p in j.Parameters)
            {
                result.Add(Chain.Restore(p));
            }

            return(result);
        }
        public IParameter GetParameter()
        {
            if (Builder == null)
            {
                return(null);
            }

            IJunction junc = Builder.Conjunction();

            if (Type == JunctionType.Disjunction)
            {
                junc = Builder.Disjunction();
            }
            foreach (var v in this)
            {
                junc.Add(v.GetParameter());
            }
            return(junc);
        }
    private void LoadAccountGrid()
    {
        bool   conditionMet    = false;
        string company         = String.Empty;
        string cityStatePostal = String.Empty;
        string workPhone       = String.Empty;
        string tollFree        = String.Empty;
        string webAddress      = String.Empty;
        string industry        = String.Empty;

        ILead lead = BindingSource.Current as ILead;

        if (lead != null)
        {
            company         = lead.Company;
            cityStatePostal = lead.Address.LeadCtyStZip;
            workPhone       = lead.WorkPhone;
            tollFree        = lead.TollFree;
            webAddress      = lead.WebAddress;
            industry        = lead.Industry;
        }

        IRepository <IAccount> accountList = EntityFactory.GetRepository <IAccount>();
        IQueryable             qryAccount  = (IQueryable)accountList;
        IExpressionFactory     exp         = qryAccount.GetExpressionFactory();
        ICriteria criteria = qryAccount.CreateCriteria();

        criteria.CreateAlias("Address", "ad");
        IList <IExpression> expression = new List <IExpression>();

        if (chkCompany.Checked && company != null)
        {
            expression.Add(GetExpression(exp, "AccountName", company));
            conditionMet = true;
        }

        if (chkIndustry.Checked && industry != null)
        {
            expression.Add(GetExpression(exp, "Industry", industry));
            conditionMet = true;
        }

        if (chkWebAddress.Checked && webAddress != null)
        {
            expression.Add(GetExpression(exp, "WebAddress", webAddress));
            conditionMet = true;
        }

        if (chkCityStatePostal.Checked && cityStatePostal != null)
        {
            expression.Add(GetExpression(exp, "ad.CityStateZip", cityStatePostal));
            conditionMet = true;
        }

        if (chkWorkPhone.Checked && workPhone != null)
        {
            expression.Add(GetExpression(exp, "MainPhone", workPhone));
            conditionMet = true;
        }

        if (chkTollFreePhone.Checked && tollFree != null)
        {
            expression.Add(GetExpression(exp, "TollFree", tollFree));
            conditionMet = true;
        }

        IJunction junction = rdbMatchAll.Checked ? exp.Conjunction() : exp.Disjunction();

        foreach (IExpression e in expression)
        {
            junction.Add(e);
        }

        criteria.Add(junction);

        if (conditionMet.Equals(true))
        {
            IList list = criteria.List();
            dtsAccounts.setCustomData(list);
            lblAccountMatches.Text = String.Format(GetLocalResourceObject("PotentialAccountMatches_rsc").ToString(), list.Count);
        }
    }
    private void LoadContactGrid()
    {
        bool   conditionMet    = false;
        string company         = String.Empty;
        string firstName       = String.Empty;
        string lastName        = String.Empty;
        string title           = String.Empty;
        string email           = String.Empty;
        string cityStatePostal = String.Empty;
        string workPhone       = String.Empty;
        string webAddress      = String.Empty;

        ILead lead = BindingSource.Current as ILead;

        if (lead != null)
        {
            company         = lead.Company;
            firstName       = lead.FirstName;
            lastName        = lead.LastName;
            title           = lead.Title;
            email           = lead.Email;
            cityStatePostal = lead.Address.LeadCtyStZip;
            workPhone       = lead.WorkPhone;
            webAddress      = lead.WebAddress;
        }

        IRepository <IContact> contactList = EntityFactory.GetRepository <IContact>();
        IQueryable             qryContact  = (IQueryable)contactList;
        IExpressionFactory     exp         = qryContact.GetExpressionFactory();
        ICriteria criteria = qryContact.CreateCriteria();

        criteria.CreateAlias("Address", "ad");
        IList <IExpression> expression = new List <IExpression>();

        if (chkCompany.Checked && company != null)
        {
            expression.Add(GetExpression(exp, "AccountName", company));
            conditionMet = true;
        }

        if (chkFirstName.Checked && firstName != null)
        {
            expression.Add(GetExpression(exp, "FirstName", firstName));
            conditionMet = true;
        }

        if (chkLastName.Checked && lastName != null)
        {
            expression.Add(GetExpression(exp, "LastName", lastName));
            conditionMet = true;
        }

        if (chkTitle.Checked && title != null)
        {
            expression.Add(GetExpression(exp, "Title", title));
            conditionMet = true;
        }

        if (chkEmail.Checked && email != null)
        {
            expression.Add(GetExpression(exp, "Email", email));
            conditionMet = true;
        }

        if (chkCityStatePostal.Checked && cityStatePostal != null)
        {
            expression.Add(GetExpression(exp, "ad.CityStateZip", cityStatePostal));
            conditionMet = true;
        }

        if (chkWorkPhone.Checked && workPhone != null)
        {
            expression.Add(GetExpression(exp, "WorkPhone", workPhone));
            conditionMet = true;
        }

        if (chkWebAddress.Checked && webAddress != null)
        {
            expression.Add(GetExpression(exp, "WebAddress", webAddress));
            conditionMet = true;
        }

        IJunction junction = rdbMatchAll.Checked ? exp.Conjunction() : exp.Disjunction();

        foreach (IExpression e in expression)
        {
            junction.Add(e);
        }

        criteria.Add(junction);

        if (conditionMet.Equals(true))
        {
            IList list = criteria.List();
            dtsContacts.setCustomData(list);
            lblContactMatches.Text = String.Format(GetLocalResourceObject("PotentialContactMatches_rsc").ToString(), list.Count);
        }
    }