private IList <IImportHistoryItem> GetHistoryItems(IImportHistory importHistory, string itemType, string sortField, bool ascending) { IList <IImportHistoryItem> items = null; IRepository <IImportHistoryItem> repItems = EntityFactory.GetRepository <IImportHistoryItem>(); IQueryable qryItems = (IQueryable)repItems; IExpressionFactory expItems = qryItems.GetExpressionFactory(); Sage.Platform.Repository.ICriteria critItems = qryItems.CreateCriteria(); critItems.Add(expItems.Eq("ImportHistoryId", importHistory.Id)); if (!string.IsNullOrEmpty(itemType)) { critItems.Add(expItems.Eq("ItemType", itemType)); } if (!String.IsNullOrEmpty(sortField)) { if (ascending) { critItems.AddOrder(expItems.Asc(sortField)); } else { critItems.AddOrder(expItems.Desc(sortField)); } } items = critItems.List <IImportHistoryItem>(); return(items); }
/// <summary> /// Loads the product grid. /// </summary> protected void LoadProductGrid() { SearchParameter enumValue = (SearchParameter)ddlFilterBy.SelectedIndex; IRepository <ILeadSource> leadSource = EntityFactory.GetRepository <ILeadSource>(); IQueryable query = (IQueryable)leadSource; IExpressionFactory exp = query.GetExpressionFactory(); ICriteria criteria = query.CreateCriteria(); criteria.Add(GetExpression(exp, enumValue, GetEntityPropertyValue(), txtLookupValue.Text)); IList list = criteria.List(); grdCampaignLeadSource.DataSource = list; grdCampaignLeadSource.DataBind(); }
private IList <IOpportunity> GetResellerOppList(IAccount account) { IList <IOpportunity> list = null; using (new SessionScopeWrapper()) { IRepository <IOpportunity> rep = EntityFactory.GetRepository <IOpportunity>(); IQueryable qry = (IQueryable)rep; IExpressionFactory ep = qry.GetExpressionFactory(); Sage.Platform.Repository.ICriteria crt = qry.CreateCriteria(); crt.Add(ep.Eq("Reseller", account)); list = crt.List <IOpportunity>(); } return(list); }
/// <summary> /// Gets the product list. /// </summary> /// <returns></returns> public object GetProductList() { IRepository <Product> productRep = EntityFactory.GetRepository <Product>(); IQueryable qryableProduct = (IQueryable)productRep; IExpressionFactory expProduct = qryableProduct.GetExpressionFactory(); Sage.Platform.Repository.ICriteria criteriaProduct = qryableProduct.CreateCriteria(); if (_State.NameFilter != string.Empty) { SearchParameter enumCondition = (SearchParameter)_State.NameCond; criteriaProduct.Add(GetExpression(expProduct, enumCondition, "Name", _State.NameFilter)); } if (_State.DescFilter != string.Empty) { SearchParameter enumCondition = (SearchParameter)_State.DescCond; criteriaProduct.Add(GetExpression(expProduct, enumCondition, "Description", _State.DescFilter)); } if (_State.SKUFilter != string.Empty) { SearchParameter enumCondition = (SearchParameter)_State.SKUCond; criteriaProduct.Add(GetExpression(expProduct, enumCondition, "ActualId", _State.SKUFilter)); } if (_State.FamilyFilter != string.Empty) { SearchParameter enumCondition = SearchParameter.EqualTo; criteriaProduct.Add(GetExpression(expProduct, enumCondition, "Family", _State.FamilyFilter)); } if (_State.StatusFilter != string.Empty) { SearchParameter enumCondition = SearchParameter.EqualTo; criteriaProduct.Add(GetExpression(expProduct, enumCondition, "Status", _State.StatusFilter)); } if (chkPackage.Checked) { } List <Product> ProductList = criteriaProduct.List <Product>() as List <Product>; return(ProductList); }
/// <summary> /// Gets the package list. /// </summary> /// <returns></returns> private object GetPackageList() { IRepository <Package> PackageRep = EntityFactory.GetRepository <Package>(); IQueryable qryablePackage = (IQueryable)PackageRep; IExpressionFactory expPackage = qryablePackage.GetExpressionFactory(); Sage.Platform.Repository.ICriteria criteriaPackage = qryablePackage.CreateCriteria(); if (_State.NameFilter != string.Empty) { SearchParameter enumCondition = (SearchParameter)_State.NameCond; criteriaPackage.Add(GetExpression(expPackage, enumCondition, "Name", _State.NameFilter)); } //_criteriaPackage.SetFetchMode("PackageProducts", Sage.Platform.Repository.FetchMode.Join); List <Package> PackageList = criteriaPackage.List <Package>() as List <Package>; return(PackageList); }
/// <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 (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); }
/// <summary> /// Gets a list of the Lead targets. /// </summary> /// <returns></returns> private IList GetLeadTargets() { IQueryable query = (IQueryable)EntityFactory.GetRepository <ILead>(); IExpressionFactory expressions = query.GetExpressionFactory(); IProjections projections = query.GetProjectionsFactory(); ICriteria criteria = query.CreateCriteria("a1") .CreateCriteria("Addresses", "address") .SetProjection(projections.ProjectionList() .Add(projections.Distinct(projections.Property("Id"))) .Add(projections.Property("FirstName")) .Add(projections.Property("LastName")) .Add(projections.Property("Company")) .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); // 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(criteria.List()); }
/// <summary> /// Loads the product grid. /// </summary> protected void LoadProductGrid() { try { if (EntityContext != null && EntityContext.EntityType == typeof(ICampaign)) { SearchParameter enumValue = (SearchParameter)ddlFilterBy.SelectedIndex; IRepository <ILeadSource> leadSource = EntityFactory.GetRepository <ILeadSource>(); IQueryable query = (IQueryable)leadSource; IExpressionFactory exp = query.GetExpressionFactory(); ICriteria criteria = query.CreateCriteria(); criteria.Add(GetExpression(exp, enumValue, GetEntityPropertyValue(), txtLookupValue.Text)); IList list = criteria.List(); grdCampaignLeadSource.DataSource = list; grdCampaignLeadSource.DataBind(); } } catch (Exception ex) { log.Error(ex.Message); throw; } }