示例#1
0
        private void sendEmail(UserCheckIn userCheckIn)
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.From = new MailAddress("*****@*****.**");
            mailMessage.To.Add(userCheckIn.email);
            mailMessage.Subject    = "You've been checked in!";
            mailMessage.IsBodyHtml = true;
            mailMessage.Body       = "Hello " + userCheckIn.firstName + "! <br/> <br/>" +
                                     "You've checked into SafetyLineLoneWorker's free check-in web app. Here are your check-in details.<br/><br/>" +
                                     "<table>" +
                                     "<tr>" +
                                     "<td>Full Name</td>" +
                                     "<td>" + userCheckIn.firstName + " " + userCheckIn.lastName + "</td>" +
                                     "</tr> " +
                                     "<tr>" +
                                     "<td>Emergency contact</td>" +
                                     "<td>" + userCheckIn.contactEmail + "</td>" +
                                     "</tr> " +
                                     "<tr>" +
                                     "<td>Return time</td>" +
                                     "<td>" + userCheckIn.returnTime + "</td>" +
                                     "</tr> " +
                                     "</table> ";
            //mailMessage.IsBodyHtml = true;

            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.EnableSsl      = true;
            //to authenticate we set the username and password properites on the SmtpClient
            smtp.Credentials = new NetworkCredential("*****@*****.**", "tsunamisolutions");//no need to mention here?

            smtp.Send(mailMessage);
        }
示例#2
0
        // Subscribes the user to our newsletter
        private void subscribe(UserCheckIn userCheckIn)
        {
            string url = "http://go.pardot.com/l/82512/2017-05-08/d26jpz";

            // Create a new WebClient instance.
            WebClient myWebClient = new WebClient();

            // Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
            NameValueCollection myNameValueCollection = new NameValueCollection();

            //First Name and yes they gave us those values to use
            myNameValueCollection.Add("82512_109811pi_82512_109811", userCheckIn.firstName);

            //Last Name
            myNameValueCollection.Add("82512_109813pi_82512_109813", userCheckIn.lastName);

            //Email
            myNameValueCollection.Add("82512_109815pi_82512_109815", userCheckIn.email);

            System.Diagnostics.Debug.WriteLine("\nUploading to {0} ...", url);

            // 'The Upload(String,NameValueCollection)' implicitly method sets HTTP POST as the request method.
            byte[] responseArray = myWebClient.UploadValues(url, myNameValueCollection);

            // Decode and display the response.
            System.Diagnostics.Debug.WriteLine("\nResponse received was :\n{0}", Encoding.ASCII.GetString(responseArray));
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserCheckIn userCheckIn = db.UserCheckIns.Find(id);

            db.UserCheckIns.Remove(userCheckIn);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
 public ActionResult Edit([Bind(Include = "ID,firstName,lastName,telNum,email,contactEmail,location,returnTime,message")] UserCheckIn userCheckIn)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userCheckIn).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userCheckIn));
 }
示例#5
0
        public ActionResult Create([Bind(Include = "ID,firstName,lastName,telNum,email,contactEmail1,contactEmail2,contactEmail3,contactEmail4,location,message,subscribe")] UserCheckIn userCheckIn, string offsetName, string inputTime)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string[] splitData = offsetName.Split('-');

                    // DateTime localNow = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.Local);
                    DateTime userDateTime = new DateTime(int.Parse(splitData[0]), int.Parse(splitData[1]), int.Parse(splitData[2]), int.Parse(splitData[3]), int.Parse(splitData[4]), 0);

                    DateTime returnTime = DateTime.Parse(inputTime);

                    // roll-over to the next day if the return time is earlier than the current time
                    if (userDateTime.CompareTo(returnTime) > 0)
                    {
                        returnTime = returnTime.AddDays(1);
                    }

                    //DateTime inputTime = new DateTime()
                    int offset = int.Parse(splitData[5]);

                    userCheckIn.returnTime = returnTime.AddMinutes(offset);



                    // convert local time to UTC
                    // userCheckIn.returnTime = TimeZoneInfo.ConvertTimeToUtc(userCheckIn.returnTime, TimeZoneInfo.Local);
                    userCheckIn.inputTime = returnTime.ToString();
                    userCheckIn.secString = GetSecurityString();
                    db.UserCheckIns.Add(userCheckIn);
                    db.SaveChanges();

                    if (userCheckIn.subscribe)
                    {
                        subscribe(userCheckIn);
                    }

                    sendEmail(userCheckIn);
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("Key already exists.", e);
                    sendEmail(e.ToString());
                }

                return(RedirectToAction("PostPage"));
            }

            return(View(userCheckIn));
        }
示例#6
0
        // GET: UserCheckIns/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserCheckIn userCheckIn = db.UserCheckIns.Find(id);

            if (userCheckIn == null)
            {
                return(HttpNotFound());
            }
            return(View(userCheckIn));
        }
示例#7
0
        // GET: UserCheckIns/Delete/5/<Security String>
        public ActionResult Delete(int?id, string sec)
        {
            if (id == null || sec == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UserCheckIn userCheckIn = db.UserCheckIns.Find(id);

            if (userCheckIn == null || !sec.Equals(userCheckIn.secString))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            return(View(userCheckIn));
        }
示例#8
0
        public void UpsertProctorCheckIn(UserCheckIn userCheckIn)
        {
            var spName = "UserCheckInUpsert";

            ExecuteStatement(_connStr, (conn, cmd) =>
            {
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = spName;

                cmd.Parameters.AddWithValue("@SessionId", userCheckIn.SessionId);
                cmd.Parameters.AddWithValue("@UserId", userCheckIn.UserId);
                if (userCheckIn.CheckInTime != null)
                {
                    cmd.Parameters.AddWithValue("@CheckInTime", userCheckIn.CheckInTime);
                }
            });
        }
        //this function adds the checkin records in the table which will be later used to update the checkin status of a user
        //so that we can know if the user has started availing a package or not.
        public void AddCheckInRecords(PackageBooking booking, int packageBookingId)
        {
            int packageId = booking.PackageID;

            if (!booking.IsCustomized)
            {
                //handles non customized packages
                var itineraries = (from itir in db.Itineraries where itir.PackageID == packageId select itir).ToList <Itinerary>();
                foreach (var itir in itineraries)
                {
                    int?hotelId = db.RoomPrices.Find(itir.RoomPriceID).HotelID;
                    int?transportationProviderId = db.TransportationPrices.Find(itir.TransportationPriceID).TransportationProviderID;

                    UserCheckIn userCheckIn = new UserCheckIn();
                    userCheckIn.HotelCheckINStatus          = false;
                    userCheckIn.TransportationCheckINStatus = false;
                    userCheckIn.CheckInDate              = booking.StartDate.AddDays((itir.DayNumber - 1));
                    userCheckIn.PackageBookingID         = packageBookingId;
                    userCheckIn.HotelID                  = hotelId.GetValueOrDefault();
                    userCheckIn.TransportationProviderID = transportationProviderId.GetValueOrDefault();
                    db.UserCheckIns.Add(userCheckIn);
                    db.SaveChanges();
                }
            }
            else if (booking.IsCustomized)
            {
                //Handles customized packages
                var customItineries = (from customItir in db.UserCustomizations where customItir.CustomPackageID == packageId select customItir).ToList <UserCustomization>();
                foreach (var customItir in customItineries)
                {
                    int?        hotelId = db.RoomPrices.Find(customItir.RoomPriceID).HotelID;
                    int?        transportationProviderId = db.TransportationPrices.Find(customItir.TransportationPriceID).TransportationProviderID;
                    UserCheckIn userCheckIn = new UserCheckIn();
                    userCheckIn.HotelCheckINStatus          = false;
                    userCheckIn.TransportationCheckINStatus = false;
                    userCheckIn.CheckInDate              = booking.StartDate.AddDays((customItir.DayNumber) - 1);
                    userCheckIn.PackageBookingID         = db.PackageBookings.Max(x => x.PackageBookingID);
                    userCheckIn.HotelID                  = hotelId.GetValueOrDefault();
                    userCheckIn.TransportationProviderID = transportationProviderId.GetValueOrDefault();
                    db.UserCheckIns.Add(userCheckIn);
                    db.SaveChanges();
                }
            }
        }
示例#10
0
        // Sends an email notifying the emergency contacts that the user has failed to check-in
        private void sendMissingEmail(UserCheckIn userCheckIn)
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.From = new MailAddress("*****@*****.**");
            mailMessage.To.Add(userCheckIn.contactEmail1);

            if (userCheckIn.contactEmail2 != null)
            {
                mailMessage.To.Add(userCheckIn.contactEmail2);
            }

            if (userCheckIn.contactEmail3 != null)
            {
                mailMessage.To.Add(userCheckIn.contactEmail3);
            }

            if (userCheckIn.contactEmail4 != null)
            {
                mailMessage.To.Add(userCheckIn.contactEmail4);
            }

            mailMessage.Subject    = userCheckIn.firstName + " " + userCheckIn.lastName + " has not checked back in from " + userCheckIn.location;
            mailMessage.IsBodyHtml = true;
            mailMessage.Body       = "Hello <br/> <br/>"
                                     + "This is to inform you that " + userCheckIn.firstName + " " + userCheckIn.lastName
                                     + " has left you as an emergency contact. <br/>"
                                     + userCheckIn.firstName + " was expected to check in at "
                                     + userCheckIn.inputTime;

            if (userCheckIn.message != null)
            {
                mailMessage.Body += "<br/> Here is the message " + userCheckIn.firstName + " left:<br/>" + userCheckIn.message;
            }

            smtp = new SmtpClient("smtp.gmail.com", 587);
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.EnableSsl      = true;
            //to authenticate we set the username and password properites on the SmtpClient
            smtp.Credentials = new NetworkCredential("*****@*****.**", "tsunamisolutions");//no need to mention here?

            smtp.Send(mailMessage);
        }
 public IHttpActionResult PutTransportCheckInStatus(UserCheckIn userCheckIn)
 {
     try
     {
         if (userCheckIn == null)
         {
             return(BadRequest("Please provide valid data for updating the check-in status of the user"));
         }
         else
         {
             transportBuisnessLogic.PutTransportCheckInStatusBL(userCheckIn);
             return(Ok());
         }
     }
     catch
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Some error occured while getting the transportation details")));
     }
 }
示例#12
0
 public bool PutHotelCheckInStatusDAL(UserCheckIn userCheckIn)
 {
     db.Entry(userCheckIn).State = System.Data.Entity.EntityState.Modified;
     try
     {
         db.SaveChanges();
     }
     catch (Exception)
     {
         if (!CheckInExists(userCheckIn.CheckInID))
         {
             return(false);
         }
         else
         {
             throw new Exception();
         }
     }
     return(true);
 }
示例#13
0
        public ActionResult Create([Bind(Include = "ID,firstName,lastName,telNum,email,contactEmail,location,returnTime,message")] UserCheckIn userCheckIn)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    userCheckIn.secString = GetSecurityString();
                    db.UserCheckIns.Add(userCheckIn);
                    db.SaveChanges();
                    sendEmail(userCheckIn);
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("Key already exists.", e);
                }

                return(RedirectToAction("PostPage"));
            }

            return(View(userCheckIn));
        }
示例#14
0
        public ActionResult French([Bind(Include = "ID,firstName,lastName,telNum,email,contactEmail1,contactEmail2,contactEmail3,contactEmail4,location,message,subscribe")] UserCheckIn userCheckIn)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    DateTime localNow = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.Local);

                    // roll-over to the next day if the return time is earlier than the current time
                    if (userCheckIn.returnTime.CompareTo(localNow) < 0)
                    {
                        userCheckIn.returnTime = userCheckIn.returnTime.AddDays(1);
                    }

                    // convert local time to UTC
                    userCheckIn.returnTime = TimeZoneInfo.ConvertTimeToUtc(userCheckIn.returnTime, TimeZoneInfo.Local);

                    userCheckIn.secString = GetSecurityString();
                    db.UserCheckIns.Add(userCheckIn);
                    db.SaveChanges();

                    if (userCheckIn.subscribe)
                    {
                        subscribe(userCheckIn);
                    }

                    sendEmail(userCheckIn);
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("Key already exists.", e);
                }

                return(RedirectToAction("PostPage"));
            }

            return(View(userCheckIn));
        }
示例#15
0
        public CheckInStatusTypes CheckIn(string userId, bool checkInByAI)
        {
            if (!_checkInResult.Users.ContainsKey(userId))
            {
                return(CheckInStatusTypes.Unknown);
            }
            else
            {
                try
                {
                    UserCheckIn user = _checkInResult.Users[userId];
                    if (user.CheckInStatus)
                    {
                        return(CheckInStatusTypes.Duplicate);
                    }

                    user.CheckInDateTime = DateTime.Now;
                    user.CheckInStatus   = true;

                    if (checkInByAI)
                    {
                        user.CheckInByAI = true;
                    }
                    else
                    {
                        user.CheckInByAI = false;
                    }

                    return(CheckInStatusTypes.Success);
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, userId + " checkin with exception");
                    return(CheckInStatusTypes.Failure);
                }
            }
        }
示例#16
0
        public IHttpActionResult PutHotelCheckInStatus(UserCheckIn userCheckIn)
        {
            //Guard clauses

            //Negative check 1
            if (userCheckIn == null)
            {
                return(BadRequest("Please send valid data for updating the user checkin status"));
            }

            //Negative check 2
            if (!ModelState.IsValid)
            {
                string modelErrors = string.Join(Environment.NewLine, ModelState.Values
                                                 .SelectMany(x => x.Errors)
                                                 .Select(x => x.ErrorMessage));

                return(BadRequest(modelErrors));
            }

            try
            {
                bool response = hotelBuisnessLogic.PutHotelCheckInStatusBL(userCheckIn);
                if (!response)
                {
                    return(NotFound());
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NoContent));
                }
            }
            catch (Exception ex)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Some Error Occoured While Updating CheckIn Status")));
            }
        }
 public bool PutHotelCheckInStatusBL(UserCheckIn userCheckIn)
 {
     return(hotelDAL.PutHotelCheckInStatusDAL(userCheckIn));
 }
示例#18
0
        // Sends the confirmation email to the user
        private void sendEmail(UserCheckIn userCheckIn)
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.From = new MailAddress("*****@*****.**");
            mailMessage.To.Add(userCheckIn.email);
            mailMessage.Subject    = "You've been checked in!";
            mailMessage.IsBodyHtml = true;

            string contactEmailTableRows = "<tr>" +
                                           "<td>Emergency contact(s)</td>" +
                                           "<td>" + userCheckIn.contactEmail1 + "</td>" +
                                           "</tr> ";

            // Add additional contact emails if they exists
            if (userCheckIn.contactEmail2 != null)
            {
                contactEmailTableRows += "<tr>" +
                                         "<td></td>" +
                                         "<td>" + userCheckIn.contactEmail2 + "</td>" +
                                         "</tr> ";
            }

            if (userCheckIn.contactEmail3 != null)
            {
                contactEmailTableRows += "<tr>" +
                                         "<td></td>" +
                                         "<td>" + userCheckIn.contactEmail3 + "</td>" +
                                         "</tr> ";
            }

            if (userCheckIn.contactEmail4 != null)
            {
                contactEmailTableRows += "<tr>" +
                                         "<td></td>" +
                                         "<td>" + userCheckIn.contactEmail4 + "</td>" +
                                         "</tr> ";
            }

            mailMessage.Body = "Hello " + userCheckIn.firstName + "! <br/> <br/>" +
                               "You've checked into SafetyLineLoneWorker's free check-in web app. Here are your check-in details:<br/><br/>" +
                               "<table>" +
                               "<tr>" +
                               "<td>Full Name</td>" +
                               "<td>" + userCheckIn.firstName + " " + userCheckIn.lastName + "</td>" +
                               "</tr> " +
                               contactEmailTableRows +
                               "<tr>" +
                               "<td>Location</td>" +
                               "<td>" + userCheckIn.location + "</td>" +
                               "</tr> " +
                               "<tr>" +
                               "<td>Return time</td>" +
                               "<td>" + userCheckIn.inputTime + "</td>" +
                               "</tr> " +
                               "<tr>" +
                               "<td>Return time(UTC)</td>" +
                               "<td>" + userCheckIn.returnTime + "</td>" +
                               "</tr> " +
                               "<tr>" +
                               "<td>CUrrent time(UTC)</td>" +
                               "<td>" + DateTime.UtcNow + "</td>" +
                               "</tr> " +
                               "</table> " +
                               "<br><a href=\"" + MvcApplication.DOMAIN_URL + "/UserCheckIns/Delete/" + userCheckIn.ID + "/" + userCheckIn.secString + "\">Check-in here when you've returned.</a>";

            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.EnableSsl      = true;
            //to authenticate we set the username and password properites on the SmtpClient
            smtp.Credentials = new NetworkCredential("*****@*****.**", "tsunamisolutions");//no need to mention here?

            smtp.Send(mailMessage);
        }
示例#19
0
 public void PutTransportCheckInStatusBL(UserCheckIn userCheckIn)
 {
     transportDAL.PutTransportCheckInStatusDAL(userCheckIn);
 }
示例#20
0
        private void InitOrRestoreCheckInResult()
        {
            // 1. create new checkInResult from users.json
            CheckInResult newCheckInResult = null;
            List <User>   users            = LoadCheckInList();

            if (users != null)
            {
                newCheckInResult = new CheckInResult();
                foreach (User user in users)
                {
                    if (newCheckInResult.Users == null)
                    {
                        newCheckInResult.Users = new UserCheckInList();
                    }
                    if (!newCheckInResult.Users.ContainsKey(user.UserId))
                    {
                        UserCheckIn userCheckIn = new UserCheckIn()
                        {
                            User            = user,
                            CheckInDateTime = DateTime.MinValue,
                            CheckInStatus   = false
                        };
                        newCheckInResult.Users.Add(user.UserId, userCheckIn);
                    }
                    else
                    {
                        _logger.Warn(user.UserId + " is duplicate.");
                    }
                }
            }

            // 2. recover data from history (if have).
            CheckInResult historyCheckInResult = null;

            if (System.IO.File.Exists(Configs.ConfigManager.CheckInResultFullPath))
            {
                string json = System.IO.File.ReadAllText(Configs.ConfigManager.CheckInResultFullPath);
                if (string.IsNullOrEmpty(json))
                {
                    _logger.Warn(Configs.ConfigManager.CheckInResultFullPath + " is empty.");
                }
                else
                {
                    try
                    {
                        historyCheckInResult = JsonConvert.DeserializeObject <CheckInResult>(json);
                        _logger.Info(Configs.ConfigManager.CheckInResultFullPath + " loaded.");
                    }
                    catch (Exception ex)
                    {
                        _logger.Warn("load checkInResult with mistake. " + Configs.ConfigManager.CheckInResultFullPath + " " + ex.ToString());
                    }
                }
            }

            if (historyCheckInResult != null && historyCheckInResult.Users != null)
            {
                foreach (var userCheckInPair in historyCheckInResult.Users)
                {
                    string userId = userCheckInPair.Key;
                    if (newCheckInResult.Users.ContainsKey(userId))
                    {
                        newCheckInResult.Users[userId] = historyCheckInResult.Users[userId];
                    }
                }
            }

            this.CheckInResult = newCheckInResult;
        }
示例#21
0
        // This method is used to update the checkin status of the user by the transportation provioder for the start date of the journey ie. todays checkin

        public void PutTransportCheckInStatusDAL(UserCheckIn userCheckIn)
        {
            db.Entry(userCheckIn).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }