protected override Expression VisitMethodCall(MethodCallExpression expr) { Type = BinaryCriterionType.Criteria; //TODO: don't hardcode this alias 'sub' Criteria = DetachedCriteria.ForEntityName(rootCriteria.GetEntityOrClassName(), "sub"); EntityExpression rootEntity = EntityExpressionVisitor.RootEntity(expr); if (rootEntity != null) { string identifierName = rootEntity.MetaData.IdentifierPropertyName; Criteria.Add(Restrictions.EqProperty(rootCriteria.Alias + "." + identifierName, "sub." + identifierName)); } if (SelectArgumentsVisitor.SupportsMethod(expr.Method.Name)) { var projectionVisitor = new SelectArgumentsVisitor(Criteria.Adapt(session), session); projectionVisitor.Visit(expr); Criteria.SetProjection(projectionVisitor.Projection); } return expr; }
///<summary>Adds the permissions to the criteria query for the given usersgroup ///</summary> ///<param name="usersgroup">The usersgroup. Only permissions directly related to this usergroup /// are taken into account</param> ///<param name="operation">The operation</param> ///<param name="criteria">The criteria</param> public void AddPermissionsToQuery(UsersGroup usersgroup, string operation, DetachedCriteria criteria) { ICriterion allowed = GetPermissionQueryInternal(usersgroup, operation, GetSecurityKeyProperty(criteria)); criteria.Add(allowed); }
public static DetachedCriteria FilterBegin1DayFrom(this DetachedCriteria dc, DateTime dateFrom) { return(dc.Add(Restrictions.Between("Begin", dateFrom, dateFrom.AddDays(1)))); }
public ApplicationsQuery WithType(ApplicationType type) { _query.Add(Restrictions.Eq(ApplicationTypeProperty, type)); return(this); }
public static void SetPartyToSearchCriteria(DetachedCriteria selectCriteria, DetachedCriteria selectCountCriteria, string partyToCode, string orderType, string userCode) { if (partyToCode != null && partyToCode.Trim() != string.Empty) { //如果用户选择了PartyTo,直接用用户选择的值查询 selectCriteria.Add(Expression.Eq("pt.Code", partyToCode.Trim())); selectCountCriteria.Add(Expression.Eq("pt.Code", partyToCode.Trim())); } else //如果用户没有选择PartyFrom,根据用户权限过滤 { if (orderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { //供货路线 DetachedCriteria[] ptCrieteria = SecurityHelper.GetPartyPermissionCriteria(userCode, BusinessConstants.CODE_MASTER_PARTY_TYPE_VALUE_REGION, BusinessConstants.CODE_MASTER_PARTY_TYPE_VALUE_CUSTOMER); selectCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", ptCrieteria[0]), Subqueries.PropertyIn("pt.Code", ptCrieteria[1]) )); selectCountCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", ptCrieteria[0]), Subqueries.PropertyIn("pt.Code", ptCrieteria[1]) )); } else if (orderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION) { //发货路线 DetachedCriteria[] ptCrieteria = SecurityHelper.GetPartyPermissionCriteria(userCode, BusinessConstants.CODE_MASTER_PARTY_TYPE_VALUE_REGION, BusinessConstants.CODE_MASTER_PARTY_TYPE_VALUE_CUSTOMER); selectCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", ptCrieteria[0]), Subqueries.PropertyIn("pt.Code", ptCrieteria[1]) )); selectCountCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", ptCrieteria[0]), Subqueries.PropertyIn("pt.Code", ptCrieteria[1]) )); } else if (orderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION) { DetachedCriteria[] regionCrieteria = SecurityHelper.GetRegionPermissionCriteria(userCode); //生产 selectCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", regionCrieteria[0]), Subqueries.PropertyIn("pt.Code", regionCrieteria[1]) )); selectCountCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", regionCrieteria[0]), Subqueries.PropertyIn("pt.Code", regionCrieteria[1]) )); } else if (orderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_INSPECTION) { //检验路线 DetachedCriteria[] regionCrieteria = SecurityHelper.GetRegionPermissionCriteria(userCode); selectCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", regionCrieteria[0]), Subqueries.PropertyIn("pt.Code", regionCrieteria[1]) )); selectCountCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", regionCrieteria[0]), Subqueries.PropertyIn("pt.Code", regionCrieteria[1]) )); } else if (orderType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER) { //移库路线 DetachedCriteria[] regionCrieteria = SecurityHelper.GetRegionPermissionCriteria(userCode); selectCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", regionCrieteria[0]), Subqueries.PropertyIn("pt.Code", regionCrieteria[1]) )); selectCountCriteria.Add( Expression.Or( Subqueries.PropertyIn("pt.Code", regionCrieteria[0]), Subqueries.PropertyIn("pt.Code", regionCrieteria[1]) )); } //else if (orderType == BusinessConstants.ORDER_MODULETYPE_VALUE_PROCUREMENTCONFIRM) //{ // //发货确认 // DetachedCriteria[] ptCrieteria = SecurityHelper.GetPartyPermissionCriteria(userCode, BusinessConstants.CODE_MASTER_PARTY_TYPE_VALUE_CUSTOMER); // selectCriteria.Add( // Expression.Or( // Subqueries.PropertyIn("pt.Code", ptCrieteria[0]), // Subqueries.PropertyIn("pt.Code", ptCrieteria[1]) // )); // selectCountCriteria.Add( // Expression.Or( // Subqueries.PropertyIn("pt.Code", ptCrieteria[0]), // Subqueries.PropertyIn("pt.Code", ptCrieteria[1]) // )); //} } }
public NHibernateDynamicQueryGenerator<EntityType> AddWhereClause(ICriterion criterion) { query.Add(criterion); queryCount.Add(criterion); return this; }
public static DetachedCriteria FilterBeginGeLt(this DetachedCriteria dc, DateTime inicioFrom, DateTime inicioTo) { return(dc.Add(Restrictions.Ge("Begin", inicioFrom)).Add(Restrictions.Lt("Begin", inicioTo))); }
/// <summary> /// Builds the criteria. /// </summary> /// <param name="criteria">The criteria.</param> /// <param name="dependencyCriterion">The dependency criterion.</param> public override void BuildCriteria(DetachedCriteria criteria, Junction dependencyCriterion) { if (criteria == null) { ThrowHelper.ThrowArgumentNullException("criteria"); } if (dependencyCriterion != null) { dependencyCriterion.Add(mCriterion); } else { criteria.Add(this.mCriterion); } }
private void CreateNextPropertyLevel(DetachedCriteria criteria, List <string> propertyList, int listPointer, Junction dependencyCriterion) { Dictionary <string, AssociationEntry> ascs = GetAssociations(); string associationKey = GetAssociationKey(propertyList, listPointer); AssociationEntry e = null; if (ascs.ContainsKey(associationKey)) { e = ascs[associationKey]; if (listPointer == propertyList.Count - 1) { if (mCriterion == null) { mCriterion = BuildCriterion(e.Association); } if (dependencyCriterion != null) { dependencyCriterion.Add(mCriterion); } else { criteria.Add(mCriterion); } } else { DetachedCriteria subCriteria = e.Criteria; if (subCriteria == null) { subCriteria = criteria.CreateCriteria(e.Association, e.Alias, JoinType.InnerJoin); e.Criteria = subCriteria; } listPointer++; CreateNextPropertyLevel(subCriteria, propertyList, listPointer, dependencyCriterion); } } else { bool isThisId = associationKey.ToLower().EndsWith(".id"); if (listPointer == 0) { e = new AssociationEntry(propertyList[0], propertyList[0], string.Format("p{0}{1}", Stopwatch.GetTimestamp().ToString(), listPointer.ToString())); } else { string parentAssociation = GetAssociationKey(propertyList, listPointer - 1); AssociationEntry parentEntry = ascs[parentAssociation]; // léteznie kell, máskülönben ide sem juthattam volna e = new AssociationEntry(associationKey, string.Format("{0}.{1}", parentEntry.Alias, propertyList[listPointer]), string.Format("p{0}{1}", Stopwatch.GetTimestamp().ToString(), listPointer.ToString())); } if (!isThisId) { // az id asszociációkat nem mentjük le ascs[e.Key] = e; } if (listPointer == propertyList.Count - 1 || isThisId) { if (mCriterion == null) { mCriterion = BuildCriterion((isThisId && listPointer < propertyList.Count - 1) ? string.Format("{0}.{1}", e.Association, propertyList[listPointer + 1]) : e.Association); } if (dependencyCriterion != null) { dependencyCriterion.Add(mCriterion); } else { criteria.Add(mCriterion); } } else { DetachedCriteria subCriteria = e.Criteria; if (subCriteria == null) { subCriteria = criteria.CreateCriteria(e.Association, e.Alias, JoinType.InnerJoin); e.Criteria = subCriteria; } listPointer++; CreateNextPropertyLevel(subCriteria, propertyList, listPointer, dependencyCriterion); } } }
public static DetachedCriteria FilterBeginBetween(this DetachedCriteria dc, DateTime inicioFrom, DateTime inicioTo) { return(dc.Add(Restrictions.Between("Begin", inicioFrom, inicioTo))); }
protected void btnConfirm_Click(object sender, EventArgs e) { string partyCode = this.tbPartyCode.Text != string.Empty ? this.tbPartyCode.Text.Trim() : string.Empty; string receiver = this.tbReceiver.Text != string.Empty ? this.tbReceiver.Text.Trim() : string.Empty; string startDate = this.tbStartDate.Text != string.Empty ? this.tbStartDate.Text.Trim() : string.Empty; string endDate = this.tbEndDate.Text != string.Empty ? this.tbEndDate.Text.Trim() : string.Empty; string itemCode = this.tbItemCode.Text != string.Empty ? this.tbItemCode.Text.Trim() : string.Empty; string currency = this.tbCurrency.Text != string.Empty ? this.tbCurrency.Text.Trim() : string.Empty; DateTime?effDateFrom = null; if (startDate != string.Empty) { effDateFrom = DateTime.Parse(startDate); } DateTime?effDateTo = null; if (endDate != string.Empty) { effDateTo = DateTime.Parse(endDate).AddDays(1).AddMilliseconds(-1); } //重新计价 bool needRecalculate = bool.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_RECALCULATE_WHEN_BILL).Value); if (needRecalculate) { IList <ActingBill> allactingBillList = TheActingBillMgr.GetActingBill(partyCode, receiver, effDateFrom, effDateTo, itemCode, currency, this.ModuleType, null, true); TheActingBillMgr.RecalculatePrice(allactingBillList, this.CurrentUser); } IList <ActingBill> actingBillList = TheActingBillMgr.GetActingBill(partyCode, receiver, effDateFrom, effDateTo, itemCode, currency, this.ModuleType, null); if (actingBillList != null && actingBillList.Count > 0) { foreach (ActingBill actingBill in actingBillList) { actingBill.CurrentBillQty = actingBill.BillQty - actingBill.BilledQty; decimal orgAmount = actingBill.UnitPrice * actingBill.CurrentBillQty; actingBill.CurrentDiscount = orgAmount - (actingBill.BillAmount - actingBill.BilledAmount); } IList <Bill> billList = this.TheBillMgr.CreateBill(actingBillList, this.CurrentUser, (this.IsRelease.Checked ? BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT : BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)); ; DetachedCriteria selectCriteria = DetachedCriteria.For(typeof(Bill)); DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(Bill)) .SetProjection(Projections.Count("BillNo")); selectCriteria.Add(Expression.Eq("CreateDate", billList[0].CreateDate)); selectCriteria.Add(Expression.Eq("CreateUser.Code", this.CurrentUser.Code)); selectCountCriteria.Add(Expression.Eq("CreateDate", billList[0].CreateDate)); selectCountCriteria.Add(Expression.Eq("CreateUser.Code", this.CurrentUser.Code)); SearchEvent((new object[] { selectCriteria, selectCountCriteria }), null); this.ShowSuccessMessage("MasterData.Bill.BatchCreateSuccessfully"); } else { this.ShowErrorMessage("Bill.Error.EmptyBillDetail"); } }
private static void FilteredListCriteria(PatientReminderSearchRequest request, DetachedCriteria criteria) { if (request.PatientReminderCriteriaDto.Age.HasValue) { var ageDateEnd = DateTime.Now.Date.AddYears(-1 * request.PatientReminderCriteriaDto.Age.Value); var ageDateStart = ageDateEnd.AddYears(-1); var ageDate = ageDateEnd; if (request.PatientReminderCriteriaDto.AgeFilterModifier == FilterModifier.EqualTo) { criteria.Add(Restrictions.Between(Projections.Property("Profile.BirthDate"), ageDateStart, ageDateEnd)); } else { if (request.PatientReminderCriteriaDto.AgeFilterModifier == FilterModifier.GreaterThan || request.PatientReminderCriteriaDto.AgeFilterModifier == FilterModifier.LessThenOrEqualTo) { ageDate = ageDateStart; } criteria.Add( Restrictions.Not( PatientListHelper.GetFilterModifierCriterion( Projections.Property("Profile.BirthDate"), request.PatientReminderCriteriaDto.AgeFilterModifier, ageDate))); } } if (request.PatientReminderCriteriaDto.Medication != null) { criteria.CreateAlias("p.Medications", "m") .CreateAlias("m.MedicationStatus", "ms") .Add(Restrictions.Eq(Projections.Property("ms.WellKnownName"), MedicationStatus.Active)) .Add( Restrictions.Eq( Projections.Property("m.RootMedicationCodedConcept.CodedConceptCode"), request.PatientReminderCriteriaDto.Medication.CodedConceptCode)); } if (request.PatientReminderCriteriaDto.Allergy != null) { criteria.CreateAlias("p.Allergies", "a") .CreateAlias("a.AllergyStatus", "as") .Add(Restrictions.Eq(Projections.Property("as.WellKnownName"), AllergyStatus.Active)) .Add( Restrictions.Eq( Projections.Property("a.AllergenCodedConcept.CodedConceptCode"), request.PatientReminderCriteriaDto.Allergy.CodedConceptCode)); } var setClinicalCaseAlias = false; if (request.PatientReminderCriteriaDto.Problem != null) { criteria.CreateAlias("p.ClinicalCases", "cc") .CreateAlias("cc.Problems", "pr") .CreateAlias("pr.ProblemStatus", "prs") .Add(Restrictions.Eq(Projections.Property("prs.WellKnownName"), ProblemStatus.Active)) .Add( Restrictions.Eq( Projections.Property("pr.ProblemCodeCodedConcept.CodedConceptCode"), request.PatientReminderCriteriaDto.Problem.ProblemCodeCodedConcept.CodedConceptCode)); setClinicalCaseAlias = true; } if (request.PatientReminderCriteriaDto.LabTest != null || request.PatientReminderCriteriaDto.LabResultValue.HasValue) { if (!setClinicalCaseAlias) { criteria.CreateAlias("p.ClinicalCases", "cc"); } criteria.CreateAlias("cc.Visits", "v") .CreateAlias("v.Activities", "ac") .CreateAlias("ac.LabTests", "test") .CreateAlias("test.LabTestName", "tcc"); if (request.PatientReminderCriteriaDto.LabTest != null) { criteria .Add(Restrictions.Eq(Projections.Property("tcc.Key"), request.PatientReminderCriteriaDto.LabTest.Key)); } if (request.PatientReminderCriteriaDto.LabResultValue.HasValue) { criteria.CreateAlias("test.LabResults", "result"); criteria.Add( PatientListHelper.GetFilterModifierCriterion( Projections.Property("result.Value"), request.PatientReminderCriteriaDto.LabResultFilterModifier, request.PatientReminderCriteriaDto.LabResultValue.Value)); } } }
protected override void DoSearch() { string code = this.tbFlow.Text != string.Empty ? this.tbFlow.Text.Trim() : string.Empty; string partyFrom = this.tbPartyFrom.Text != string.Empty ? this.tbPartyFrom.Text.Trim() : string.Empty; string partyTo = this.tbPartyTo.Text != string.Empty ? this.tbPartyTo.Text.Trim() : string.Empty; string locFrom = this.tbLocFrom.Text != string.Empty ? this.tbLocFrom.Text.Trim() : string.Empty; string locTo = this.tbLocTo.Text != string.Empty ? this.tbLocTo.Text.Trim() : string.Empty; string strategy = this.ddlStrategy.SelectedIndex != -1 ? this.ddlStrategy.SelectedValue : string.Empty; if (SearchEvent != null) { DetachedCriteria selectCriteria = DetachedCriteria.For(typeof(Flow)); DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(Flow)) .SetProjection(Projections.ProjectionList() .Add(Projections.Count("Code"))); selectCriteria.CreateAlias("PartyFrom", "pf"); selectCriteria.CreateAlias("PartyTo", "pt"); selectCountCriteria.CreateAlias("PartyFrom", "pf"); selectCountCriteria.CreateAlias("PartyTo", "pt"); #region partyFrom SecurityHelper.SetPartyFromSearchCriteria( selectCriteria, selectCountCriteria, (this.tbPartyFrom != null ? this.tbPartyFrom.Text : null), BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER, this.CurrentUser.Code); #endregion #region partyTo SecurityHelper.SetPartyToSearchCriteria( selectCriteria, selectCountCriteria, (this.tbPartyTo != null ? this.tbPartyTo.Text : null), BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER, this.CurrentUser.Code); #endregion #region flowType selectCriteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER)); selectCountCriteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER)); #endregion if (code != string.Empty) { selectCriteria.Add(Expression.Eq("Code", code)); selectCountCriteria.Add(Expression.Eq("Code", code)); } if (locFrom != string.Empty) { selectCriteria.Add(Expression.Eq("LocationFrom.Code", locFrom)); selectCountCriteria.Add(Expression.Eq("LocationFrom.Code", locFrom)); } if (locTo != string.Empty) { selectCriteria.Add(Expression.Eq("LocationTo.Code", locTo)); selectCountCriteria.Add(Expression.Eq("LocationTo.Code", locTo)); } if (strategy != string.Empty) { selectCriteria.Add(Expression.Eq("FlowStrategy", strategy)); selectCountCriteria.Add(Expression.Eq("FlowStrategy", strategy)); } SearchEvent((new object[] { selectCriteria, selectCountCriteria }), null); } }
/// <summary> /// Status: Submit,In-Process,Complete,Close /// </summary> /// <param name="criteria"></param> /// <param name="propertyName"></param> public static void SetActiveOrderStatusCriteria(DetachedCriteria criteria, string propertyName) { criteria.Add(Expression.In(propertyName, new object[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT, BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS, BusinessConstants.CODE_MASTER_STATUS_VALUE_COMPLETE, BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE})); }
public static DetachedCriteria FilterUpToEnd(this DetachedCriteria dc, DateTime finTo) { return(dc.Add(Restrictions.Le("End", finTo))); }
/// <summary> /// Status: Submit,In-Process /// </summary> /// <param name="criteria"></param> /// <param name="propertyName"></param> public static void SetOpenOrderStatusCriteria(DetachedCriteria criteria, string propertyName) { criteria.Add(Expression.In(propertyName, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT, BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS})); }
///// <summary> ///// Gets operator ranking information for the current tmespan. ///// </summary> ///// <param name="desde"></param> ///// <param name="hasta"></param> ///// <param name="tipos"></param> ///// <param name="transportistas"></param> ///// <param name="bases"></param> ///// <param name="distritos"></param> ///// <returns></returns> //public IEnumerable<OperatorRanking> GetOperatorsRanking(DateTime desde, DateTime hasta, List<Int32> tipos, List<Int32> transportistas, List<Int32> bases, List<Int32> distritos) //{ // return Session.Query<Datamart>() // .Where(data => data.Employee != null && ((data.Employee.TipoEmpleado == null && tipos.Contains(-2)) || (data.Employee.TipoEmpleado != null && tipos.Contains(data.Employee.TipoEmpleado.Id))) // && ((data.Employee.Transportista == null && transportistas.Contains(-2)) || (data.Employee.Transportista != null && transportistas.Contains(data.Employee.Transportista.Id))) // && (data.Employee.Linea == null || bases.Contains(data.Employee.Linea.Id)) && (data.Employee.Empresa == null || distritos.Contains(data.Employee.Empresa.Id)) // && data.Begin >= desde && data.Begin <= hasta) // .GroupBy(data => new { data.Employee.Id, data.Employee.Entidad.Descripcion, data.Employee.Legajo }) // .Select(data => new OperatorRanking // { // Kilometros = data.Sum(datamart => datamart.Kilometers), // Hours = data.Sum(datamart => datamart.MovementHours), // IdOperador = data.Key.Id, // Operador = data.Key.Descripcion, // Legajo = data.Key.Legajo // }) // .ToList(); //} /// <summary> /// Gets operator ranking information for the current tmespan. /// </summary> /// <param name="desde"></param> /// <param name="hasta"></param> /// <param name="tipos"></param> /// <param name="transportistas"></param> /// <param name="bases"></param> /// <param name="distritos"></param> /// <returns></returns> public IEnumerable <OperatorRanking> GetOperatorsRanking( DateTime desde, DateTime hasta, List <Int32> tipos, List <Int32> transportistas, List <Int32> bases, List <Int32> distritos) { OperatorRanking or = null; Empleado ch = null; DetachedCriteria dc = GetDatamartDetachedCriteria() .FilterBeginBetween(desde, hasta) .CreateAlias("Employee", "ch", JoinType.InnerJoin) .CreateAlias("Employee.Entidad", "en", JoinType.InnerJoin); // Tipo de Empleado bool tipoNone = tipos.Contains(-2); bool tipoOther = tipos.Any(t => t > 0); bool tipoAll = tipos.Contains(-1); if (!tipoAll) { if (tipoNone && tipoOther) { dc.Add(Restrictions.Or(Restrictions.IsNull(Projections.Property <Empleado>(p => ch.TipoEmpleado)), Restrictions.In(Projections.Property <Empleado>(p => ch.TipoEmpleado.Id), tipos))); } else { if (tipoNone) { dc.Add(Restrictions.IsNull(Projections.Property <Empleado>(p => ch.TipoEmpleado))); } if (tipoOther) { dc.Add(Restrictions.In(Projections.Property <Empleado>(p => ch.TipoEmpleado.Id), tipos)); } } } // Transportista bool transNone = transportistas.Contains(-2); bool transOther = transportistas.Any(t => t > 0); bool transAll = transportistas.Contains(-1); if (!transAll) { if (transNone && transOther) { dc.Add(Restrictions.Or(Restrictions.IsNull(Projections.Property <Empleado>(p => ch.Transportista)), Restrictions.In(Projections.Property <Empleado>(p => ch.Transportista.Id), transportistas))); } else { if (tipoNone) { dc.Add(Restrictions.IsNull(Projections.Property <Empleado>(p => ch.Transportista))); } if (tipoOther) { dc.Add(Restrictions.InG(Projections.Property <Empleado>(p => ch.Transportista.Id), transportistas)); } } } if (!bases.Contains(-1)) { dc.Add(Restrictions.Or(Restrictions.IsNull(Projections.Property <Empleado>(p => ch.Linea)), Restrictions.In(Projections.Property <Empleado>(p => ch.Linea.Id), bases))); } if (!distritos.Contains(-1)) { dc.Add(Restrictions.Or(Restrictions.IsNull(Projections.Property <Empleado>(p => ch.Empresa)), Restrictions.In(Projections.Property <Empleado>(p => ch.Empresa.Id), distritos))); } ProjectionList pl = Projections.ProjectionList(); pl.Add(Projections.Sum <Datamart>(dm => dm.Kilometers).WithAlias(() => or.Kilometros)); pl.Add(Projections.Sum <Datamart>(dm => dm.MovementHours).WithAlias(() => or.Hours)); pl.Add(Projections.Group <Datamart>(dm => dm.Employee.Id).WithAlias(() => or.IdOperador)); pl.Add(Projections.Group <Datamart>(dm => dm.Employee.Legajo).WithAlias(() => or.Legajo)); pl.Add(Projections.Group <Datamart>(dm => dm.Employee.Entidad.Apellido).WithAlias(() => or.Operador)); ICriteria crit = GetDatamartCriteria(0, dc, pl, null, typeof(OperatorRanking)); IList <OperatorRanking> results = crit.List <OperatorRanking>(); return(results); }
private void addDisjunction(String[] values, String columnLabel, ref DetachedCriteria criteria) { if (values != null && values.Length > 0) { Disjunction dis = Expression.Disjunction(); foreach (String value in values) { dis.Add(Expression.Eq(columnLabel, value)); } criteria.Add(dis); } }
public static DetachedCriteria FilterBeginEndBetween(this DetachedCriteria dc, DateTime inicioFrom, DateTime finTo) { return(dc.Add(Restrictions.Ge("Begin", inicioFrom)).Add(Restrictions.Lt("End", finTo))); }
public static void SetPartySearchCriteria(DetachedCriteria criteria, string propertyName, string userCode) { DetachedCriteria[] partyCrieteria = SecurityHelper.GetPartyPermissionCriteria(userCode); criteria.Add( Expression.Or( Subqueries.PropertyIn(propertyName, partyCrieteria[0]), Subqueries.PropertyIn(propertyName, partyCrieteria[1]) )); }
private object[] CollectParam() { DetachedCriteria selectCriteria = DetachedCriteria.For(typeof(ActingBillView)); DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(ActingBillView)) .SetProjection(Projections.Count("Id")); IDictionary <string, string> alias = new Dictionary <string, string>(); selectCriteria.CreateAlias("BillAddress", "ba"); selectCountCriteria.CreateAlias("BillAddress", "ba"); alias.Add("BillAddress", "ba"); if (this.tbOrderNo.Text.Trim() != string.Empty) { selectCriteria.Add(Expression.Eq("OrderNo", this.tbOrderNo.Text.Trim())); selectCountCriteria.Add(Expression.Eq("OrderNo", this.tbOrderNo.Text.Trim())); } if (this.tbReceiptNo.Text.Trim() != string.Empty) { if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { selectCriteria.Add(Expression.Eq("ReceiptNo", this.tbReceiptNo.Text.Trim())); selectCountCriteria.Add(Expression.Eq("ReceiptNo", this.tbReceiptNo.Text.Trim())); } else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION) { selectCriteria.Add(Expression.Eq("ExternalReceiptNo", this.tbReceiptNo.Text.Trim())); selectCountCriteria.Add(Expression.Eq("ExternalReceiptNo", this.tbReceiptNo.Text.Trim())); } } #region party设置 if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT) { selectCriteria.CreateAlias("ba.Party", "pf"); selectCountCriteria.CreateAlias("ba.Party", "pf"); alias.Add("BillAddress.Party", "pf"); if (this.tbParty.Text.Trim() != string.Empty) { selectCriteria.Add(Expression.Eq("pf.Code", this.tbParty.Text.Trim())); selectCountCriteria.Add(Expression.Eq("pf.Code", this.tbParty.Text.Trim())); } else { SecurityHelper.SetPartyFromSearchCriteria( selectCriteria, selectCountCriteria, (this.tbParty != null ? this.tbParty.Text : null), this.ModuleType, this.CurrentUser.Code); } selectCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.BILL_TRANS_TYPE_PO)); selectCountCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.BILL_TRANS_TYPE_PO)); } else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION) { selectCriteria.CreateAlias("ba.Party", "pt"); selectCountCriteria.CreateAlias("ba.Party", "pt"); alias.Add("BillAddress.Party", "pt"); if (this.tbParty.Text.Trim() != string.Empty) { selectCriteria.Add(Expression.Eq("pt.Code", this.tbParty.Text.Trim())); selectCountCriteria.Add(Expression.Eq("pt.Code", this.tbParty.Text.Trim())); } else { SecurityHelper.SetPartyToSearchCriteria( selectCriteria, selectCountCriteria, (this.tbParty != null ? this.tbParty.Text : null), this.ModuleType, this.CurrentUser.Code); } selectCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.BILL_TRANS_TYPE_SO)); selectCountCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.BILL_TRANS_TYPE_SO)); } #endregion if (this.tbItem.Text.Trim() != string.Empty) { selectCriteria.CreateAlias("Item", "it"); selectCountCriteria.CreateAlias("Item", "it"); alias.Add("Item", "it"); selectCriteria.Add(Expression.Eq("it.Code", this.tbItem.Text.Trim())); selectCountCriteria.Add(Expression.Eq("it.Code", this.tbItem.Text.Trim())); } if (this.tbEffectiveDateFrom.Text.Trim() != string.Empty) { selectCriteria.Add(Expression.Ge("EffectiveDate", DateTime.Parse(this.tbEffectiveDateFrom.Text.Trim()))); selectCountCriteria.Add(Expression.Ge("EffectiveDate", DateTime.Parse(this.tbEffectiveDateFrom.Text.Trim()))); } if (this.tbEffectiveDateTo.Text.Trim() != string.Empty) { selectCriteria.Add(Expression.Le("EffectiveDate", DateTime.Parse(this.tbEffectiveDateTo.Text.Trim()).AddDays(1).AddMilliseconds(-1))); selectCountCriteria.Add(Expression.Le("EffectiveDate", DateTime.Parse(this.tbEffectiveDateTo.Text.Trim()).AddDays(1).AddMilliseconds(-1))); } if (ddlIsProvisionalEstimate.SelectedIndex != 0) { selectCriteria.Add(Expression.Eq("IsProvisionalEstimate", this.ddlIsProvisionalEstimate.SelectedValue == "Y"?true:false)); selectCountCriteria.Add(Expression.Eq("IsProvisionalEstimate", this.ddlIsProvisionalEstimate.SelectedValue == "Y" ? true : false)); } if (ddlIsCreateBill.SelectedIndex != 0) { selectCriteria.Add(Expression.Eq("IsCreateBill", this.ddlIsCreateBill.SelectedValue == "Y" ? true : false)); selectCountCriteria.Add(Expression.Eq("IsCreateBill", this.ddlIsCreateBill.SelectedValue == "Y" ? true : false)); } return(new object[] { selectCriteria, selectCountCriteria, alias }); }