Exemple #1
0
        private void BtnGenerate_Click(object sender, EventArgs e)
        {
            #region Private Variables

            string addressline;
            bool   compemail_set;

            #endregion Private Variables

            #region Cleanup

            Setup.Cleanup();

            #endregion Cleanup

            #region Settings

            User myuser = new User();

            #endregion Settings

            #region JobApplication Data

            JobApplication myapplication = new JobApplication(txtURL.Text, txtEmail.Text, txtJobtitle.Text);
            if (myuser.BitLyToken != "Not Found" && !string.IsNullOrEmpty(myapplication.URL))
            {
                System.Threading.Tasks.Task task = myapplication.UseBitLy(myuser.BitLyToken, myapplication.URL);
            }
            else
            {
                //Test
            }

            if (string.IsNullOrEmpty(myapplication.Email))
            {
                compemail_set = false;
            }
            else
            {
                compemail_set = true;
            }

            Company company;
            if (string.IsNullOrEmpty(txtCompanyStreet.Text) || (string.IsNullOrEmpty(txtZIP.Text)) || (string.IsNullOrEmpty(txtCity.Text)))
            {
                company = new Company(txtCompanyName.Text);
            }
            else
            {
                company = new Company(txtCompanyName.Text, txtCompanyStreet.Text, txtZIP.Text, txtCity.Text);
            }

            ComboBoxItem typeItem = (ComboBoxItem)cboGender.SelectedItem;
            string       gender   = typeItem.Content.ToString();

            Contact contact = new Contact(txtContactName.Text, gender);
            addressline = contact.Addressline(company.Name, contact.Name, contact.Gender, company.Street, company.ZIP, company.City);

            #endregion JobApplication Data

            #region Build, Compile and Send

            Build.PrepareBuild();
            string subject             = Build.GetSubject(SubjectPrefixGlob, myapplication.Jobtitle);
            ApplicationConfigModel acm = new ApplicationConfigModel
            {
                JobTitle   = myapplication.Jobtitle,
                Company    = company.Name,
                Contact    = contact.Name,
                Street     = company.Street,
                City       = company.City,
                Salutation = contact.Salutation,
                Subject    = subject,
                Address    = addressline
            };
            Build.CreateApplicationConfig(acm);
            Build.CompileApplication();
            Build.CombineApplication(myuser.Firstname, myuser.Familyname);

            if (!compemail_set)
            {
                Build.OpenExplorer();
            }
            else
            {
                subject = Build.GetEmailSubject(SubjectPrefixGlob, myapplication.Jobtitle);
                string     finalpdf = Build.GetFinalPdfName(myuser.Firstname, myuser.Familyname);
                EmailModel email    = new EmailModel
                {
                    FirstName   = myuser.Firstname,
                    FamilyName  = myuser.Familyname,
                    MyEmail     = myuser.Email,
                    ContactName = contact.Name,
                    CompEmail   = myapplication.Email,
                    Subject     = subject,
                    Salutation  = contact.Salutation,
                    Attachment  = finalpdf,
                    SmtpServer  = myuser.SmtpServer,
                    SmtpUser    = myuser.SmtpUser,
                    SmtpPass    = myuser.SmtpPass,
                    SmtpPort    = myuser.SmtpPort
                };
                Email.CreateMessage(email);
            }

            #endregion Build, Compile and Send

            #region Add Information to CSV

            CsvExport.WriteCSV(company.Name, myapplication.Jobtitle, company.City, myapplication.URL);

            #endregion Add Information to CSV

            #region Clean UI

            txtCity.Clear();
            txtCompanyName.Clear();
            txtCompanyStreet.Clear();
            txtContactName.Clear();
            txtEmail.Clear();
            txtJobtitle.Clear();
            txtURL.Clear();
            txtZIP.Clear();
            chkInitiative.IsChecked = false;
            SubjectPrefixGlob       = Properties.Resources.Subjectprefix;

            #endregion Clean UI
        }
        private void BtnGenerate_Click(object sender, EventArgs e)
        {
            #region Private Variables
            string addressline;
            bool   compemail_set;
            #endregion

            #region Cleanup
            Setup.Cleanup();
            #endregion

            #region Settings
            User myuser = new User();
            #endregion

            #region JobApplication Data
            JobApplication myapplication = new JobApplication(txtURL.Text, txtEmail.Text, txtJobtitle.Text);
            if (myuser.BitLyToken != "Not Found")
            {
                myapplication.UseBitLy(myuser.BitLyToken, myapplication.URL);
            }

            if (myapplication.Email == "")
            {
                compemail_set = false;
            }
            else
            {
                compemail_set = true;
            }

            Company company;
            if (txtCompanyStreet.Text == "" || txtZIP.Text == "" || txtCity.Text == "")
            {
                company = new Company(txtCompanyName.Text);
            }
            else
            {
                company = new Company(txtCompanyName.Text, txtCompanyStreet.Text, Convert.ToInt32(txtZIP.Text), txtCity.Text);
            }

            ComboBoxItem typeItem = (ComboBoxItem)cboGender.SelectedItem;
            string       gender   = typeItem.Content.ToString();

            Contact contact = new Contact(txtContactName.Text, gender);
            addressline = contact.Addressline(company.Name, contact.Name, contact.Gender, company.Street, company.ZIP, company.City);
            #endregion

            #region Build, Compile and Send
            Build.PrepareBuild();
            string subject = Build.GetSubject(SubjectPrefixGlob, myapplication.Jobtitle);
            Build.CreateApplicationConfig(myapplication.Jobtitle, company.Name, contact.Name, company.Street, company.City, contact.Salutation, subject, addressline);
            Build.CompileApplication();
            Build.CombineApplication(myuser.Firstname, myuser.Familyname);

            if (compemail_set == false)
            {
                Build.OpenExplorer();
            }
            else
            {
                subject = Build.GetEmailSubject(SubjectPrefixGlob, myapplication.Jobtitle);
                string finalpdf = Build.GetFinalPdfName(myuser.Firstname, myuser.Familyname);
                Email.CreateMessage(myuser.Firstname, myuser.Familyname, myuser.Email, contact.Name, myapplication.Email, subject, contact.Salutation, finalpdf, myuser.SmtpServer, myuser.SmtpUser, myuser.SmtpPass, myuser.SmtpPort);
            }
            #endregion

            #region Add Information to CSV
            CSVExport.WriteCSV(company.Name, myapplication.Jobtitle, company.City, myapplication.URL);
            #endregion

            #region Clean UI
            txtCity.Clear();
            txtCompanyName.Clear();
            txtCompanyStreet.Clear();
            txtContactName.Clear();
            txtEmail.Clear();
            txtJobtitle.Clear();
            txtURL.Clear();
            txtZIP.Clear();
            chkInitiative.IsChecked = false;
            SubjectPrefixGlob       = Properties.Resources.Subjectprefix;
            #endregion
        }