예제 #1
0
        public List <Gym> GetGyms()
        {
            List <Gym> gyms        = new List <Gym>();
            string     csvLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "NewMemberMailer\\Information\\GymInfo.csv");
            //string csvLocation = Path.Combine(Environment.CurrentDirectory, @"Dependencies\\GymInfo.csv");
            var reader = new StreamReader(File.OpenRead(csvLocation));

            while (!reader.EndOfStream)
            {
                var line     = reader.ReadLine();
                var values   = line.Split(',');
                var validGym = new Gym()
                {
                    Name           = values[0],
                    Address        = values[1],
                    CityZip        = values[2],
                    Phone          = values[3],
                    ManagerName    = values[4],
                    ManagerPicture = (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\NewMemberMailer\\" + values[5]),
                    TrainerName    = values[6],
                    TrainerPicture = (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\NewMemberMailer\\" + values[7]),
                    Website        = values[8]
                };
                gyms.Add(validGym);
                string destFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), string.Format("NewMemberMailer\\GymPictures\\{0}", validGym.Name));
                if (!Directory.Exists(destFolder))
                {
                    Directory.CreateDirectory(destFolder);
                }
            }
            reader.Close();
            return(gyms);
        }
예제 #2
0
        private AlternateView GetEmbeddedImage(Gym gym, GymMember member)
        {
            LinkedResource managerPicture = new LinkedResource(gym.ManagerPicture);
            LinkedResource trainerPicture = new LinkedResource(gym.TrainerPicture);
            LinkedResource logo           = new LinkedResource(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "NewMemberMailer\\PlanetFitnessLogo.jpg"));
            LinkedResource banner         = new LinkedResource(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "NewMemberMailer\\PlanetFitnessBanner.jpg"));
            LinkedResource header         = new LinkedResource(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "NewMemberMailer\\header.jpg"));
            LinkedResource footer         = new LinkedResource(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "NewMemberMailer\\footer.jpg"));
            LinkedResource pot            = new LinkedResource(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "NewMemberMailer\\PoT.jpg"));

            managerPicture.ContentId = Guid.NewGuid().ToString();
            trainerPicture.ContentId = Guid.NewGuid().ToString();
            logo.ContentId           = Guid.NewGuid().ToString();
            banner.ContentId         = Guid.NewGuid().ToString();
            header.ContentId         = Guid.NewGuid().ToString();
            footer.ContentId         = Guid.NewGuid().ToString();
            pot.ContentId            = Guid.NewGuid().ToString();
            StreamReader reader    = new StreamReader(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "NewMemberMailer\\Information\\EmailBody.txt"));
            string       emailText = reader.ReadToEnd();
            string       htmlBody  = string.Format(emailText.ToString(), gym.Name, member.Name, gym.Address, gym.CityZip,
                                                   gym.ManagerName, managerPicture.ContentId, gym.TrainerName, trainerPicture.ContentId, header.ContentId, footer.ContentId, logo.ContentId, pot.ContentId, banner.ContentId, gym.Website);
            AlternateView alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);

            alternateView.LinkedResources.Add(managerPicture);
            alternateView.LinkedResources.Add(trainerPicture);
            alternateView.LinkedResources.Add(logo);
            alternateView.LinkedResources.Add(banner);
            alternateView.LinkedResources.Add(header);
            alternateView.LinkedResources.Add(footer);
            alternateView.LinkedResources.Add(pot);
            return(alternateView);
        }
예제 #3
0
        public EditCreateSelect()
        {
            InitializeComponent();
            Gym planetGym = new Gym();

            Gyms = planetGym.GetGyms();
            foreach (Gym gym in Gyms)
            {
                Gym_List.Items.Add(gym);
            }
        }
예제 #4
0
        public CreateGym(string GymName)
        {
            InitializeComponent();
            get_GymName.Text = GymName;
            Gyms             = new List <Gym>();
            newGym           = new Gym()
            {
                Name = GymName
            };
            Gym planetGym = new Gym();

            Gyms = planetGym.GetGyms();
        }
예제 #5
0
        public EditGym(Gym edittedGym)
        {
            InitializeComponent();
            Gym planetGym = new Gym();

            Gyms                = planetGym.GetGyms();
            get_GymName.Text    = edittedGym.Name;
            get_GymAdd.Text     = edittedGym.Address;
            get_GymCSZ.Text     = edittedGym.CityZip;
            get_GymPhone.Text   = edittedGym.Phone;
            get_GymMN.Text      = edittedGym.ManagerName;
            get_GymTN.Text      = edittedGym.TrainerName;
            get_GymWebsite.Text = edittedGym.Website;
        }
예제 #6
0
        private void Gym_List_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var ListBox     = sender as ListBox;
            Gym selectedGym = (Gym)ListBox.SelectedItem;

            get_GymName.Text  = selectedGym.Name;
            get_GymAdd.Text   = selectedGym.Address;
            get_GymCSZ.Text   = selectedGym.CityZip;
            get_GymPhone.Text = selectedGym.Phone;
            get_GymMN.Text    = selectedGym.ManagerName;
            get_GymTN.Text    = selectedGym.TrainerName;
            get_Website.Text  = selectedGym.Website;
            //if (ListBox.SelectedIndex != -1)
            //{
            //    string fileManager = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), string.Format("NewMemberMailer\\GymPictures\\{0}\\manager.jpg", get_GymName.Text));
            //    string fileTrainer = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), string.Format("NewMemberMailer\\GymPictures\\{0}\\trainer.jpg", get_GymName.Text));
            //    if (File.Exists(fileManager))
            //    {
            //        BitmapImage b = new BitmapImage();
            //        b.BeginInit();
            //        b.UriSource = new Uri(fileManager, UriKind.RelativeOrAbsolute);
            //        b.EndInit();
            //        get_MPic.Stretch = Stretch.Fill;
            //        get_MPic.Source = b;
            //    }
            //    else
            //    {
            //        get_MPic.Source = null;
            //    }
            //    if (File.Exists(fileTrainer))
            //    {
            //        BitmapImage b = new BitmapImage();
            //        b.BeginInit();
            //        b.UriSource = new Uri(fileTrainer, UriKind.RelativeOrAbsolute);
            //        b.EndInit();
            //        get_TPic.Stretch = Stretch.Fill;
            //        get_TPic.Source = b;
            //    }
            //    else
            //    {
            //        get_TPic.Source = null;
            //    }
            //}
        }
예제 #7
0
        private void MassEmail(object sender, RoutedEventArgs e)
        {
            int    counter = 0;
            Gym    gymData = new Gym();
            string CSV     = btnOpenFile_Click();

            if (CSV == null)
            {
                return;
            }
            List <GymMember> EmailList = CSVParse(CSV);

            foreach (GymMember member in EmailList)
            {
                Gym         localGym = gymData.SelectGym(member);
                MailMessage message  = new MailMessage();
                message.IsBodyHtml = true;
                message.AlternateViews.Add(GetEmbeddedImage(localGym, member));
                message.To.Add(member.Email);
                message.From    = new MailAddress("*****@*****.**");
                message.Subject = "Welcome to Planet Fitness " + localGym.Name;

                SmtpClient client = new SmtpClient
                {
                    Host = "smtp.gmail.com",
                    Port = 587,
                    UseDefaultCredentials = false,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    Credentials           = new NetworkCredential("*****@*****.**", "M3i5l4l6!"), //Comment in password
                    Timeout = 20000
                };
                try
                {
                    client.Send(message);
                    counter++;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(string.Format("Exception caught in CreateTimeoutTestMessage(): {0}", ex.ToString()));
                }
            }
            System.Windows.MessageBox.Show(string.Format("Successfully Sent {0} Emails!", counter.ToString()));
        }