public JsonResult VisitorNotify(DAL.db.Appointment appointment) { appointment.ReachTime = DateTime.Now; emailUtility = new EmailUtility(); unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); result = unScheduleAppointmentFactory.SaveAppointment(appointment); if (result.isSucess) { //if (emailUtility.IsInternetConnected()) //{ // var email = db.Employees.Where(x => x.EmployeeID == appointment.EmployeeID).FirstOrDefault(); // if (email != null && email.Email != null) // { // bool isMail = emailUtility.SentMail(email.Email, appointment.CompanyName, appointment.VisitorName, "", ""); // if (isMail) // { // result.message = "Notify And Email Successful."; // } // return Json(result, JsonRequestBehavior.AllowGet); // } //} result.message = "Notify Successful."; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult GetDtlsCancel() { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); List <DAL.db.Appointment> list = unScheduleAppointmentFactory.SearchCancel("C"); var appointmentList = list.Select(x => new { x.AppointmentBy, x.AppointmentID, x.AppointmentDate, x.EmployeeID, x.Employee.EmpName, x.CompanyName, x.Purpose, x.AppointmentTime, x.ReachTime, x.EndTime, x.Status, x.VisitorName, x.VisitorMobile, x.VisitorEmail, x.CardNO, x.CreatedBy, x.CreatedDate }); return(Json(appointmentList, JsonRequestBehavior.AllowGet)); }
public JsonResult VisitorOut(string cardNO) { //string cardID; if (cardNO != null) { cardFactory = new CardFactorys(); utility = new Utility(); var appData = db.Appointments.Where(x => (x.CardNO == cardNO) && (x.Status == "I")).FirstOrDefault(); if (appData != null) { db.Entry(appData).State = EntityState.Detached; appData.CheckedOutTime = DateTime.Now; appData.Status = "O"; var cardInfo = db.Cards.Where(x => x.CardNO == cardNO).ToList(); if (cardInfo.Count > 0) { foreach (var card in cardInfo) { var deviceInfo = db.DeviceInfoes.Where(x => x.DeviceNO == card.DeviceNO).FirstOrDefault(); if (deviceInfo != null) { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); result = unScheduleAppointmentFactory.SaveAppointment(appData); if (result.isSucess) { card.CardNO = null; result = cardFactory.SaveCard(card); result.message = "Checked OUT Successful."; } } else { result.message = card.DeviceNO + " Number Device Not Found!"; return(Json(result, JsonRequestBehavior.AllowGet)); } } } } else { result.isSucess = false; result.message = "No Checked IN Visitor Found Against This Card"; } } else { result.isSucess = false; result.message = "Please Punch Visitor Card"; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult CardWiseAppointmentData(string cardNO) { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); DAL.db.Appointment list = unScheduleAppointmentFactory.SearchCardWiseAppointmentData(cardNO); //var appointmentList = list.Select(x => new { x.AppointmentBy, x.AppointmentID, x.AppointmentDate, x.EmployeeID, x.Employee.EmpName, x.CompanyName, x.Purpose, x.AppointmentTime, x.ReachTime, x.Status, x.VisitorName, x.CardNO, x.CreatedBy, x.CreatedDate, x.ReplayMessage, x.NotifyMessage }); if (list != null) { list = new DAL.db.Appointment { AppointmentID = list.AppointmentID, VisitorName = list.VisitorName, VisitorMobile = list.VisitorMobile, VisitorEmail = list.VisitorEmail, CompanyName = list.CompanyName, EmployeeID = list.EmployeeID, Purpose = list.Purpose, AppointmentDate = list.AppointmentDate, AppointmentTime = list.AppointmentTime, ReachTime = list.ReachTime, CheckedInTime = list.CheckedInTime, CheckedOutTime = list.CheckedOutTime, CreatedBy = list.CreatedBy, CreatedDate = list.CreatedDate, AppointmentBy = list.AppointmentBy, Status = list.Status, CardNO = list.CardNO, BankCardID = list.BankCardID, ReplayMessage = list.ReplayMessage, NotifyMessage = list.NotifyMessage, AccessFloors = list.AccessFloors }; } return(Json(list, JsonRequestBehavior.AllowGet)); }
public JsonResult GetDtlsCheckIn() { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); List <DAL.db.Appointment> list = unScheduleAppointmentFactory.SearchCheckIn("I"); var appointmentList = list.Select(x => new { x.AppointmentBy, x.AppointmentID, x.AppointmentDate, x.EmployeeID, x.Employee.EmpName, x.CompanyName, x.Purpose, x.AppointmentTime, x.ReachTime, x.EndTime, x.CheckedInTime, x.CheckedOutTime, x.Status, x.CardNO, x.VisitorName, x.VisitorMobile, x.VisitorEmail, x.CreatedBy, x.CreatedDate }).OrderByDescending(x => x.CheckedInTime).Take(10); return(Json(appointmentList, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveCancelAppointment(DAL.db.Appointment appointment, List <VM_Employee> empList) { int empID = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id)); if (empID == 0) { result.sessionOut = true; return(Json(result, JsonRequestBehavior.AllowGet)); } // Testing if (empList == null) { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); appointment.CreatedBy = empID; appointment.CreatedDate = toDayTime; appointment.AppointmentTime = appointment.AppointmentTime; appointment.ReachTime = toDayTime; appointment.AppointmentDate = appointment.AppointmentDate; result = unScheduleAppointmentFactory.SaveAppointment(appointment); if (result.isSucess) { emailUtility = new EmailUtility(); unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); appointment.Status = "C"; result = unScheduleAppointmentFactory.SaveAppointment(appointment); } } else { foreach (var floor in empList) { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); if (floor.AppointmentID < 1) { appointment.AppointmentID = 0; } appointment.CreatedBy = empID; appointment.CreatedDate = toDayTime; appointment.AppointmentTime = appointment.AppointmentTime; appointment.AppointmentDate = appointment.AppointmentDate; appointment.ReachTime = toDayTime; appointment.EmployeeID = floor.EmployeeID; result = unScheduleAppointmentFactory.SaveAppointment(appointment); } } result.lastInsertedID = appointment.EmployeeID; return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult VisitorBreakIn(DAL.db.Appointment appointment) { //Card card = new Card(); //string cardID = string.Empty; if (appointment.CardNO != string.Empty) { int deviceNo = 1; cardFactory = new CardFactorys(); utility = new Utility(); // Getting device Information //var empInfo = db.Employees.Where(x => x.EmployeeID == appointment.EmployeeID).FirstOrDefault(); var appInfo = db.Appointments.Where(x => x.AppointmentID == appointment.AppointmentID).FirstOrDefault(); db.Entry(appInfo).State = EntityState.Detached; if (appointment.Status == "I") { var cardInfo = cardFactory.GetFreeCard(deviceNo); if (cardInfo != null) { //cardID = cardInfo.CardID.ToString(); cardInfo.CardNO = appointment.CardNO; result = cardFactory.SaveCard(cardInfo); appInfo.CardNO = appointment.CardNO; appInfo.BreakInTime = DateTime.Now; appInfo.Status = appointment.Status; if (result.isSucess) { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); result = unScheduleAppointmentFactory.SaveAppointment(appInfo); if (result.isSucess) { result.message = "Visitor Checked IN From Break Successful."; } } } } } else { result.message = "Please Punch Visitor Card"; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult VisitorBreakOut(MV_Appointment appointment) { //Card card = new Card(); string cardID = string.Empty; if (appointment.CardNO != string.Empty) { int deviceNo = 1; cardFactory = new CardFactorys(); utility = new Utility(); // Getting device Information //var empInfo = db.Employees.Where(x => x.EmployeeID == appointment.EmployeeID).FirstOrDefault(); //DAL.db.Appointment appInfo = new DAL.db.Appointment(); var appInfo = db.Appointments.Where(x => x.AppointmentID == appointment.AppointmentID).FirstOrDefault(); db.Entry(appInfo).State = EntityState.Detached; if (appointment.Status == "B") { //var cardInfo = cardFactory.GetFreeCard(deviceNo); appInfo.Status = appointment.Status; result = cardFactory.UnassignCard(deviceNo, appInfo.CardNO); if (result.isSucess) { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); appInfo.BreakOutTime = DateTime.Now; result = unScheduleAppointmentFactory.SaveAppointment(appInfo); if (result.isSucess) { result.message = "Visitor Checked Out For Break Successful."; } } else { result.message = appInfo.CardNO + " No card not found for break!!!"; } } } else { result.message = "Please Punch Visitor Card"; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult VisitorIn(DAL.db.Appointment appointment) { int deviceNo = 1; string cardID = string.Empty; if (appointment.CardNO != string.Empty) { cardFactory = new CardFactorys(); utility = new Utility(); // Getting device Information //var empInfo = db.Employees.Where(x => x.EmployeeID == appointment.EmployeeID).FirstOrDefault(); if (appointment.Status == "I") { var cardInfo = cardFactory.GetFreeCard(deviceNo); if (cardInfo != null) { appointment.CheckedInTime = DateTime.Now; cardID = cardInfo.CardID.ToString(); //result = utility.AssignToDevice(deviceNo, cardID, appointment.CardNO); cardInfo.CardNO = appointment.CardNO; result = cardFactory.SaveCard(cardInfo); if (result.isSucess) { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); result = unScheduleAppointmentFactory.SaveAppointment(appointment); if (result.isSucess) { result.message = "Checked IN Successful."; } } } else { result.isSucess = false; result.message = deviceNo + " NO. Free Card Found."; } } } else { result.message = "Please Punch Visitor Card"; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult VisitorInWithDevice(DAL.db.Appointment appointment) { //Card card = new Card(); string cardID = string.Empty; if (appointment.CardNO != string.Empty) { string ip = ""; int deviceNo = 0; int portNO = 0; cardFactory = new CardFactorys(); utility = new Utility(); // Getting device Information var empInfo = db.Employees.Where(x => x.EmployeeID == appointment.EmployeeID).FirstOrDefault(); var deviceInfo = db.DeviceInfoes.Where(x => x.FloorNO == empInfo.Floor).FirstOrDefault(); //var cardInfo = db.Cards.Where(x => x.CardNO == appointment.CardNO).ToList(); if (deviceInfo != null) { ip = deviceInfo.IPAddress; deviceNo = deviceInfo.DeviceNO; portNO = deviceInfo.PortNO; if (appointment.Status == "I") { result = utility.Connect(ip, deviceNo, portNO); if (result.isSucess) { var cardInfo = cardFactory.GetFreeCard(deviceNo); if (cardInfo != null) { appointment.CheckedInTime = DateTime.Now; cardID = cardInfo.CardID.ToString(); result = utility.AssignToDevice(deviceNo, cardID, appointment.CardNO); //var card = new Card { CardID = Convert.ToInt16(cardID), CardNO = appointment.CardNO, DeviceNO = deviceNo }; cardInfo.CardNO = appointment.CardNO; result = cardFactory.SaveCard(cardInfo); if (result.isSucess) { unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); result = unScheduleAppointmentFactory.SaveAppointment(appointment); if (result.isSucess) { result.message = "Checked IN Successful."; } } } else { result.isSucess = false; result.message = deviceNo + " NO. Device Not Found."; } } else { result.message = deviceNo + " Device Not Connected."; return(Json(result, JsonRequestBehavior.AllowGet)); } } } } else { result.message = "Please Punch Visitor Card"; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveUnScheduleAppointment(DAL.db.Appointment appointment) { int empID = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id)); if (empID == 0) { result.sessionOut = true; return(Json(result, JsonRequestBehavior.AllowGet)); } unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); appointment.CreatedBy = empID; appointment.CreatedDate = toDayTime; appointment.AppointmentTime = appointment.AppointmentTime; appointment.ReachTime = toDayTime; appointment.AppointmentDate = appointment.AppointmentDate; appointment.ReachTime = DateTime.Now; appointment.Status = "N"; appointment.NotifyMessage = "Mr." + " " + appointment.VisitorName + " " + "wants to meet with you."; result = unScheduleAppointmentFactory.SaveAppointment(appointment); if (result.isSucess) { result.message = "Notify Successful."; //appointment.ReachTime = DateTime.Now; //emailUtility = new EmailUtility(); //unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); //appointment.Status = "N"; //appointment.NotifyMessage = "Mr." + " " + appointment.VisitorName + " " + "wants to meet with you."; //result = unScheduleAppointmentFactory.SaveAppointment(appointment); //if (result.isSucess) //{ // result.message = "Notify Successful."; //} } //else //{ // foreach (var floor in empList) // { // unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); // if (floor.AppointmentID < 1) // { // appointment.AppointmentID = 0; // } // appointment.CreatedBy = empID; // appointment.CreatedDate = toDayTime; // appointment.AppointmentTime = appointment.AppointmentTime; // appointment.AppointmentDate = appointment.AppointmentDate; // appointment.ReachTime = toDayTime; // appointment.EmployeeID = floor.EmployeeID; // result = unScheduleAppointmentFactory.SaveAppointment(appointment); // if (result.isSucess) // { // appointment.ReachTime = DateTime.Now; // emailUtility = new EmailUtility(); // unScheduleAppointmentFactory = new UnScheduleAppointmentFactorys(); // result = unScheduleAppointmentFactory.SaveAppointment(appointment); // if (result.isSucess) // { // //if (emailUtility.IsInternetConnected()) // //{ // // var email = db.Employees.Where(x => x.EmployeeID == appointment.EmployeeID).FirstOrDefault(); // // if (email != null && email.Email != null) // // { // // bool isMail = emailUtility.SentMail(email.Email, appointment.CompanyName, appointment.VisitorName, "", ""); // // if (isMail) // // { // // result.message = "Notify And Email Successful."; // // } // // return Json(result, JsonRequestBehavior.AllowGet); // // } // //} // result.message = "Notify Successful."; // } // } // } //} result.lastInsertedID = appointment.EmployeeID; return(Json(result, JsonRequestBehavior.AllowGet)); }