public IPage <PeanutParticipation> FindParticipationsOfUser(IPageable pageRequest, User forUser, DateTime from, DateTime to, IList <PeanutParticipationState> participationStates = null) { HibernateDelegate <IPage <PeanutParticipation> > finder = delegate(ISession session) { IQueryOver <PeanutParticipation, PeanutParticipation> queryOver = session.QueryOver <PeanutParticipation>(); IQueryOver <PeanutParticipation, UserGroupMembership> joinUserGroupMembership = queryOver.JoinQueryOver(participation => participation.UserGroupMembership); /*Nur für den Nutzer*/ joinUserGroupMembership.Where(userGroupMembership => userGroupMembership.User == forUser); IQueryOver <PeanutParticipation, Peanut> joinPeanut = queryOver.JoinQueryOver(participation => participation.Peanut); joinPeanut /*Am oder nach dem ab Datum*/ .And(peanut => peanut.Day >= from) .And(peanut => peanut.PeanutState != PeanutState.Canceled) /*Nicht nach dem To Datum*/ .AndNot(peanut => peanut.Day > to); if (participationStates != null && participationStates.Any()) { /*Nur wenn die Teilnahme einen bestimmten Status hat.*/ queryOver.AndRestrictionOn(part => part.ParticipationState).IsIn(participationStates.ToArray()); } return(FindPage(queryOver, pageRequest)); }; return(HibernateTemplate.Execute(finder)); }
/// <summary> /// The filtering. /// </summary> /// <param name="query"> /// The query. /// </param> /// <param name="filter"> /// The filter. /// </param> /// <returns> /// The <see cref="IQueryOver"/>. /// </returns> public override IQueryOver <UnitFunction, UnitFunction> Filtering(IQueryOver <UnitFunction, UnitFunction> query, UnitFunctionFilter filter) { if (filter.SectionOfSystemUnitcode != null) { if (!string.IsNullOrWhiteSpace(filter.SectionOfSystemUnitcode.UnitCode)) { query.JoinQueryOver(x => x.SectionOfSystemUnitcode, JoinType.InnerJoin) .Where(x => x.Rn == filter.SectionOfSystemUnitcode.UnitCode); } } if (filter.UserPrivilegeFilter.RnAccessCatalog > 0) { IQueryOver <UnitFunction, UserPrivilege> joinPrivileges = query.JoinQueryOver <UserPrivilege>(x => x.UserPrivileges); joinPrivileges.JoinQueryOver(x => x.Role, JoinType.InnerJoin) .JoinQueryOver <UserRole>(x => x.UserRoles, JoinType.InnerJoin) .EqualsUser(x => x.UserList.AUTHID); joinPrivileges.JoinQueryOver(x => x.Acatalog) .Where(x => x.Rn == filter.UserPrivilegeFilter.RnAccessCatalog); } query.Where(x => x.Standard == filter.Standard); return(query); }
/// <summary> /// The filtering. /// </summary> /// <param name="query"> /// The query. /// </param> /// <param name="filter"> /// The filter. /// </param> /// <returns> /// The <see cref="IQueryOver"/>. /// </returns> public override IQueryOver <Acatalog, Acatalog> Filtering(IQueryOver <Acatalog, Acatalog> query, AcatalogFilter filter) { if (!string.IsNullOrEmpty(filter.Name)) { query.WhereRestrictionOn(x => x.Name).IsLike(filter.Name); } if (filter.SectionOfSystem != null && !string.IsNullOrWhiteSpace(filter.SectionOfSystem.UnitCode)) { query.JoinQueryOver(x => x.SectionOfSystem, JoinType.LeftOuterJoin) .Where(x => x.Rn == filter.SectionOfSystem.UnitCode); } if (filter.UserPrivilege != null) { UserPrivilege userPrivilegeALias = null; query.JoinAlias(x => x.UserPrivileges, () => userPrivilegeALias); query.JoinQueryOver(() => userPrivilegeALias.Role, JoinType.InnerJoin); if (filter.UserPrivilege.Role != null) { if (filter.UserPrivilege.Role.Rn != 0) { query.Where(() => userPrivilegeALias.Role.Rn == filter.UserPrivilege.Role.Rn); } if (filter.UserPrivilege.Role.UserRoles != null) { UserRole userRoleAlias = null; query.JoinAlias(() => userPrivilegeALias.Role.UserRoles, () => userRoleAlias) .EqualsUser(x => userRoleAlias.UserList.AUTHID); // var fil = Restrictions.EqProperty( // Projections.SqlFunction("User", NHibernateUtil.String), // Projections.Property<UserRole>(x => userRoleAlias.UserList.AUTHID)); // query.Where(fil); } } if (filter.UserPrivilege.UnitFunction != null) { UnitFunction unitfuncAlias = null; query.JoinAlias(() => userPrivilegeALias.UnitFunctions, () => unitfuncAlias); query.Where(x => unitfuncAlias.Standard == filter.UserPrivilege.UnitFunction.Standard); if (filter.UserPrivilege.UnitFunction.SectionOfSystemUnitcode != null) { query.JoinQueryOver(() => unitfuncAlias.SectionOfSystemUnitcode, JoinType.InnerJoin); if (!string.IsNullOrWhiteSpace(filter.UserPrivilege.UnitFunction.SectionOfSystemUnitcode.UnitCode)) { query.Where(x => unitfuncAlias.SectionOfSystemUnitcode.Rn == filter.UserPrivilege.UnitFunction.SectionOfSystemUnitcode.UnitCode); } } } } return(query); }
/// <summary> /// The filtering. /// </summary> /// <param name="query"> /// The query. /// </param> /// <param name="filter"> /// The filter. /// </param> /// <returns> /// The <see cref="IQueryOver"/>. /// </returns> public override IQueryOver <MechanicIndicatorValue, MechanicIndicatorValue> Filtering(IQueryOver <MechanicIndicatorValue, MechanicIndicatorValue> query, MechanicIndicatorValueFilter filter) { query.FindByRn(filter.Rn); if (filter.CertificateQuality != null) { query.JoinQueryOver(x => x.CertificateQuality, JoinType.LeftOuterJoin); } if (filter.MechanicalIndicator != null) { query.JoinQueryOver(x => x.MechanicalIndicator, JoinType.LeftOuterJoin); } return(query); }
/// <summary> /// The filtering. /// </summary> /// <param name="query"> /// The query. /// </param> /// <param name="filter"> /// The filter. /// </param> /// <returns> /// The <see cref="IQueryOver"/>. /// </returns> public override IQueryOver <PlanAndSpecification, PlanAndSpecification> Filtering(IQueryOver <PlanAndSpecification, PlanAndSpecification> query, PlanAndSpecificationFilter filter) { query.FindByRn(filter.Rn); query.IsBetween(x => x.BeginDate, filter.BeginDate); query.IsBetween(x => x.EndDate, filter.EndDate); if (filter.ModificationNomenclature != null) { if (!string.IsNullOrWhiteSpace(filter.ModificationNomenclature.Code)) { query.JoinQueryOver(x => x.ModificationNomenclature, JoinType.LeftOuterJoin); //NomenclatureNumberModification nommodifAlias = null; //query.JoinAlias((x) => filter.ModificationNomenclature, () => nommodifAlias, JoinType.LeftOuterJoin); query.WhereRestrictionOn(x => x.ModificationNomenclature.Code) .IsLike(filter.ModificationNomenclature.Code.ReplaceStar()); } } if (filter.PersonalAccount != null) { // query.JoinQueryOver(x => x.PersonalAccount, JoinType.LeftOuterJoin); query.Where(x => x.PersonalAccount.Rn == filter.PersonalAccount.Rn); } return(query); }
public IPage <Peanut> FindBilledPeanutsInGroup(IPageable pageRequest, UserGroup userGroup, DateTime?from = null, DateTime?to = null) { Require.NotNull(userGroup, "userGroup"); Require.NotNull(pageRequest, "pageRequest"); HibernateDelegate <IPage <Peanut> > finder = delegate(ISession session) { IQueryOver <Peanut, Peanut> queryOver = session.QueryOver <Peanut>(); queryOver.JoinQueryOver <Bill>(peanut => peanut.Bills).Where(peanutBill => peanutBill.IsSettled && peanutBill.UserGroup == userGroup); queryOver.Where(peanut => peanut.UserGroup == userGroup); if (from.HasValue) { queryOver.And(p => p.Day > from.Value); } if (to.HasValue) { queryOver.And(p => p.Day <= to.Value); } return(FindPage(queryOver, pageRequest)); }; return(HibernateTemplate.Execute(finder)); }
Filtering(IQueryOver <HeatTreatment, HeatTreatment> query, HeatTreatmentFilter filter) { if (filter != null) { query.FindByRn(filter.Rn); query.JoinQueryOver(x => x.TestSheet, JoinType.InnerJoin) .Where(x => x.Rn == filter.RnTestSheet); } return(query); }
protected override IQueryOver <WorkflowActivity, WorkflowActivity> DecorateCriteria(IQueryOver <WorkflowActivity, WorkflowActivity> queryOver) { WorkflowRepository workflowRepository = null; WorkflowInstance workflowInstance = null; queryOver .JoinQueryOver(o => o.WorkflowInstance, () => workflowInstance) .JoinQueryOver(o => o.WorkflowRepository, () => workflowRepository); queryOver.Where(q => !q.ActivityType.IsIn(ExcludeDefaultWorkflowActivityType.ToList())); if (WorkflowActivityType.Count > 0) { queryOver.Where(q => q.ActivityType.IsIn(WorkflowActivityType.ToList())); } if (WorkflowActivityStatus.Count > 0) { queryOver.Where(q => q.Status.IsIn(WorkflowActivityStatus.ToList())); } if (ExcludeDocumentUnitReferencedId.HasValue && ExcludeDocumentUnitReferencedId.Value) { queryOver.Where(q => q.DocumentUnitReferencedId == null); } if (ExcludeWorkflowActivityId.HasValue) { queryOver.Where(q => q.Id != ExcludeWorkflowActivityId.Value); } if (WorkflowInstanceId.HasValue) { queryOver.Where(q => q.WorkflowInstance.Id == WorkflowInstanceId.Value); } if (WorkflowDateFrom.HasValue && WorkflowDateTo.HasValue) { queryOver.Where(q => q.RegistrationDate >= WorkflowDateFrom.Value && q.RegistrationDate <= WorkflowDateTo); } if (IdTenant.HasValue) { queryOver.Where(q => q.IdTenant == null || q.IdTenant == IdTenant.Value); } queryOver = FilterBySearchField(queryOver); queryOver = FilterByUserPermission(queryOver); return(queryOver); }
public Peanut FindFromBill(Bill bill) { Require.NotNull(bill, "bill"); HibernateDelegate <Peanut> finder = delegate(ISession session) { IQueryOver <Peanut, Peanut> queryOver = session.QueryOver <Peanut>(); queryOver.JoinQueryOver <Bill>(peanut => peanut.Bills).Where(peanutBill => peanutBill.Id == bill.Id); return(queryOver.SingleOrDefault()); }; return(HibernateTemplate.Execute(finder)); }
public IPage <BookingEntry> FindByAccount(IPageable pageRequest, Account account) { HibernateDelegate <IPage <BookingEntry> > finder = delegate(ISession session) { IQueryOver <BookingEntry, BookingEntry> queryOverBookingEntries = session.QueryOver <BookingEntry>(); IQueryOver <BookingEntry, Booking> joinBooking = queryOverBookingEntries.JoinQueryOver(entry => entry.Booking).OrderBy(booking => booking.BookingDate).Desc; queryOverBookingEntries = queryOverBookingEntries.Where(entry => entry.Account == account); return(FindPage(queryOverBookingEntries, pageRequest)); }; return(HibernateTemplate.Execute(finder)); }
public override IQueryOver <CertificateQuality, CertificateQuality> Filtering( IQueryOver <CertificateQuality, CertificateQuality> query, CertificateQualityFilter filter) { query.FindByRn(filter.Rn); query.IsBetween(x => x.CreationDate, filter.CreationDate); query.IsBetween(x => x.StorageDate, filter.StorageDate); query.IsBetween(x => x.MakingDate, filter.MakingDate); query.IsLike(x => x.StandardSize, filter.StandardSize.ReplaceStar()); query.IsLike(x => x.NomerCertificata, filter.NomerCertificata.ReplaceStar()); query.IsLike(x => x.ModeThermoTreatment, filter.ModeThermoTreatment.ReplaceStar()); query.IsLike(x => x.Mix, filter.Mix.ReplaceStar()); query.IsLike(x => x.Marka, filter.Marka.ReplaceStar()); query.IsLike(x => x.GostMix, filter.GostMix.ReplaceStar()); query.IsLike(x => x.GostMarka, filter.GostMarka.ReplaceStar()); query.IsLike(x => x.FullRepresentation, filter.FullRepresentation.ReplaceStar()); query.IsLike(x => x.DeliveryCondition, filter.DeliveryCondition.ReplaceStar()); query.IsLike(x => x.Cast, filter.Cast.ReplaceStar()); query.IsIn(x => x.State, filter.State); if (filter.UserCreator != null) { query.Where(x => x.UserCreator.Rn == filter.UserCreator.Rn); } if (!string.IsNullOrWhiteSpace(filter.Pref)) { query.Where(x => x.Pref == filter.Pref); } if (filter.Numb != null) { query.Where(x => x.Numb == filter.Numb); } if (filter.CreatorFactory != null) { query.Where(x => x.CreatorFactory.Rn == filter.CreatorFactory.Rn); } if (filter.NomenclatureNumber != null) { query.JoinQueryOver(x => x.PlanCertificate, JoinType.LeftOuterJoin); NomenclatureNumberModification nommodifAlias = null; query.JoinAlias(x => x.PlanCertificate.ModificationNomenclature, () => nommodifAlias, JoinType.LeftOuterJoin); query.Where(x => nommodifAlias.Code == filter.NomenclatureNumber.Code); } return(query); }
/// <summary> /// Conteggio degli elementi restituiti dalla query attualmente utilizzata /// </summary> /// <returns></returns> public override int Count() { Container container = null; IQueryOver <Desk, Desk> queryOver = CreateQueryOver(); queryOver = DecorateCriteria(queryOver); queryOver = AttachFilterExpressions(queryOver); return(queryOver.JoinQueryOver <Container>(o => o.Container, () => container) .Select(Projections.CountDistinct <Desk>(desk => desk.Id)) .FutureValue <int>() .Value); }
public override IQueryOver <Sample, Sample> Filtering(IQueryOver <Sample, Sample> query, SampleFilter filter) { query.FindByRn(filter.Rn); if (filter.CuttingOrderSpecification != null) { query.JoinQueryOver(x => x.CuttingOrderSpecification, JoinType.LeftOuterJoin); if (filter.CuttingOrderSpecification.Rn != 0) { query.Where(x => x.CuttingOrderSpecification.Rn == filter.CuttingOrderSpecification.Rn); } } return(query); }
public override IQueryOver <SampleCertification, SampleCertification> Filtering(IQueryOver <SampleCertification, SampleCertification> query, SampleCertificationFilter filter) { query.FindByRn(filter.Rn); if (filter.Sample != null) { query.JoinQueryOver(x => x.Sample, JoinType.LeftOuterJoin); if (filter.Sample.Rn != 0) { query.Where(x => x.Sample.Rn == filter.Sample.Rn); } } return(query); }
Filtering(IQueryOver <PlanReceiptOrderPersonalAccount, PlanReceiptOrderPersonalAccount> query, PlanReceiptOrderPersonalAccountFilter filter) { query.FindByRn(filter.Rn); if (filter.PlanCertificate != null) { if (filter.PlanCertificate.Rn > 0) { query.JoinQueryOver(x => x.PlaneCertificate, JoinType.LeftOuterJoin) .Where(x => x.Rn == filter.PlanCertificate.Rn); } } return(query); }
/// <summary> /// The filtering. /// </summary> /// <param name="query"> /// The query. /// </param> /// <param name="filter"> /// The filter. /// </param> /// <returns> /// The <see cref="IQueryOver"/>. /// </returns> public override IQueryOver <PlanCertificate, PlanCertificate> Filtering( IQueryOver <PlanCertificate, PlanCertificate> query, PlanCertificateFilter filter) { if (filter != null) { query.FindByRn(filter.Rn); if (filter.RnPlanReceiptOrder != 0) { query.JoinQueryOver(x => x.PlanReceiptOrder, JoinType.LeftOuterJoin) .Where(x => x.Rn == filter.RnPlanReceiptOrder); } } return(query); }
private IList <BasicTraffic> GetBasicTrafficsOverMachine(decimal machineID, IQueryOver <BasicTraffic, BasicTraffic> IQueryOverBasicTraffic) { IList <BasicTraffic> BasicTrafficsList = new List <BasicTraffic>(); if (machineID == 0) { BasicTrafficsList = IQueryOverBasicTraffic.List <BasicTraffic>(); } else { BasicTrafficsList = IQueryOverBasicTraffic.JoinQueryOver(basicTraffic => basicTraffic.Clock) .Where(clock => clock.ID == machineID) .List <BasicTraffic>(); } return(BasicTrafficsList); }
Filtering( IQueryOver <PermissionMaterialExtension, PermissionMaterialExtension> query, PermissionMaterialExtensionFilter filter) { query.FindByRn(filter.Rn); if (filter.PermissionMaterial != null) { if (filter.PermissionMaterial.Rn > 0) { query.JoinQueryOver(x => x.PermissionMaterial, JoinType.LeftOuterJoin) .Where(x => x.Rn == filter.PermissionMaterial.Rn); } } return(query.OrderBy(x => x.CreationDate).Desc()); }
protected override IQueryOver <Desk, Desk> MappingProjection(IQueryOver <Desk, Desk> queryOver) { DeskResult deskResult = null; Container container = null; queryOver .JoinQueryOver <Container>(o => o.Container, () => container) .SelectList(list => list // Mappatura degli oggetti Desk .Select(x => x.Id).WithAlias(() => deskResult.DeskId) .Select(x => x.Name).WithAlias(() => deskResult.DeskName) .Select(x => x.Description).WithAlias(() => deskResult.DeskSubject) .Select(x => x.Status).WithAlias(() => deskResult.DeskState) .Select(x => x.ExpirationDate).WithAlias(() => deskResult.DeskExpirationDate) // Mappatura degli oggetti Container .Select(() => container.Name).WithAlias(() => deskResult.ContainerName)); return(queryOver); }
/// <summary> /// The filtering. /// </summary> /// <param name="query"> /// The query. /// </param> /// <param name="filter"> /// The filter. /// </param> /// <returns> /// The <see cref="IQueryOver"/>. /// </returns> public override IQueryOver <PlanReceiptOrder, PlanReceiptOrder> Filtering( IQueryOver <PlanReceiptOrder, PlanReceiptOrder> query, PlanReceiptOrderFilter filter) { query.FindByRn(filter.Rn); query.IsBetween(x => x.CreationDate, filter.CreationDate); query.IsBetween(x => x.GroundDocumentDate, filter.GroundDocumentDate); query.IsLike(x => x.GroundDocumentNumb, filter.GroundDocumentNumb, MatchMode.Start); query.IsLike(x => x.Note, filter.Note, MatchMode.Start); query.IsLike(x => x.Pref, filter.Pref, MatchMode.Start); query.IsBetween(x => x.StateDate, filter.StateDate); if (filter.Numb != null) { query.Where(x => x.Numb == filter.Numb); } if (filter.States.Any()) { query.WhereRestrictionOn(x => x.State) .IsIn(filter.States.ToArray()); } if (filter.PlanCertificate != null) { if (filter.PlanCertificate.ModificationNomenclature != null) { if (filter.PlanCertificate.ModificationNomenclature.NomenclatureNumber != null) { if (!string.IsNullOrWhiteSpace(filter.PlanCertificate.ModificationNomenclature.NomenclatureNumber.Code)) { query.JoinQueryOver(x => x.PlanCertificates, JoinType.LeftOuterJoin); NomenclatureNumberModification nommodifAlias = null; query.JoinAlias((x) => filter.PlanCertificate.ModificationNomenclature, () => nommodifAlias, JoinType.LeftOuterJoin); NomenclatureNumber nomenclatureNumberAlias = null; query.JoinQueryOver(() => nommodifAlias.NomenclatureNumber, () => nomenclatureNumberAlias, JoinType.LeftOuterJoin); query.WhereRestrictionOn(() => nomenclatureNumberAlias.NomenCode) .IsLike( filter.PlanCertificate.ModificationNomenclature.NomenclatureNumber.Code .ReplaceStar()); } } } } if (filter.StaffingDivision != null) { if (filter.StaffingDivision.Code != null && filter.StaffingDivision.Code.Any()) { query.JoinQueryOver(x => x.StaffingDivision, JoinType.LeftOuterJoin) .WhereRestrictionOn(x => x.Code) .IsIn(filter.StaffingDivision.Code.ToArray()); } } if (filter.StoreGasStationOilDepot != null) { if (!string.IsNullOrWhiteSpace(filter.StoreGasStationOilDepot.AzsNumber)) { query.JoinQueryOver(x => x.StoreGasStationOilDepot, JoinType.LeftOuterJoin) .Where(x => x.Number == filter.StoreGasStationOilDepot.AzsNumber); } } if (!string.IsNullOrWhiteSpace(filter.GroundTypeOfDocument.DocCode)) { query.JoinQueryOver(x => x.GroundTypeOfDocument, JoinType.LeftOuterJoin) .Where(x => x.DocumentCode == filter.GroundTypeOfDocument.DocCode); } return(query); }