コード例 #1
0
 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));
 }
コード例 #2
0
        public Result SaveAppointment(DAL.db.Appointment appointment)
        {
            _unScheduleAppointment = new UnScheduleAppointmentFactory();
            try
            {
                if (appointment.AppointmentID > 0)
                {
                    _unScheduleAppointment.Edit(appointment);
                    _result = _unScheduleAppointment.Save();
                    if (_result.isSucess)
                    {
                        _result.message = _result.UpdateSuccessfull(tableName);
                    }
                }
                else
                {
                    _unScheduleAppointment.Add(appointment);
                    _result = _unScheduleAppointment.Save();
                    if (_result.isSucess)
                    {
                        _result.message = _result.SaveSuccessfull(tableName);
                    }
                }
            }
            catch (Exception e)
            {
                _result.isSucess = false;
                _result.message  = e.Message;
            }

            return(_result);
        }
コード例 #3
0
        public JsonResult SaveScheduleAppointment(DAL.db.Appointment appointment)
        {
            scheduleAppointmentFactory = new ScheduleAppointmentFactorys();
            int employeeID = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id));

            appointment.CreatedBy   = employeeID;
            appointment.CreatedDate = toDayTime;
            result = scheduleAppointmentFactory.SaveAppointment(appointment);
            return(Json(result));
        }
コード例 #4
0
 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));
 }
コード例 #5
0
 public DAL.db.Appointment SearchCardWiseAppointmentData(string cardNO)
 {
     _unScheduleAppointment = new UnScheduleAppointmentFactory();
     try
     {
         var list = new DAL.db.Appointment();
         list = _unScheduleAppointment.FindBy(x => (x.CardNO == cardNO) && (x.Status == "I")).FirstOrDefault();
         return(list);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #6
0
        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));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        public JsonResult VisitorForward(DAL.db.Appointment appointment, int apID)
        {
            int results = 0;

            result = new Result();

            int EmployeeID = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id));
            //var appData = db.Appointments.Where(x => (x.EmployeeID == EmployeeID) && (x.Status == "I") && (x.AppointmentID == apID)).FirstOrDefault();
            var appData = db.Appointments.Where(x => x.AppointmentID == apID).FirstOrDefault();

            if (appointment.EmployeeID == appData.EmployeeID)
            {
                result.isSucess = false;
                result.message  = "Self forward is not allowed, Please select another employee!!!";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            appData.CheckedOutTime = DateTime.Now;
            appData.Status         = "O";

            appointment.VisitorMobile = appData.VisitorMobile;

            db.Entry(appData).State = System.Data.Entity.EntityState.Modified;
            results = db.SaveChanges();

            if (results == 1)
            {
                appointment.CheckedInTime  = DateTime.Now;
                scheduleAppointmentFactory = new ScheduleAppointmentFactorys();
                result = scheduleAppointmentFactory.SaveAppointment(appointment);
                if (result.isSucess)
                {
                    result.message = "Visitor Forward Successful.";
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
            ////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 == "AP")
            //        {
            //            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)
            //                    {
            //                        scheduleAppointmentFactory = new ScheduleAppointmentFactorys();
            //                        result = scheduleAppointmentFactory.SaveAppointment(appointment);
            //                        if (result.isSucess)
            //                        {
            //                            result.message = "Visitor Forward 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";
            //}
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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));
        }