Ejemplo n.º 1
0
    protected void showFullStatement(object sender, ListViewCommandEventArgs e)
    {
        string[] emailList;
        nEmailHandler emailer = new nEmailHandler();

        //grab full list of emails
        ISession session = DatabaseEntities.NHibernateHelper.CreateSessionFactory().OpenSession();
        List<DatabaseEntities.User> userList = DatabaseEntities.User.GetAllUsers(session);

        string[] data = e.CommandArgument.ToString().Split(new char[] { '%' });

        if (String.Equals(e.CommandName, "remove"))
        {
            dbLogic.updateEligible(data[0], "0");
            LabelFeedback.Text = "User successfully removed from the current ballot. Email sent to ALL users alerting them of this action.";
            emailer.sendRemoveFromBallot(userList, GetName(Convert.ToInt32(data[1])));
        }

        else if (String.Equals(e.CommandName, "add"))
        {
            dbLogic.updateEligible(data[0], "1");
            LabelFeedback.Text = "User successfully placed back on the current ballot. Email sent to ALL users alerting them of this action.";
            emailer.sendReAddToBallot(userList, GetName(Convert.ToInt32(data[1])));
        }
        dbLogic.selectInfoForApprovalTable();
        DataSet emailSet = dbLogic.getResults();
        ListViewApproval.DataSource = emailSet;
        ListViewApproval.DataBind();
        loadApprovalInfo();
    }
Ejemplo n.º 2
0
    public void submit(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            ISession session = DatabaseEntities.NHibernateHelper.CreateSessionFactory().OpenSession();

            int userID;

            // check if email exists in union_members table
            if (!DatabaseEntities.User.CheckIfEmailExists(session, email.Text))
            {
                lblError.Visible = true;
                return;
            }

            // get userID and from email
            DatabaseEntities.User user = DatabaseEntities.User.FindUser(session, email.Text);

            // send email to that person if the email exists
            nEmailHandler emailer = new nEmailHandler();
            emailer.sendConfirmationEmail(user, "APSCUF iVote System Password Reset", "userForgotPassword");
            lblConfirm.Visible = true;
            lblForgot.Visible = false;
            lblError.Visible = false;
        }
    }
    //saves user changes
    protected void Click_ButtonSave(object sender, EventArgs e)
    {
        ISession session = DatabaseEntities.NHibernateHelper.CreateSessionFactory().OpenSession();
        int count = 0;
        foreach (ListViewDataItem eachItem in ListViewApproval.Items)
        {
            bool changeMade = false;
            HiddenField id = (HiddenField)eachItem.FindControl("HiddenFieldID");
            HiddenField userid = (HiddenField)eachItem.FindControl("HiddenUserID");
            HiddenField eligible = (HiddenField)eachItem.FindControl("HiddenFieldEligible");

            RadioButton approve = (RadioButton)eachItem.FindControl("RadioButton1");
            RadioButton deny = (RadioButton)eachItem.FindControl("RadioButton2");

            User u = DatabaseEntities.User.FindUser(session, int.Parse(userid.Value));

            nEmailHandler emailer = new nEmailHandler();

            if (approve.Checked && u != null)
            {
                dbLogic.updateEligible(id.Value, "1");
                //email to user saying they were accepted
                emailer.sendApproveEligibility(u);

                if (eligible.Value != "1")
                {
                    count += 1;
                    eligible.Value = "1";
                }
            }
            else if (deny.Checked || u == null)
            {
                dbLogic.updateEligible(id.Value, "0");
                //email to user saying they were rejected
                if(u != null)
                    emailer.sendDenyEligibility(u);

                if (eligible.Value != "0")
                {
                    count += 1;
                    eligible.Value = "0";
                }
            }

        }
        if (count > 0) {
            SavedConfirmation.Visible = true;
            LabelFeedbackAlert.Visible = false;
        } else {
            SavedConfirmation.Visible = false;
            LabelFeedbackAlert.Visible = true;
            LabelFeedback.Text = "No changes made.";
            LabelFeedbackAlert.CssClass = "alert";
        }
    }
Ejemplo n.º 4
0
    public bool changePhaseToCurrent(string phase)
    {
        if(dbLogic.currentPhase() == phase)
            return false;

        string[] iter_phases = {"nominate", "accept1", "slate", "petition", "accept2", "approval", "vote", "result"};
        int changed_to = 0;
        for(int i = 0; i < iter_phases.Length; i++)
        {
            if(phase == iter_phases[i])
            {
                dbLogic.turnOnPhase(iter_phases[i]);
                changed_to = i;
                break;
            }
        }

        nEmailHandler emailer = new nEmailHandler();
        switch(phase)
        {
            case "nominate":
                emailer.sendGenericOfficerPhase("officerPhaseNominations", "APSCUF iVote Nomination Period Started");
                break;
            case "accept1":
                emailer.sendGenericOfficerPhase("officerPhaseAccept1", "APSCUF iVote Nomination, Action Required");
                break;
            case "slate":
                emailer.sendGenericOfficerPhase("officerPhaseSlate", "APSCUF iVote Slate Created, Action Required");
                break;
            case "petition":
                emailer.sendGenericOfficerPhase("officerPhasePetition", "APSCUF iVote Petition Period");
                dbLogic.phase_ClearNullNominations();
                break;
            case "accept2":
                emailer.sendGenericOfficerPhase("officerPhaseAccept2", "APSCUF iVote Action Required");
                break;
            case "approval":
                emailer.sendGenericOfficerPhase("officerPhaseApproval", "APSCUF iVote Approval Needed");
                break;
            case "vote":
                emailer.sendGenericOfficerPhase("officerPhaseVote", "APSCUF iVote Voting Period Officially Begun");
                dbLogic.phase_ClearNullNominations();
                break;
            case "result":
                emailer.sendGenericOfficerPhase("officerPhaseResults", "APSCUF iVote Election Officially Concluded");
                break;
        }

        return true;
    }
Ejemplo n.º 5
0
        /// <summary>
        /// This function sets the phase of the specified election.  You still
        /// to call transaction.Commit() to ensure pending changes are saved.
        /// </summary>
        /// <param name="session">A valid session.</param>
        /// <param name="id">The id of the election to edit.</param>
        /// <param name="electionPhase">The new phase of the election.</param>
        public virtual void SetPhase(ISession session,
            ElectionPhase electionPhase)
        {
            this.Phase = electionPhase;
            Committee com = Committee.FindCommittee(session, PertinentCommittee);

            if (electionPhase == ElectionPhase.WTSPhase)
            {
                List<User> userList = User.GetAllUsers(session);
                userList.RemoveAll(x => (!(!com.TenureRequired || x.IsTenured) ||
                                        !(!com.BargainingUnitRequired || x.IsBargainingUnit)));
                userList.RemoveAll(x => (x.CurrentCommittee == com.ID));
                nEmailHandler emailHandler = new nEmailHandler();
                emailHandler.sendGenericCommitteePhase(this, userList, "committeePhaseWTS");
            }
            else if (electionPhase == ElectionPhase.NominationPhase)
            {
                List<User> userList = User.GetAllUsers(session);

                nEmailHandler emailHandler = new nEmailHandler();
                userList.RemoveAll(x => (!x.CanVote));
                emailHandler.sendGenericCommitteePhase(this, userList, "committeePhaseNomination");
            }
            else if (electionPhase == ElectionPhase.VotePhase)
            {
                // if theres no need to enter the nomination phase,
                // automatically enter nominations for users who
                //submitted wts
                if (!ShouldEnterNominationPhase(session))
                {
                    List<CommitteeWTS> wtses = CommitteeWTS.FindCommitteeWTS(session, ID);
                    foreach (CommitteeWTS wts in wtses)
                    {
                        ISession nomSession = NHibernateHelper.CreateSessionFactory().OpenSession();
                        Nomination nomination = new Nomination();
                        nomination.User = wts.User;
                        nomination.Election = ID;
                        nomSession.SaveOrUpdate(nomination);
                        nomSession.Flush();
                    }
                }
                // distribute emails prompting faculty members to come
                List<User> userList = User.GetAllUsers(session);
                userList.RemoveAll(x => (!(x.CanVote || x.IsAdmin)));

                nEmailHandler emailHandler = new nEmailHandler();
                emailHandler.sendGenericCommitteePhase(this, userList, "committeePhaseVote");
                // vote
            }
            else if (electionPhase == ElectionPhase.CertificationPhase)
            {
                ConflictLogic(session); // Get an idea of what the conflicts will be.
                List<User> userList = User.GetAllUsers(session);
                userList.RemoveAll(x => (!(x.IsNEC || x.IsAdmin)));

                nEmailHandler emailHandler = new nEmailHandler();
                emailHandler.sendGenericCommitteePhase(this, userList, "committeePhaseCertification");
            }
            else if (electionPhase == ElectionPhase.ConflictPhase)
            {
                ConflictLogic(session); // Re-calculate in case the admin fixed it up.
                // maybe send out emails telling admins / NEC that there are conflicts?
                List<User> userList = User.GetAllUsers(session);
                userList.RemoveAll(x => (!(x.IsNEC || x.IsAdmin)));

                nEmailHandler emailHandler = new nEmailHandler();
                emailHandler.sendGenericCommitteePhase(this, userList, "committeePhaseConflict");
            }
            else if (electionPhase == ElectionPhase.ClosedPhase)
            {
                // Put the users into the correct committee.
                Dictionary<string, int> winners = GetResults(session);
                List<User> winningUsers = new List<User>();
                foreach (string email in winners.Keys) {
                    User u = User.FindUser(session, email);
                    u.CurrentCommittee = PertinentCommittee;
                    session.SaveOrUpdate(u);
                }
            }
            // Store the current date in the PhaseStarted field
            this.PhaseStarted = DateTime.Now;
            this.PhaseEndDelta = 0;

            session.SaveOrUpdate(this);
            session.Flush();
        }
Ejemplo n.º 6
0
    protected void submit(object sender, EventArgs e)
    {
        //make sure the page is valid before processing
        if (Page.IsValid)
        {
            ISession session = DatabaseEntities.NHibernateHelper.CreateSessionFactory().OpenSession();
            Committee committee = Committee.FindCommittee(session, int.Parse(CurrentCommittee.SelectedValue));

            ITransaction transaction = session.BeginTransaction();

            if (DatabaseEntities.User.CheckIfEmailExists(session, Email.Text)) {
                //checks if new user's email address already exists
                EmailExistsPanel.Visible = true;
                SuccessPanel.Visible = false;
                ConflictPanel.Visible = false;
            } else if(committee != null &&
                      Committee.DepartmentRepresented(session, committee, (DepartmentType)Enum.Parse(typeof(DepartmentType), DeptDropDown.SelectedValue)))
            {
                ConflictPanel.Visible = true;
                EmailExistsPanel.Visible = false;
                InElectionPanel.Visible = false;
                SuccessPanel.Visible = false;
            } else if(committee != null && committee.InElection(session)) {
                InElectionPanel.Visible = true;
                EmailExistsPanel.Visible = false;
                ConflictPanel.Visible = false;
                SuccessPanel.Visible = false;
            } else {
                string user = Email.Text;

                User nUser = CreateUser(Email.Text, FirstName.Text, LastName.Text, DeptDropDown.SelectedValue);

                // Set up the user permissions and such.
                nUser.IsAdmin = IsAdmin.Checked;
                nUser.IsNEC = IsNEC.Checked;
                nUser.IsFaculty = IsFaculty.Checked;
                nUser.IsTenured = IsTenured.Checked;
                nUser.IsUnion = IsUnion.Checked;
                nUser.IsBargainingUnit = IsBU.Checked;

                nUser.CanVote = CanVote.Checked;

                DatabaseEntities.NHibernateHelper.UpdateDatabase(session, nUser);

                User testUser = DatabaseEntities.User.FindUser(session, nUser.Email);

                nEmailHandler emailer = new nEmailHandler();
                emailer.sendConfirmationEmail(testUser, "Welcome to the APSCUF iVote System", "userRegister");

                NHibernateHelper.Finished(transaction);

                SuccessPanel.Visible = true;
                ConflictPanel.Visible = false;

                FirstName.Text = "";
                LastName.Text = "";
                Email.Text = "";

            }
        }
    }