コード例 #1
0
        internal Expression RecentBundleType()
        {
            if (!db.FromBatch)
            {
                if (db.CurrentUser == null || db.CurrentUser.Roles.All(rr => rr != "Finance"))
                {
                    return(AlwaysFalse());
                }
            }
            var now = DateTime.Now;
            var dt  = now.AddDays(-Days);
            Expression <Func <Person, bool> > pred = p =>
                                                     (
                from c in p.Contributions
                where c.ContributionDate > dt
                where c.ContributionAmount > 0
                where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId)
                where c.BundleDetails.Any(cc => CodeIntIds.Contains(cc.BundleHeader.BundleHeaderTypeId))
                select c
                                                     ).Any();
            Expression expr = Expression.Invoke(pred, parm);

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #2
0
        internal Expression MemberTypeAsOf()
        {
            var end = EndDate?.AddDays(1) ?? StartDate?.AddDays(1);

            Expression <Func <Person, bool> > pred = p => (
                from et in p.EnrollmentTransactions
                where et.TransactionTypeId <= 3                        // things that start a change
                where et.TransactionStatus == false
                where StartDate <= (et.NextTranChangeDate ?? Util.Now) // where it ends
                where et.TransactionDate <= end                        // where it begins
                where (et.Pending ?? false) == false
                where CodeIntIds.Contains(et.MemberTypeId)             // what it's type was during that time
                where (OrgTypeInt ?? 0) == 0 || et.Organization.OrganizationTypeId == OrgTypeInt
                where OrganizationInt == 0 || et.OrganizationId == OrganizationInt
                where DivisionInt == 0 || et.Organization.DivOrgs.Any(dg => dg.DivId == DivisionInt)
                where ProgramInt == 0 || et.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == ProgramInt))
                select et
                ).Any();
            Expression expr = Expression.Invoke(pred, parm);

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #3
0
        internal Expression NeedAttendance()
        {
            var mindt = Util.Now.AddDays(-Days).Date;
            var dow   = Quarters.ToInt2();
            Expression <Func <Person, bool> > pred = p => (
                from m in p.OrganizationMembers
                where m.Organization.OrganizationStatusId == Codes.OrgStatusCode.Active
                let sc = m.Organization.OrgSchedules.FirstOrDefault()
                         where sc != null
                         where !dow.HasValue || sc.SchedDay == dow
                         where CodeIntIds.Contains(m.MemberTypeId)
                         where Organization == 0 || m.OrganizationId == Organization
                         where Division == 0 || m.Organization.DivOrgs.Any(dg => dg.DivId == Division)
                         where Program == 0 || m.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == Program))
                         where !m.Organization.Meetings.Any(mm => mm.MeetingDate > mindt && (mm.HeadCount > 0 || mm.Attends.Any(aa => aa.AttendanceFlag)))
                         select m
                ).Any();
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #4
0
ファイル: Volunteer.cs プロジェクト: rastographics/bvcms
        internal Expression MVRStatusCode()
        {
            Expression <Func <Person, bool> > pred = p =>
                                                     p.Volunteers.Any(v => CodeIntIds.Contains(v.MVRStatusId ?? 0));
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #5
0
ファイル: Volunteer.cs プロジェクト: rastographics/bvcms
        internal Expression VolunteerApprovalCode()
        {
            Expression <Func <Person, bool> > pred =
                p => p.VoluteerApprovalIds.Any(vid => CodeIntIds.Contains(vid.ApprovalId)) ||
                (!p.VoluteerApprovalIds.Any() && CodeIntIds.Contains(0));
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #6
0
ファイル: Ministry.cs プロジェクト: marius310/bvcms
        internal Expression RecentContactReason()
        {
            var mindt = Util.Now.AddDays(-Days).Date;
            Expression <Func <Person, bool> > pred = p =>
                                                     p.contactsHad.Any(a => a.contact.ContactDate >= mindt &&
                                                                       CodeIntIds.Contains(a.contact.ContactReasonId ?? 0));
            Expression expr = Expression.Invoke(pred, parm);

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #7
0
ファイル: Membership.cs プロジェクト: thewruck/bvcms
        internal Expression RecentDecisionType()
        {
            var mindt = Util.Now.AddDays(-Days).Date;
            Expression <Func <Person, bool> > pred = p =>
                                                     p.DecisionDate > mindt &&
                                                     CodeIntIds.Contains(p.DecisionTypeId.Value);
            Expression expr = Expression.Invoke(pred, parm);

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #8
0
        internal Expression AttendTypeIds()
        {
            Expression <Func <Person, bool> > pred;

            if (Schedule == -1)
            {
                pred = p => (
                    from m in p.OrganizationMembers
                    where CodeIntIds.Contains(m.MemberType.AttendanceTypeId ?? 0)
                    where ((Campus ?? 0) == 0 ||
                           m.Organization.CampusId == (Campus ?? 0) ||
                           (Campus == -1 && m.Organization.CampusId == null)
                           )
                    where (OrgType ?? 0) == 0 || m.Organization.OrganizationTypeId == OrgType
                    where Organization == 0 || m.OrganizationId == Organization
                    where Division == 0 || m.Organization.DivOrgs.Any(dg => dg.DivId == Division)
                    where Program == 0 || m.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == Program))
                    where !m.Organization.OrgSchedules.Any()
                    select m
                    ).Any();
            }
            else
            {
                pred = p => (
                    from m in p.OrganizationMembers
                    where CodeIntIds.Contains(m.MemberType.AttendanceTypeId ?? 0)
                    where ((Campus ?? 0) == 0 ||
                           m.Organization.CampusId == (Campus ?? 0) ||
                           (Campus == -1 && m.Organization.CampusId == null)
                           )
                    where (OrgType ?? 0) == 0 || m.Organization.OrganizationTypeId == OrgType
                    where Organization == 0 || m.OrganizationId == Organization
                    where Division == 0 || m.Organization.DivOrgs.Any(dg => dg.DivId == Division)
                    where Program == 0 || m.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == Program))
                    where Schedule == 0 || m.Organization.OrgSchedules.Any(os => os.ScheduleId == Schedule)
                    select m
                    ).Any();
            }
            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                return(Expression.Not(Expression.Invoke(pred, parm)));
            }
            else
            {
                return(Expression.Invoke(pred, parm));
            }
        }
コード例 #9
0
        internal Expression MemberTypeIds()
        {
            Expression <Func <Person, bool> > pred;

            if (ScheduleInt == -1)
            {
                pred = p => (
                    from m in p.OrganizationMembers
                    where CodeIntIds.Contains(m.MemberTypeId)
                    where ((CampusInt ?? 0) == 0 ||
                           m.Organization.CampusId == (CampusInt ?? 0) ||
                           (CampusInt == -1 && m.Organization.CampusId == null)
                           )
                    where (OrgTypeInt ?? 0) == 0 || m.Organization.OrganizationTypeId == OrgTypeInt
                    where OrganizationInt == 0 || m.OrganizationId == OrganizationInt
                    where DivisionInt == 0 || m.Organization.DivOrgs.Any(dg => dg.DivId == DivisionInt)
                    where ProgramInt == 0 || m.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == ProgramInt))
                    where !m.Organization.OrgSchedules.Any()
                    select m
                    ).Any();
            }
            else
            {
                pred = p => (
                    from m in p.OrganizationMembers
                    where CodeIntIds.Contains(m.MemberTypeId)
                    where ((CampusInt ?? 0) == 0 ||
                           m.Organization.CampusId == (CampusInt ?? 0) ||
                           (CampusInt == -1 && m.Organization.CampusId == null)
                           )
                    where (OrgTypeInt ?? 0) == 0 || m.Organization.OrganizationTypeId == OrgTypeInt
                    where OrganizationInt == 0 || m.OrganizationId == OrganizationInt
                    where DivisionInt == 0 || m.Organization.DivOrgs.Any(dg => dg.DivId == DivisionInt)
                    where ProgramInt == 0 || m.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == ProgramInt))
                    where ScheduleInt == 0 || m.Organization.OrgSchedules.Any(os => os.ScheduleId == ScheduleInt)
                    select m
                    ).Any();
            }
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #10
0
ファイル: Family.cs プロジェクト: sengithub/SenSourcecode
        internal Expression FamilyHasChildrenAged3()
        {
            var range = Quarters.Split('-');
            Expression <Func <Person, bool> > pred = p =>
                                                     p.Family.People.Any(m =>
                                                                         (m.Age ?? 0) >= range[0].ToInt() &&
                                                                         (m.Age ?? 0) <= range[1].ToInt() &&
                                                                         CodeIntIds.Contains(m.GenderId) &&
                                                                         m.PositionInFamilyId == PositionInFamily.Child
                                                                         );
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #11
0
ファイル: Ministry.cs プロジェクト: marius310/bvcms
        internal Expression MadeContactTypeAsOf()
        {
            //StartDate, EndDate, Program, CodeIntIds
            var to = (EndDate ?? StartDate ?? DateTime.Now).AddDays(1);

            Expression <Func <Person, bool> > pred = p => (
                from c in p.contactsMade
                where c.contact.MinistryId == MinistryInt || MinistryInt == 0
                where CodeIntIds.Contains(c.contact.ContactTypeId ?? 0) || CodeIntIds.Length == 0 || CodeIntIds[0] == 0
                where StartDate == null || StartDate <= c.contact.ContactDate
                where c.contact.ContactDate <= to
                select c
                ).Any();
            Expression expr = Expression.Invoke(pred, parm);

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #12
0
        internal Expression MembOfOrgWithSched()
        {
            Expression <Func <Person, bool> > pred = p => (
                from m in p.OrganizationMembers
                where m.MemberTypeId != MemberTypeCode.InActive
                where m.MemberTypeId != MemberTypeCode.Prospect
                where (m.Pending ?? false) == false
                where Organization == 0 || m.OrganizationId == Organization
                where Division == 0 || m.Organization.DivOrgs.Any(dg => dg.DivId == Division)
                where Program == 0 || m.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == Program))
                where m.Organization.OrgSchedules.Any(os => CodeIntIds.Contains(os.ScheduleId ?? 0))
                select m
                ).Any();
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #13
0
        internal Expression RecentRegistrationType()
        {
            var mindt = Util.Now.AddDays(-Days).Date;
            Expression <Func <Person, bool> > pred = p => (
                from m in p.EnrollmentTransactions
                where m.TransactionTypeId == 1
                where m.EnrollmentDate >= mindt
                where CodeIntIds[0] == 99 || CodeIntIds.Contains(m.Organization.RegistrationTypeId ?? 0)
                where (OrgType ?? 0) == 0 || m.Organization.OrganizationTypeId == OrgType
                where Organization == 0 || m.OrganizationId == Organization
                where Division == 0 || m.Organization.DivOrgs.Any(dg => dg.DivId == Division)
                where Program == 0 || m.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == Program))
                select m
                ).Any();
            Expression expr = Expression.Invoke(pred, parm);

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #14
0
        internal Expression MembOfOrgWithCampus()
        {
            Expression <Func <Person, bool> > pred = p => (
                from m in p.OrganizationMembers
                where m.MemberTypeId != MemberTypeCode.InActive
                where m.MemberTypeId != MemberTypeCode.Prospect
                where (m.Pending ?? false) == false
                where (OrgTypeInt ?? 0) == 0 || m.Organization.OrganizationTypeId == OrgTypeInt
                where OrganizationInt == 0 || m.OrganizationId == OrganizationInt
                where DivisionInt == 0 || m.Organization.DivOrgs.Any(dg => dg.DivId == DivisionInt)
                where ProgramInt == 0 || m.Organization.DivOrgs.Any(dg => dg.Division.ProgDivs.Any(pg => pg.ProgId == ProgramInt))
                where CodeIntIds.Contains(m.Organization.CampusId ?? 0) ||
                (CodeIntIds[0] == -1 && m.Organization.CampusId == null)
                select m
                ).Any();
            Expression expr = Expression.Invoke(pred, parm); // substitute parm for p

            if (op == CompareType.NotEqual || op == CompareType.NotOneOf)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #15
0
        internal Expression GetEldestFamilyMember()
        {
            Expression expr;
            Expression <Func <Person, bool> > pred;

            var  aMemberType   = (MemberTypes ?? "").Split(';').Select(s => s.Split(',')[0].ToInt()).ToArray();
            var  idMemberTypes = string.Join(",", aMemberType);
            var  aAttendType   = (AttendTypes ?? "").Split(';').Select(s => s.Split(',')[0].ToInt()).ToArray();
            var  idAttendTypes = string.Join(",", aAttendType);
            bool boolFilterAttendType;

            if (MemberTypes == null || aMemberType[0] == 0)
            {
                idMemberTypes = "";
            }

            // Note: For Attend type, the people IDs that is generated for database function
            // AttendanceTypeAsOf, does not generate entries ignoring the Attend Type, if the id is an
            // empty string.

            // Set variable to indicate whether or not Attend Type is filtered
            if (AttendTypes == null || aAttendType[0] == 0)
            {
                boolFilterAttendType = false;
            }
            else
            {
                boolFilterAttendType = true;
            }

            DateTime?enddt = null;

            if (!EndDate.HasValue && StartDate.HasValue)
            {
                enddt = StartDate.Value.AddHours(24);
            }
            if (EndDate.HasValue)
            {
                enddt = EndDate.Value.AddHours(24);
            }

            IQueryable <int> qMemberType;

            qMemberType = db.AttendMemberTypeAsOf(StartDate, enddt, ProgramInt, DivisionInt, OrganizationInt, idMemberTypes, null)
                          .Select(a => a.PeopleId ?? 0).Distinct();

            IQueryable <int> qAttendType;

            if (boolFilterAttendType)
            {
                qAttendType = db.AttendanceTypeAsOf(StartDate, enddt, ProgramInt, DivisionInt, OrganizationInt, OrgTypeInt ?? 0, idAttendTypes)
                              .Select(a => a.PeopleId).Distinct();
            }
            else
            {
                qAttendType = db.AttendedAsOf(ProgramInt, DivisionInt, OrganizationInt, StartDate, enddt, false)
                              .Select(a => a.PeopleId).Distinct();
            }

            IQueryable <int> q;

            q = qMemberType.Intersect(qAttendType);

            pred = p =>
                   (from p2 in p.Family.People
                    where (op == CompareType.Equal || op == CompareType.OneOf) ? CodeIntIds.Contains(p2.PositionInFamilyId) : !CodeIntIds.Contains(p2.PositionInFamilyId)
                    where q.Contains(p2.PeopleId)
                    orderby(p2.BirthYear ?? 9999), (p2.BirthMonth ?? 99), (p2.BirthDay ?? 99),
                    db.SpaceToNull(p2.LastName) ?? "zzz",
                    db.SpaceToNull(p2.NickName) ?? db.SpaceToNull(p2.FirstName) ?? "zzz",
                    p2.MiddleName + p2.SuffixCode, p2.PeopleId > 0 ? p2.PeopleId : 99999999
                    select p2).First().PeopleId == p.PeopleId;

            expr = Expression.Invoke(pred, parm);
            return(expr);
        }
コード例 #16
0
ファイル: AttendanceHistory.cs プロジェクト: thewruck/bvcms
        internal Expression CommitmentForMeetingId()
        {
            var meetingid = Quarters.ToInt();
            Expression <Func <Person, bool> > pred = p => p.Attends.Any(a =>
                                                                        a.MeetingId == meetingid && CodeIntIds.Contains(a.Commitment ?? 99));
            Expression expr = Expression.Invoke(pred, parm);

            if (op == CompareType.NotEqual)
            {
                expr = Expression.Not(expr);
            }
            return(expr);
        }
コード例 #17
0
        internal Expression UserRole()
        {
            Expression <Func <Person, bool> > pred = p =>
                                                     p.Users.Any(u => u.UserRoles.Any(ur => CodeIntIds.Contains(ur.RoleId)) ||
                                                                 (!u.UserRoles.Any() && CodeIntIds.Contains(0))
                                                                 );

            return(op == CompareType.NotEqual || op == CompareType.NotOneOf
                ? Expression.Not(Expression.Invoke(pred, parm))
                : (Expression)Expression.Invoke(pred, parm));
        }
コード例 #18
0
        internal Expression GetEldestFamilyMember()
        {
            DateTime?enddt = null;

            if (!EndDate.HasValue && StartDate.HasValue)
            {
                enddt = StartDate.Value.AddHours(24);
            }
            if (EndDate.HasValue)
            {
                enddt = EndDate.Value.AddHours(24);
            }

            var q = db.AttendedAsOf(ProgramInt, DivisionInt, OrganizationInt, StartDate, enddt, false);

            Expression <Func <Person, bool> > pred = p =>
                                                     (from p2 in p.Family.People
                                                      where (op == CompareType.Equal || op == CompareType.OneOf) ? CodeIntIds.Contains(p2.PositionInFamilyId) : !CodeIntIds.Contains(p2.PositionInFamilyId)
                                                      where q.Select(c => c.PeopleId).Contains(p2.PeopleId)
                                                      orderby(p2.BirthYear ?? 9999), (p2.BirthMonth ?? 99), (p2.BirthDay ?? 99),
                                                      db.SpaceToNull(p2.LastName) ?? "zzz",
                                                      db.SpaceToNull(p2.NickName) ?? db.SpaceToNull(p2.FirstName) ?? "zzz",
                                                      p2.MiddleName + p2.SuffixCode, p2.PeopleId > 0 ? p2.PeopleId : 99999999
                                                      select p2).First().PeopleId == p.PeopleId;

            Expression expr = Expression.Invoke(pred, parm);

            return(expr);
        }