Beispiel #1
0
        public ActionResult FetchImage(int id)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }

            var person = CurrentDatabase.People.Single(pp => pp.PeopleId == id);

            if (person.PictureId != null)
            {
                DbUtil.LogActivity("checkin picture " + id);
                return(new ImageResult(CurrentImageDatabase, person.Picture.MediumId ?? 0));
            }
            return(new ImageResult(CurrentImageDatabase, 0));
        }
Beispiel #2
0
        public ContentResult Membership(int PeopleId, int OrgId, bool Member)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }

            DbUtil.LogActivity($"checkin {PeopleId}, {OrgId}, {(Member ? "join" : "unjoin")}");
            var m = new CheckInModel(CurrentDatabase);

            m.JoinUnJoinOrg(PeopleId, OrgId, Member);
            var r = new ContentResult();

            r.Content = "success";
            return(r);
        }
Beispiel #3
0
        public ContentResult RecordAttend(int PeopleId, int OrgId, bool Present, int thisday, string kiosk)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }

            DbUtil.LogActivity($"checkin {PeopleId}, {OrgId}, {(Present ? "attend0" : "unattend0")}");
            var m = new CheckInModel(CurrentDatabase);

            m.RecordAttend(PeopleId, OrgId, Present, thisday);
            var r = new ContentResult();

            r.Content = "success";
            return(r);
        }
Beispiel #4
0
        public ActionResult NumberSearch( string data )
        {
            if( !Auth() )
                return CheckInMessage.createErrorReturn( "Authentication failed, please try again", CheckInMessage.API_ERROR_INVALID_CREDENTIALS );

            CheckInMessage dataIn = CheckInMessage.createFromString( data );
            CheckInNumberSearch cns = JsonConvert.DeserializeObject<CheckInNumberSearch>( dataIn.data );

            DbUtil.LogActivity( "Check-In Number Search: " + cns.search );

            List<CheckinMatch> matches = DbUtil.Db.CheckinMatch( cns.search ).ToList();

            CheckInMessage br = new CheckInMessage();
            br.setNoError();

            int tzOffset = DbUtil.Db.Setting( "TZOffset", "0" ).ToInt();

            List<CheckInFamily> families = new List<CheckInFamily>();

            if( matches.Count > 0 ) {
                foreach( CheckinMatch match in matches ) {
                    if( match.Familyid != null ) {
                        CheckInFamily family = new CheckInFamily( match.Familyid.Value, match.Name, match.Locked ?? false );

                        List<CheckinFamilyMember> members = (from a in DbUtil.Db.CheckinFamilyMembers( match.Familyid, cns.campus, cns.day ).ToList()
                                                             orderby a.Position, a.Position == 10 ? a.Genderid : 10, a.Age descending, a.Hour
                                                             select a).ToList();

                        foreach( CheckinFamilyMember member in members ) {
                            family.addMember( member, cns.day, tzOffset );
                        }

                        families.Add( family );

                        br.count++;
                    }
                }

                br.data = SerializeJSON( families, dataIn.version );
            }

            return br;
        }
        public ActionResult JoinOrg(string data)
        {
            if (!Auth())
            {
                return(CheckInMessage.createErrorReturn("Authentication failed, please try again", CheckInMessage.API_ERROR_INVALID_CREDENTIALS));
            }

            CheckInMessage dataIn = CheckInMessage.createFromString(data);
            CheckInJoinOrg cjo    = JsonConvert.DeserializeObject <CheckInJoinOrg>(dataIn.data);

            OrganizationMember om = CurrentDatabase.OrganizationMembers.SingleOrDefault(m => m.PeopleId == cjo.peopleID && m.OrganizationId == cjo.orgID);

            if (om == null && cjo.join)
            {
                om = OrganizationMember.InsertOrgMembers(CurrentDatabase, cjo.orgID, cjo.peopleID, MemberTypeCode.Member, DateTime.Today);
            }

            if (om != null && !cjo.join)
            {
                om.Drop(CurrentDatabase, CurrentImageDatabase, DateTime.Now);

                DbUtil.LogActivity($"Dropped {om.PeopleId} for {om.Organization.OrganizationId} via {dataIn.getSourceOS()} app", peopleid: om.PeopleId, orgid: om.OrganizationId);
            }

            CurrentDatabase.SubmitChanges();

            // Check Entry Point and replace if Check-In
            Person person = CurrentDatabase.People.FirstOrDefault(p => p.PeopleId == cjo.peopleID);

            if (person?.EntryPoint != null && person.EntryPoint.Code == "CHECKIN" && om != null)
            {
                person.EntryPoint = om.Organization.EntryPoint;
                CurrentDatabase.SubmitChanges();
            }

            CheckInMessage br = new CheckInMessage();

            br.setNoError();
            br.count = 1;

            return(br);
        }
Beispiel #6
0
        public ActionResult AddPerson(int id, PersonInfo m)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }
            DbUtil.LogActivity($"checkin AddPerson {m.first} {m.last} ({m.dob})");

            var f = id > 0
                ? DbUtil.Db.Families.Single(fam => fam.FamilyId == id)
                : new Family();

            var position = DbUtil.Db.ComputePositionInFamily(m.dob.Age0(), m.marital == 20, id) ?? 10;
            var p        = Person.Add(f, position,
                                      null, m.first, m.goesby, m.last, m.dob, false, m.gender,
                                      OriginCode.Visit, null);

            UpdatePerson(p, m, true);
            return(Content(f.FamilyId + "." + p.PeopleId));
        }
        public ActionResult RecordAttend(string data)
        {
            // Authenticate first
            if (!Auth())
            {
                return(CheckInMessage.createErrorReturn("Authentication failed, please try again", CheckInMessage.API_ERROR_INVALID_CREDENTIALS));
            }

            CheckInMessage dataIn = CheckInMessage.createFromString(data);
            CheckInAttend  cia    = JsonConvert.DeserializeObject <CheckInAttend>(dataIn.data);

            Meeting meeting = CurrentDatabase.Meetings.SingleOrDefault(m => m.OrganizationId == cia.orgID && m.MeetingDate == cia.datetime);

            if (meeting == null)
            {
                int meetingID = CurrentDatabase.CreateMeeting(cia.orgID, cia.datetime);

                meeting = CurrentDatabase.Meetings.SingleOrDefault(m => m.MeetingId == meetingID);
            }

            Attend.RecordAttend(CurrentDatabase, cia.peopleID, cia.orgID, cia.present, cia.datetime);

            CurrentDatabase.UpdateMeetingCounters(cia.orgID);
            DbUtil.LogActivity($"Check-In Record Attend Org ID:{cia.orgID} People ID:{cia.peopleID} User ID:{CurrentDatabase.UserPeopleId} Attended:{cia.present}");

            // Check Entry Point and replace if Check-In
            Person person = CurrentDatabase.People.FirstOrDefault(p => p.PeopleId == cia.peopleID);

            if (person != null && person.EntryPoint != null && person.EntryPoint.Code != null && person.EntryPoint.Code == "CHECKIN" && meeting != null)
            {
                person.EntryPoint = meeting.Organization.EntryPoint;
                CurrentDatabase.SubmitChanges();
            }

            CheckInMessage br = new CheckInMessage();

            br.setNoError();
            br.count = 1;

            return(br);
        }
        public ActionResult Family(string data)
        {
            if (!Auth())
            {
                return(CheckInMessage.createErrorReturn("Authentication failed, please try again", CheckInMessage.API_ERROR_INVALID_CREDENTIALS));
            }

            CheckInMessage      dataIn = CheckInMessage.createFromString(data);
            CheckInFamilySearch cfs    = JsonConvert.DeserializeObject <CheckInFamilySearch>(dataIn.data);

            DbUtil.LogActivity("Check-In Family: " + cfs.familyID);

            CheckInMessage br = new CheckInMessage();

            br.setNoError();

            int tzOffset = CurrentDatabase.Setting("TZOffset", "0").ToInt();

            List <CheckInFamily> families = new List <CheckInFamily>();

            FamilyCheckinLock familyLock = CurrentDatabase.FamilyCheckinLocks.SingleOrDefault(f => f.FamilyId == dataIn.argInt);

            CheckInFamily family = new CheckInFamily(cfs.familyID, "", familyLock?.Locked ?? false, CurrentDatabase, CurrentImageDatabase);

            List <CheckinFamilyMember> members = (from a in CurrentDatabase.CheckinFamilyMembers(cfs.familyID, cfs.campus, cfs.day).ToList()
                                                  orderby a.Position, a.Position == 10 ? a.Genderid : 10, a.Age descending, a.Hour
                                                  select a).ToList();

            foreach (CheckinFamilyMember member in members)
            {
                family.addMember(CurrentDatabase, CurrentImageDatabase, member, cfs.day, tzOffset);
            }

            families.Add(family);
            br.count = 1;

            br.data = SerializeJSON(families, dataIn.version);
            return(br);
        }
        public ActionResult RecordHeadcount(string data)
        {
            if (DbUtil.Db.Setting("RegularMeetingHeadCount", "true") == "disabled")
            {
                return(BaseMessage.createErrorReturn("Headcounts for meetings are disabled"));
            }

            // Authenticate first
            var result = AuthenticateUser();

            if (!result.IsValid)
            {
                return(AuthorizationError(result));
            }

            // Check Role
            if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance"))
            {
                return(BaseMessage.createErrorReturn("Attendance roles is required to take attendance for organizations"));
            }

            BaseMessage         dataIn = BaseMessage.createFromString(data);
            MobilePostHeadcount mph    = JsonConvert.DeserializeObject <MobilePostHeadcount>(dataIn.data);

            var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == mph.orgID && m.MeetingDate == mph.datetime);

            meeting.HeadCount = mph.headcount;

            DbUtil.Db.SubmitChanges();

            DbUtil.LogActivity("Mobile Headcount o:{0} m:{1} h:{2}".Fmt(meeting.OrganizationId, meeting.MeetingId, mph.headcount));

            BaseMessage br = new BaseMessage();

            br.error = 0;
            br.count = 1;

            return(br);
        }
Beispiel #10
0
        public ActionResult Match(string id, int campus, int thisday, int?page, string kiosk, bool?kioskmode)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }
            Response.NoCache();
            DbUtil.Db.SetNoLock();
            DbUtil.LogActivity("checkin " + id);

            var matches = DbUtil.Db.CheckinMatch(id).ToList();

            if (!matches.Any())
            {
                return(new FamilyResult(0, campus, thisday, 0, false)); // not found
            }
            if (matches.Count() == 1)
            {
                return(new FamilyResult(matches.Single().Familyid.Value, campus, thisday, 0, matches[0].Locked ?? false));
            }
            return(new MultipleResult(matches, page));
        }
Beispiel #11
0
        public ActionResult Find(string id, string building, int?page, string querybit)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }
            Response.NoCache();
            DbUtil.Db.SetNoLock();
            DbUtil.LogActivity("CheckinFind " + building + " " + id);

            var m       = new CheckInModel();
            var matches = m.Find(id);

            if (!matches.Any())
            {
                return(new FindResult(0, building, querybit));
            }
            if (matches.Count() == 1)
            {
                return(new FindResult(matches.Single().Familyid.Value, building, querybit));
            }

            return(new MultipleResult(matches, page));
        }
Beispiel #12
0
 public QueryFunctions(string dbname)
 {
     db = DbUtil.Create(dbname);
 }
Beispiel #13
0
 public void LogExtraValue(string op, string field)
 {
     DbUtil.LogActivity($"EVOrgMem {op}:{field}", orgid: OrganizationId, peopleid: PeopleId);
 }
        public ActionResult NameSearch(string data)
        {
            if (!Auth())
            {
                return(CheckInMessage.createErrorReturn("Authentication failed, please try again", CheckInMessage.API_ERROR_INVALID_CREDENTIALS));
            }

            CheckInMessage    dataIn = CheckInMessage.createFromString(data);
            CheckInNameSearch cns    = JsonConvert.DeserializeObject <CheckInNameSearch>(dataIn.data);

            cns.splitName();

            DbUtil.LogActivity("Check-In Name Search: " + cns.name);

            IQueryable <Person> q = CurrentDatabase.People.Select(p => p);

            if (cns.first.HasValue())
            {
                q = from p in q
                    where (p.LastName.StartsWith(cns.last) || p.MaidenName.StartsWith(cns.last)) &&
                    (p.FirstName.StartsWith(cns.first) || p.NickName.StartsWith(cns.first) || p.MiddleName.StartsWith(cns.first))
                    select p;
            }
            else
            {
                q = from p in q
                    where p.LastName.StartsWith(cns.last) || p.FirstName.StartsWith(cns.last) || p.NickName.StartsWith(cns.last) || p.MiddleName.StartsWith(cns.last)
                    select p;
            }

            List <CheckInPerson> q2 = (from p in q
                                       let recreg = p.RecRegs.FirstOrDefault()
                                                    orderby p.Name2, p.PeopleId
                                       where p.DeceasedDate == null
                                       select new CheckInPerson
            {
                id = p.PeopleId,
                familyID = p.FamilyId,
                first = p.PreferredName,
                last = p.LastName,
                goesby = p.NickName,
                altName = p.AltName,
                cell = p.CellPhone,
                home = p.HomePhone,
                address = p.Family.AddressLineOne,
                age = p.Age ?? 0
            }).Take(200).ToList();

            foreach (CheckInPerson person in q2)
            {
                person.loadImage(CurrentDatabase, CurrentImageDatabase);
            }

            CheckInMessage br = new CheckInMessage();

            br.setNoError();
            br.count = q2.Count();
            br.data  = SerializeJSON(q2, dataIn.version);

            return(br);
        }
Beispiel #15
0
 public void LogExtraValue(string op, string field)
 {
     DbUtil.LogActivity($"EVMeeting {op}:{field}:{MeetingId}");
 }
        public ActionResult ClassSearch(string data)
        {
            if (!Auth())
            {
                return(CheckInMessage.createErrorReturn("Authentication failed, please try again", CheckInMessage.API_ERROR_INVALID_CREDENTIALS));
            }

            CheckInMessage     dataIn = CheckInMessage.createFromString(data);
            CheckInClassSearch ccs    = JsonConvert.DeserializeObject <CheckInClassSearch>(dataIn.data);

            DbUtil.LogActivity("Check-In Class Search: " + ccs.peopleID);

            var person = (from p in CurrentDatabase.People
                          where p.PeopleId == ccs.peopleID
                          select new { p.FamilyId, p.BirthDate, p.Grade }).SingleOrDefault();

            if (person == null)
            {
                return(CheckInMessage.createErrorReturn("Person not found", CheckInMessage.API_ERROR_PERSON_NOT_FOUND));
            }

            CheckInMessage br = new CheckInMessage();

            br.setNoError();

            List <CheckInOrganization> orgs = (from o in CurrentDatabase.Organizations
                                               let sc = o.OrgSchedules.FirstOrDefault()
                                                        let meetingHours = CurrentDatabase.GetTodaysMeetingHours(o.OrganizationId, ccs.day)
                                                                           let bdaystart = o.BirthDayStart ?? DateTime.MaxValue
                                                                                           where (o.SuspendCheckin ?? false) == false || ccs.noAgeCheck
                                                                                           where person.BirthDate == null || person.BirthDate <= o.BirthDayEnd || o.BirthDayEnd == null || ccs.noAgeCheck
                                                                                           where person.BirthDate == null || person.BirthDate >= o.BirthDayStart || o.BirthDayStart == null || ccs.noAgeCheck
                                                                                           where o.CanSelfCheckin == true
                                                                                           where (o.ClassFilled ?? false) == false
                                                                                           where (o.CampusId == null && o.AllowNonCampusCheckIn == true) || o.CampusId == ccs.campus || ccs.campus == 0
                                                                                           where o.OrganizationStatusId == OrgStatusCode.Active
                                                                                           orderby sc.SchedTime.Value.TimeOfDay, bdaystart, o.OrganizationName
                                               from meeting in meetingHours
                                               select new CheckInOrganization()
            {
                id = o.OrganizationId,
                leader = o.LeaderName,
                name = o.OrganizationName,
                hour = meeting.Hour.Value,
                birthdayStart = o.BirthDayStart,
                birthdayEnd = o.BirthDayEnd,
                location = o.Location,
                allowOverlap = o.AllowAttendOverlap
            }).ToList();

            // Add lead time adjustment for different timezones here
            int tzOffset = CurrentDatabase.Setting("TZOffset", "0").ToInt();

            foreach (CheckInOrganization org in orgs)
            {
                org.adjustLeadTime(ccs.day, tzOffset);
            }

            br.data = SerializeJSON(orgs, dataIn.version);

            return(br);
        }
Beispiel #17
0
 public void DeleteAllExtraValueLike(string value)
 {
     DbUtil.LogActivity(db.Host, $"Delete PeopleExtra where Field like '{value}'");
     db.Connection.Execute("delete dbo.PeopleExtra where Field like @value", new { value });
 }
Beispiel #18
0
 public void LogExtraValue(string op, string field)
 {
     DbUtil.LogActivity($"EVFamily {op}:{field}");
 }
Beispiel #19
0
 public void LogExtraValue(string op, string field)
 {
     DbUtil.LogActivity($"EVContact {op}:{field}", ContactId);
 }
Beispiel #20
0
 private CMSDataContext NewDataContext()
 {
     return(DbUtil.Create(db.Host));
 }
Beispiel #21
0
 public void LogActivity(string activity, int?oid = null, int?pid = null, int?did = null, int?uid = null)
 {
     DbUtil.LogActivity(Host, activity, oid, pid, did, uid);
 }
Beispiel #22
0
 public PythonModel(string dbname, Dictionary <string, object> dict)
 {
     dictionary = dict;
     Data       = new DynamicData(dictionary);
     db         = DbUtil.Create(dbname);
 }