//creat visitor information to be store to database public static void VisitorSignin(List <visitor> Visitors, List <int> TrackIDs, int Duration) { group_visitor Gv = new group_visitor(); Gv.group_id = Guid.NewGuid().ToString(); DateTime StartTime = DateTime.Now; Gv.duration = Duration; Gv.startTime = StartTime; Gv.endTime = StartTime.AddHours(Duration); foreach (visitor V in Visitors) { V.mailSent = false; V.ID = Guid.NewGuid().ToString(); V.group_visitor = Gv; } foreach (int ID in TrackIDs) { visitor_track vt = new visitor_track(); TrackDAO.TrackVisited(ID); vt.track_ID = ID; vt.group_visitor = Gv; } VisitorDAO.SaveGroup(Gv); VisitorDAO.SaveChanges(); }
// send a group information who are overdue sar public static void SendReportToSAR(string GroupID) { group_visitor Group = VisitorDAO.GetGroup(GroupID); MailService.SendEmail("Overdue Visitor!", SAREMAILADDRESS, FormatVisitors(Group.visitor.ToList())); foreach (visitor V in Group.visitor) { V.mailSent = true; } VisitorDAO.SaveChanges(); }
//signout group if succeed return true and change status to signout otherwise return false public static Boolean SignOutGroup(string FirstName, string LastName, string PhoneNumber, DateTime dob) { visitor FoundVisitor = VisitorDAO.GetVisitor(FirstName, LastName, PhoneNumber, dob); if (FoundVisitor == null) { return(false); } else { FoundVisitor.signedOut = true; foreach (visitor V in FoundVisitor.group_visitor.visitor) { V.signedOut = true; } VisitorDAO.SaveChanges(); return(true); } }
//monitor visitor public static void MonitorVisitor() { List <visitor> ReportingVisitors = new List <visitor>(); foreach (visitor V in VisitorDAO.GetTravellingVisitor()) { //get visitors from database and check if they are overdue if yes change status if (DateTime.Compare(DateTime.Now, Convert.ToDateTime(V.group_visitor.endTime.ToString())) > 0) { if (V.isoverdue == false) { V.isoverdue = true; foreach (visitor_track V_T in V.group_visitor.visitor_track) { V_T.track.overdueTime = V_T.track.overdueTime + 1; } } TimeSpan ExpiredTime = DateTime.Now.Subtract(Convert.ToDateTime(V.group_visitor.endTime)); // if overdue time is longer than 1 hour add to reporting visitor if (ExpiredTime.Hours > 0 && V.mailSent == false) { V.mailSent = true; ReportingVisitors.Add(V); } } } if (ReportingVisitors.Count > 0) {// if reporting visitors is not empty then send to SAR try { MailService.SendEmail("Overdue Visitor!", SAREMAILADDRESS, FormatVisitors(ReportingVisitors)); } catch (Exception e) { MailService.SendEmail("Email Sent Failed!", "", "email sent failed to " + SAREMAILADDRESS); } ReportingVisitors.Clear(); } VisitorDAO.SaveChanges(); }
//list all the visitors based on page number public static List <visitor> GetAllVisitors() { return(VisitorDAO.GetAllVisitor()); }
public static List <visitor> GetOverdueVisitor() { return(VisitorDAO.GetOverdueVisitor()); }