public ContentResult RecordAttend2(int PeopleId, int OrgId, bool Present, string hour, string kiosk) { if (!Authenticate()) { return(Content("not authorized")); } DbUtil.LogActivity($"checkin {PeopleId}, {OrgId}, {(Present ? "attend" : "unattend")}"); DateTime dt; if (Util.IsCultureUS()) { if (!hour.DateTryParse(out dt)) { return(Content("date not parsed")); } } else { if (!hour.DateTryParseUS(out dt)) { return(Content("date not parsed")); } } Attend.RecordAttend(CurrentDatabase, PeopleId, OrgId, Present, dt); var r = new ContentResult(); r.Content = "success"; return(r); }
public void recordAttendance(CMSDataContext dataContext) { foreach (Attendance attendance in attendances) { foreach (AttendanceGroup group in attendance.groups) { Attend.RecordAttend(dataContext, attendance.peopleID, group.groupID, group.present, group.datetime); Attend attend = dataContext.Attends.FirstOrDefault(a => a.PeopleId == attendance.peopleID && a.OrganizationId == group.groupID && a.MeetingDate == group.datetime); if (attend == null) { continue; } if (group.present) { attend.SubGroupID = group.subgroupID; attend.SubGroupName = group.subgroupName; } else { attend.SubGroupID = 0; attend.SubGroupName = ""; } if (group.join) { joinToOrg(dataContext, attendance.peopleID, group.groupID); } } dataContext.SubmitChanges(); } }
public ContentResult RecordAttend2(int PeopleId, int OrgId, bool Present, DateTime hour, string kiosk) { if (!Authenticate()) { return(Content("not authorized")); } DbUtil.LogActivity($"checkin {PeopleId}, {OrgId}, {(Present ? "attend" : "unattend")}"); Attend.RecordAttend(DbUtil.Db, PeopleId, OrgId, Present, hour); var r = new ContentResult(); r.Content = "success"; return(r); }
public void RecentAttendCount_Should_Work() { var code = "RecentAttendCount( Days=2, Org=36[App Testing Org] ) = 1"; var org = 36; var pid = 2; var dt = DateTime.Today.AddHours(-10); Attend.RecordAttend(db, pid, org, true, dt); db.SubmitChanges(); var qb = db.PeopleQuery2(code); var count = qb.Count(); db.ExecuteCommand("DELETE dbo.attend where OrganizationId = {0} AND MeetingDate = {1}", org, dt); db.ExecuteCommand("DELETE dbo.meetings where OrganizationId = {0} AND MeetingDate = {1}", org, dt); count.ShouldBe(1); }
public void RecentVisitNumberOrgs() { var code = "RecentVisitNumberOrgs( VisitNumber='2', Days=2, Org=36[App Testing Org] ) = 1"; var org = 36; var pid = 2; var dt1 = DateTime.Today.AddHours(-10); var dt2 = dt1.AddDays(-1); Attend.RecordAttend(db, pid, org, true, dt1); Attend.RecordAttend(db, pid, org, true, dt2); db.SubmitChanges(); var qb = db.PeopleQuery2(code); var count = qb.Count(); db.ExecuteCommand("DELETE dbo.attend where OrganizationId = {0} AND MeetingDate IN ({1}, {2})", org, dt1, dt2); db.ExecuteCommand("DELETE dbo.meetings where OrganizationId = {0} AND MeetingDate IN ({1}, {2})", org, dt1, dt2); count.ShouldBe(1); }
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 ContentResult BuildingCheckin(int id, string location, int accesstype, int?guestof) { if (!Authenticate()) { return(Content("not authorized")); } CheckInTime g = null; if (guestof != null) { g = (from e in DbUtil.Db.CheckInTimes where e.Id == guestof select e).FirstOrDefault(); } var reader = new StreamReader(Request.InputStream); var s = reader.ReadToEnd(); if (!s.HasValue()) { s = "<Activities />"; } var xs = new XmlSerializer(typeof(List <Activity>), new XmlRootAttribute("Activities")); var activities = xs.Deserialize(new StringReader(s)) as List <Activity>; var last = from e in DbUtil.Db.CheckInTimes where e.PeopleId == id where e.CheckInTimeX <= DateTime.Now where e.CheckInTimeX >= DateTime.Now.AddHours(-1.5) select e; if (guestof == null) { last = from f in last where f.GuestOfId == null select f; } else { last = from f in last where f.GuestOfId == guestof select f; } CheckInTime ac = null; if (last.Any()) { ac = last.Single(); foreach (var e in ac.CheckInActivities) { DbUtil.Db.CheckInActivities.DeleteOnSubmit(e); } DbUtil.Db.SubmitChanges(); foreach (var a in activities) { ac.CheckInActivities.Add(new CheckInActivity { Activity = a.Name }); } ac.AccessTypeID = accesstype; } else { ac = new CheckInTime { PeopleId = id, Location = location, CheckInTimeX = DateTime.Now, GuestOfId = guestof, GuestOfPersonID = (g != null ? g.PeopleId ?? 0 : 0), AccessTypeID = accesstype }; foreach (var a in activities) { ac.CheckInActivities.Add(new CheckInActivity { Activity = a.Name }); } DbUtil.Db.CheckInTimes.InsertOnSubmit(ac); } DbUtil.Db.SubmitChanges(); foreach (var a in activities) { if (a.org > 0) { Attend.RecordAttend(DbUtil.Db, id, a.org, true, DateTime.Today); } } return(Content(ac.Id.ToString())); }