Beispiel #1
0
        public async static void RunProcessor()
        {
            //You'll need to edit Hyvee class. Lat Lon is hard coded to Sycamore's.
            Hyvee h = new Hyvee();
            CovidSearchDatabase database = new CovidSearchDatabase();

            var users             = database.GetAllUsers();
            var sentNotifications = database.GetAllNotifications();
            var emailAccount      = "";
            var password          = "";

            var mailRepository = new MailManager("imap.gmail.com", 993, true, emailAccount, password);

            foreach (var user in users)
            {
                var locationAvailibilities = h.GetHyveeAppointments(user.Radius);

                foreach (var location in locationAvailibilities.data.searchPharmaciesNearPoint)
                {
                    if (location.distance < user.Radius)
                    {
                        if (location.location.isCovidVaccineAvailable && !sentNotifications.Any(p => p.LocationID == location.location.locationId && p.SentDate != null && DateTime.Parse(p.SentDate) > System.DateTime.Now.AddHours(-1)))
                        {
                            SendNotification(mailRepository, user, location, database);
                        }
                    }
                }
            }

            Thread.Sleep(5000);
        }
        public static void Main(string[] args)
        {
            Hyvee h              = new Hyvee();
            var   users          = CovidSearchDatabase.GetAllUsers();
            var   mailRepository = new MailManager("imap.gmail.com", 993, true, "email", "password");

            foreach (var user in users)
            {
                var locationAvailibilities = h.GetHyveeAppointments(user.Radius);

                foreach (var location in locationAvailibilities.data.searchPharmaciesNearPoint)
                {
                    if (location.distance < user.Radius)
                    {
                        if (location.location.isCovidVaccineAvailable)
                        {
                            mailRepository.SendVaccineAvailability(location.location, user);
                            Console.WriteLine("Available at " + location.location.name + " in " + location.location.address.city + ", " + location.location.address.state + ". " + location.distance + " miles away.");
                        }
                    }
                }
            }
        }