Exemplo n.º 1
0
        public static void SendWelcomeMail(string email, string username, string password, string comID)
        {
            string msg;

            try
            {
                // Get the name of the company
                ProcessCompanyQueries processCompany = new ProcessCompanyQueries(int.Parse(comID));
                processCompany.invoke();
                DataSet _ds = processCompany.Ds;

                string companyName = _ds.Tables[0].Rows[0]["companyName"].ToString();

                msg = "Welcome to the " + companyName + " Tracking System!\r\n\r\n";
                msg += "Your username and password have been added to our database. ";
                msg += "Please write them down and store them in a safe place for your reference.";
                msg += "\r\n\r\n";
                msg += "Username: "******"\r\n";
                msg += "Password: "******"\r\n";
                msg += "\r\n";
                msg += "Head over to http://xtremek.com/" + _ds.Tables[0].Rows[0]["serverDirectory"].ToString();
                msg += " to login!\r\n\r\n";
                msg += "Thank you for using the " + companyName + " Tracking System!\r\n";

                SendMailMessage("*****@*****.**", email, "", "", "Welcome to the "
                                        + companyName + " Tracking System!", msg);
            }
            catch (Exception ex)
            {
                Console.WriteLine("SendWelcomeMail(): " + ex.Message.ToString());
            }
        }
Exemplo n.º 2
0
    private void submitForm()
    {
        try
        {
            if (!isValid()) return;

            string fullName = txtFirstName.Text.Trim() + " " + txtLastName.Text.Trim();
            string name = txtLogin.Text.Trim();
            string email = txtEmail.Text.Trim();
            string deviceID = txtUnitSerial.Text.Trim();

            // Now check if the users and units already exist
            if (userExists(name, email))
            {
                lblMessage.ForeColor = System.Drawing.Color.Red;
                lblMessage.Text = "A user with the provided login name and " +
                                    "email already exists.";
                return;
            }
            if (unitExists(deviceID))
            {
                lblMessage.ForeColor = System.Drawing.Color.Red;
                lblMessage.Text = "A unit with the provided Unit Serial Number" +
                                    " already exists.";
                return;
            }

            int userGroupID = createUserGroup(name);
            int unitGroupID = createUnitGroup(name);
            createUnit(int.Parse(deviceID), unitGroupID);
            createUser(fullName, name, txtPassword.Text, email, unitGroupID,
                       userGroupID, int.Parse(ddlSecurityQuestion.SelectedValue),
                       txtSecurityAnswer.Text);

            string msg;

            ProcessCompanyQueries processCompany = new ProcessCompanyQueries(comID);
            processCompany.invoke();
            DataSet _ds = processCompany.Ds;

            string companyName = _ds.Tables[0].Rows[0]["companyName"].ToString();
            msg = "A user account has been created in the " + companyName + " application.\r\n";
            msg += "Here is the user information: \r\n\r\n";
            msg += "Full Name: " + fullName + "\r\n";
            msg += "Login: "******"\r\n";
            msg += "Password: "******"\r\n";
            msg += "Email: " + email + "\r\n";
            msg += "Unit ID: " + deviceID + "\r\n";
            msg += "Security Question: " + ddlSecurityQuestion.Text + "\r\n";
            msg += "Security Answer: " + txtSecurityAnswer.Text + "\r\n";
            msg += "Notes/Comments: " + txtNotesComments.Text + "\r\n\r\n";
            msg += "Other Info: \r\n";
            msg += " - A unit group (" + name + ") was created.\r\n";
            msg += " - A user group (" + name + ") was created.\r\n";
            msg += " - The unit group \"" + name + "\" was assigned to the user.\r\n";

            Mailer.SendMailMessage("*****@*****.**", "*****@*****.**", "", "",
                                   "A user account has been created  in the "
                                    + companyName + " application", msg);

            lblMessage.ForeColor = System.Drawing.Color.Green;
            lblMessage.Text = "A new account has been created.\n" +
                            " A message has been sent to the provided email address.";
        }
        catch (Exception ex)
        {
            lblMessage.ForeColor = System.Drawing.Color.Red;
            lblMessage.Text = "Could not create a new user.";
            Console.WriteLine("CreateNewAccount::submitForm(): " + ex.Message.ToString());
        }
        finally
        {

        }
    }