Ejemplo n.º 1
0
        private void _newAccountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ActiveCandidate ac = _treeView.SelectedNode.Tag as ActiveCandidate;

            if (ac != null)
            {
                UserAccountForm.CreateNewAccountForm(null, ac.ID, ac.ElectionCycle, null).ShowAsOwnedBy(this);
            }
        }
Ejemplo n.º 2
0
        public static CandidateProfileViewModel CandidateProfileFrom(ActiveCandidate cand, IEnumerable <AuthorizedCommittee> committees = null)
        {
            var model = new CandidateProfileViewModel
            {
                ID                  = cand.ID,
                FullName            = cand.Name,
                Classification      = cand.Classification,
                OfficeSoughtDetails = cand.Office.ToString(),
                RegistrationDate    = cand.FilerRegistrationDate,
                CertificationDate   = cand.CertificationDate,
                PrincipalCommittee  = cand.PrincipalCommittee,
                CsuLiaison          = cand.CsuLiaisonName,
                Auditor             = cand.AuditorName
            };

            if (committees == null)
            {
                model.ContactInfo = new ContactInfoViewModel();
            }
            else
            {
                // candidate info
                model.Name        = PersonNameFrom(cand);
                model.ContactInfo = ContactInfoFrom(cand);

                // employer info
                model.Employer = EmployerFrom(cand.Employer);

                // activation info
                model.PoliticalParty  = cand.PoliticalParty;
                model.TerminationDate = cand.TerminationDate;
                if (cand.Office != null)
                {
                    var office = cand.Office;
                    model.OfficeSought = office.Type;
                    NycBorough borough;
                    byte       district;
                    if (office.TryGetBorough(out borough))
                    {
                        model.Borough = borough;
                    }
                    else if (office.TryGetDistrict(out district))
                    {
                        model.District = district;
                    }
                }
                model.DDAuth = cand.IsDirectDepositAuthorized;
                if (model.HasRRAccounts = committees.Any(c => c.BankAccounts.Values.Any(a => a.Purpose == BankAccountPurpose.RunoffRerun)))
                {
                    model.RRAuth = cand.IsRRDirectDepositAuthorized;
                }
                model.LastUpdated = cand.LastUpdated;
            }
            model.ContactInfo.Email = cand.Email;
            return(model);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Populates a <see cref="DropDownList"/> with all known candidates active in a specific election cycle.
        /// </summary>
        /// <param name="list">The <see cref="DropDownList"/> to fill.</param>
        /// <param name="electionCycle">The election cycle to filter by.</param>
        protected void FillActiveCandidates(DropDownList list, string electionCycle)
        {
            list.Items.Clear();
            list.Items.Add(new ListItem("(Select a candidate below)", string.Empty));
            Dictionary <string, ActiveCandidate> candidates = ActiveCandidate.GetActiveCandidates(electionCycle);

            foreach (var c in candidates.Values)
            {
                list.Items.Add(new ListItem(string.Format("{0} (ID: {1})", c.Name, c.ID), c.ID));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Retrieves the child nodes of a specific <see cref="TreeNode"/>.
        /// </summary>
        /// <param name="node">The parent <see cref="TreeNode"/>.</param>
        /// <returns>An array of <see cref="TreeNode"/> objects that are the children of <paramref name="node"/>.</returns>
        private TreeNode[] GetChildNodes(TreeNode node)
        {
            IEnumerable <TreeNode> childNodes = null;

            if (node == _candidatesNode && !_candidatesLoaded)
            {
                // candidates
                childNodes                         = from c in Cfb.CandidatePortal.Cfis.GetCandidates().Values
                                         let cNode = CreateCandidateNode(c)
                                                     where cNode.Nodes.Count > 0
                                                     orderby c.FormalName
                                                     select cNode;
                _candidatesLoaded = true;
            }
            else if (node == _electionCyclesNode)
            {
                if (!_electionsLoaded)
                {
                    // election cycles
                    childNodes = from e in Elections.GetElections().Values
                                 orderby e.Cycle
                                 select CreateElectionCycleNode(e.Cycle);

                    _electionsLoaded = true;
                }
            }
            else if (node == _groupsNode && !_groupsLoaded)
            {
                // security groups
                childNodes = from g in CPSecurity.Provider.GetGroups()
                             select CreateGroupNode(g);

                _groupsLoaded = true;
            }
            else if (node.Tag is ActiveCandidate)
            {
                // active candidate -- do nothing
            }
            else if (node.Tag is Candidate)
            {
                // active election cycles
                childNodes = from e in Elections.GetActiveElectionCycles(node.Name)
                             orderby e
                             select CreateElectionCycleNode(e, node.Tag as Candidate);
            }
            else if (node.ImageIndex == _electionCyclesImageIndex)
            {
                // active candidates
                childNodes = from c in ActiveCandidate.GetActiveCandidates(node.Name).Values
                             orderby c.FormalName
                             select CreateCandidateNode(c);
            }
            return(childNodes == null ? null : childNodes.ToArray());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Retrieves the original Final Audit Report issuance date for a specific candidate and election cycle.
        /// </summary>
        /// <param name="candidateID">The ID of the desired candidate.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <returns>The original issuance date if the election cycle is valid and the candidate is active in that election cycle; otherwise, null.</returns>
        public static DateTime?GetOriginalIssuanceDate(string candidateID, string electionCycle)
        {
            ActiveCandidate c = ActiveCandidate.GetActiveCandidate(candidateID, electionCycle);

            if (c != null)
            {
                DateTime?date = DraftAuditReport.GetOriginalIssuanceDate(candidateID, electionCycle);
                if (date.HasValue)
                {
                    return(date.Value.AddMonths(Properties.Settings.Default.DarFarIntervalMonths));
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Determines whether or not an <see cref="ActiveCandidate"/> has rerun or runoff bank accounts.
 /// </summary>
 /// <param name="ac">The <see cref="ActiveCandidate"/> to examine.</param>
 /// <returns>true if <paramref name="ac"/> has rerun or runoff bank accounts, otherwise false.</returns>
 bool HasRRAccounts(ActiveCandidate ac)
 {
     foreach (AuthorizedCommittee comm in CPProfile.AuthorizedCommittees.Committees.Values)
     {
         foreach (BankAccount ba in comm.BankAccounts.Values)
         {
             if (ba.Purpose == BankAccountPurpose.RunoffRerun)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 7
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (!Page.IsPostBack)
     {
         ActiveCandidate ac = CPProfile.ActiveCandidate;
         if (ac != null)
         {
             // general candidate information
             this.CandidateName.Text = string.Format("{0} (ID: {1})", ac.Name, ac.ID);
             if (ac.Office != null)
             {
                 this.OfficeLabel.Text = ac.Office.ToString();
             }
             this.ClassificationLabel.Text = CPConvert.ToString(ac.Classification);
             Election ec = CPApplication.Elections[CPProfile.ElectionCycle];
             if (ec != null)
             {
                 FinancialSummary fs = FinancialSummary.GetFinancialSummary(CPProfile.Cid, CPProfile.ElectionCycle);
                 if (fs != null)
                 {
                     Statement lastStatement;
                     if (ec.Statements.TryGetValue(fs.LastStatementSubmitted, out lastStatement))
                     {
                         // receipts
                         this.NetContributionsLabel.Text = FormatCurrency(fs.NetContributions);
                     }
                     this.NumberOfContributorsLabel.Text  = string.Format("{0:N0}", fs.ContributorCount);
                     this.MiscellaneousReceiptsLabel.Text = FormatCurrency(fs.MiscellaneousReceipts);
                     this.MatchingClaimsLabel.Text        = FormatCurrency(fs.MatchingClaims);
                     this.LoansReceivedLabel.Text         = FormatCurrency(fs.LoansReceived);
                     // disbursements
                     this.NetExpendituresLabel.Text = FormatCurrency(fs.NetExpenditures);
                     this.LoansPaidLabel.Text       = FormatCurrency(fs.LoansPaid);
                     this.OustandingBillsLabel.Text = FormatCurrency(fs.OutstandingBills);
                     if (!_isTIE)
                     {
                         this.PublicFundsReceivedLabel.Text = FormatCurrency(fs.PublicFundsReceived);
                         this.PublicFundsReturnedLabel.Text = FormatCurrency(fs.PublicFundsReturned);
                     }
                 }
                 if (_isTIE)
                 {
                     FSClassificationCol.Visible = FSClassificationHeader.Visible = FSClassificationCell.Visible = false;
                     ContributorsPanel.CssClass  = null;
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Retrieves the original Draft Audit Report issuance date for a specific candidate and election cycle.
        /// </summary>
        /// <param name="candidateID">The ID of the desired candidate.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <returns>The original issuance date if the election cycle is valid and the candidate is active in that election cycle; otherwise, null.</returns>
        public static DateTime?GetOriginalIssuanceDate(string candidateID, string electionCycle)
        {
            ActiveCandidate c = ActiveCandidate.GetActiveCandidate(candidateID, electionCycle);

            if (c != null)
            {
                DateTime?startDate = CPProviders.DataProvider.GetTollingStartDate(electionCycle);
                if (startDate.HasValue)
                {
                    return(startDate.Value.AddMonths(c.Office.IsCitywide ? Properties.Settings.Default.CitywideDarIntervalMonths : Properties.Settings.Default.DarFarIntervalMonths));
                }
            }
            return(null);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Retrieves basic profile information for all candidates active in a specific election cycle.
        /// </summary>
        /// <param name="electionCycle">The election cycle to filter by.</param>
        /// <returns>A collection of <see cref="ActiveCandidate"/> objects representing all candidates active in the <paramref name="electionCycle"/> election cycle, indexed by CFIS ID.</returns>
        public Dictionary <string, ActiveCandidate> GetActiveCandidates(string electionCycle)
        {
            Dictionary <string, ActiveCandidate> candidates = new Dictionary <string, ActiveCandidate>();

            using (ActiveCandidateTds ds = new ActiveCandidateTds())
            {
                using (ActiveCandidateTableAdapter ta = new ActiveCandidateTableAdapter())
                {
                    ta.FillBy(ds.ActiveCandidate, electionCycle);
                }
                foreach (ActiveCandidateTds.ActiveCandidateRow row in ds.ActiveCandidate.Rows)
                {
                    ActiveCandidate c = Parse(row);
                    if (c != null)
                    {
                        candidates.Add(c.ID, c);
                    }
                }
            }
            return(candidates);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates a tree node to represent an election cycle.
        /// </summary>
        /// <param name="electionCycle">The election cycle represented by the tree node.</param>
        /// <param name="candidate">A candidate active in the cycle.</param>
        /// <returns>A new tree node that represents the specified election cyle.</returns>
        private TreeNode CreateElectionCycleNode(string electionCycle, Candidate candidate = null)
        {
            TreeNode node = null;

            if (!string.IsNullOrEmpty(electionCycle))
            {
                node = new TreeNode(electionCycle, _electionCyclesImageIndex, _electionCyclesImageIndex)
                {
                    Name = electionCycle,
                };
                if (candidate == null)
                {
                    node.Tag = electionCycle;
                    node.Nodes.Add(new TreeNode());
                }
                else
                {
                    node.Tag = ActiveCandidate.GetActiveCandidate(candidate.ID, electionCycle);
                }
            }
            return(node);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates a tree node to represent a candidate.
        /// </summary>
        /// <param name="candidate">The candidate represented by the tree node.</param>
        /// <returns>A new tree node that represents the specified candidate.</returns>
        private TreeNode CreateCandidateNode(Candidate candidate)
        {
            TreeNode node = null;

            if (candidate != null)
            {
                node = new TreeNode(string.Format("{0} [{1}]", candidate.FormalName, candidate.ID), _candidatesImageIndex, _candidatesImageIndex)
                {
                    Name = candidate.ID
                };
                ActiveCandidate ac = candidate as ActiveCandidate;
                if (ac == null)
                {
                    node.Tag = candidate;
                    node.Nodes.Add(new TreeNode());
                }
                else
                {
                    node.Tag = ac;
                }
            }
            return(node);
        }
Ejemplo n.º 12
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // candidate profile
            ActiveCandidate candidate = CPProfile.ActiveCandidate;

            _profileSummary.DataSource = candidate;
            _profileSummary.DataBind();

            // announcements list
            _announcementsList.DataSource = CPProviders.DataProvider.GetAnnouncements(CPProfile.ElectionCycle);
            _announcementsList.DataBind();

            //if (_pressReleasesLink.EnableViewState && !this.IsPostBack)
            //{
            //    if (_pressReleasesLink.Visible = candidate != null)
            //    {
            //        _pressReleasesLink.FirstName = candidate.FirstName;
            //        _pressReleasesLink.LastName = candidate.LastName;
            //        _pressReleasesLink.MiddleInitial = candidate.MiddleInitial;
            //    }
            //}
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Updates control fields with an active candidate's profile information.
        /// </summary>
        /// <param name="ac">The active candidate profile to display.</param>
        private void ShowCandidate(ActiveCandidate ac)
        {
            if (ac == null)
            {
                _errorMessage.Text    = string.Format("You do not currently have an active candidate profile for the {0} election.", CPProfile.ElectionCycle);
                _errorMessage.Visible = true;
                _details.Visible      = false;
            }
            else
            {
                PostalAddress address;

                // basic candidate info
                _ID.Value         = ac.ID;
                _salutation.Value = CPConvert.ToString(ac.Honorific);
                _lastName.Value   = ac.LastName;
                _firstName.Value  = ac.FirstName;
                _mi.Value         = ac.MiddleInitial.HasValue ? ac.MiddleInitial.Value.ToString() : null;
                address           = ac.Address;
                if (!object.Equals(address, null))
                {
                    _streetNumber.Value = address.StreetNumber;
                    _streetName.Value   = address.StreetName;
                    _apartment.Value    = address.Apartment;
                    _city.Value         = address.City;
                    _state.Value        = CPConvert.ParseStateCode(address.State);
                    if (!object.Equals(address.Zip, null))
                    {
                        _zip.Value = address.Zip.ToString();
                    }
                }
                if (!object.Equals(ac.DaytimePhone, null))
                {
                    _daytimePhone.Value = ac.DaytimePhone.ToString();
                }
                if (!object.Equals(ac.EveningPhone, null))
                {
                    _eveningPhone.Value = ac.EveningPhone.ToString();
                }
                if (!object.Equals(ac.Fax, null))
                {
                    _fax.Value = ac.Fax.ToString();
                }
                if (!string.IsNullOrEmpty(ac.Email))
                {
                    _email.Value = string.Format("<a href=\"mailto:{0}\">{0}</a>", ac.Email);
                }

                // employer info
                Entity employer = ac.Employer;
                if (!object.Equals(employer, null))
                {
                    _empName.Value = employer.Name;
                    address        = employer.Address;
                    if (!object.Equals(address, null))
                    {
                        _empStreetNumber.Value = address.StreetNumber;
                        _empStreetName.Value   = address.StreetName;
                        _empCity.Value         = address.City;
                        _empState.Value        = CPConvert.ParseStateCode(address.State);
                        if (!object.Equals(address.Zip, null))
                        {
                            _empZip.Value = address.Zip.ToString();
                        }
                    }
                    if (!object.Equals(employer.DaytimePhone, null))
                    {
                        _empPhone.Value = employer.DaytimePhone.ToString();
                    }
                    if (!object.Equals(employer.Fax, null))
                    {
                        _empFax.Value = employer.Fax.ToString();
                    }
                }

                // candidate activation info
                if (ac.FilerRegistrationDate.HasValue)
                {
                    _frDate.Value = ac.FilerRegistrationDate.Value.ToDateString();
                }
                else
                {
                    _frDate.Value = "(n/a)";
                }
                _party.Value = ac.PoliticalParty;
                if (_isTIE)
                {
                    _office.Visible = _certDate.Visible = _terminationDate.Visible = _boroDistrict.Visible = _classification.Visible = _ddAuth.Visible = _rrddAuth.Visible = false;
                }
                else
                {
                    _office.Value = CPConvert.ToString(ac.Office.Type);
                    if (ac.CertificationDate.HasValue)
                    {
                        _certDate.Value = ac.CertificationDate.Value.ToDateString();
                    }
                    else
                    {
                        _certDate.Value = "(n/a)";
                    }
                    if (ac.IsTerminated)
                    {
                        _terminationDate.Value   = ac.TerminationDate.Value.ToDateString();
                        _terminationDate.Visible = true;
                    }
                    if (_boroDistrict.Visible = (ac.Office.Type == NycPublicOfficeType.BoroughPresident) || (ac.Office.Type == NycPublicOfficeType.CityCouncilMember))
                    {
                        NycBorough borough;
                        byte       district;
                        if (ac.Office.TryGetBorough(out borough))
                        {
                            _boroDistrict.LabelText = "Borough";
                            _boroDistrict.Value     = CPConvert.ToString(borough);
                        }
                        else if (ac.Office.TryGetDistrict(out district))
                        {
                            _boroDistrict.LabelText = "District";
                            _boroDistrict.Value     = district.ToString();
                        }
                    }
                    _classification.Value = CPConvert.ToString(ac.Classification);
                    _ddAuth.Value         = ac.IsDirectDepositAuthorized ? "Yes" : "No";
                    if (_rrddAuth.Visible = HasRRAccounts(ac))
                    {
                        _rrddAuth.Value = ac.IsRRDirectDepositAuthorized ? "Yes" : "No";
                    }
                }
                _lastUpdated.Text = "Data last modified: " + ac.LastUpdated.ToDateString();
            }
        }
Ejemplo n.º 14
0
 private void _listView_ItemActivate(object sender, EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     try
     {
         ListViewItem item = this.SelectedItem;
         if (item == null)
         {
             return;
         }
         ActiveCandidate ac = null;
         if (_treeView.SelectedNode != null)
         {
             ac = _treeView.SelectedNode.Tag as ActiveCandidate;
         }
         var user = this.SelectedUser;
         if (user != null || item.Text.EndsWith("*"))
         {
             var status = this.SelectedIneligibilityStatus;
             if (status != null)
             {
                 // other cycle user, prompt for open or update
                 user = status.MatchedUser;
                 if (user != null)
                 {
                     if (MessageBox.Show(this, string.Format("{0} already has an account from EC{1}. Would you like to associate this account with the EC{2} data before opening it?", user.DisplayName, user.SourceElectionCycle, ac.ElectionCycle), "Update Account?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                     {
                         // remap account
                         Entity entity    = status.Entity;
                         string contactID = status.ContactID;
                         if (entity != null && contactID != null)
                         {
                             char?sourceCommitteeID = AccountAnalysis.ParseCommitteeID(contactID);
                             byte?sourceLiaisonID   = AccountAnalysis.ParseLiaisonID(contactID);
                             if (sourceCommitteeID.HasValue)
                             {
                                 user.SourceCommitteeID = sourceCommitteeID;
                             }
                             if (sourceLiaisonID.HasValue)
                             {
                                 user.SourceLiaisonID = sourceLiaisonID;
                             }
                             if (ac != null)
                             {
                                 user.SourceElectionCycle = ac.ElectionCycle;
                             }
                             user.SourceType = entity.Type;
                             user.ElectionCycles.Add(ac.ElectionCycle);
                         }
                         if (!user.Save())
                         {
                             MessageBox.Show(this, string.Format("An error occurred attempting to update {0}'s account. Please try again, or contact an administrator for further assistance.", user.DisplayName), "Account Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                             return;
                         }
                         _refreshToolStripButton.PerformClick();
                     }
                 }
             }
             if (user != null)
             {
                 // show existing user account properties
                 UserAccountForm.ShowExistingAccountForm(user, this.MdiParent);
             }
         }
         else
         {
             // create new user
             if (ac != null)
             {
                 Entity entity = this.SelectedEntity;
                 if (entity != null)
                 {
                     UserAccountForm.CreateNewAccountForm(entity, ac.ID, ac.ElectionCycle, item.Name).ShowAsOwnedBy(this.MdiParent);
                     _refreshToolStripButton.PerformClick();
                 }
                 else
                 {
                     var status = this.SelectedIneligibilityStatus;
                     if (status != null)
                     {
                         entity = status.Entity;
                         MessageBox.Show(this, string.Format("A C-Access user account cannot be created for {0} for the following reason:\n\n{1}", entity != null ? entity.Name : this.SelectedItem.Name, status.Status.GetDescription()), "Ineligible Contact", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                 }
             }
             else
             {
                 // does not match a leaf node, so expand tree
                 lock (_listViewClickedLock)
                 {
                     _listViewClicked = true;
                 }
                 if (!_treeView.SelectedNode.IsExpanded)
                 {
                     _treeView.SelectedNode.Expand();
                 }
                 var nodes = _treeView.SelectedNode.Nodes.Find(item.Name, false);
                 if (nodes.Length > 0 && nodes[0].TreeView != null)
                 {
                     nodes[0].EnsureVisible();
                     _treeView.SelectedNode = nodes[0];
                 }
             }
         }
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Retrieves the content to display in a <see cref="ListView"/> when a <see cref="TreeNode"/> is selected.
        /// </summary>
        /// <param name="node">The <see cref="TreeNode"/> that was selected.</param>
        /// <returns>A <see cref="ListViewContents"/> that defines the columns and items of the content.</returns>
        private ListViewContents GetListItems(TreeNode node)
        {
            ColumnHeader[]             headers = null;
            IEnumerable <ListViewItem> items   = null;

            if (node.Tag is ActiveCandidate)
            {
                // active candidate leaf node selected, show active candidate contacts/users
                headers = new[] { _nameColumnHeader, _typeColumnHeader, _usernameColumnHeader, _emailColumnHeader };
                ActiveCandidate ac      = node.Tag as ActiveCandidate;
                AnalysisResults results = AccountAnalysis.Analyze(Cfb.CandidatePortal.Cfis.GetCandidate(ac.ID), ac.ElectionCycle);

                // users for current campaign
                var current = from u in results.CurrentUsers
                              where _adminMode || u.SourceType != EntityType.Generic // hide generic accounts from non-admins
                              select new ListViewItem(new[] { u.DisplayName, string.Format("User ({0})", u.SourceType), u.UserName, u.Email }, u.Enabled ? _userImageIndex : _userDisabledImageIndex)
                {
                    Tag = u
                };
                // existing users from a different campaign
                var other = from s in results.OtherCampaignUsers
                            let u = s.MatchedUser
                                    select new ListViewItem(new[] { u.DisplayName + "*", string.Format("EC{0} User", u.SourceElectionCycle), u.UserName, u.Email }, u.Enabled ? _userImageIndex : _userDisabledImageIndex)
                {
                    Tag = s
                };
                // eligible contacts
                var eligible = from e in results.EligibleContacts
                               let v = e.Value
                                       select new ListViewItem(new[] { v.Name, AccountAnalysis.ParseEntityType(e.Key).ToString(), null, v.Email }, _userInactiveImageIndex)
                {
                    Name = e.Key,
                    Tag  = e.Value
                };
                // ineligible contacts
                var ineligible = from s in results.IneligibleContacts
                                 select new ListViewItem(new[] { s.Entity.Name, "Ineligible Contact", null, s.Entity.Email }, _blockImageIndex)
                {
                    Tag = s
                };
                items = eligible.Union(ineligible).Union(current).Union(other);
            }
            else if (node.Tag as string == GroupNodeTag)
            {
                // group leaf node selected, show groups
                headers                     = new[] { _nameColumnHeader, _usernameColumnHeader, _idColumnHeader, _emailColumnHeader };
                items                       = from u in CPSecurity.Provider.GetGroupMembers(node.Name)
                                   let user = CPSecurity.Provider.GetUser(u)
                                              where user != null && (_adminMode || user.SourceType != EntityType.Generic)
                                              select new ListViewItem(new[] { user.DisplayName, user.UserName, user.Cid, user.Email }, user.Enabled ? _userImageIndex : _userDisabledImageIndex)
                {
                    Tag = user
                };
            }
            else
            {
                // non-leaf nodes
                if (node == _candidatesNode)
                {
                    headers = new[] { _nameColumnHeader, _typeColumnHeader, _idColumnHeader }
                }
                ;
                else if (node == _electionCyclesNode || node == _groupsNode || node.Tag is Candidate || node.ImageIndex == _electionCyclesImageIndex)
                {
                    headers = new[] { _nameColumnHeader, _typeColumnHeader }
                }
                ;
                TreeNodeCollection  children      = node.Nodes;
                List <ListViewItem> treeNodeItems = new List <ListViewItem>();
                foreach (TreeNode child in children)
                {
                    ListViewItem item = null;
                    if (child.ImageIndex == _candidatesImageIndex && child.Tag is Candidate)
                    {
                        Candidate cand = child.Tag as Candidate;
                        item = new ListViewItem(new[] { cand.FormalName, "Candidate", cand.ID }, _candidatesImageIndex)
                        {
                            Name = cand.ID,
                            Tag  = child.Tag
                        };
                    }
                    else if (child.ImageIndex == _electionCyclesImageIndex)
                    {
                        item = new ListViewItem(new[] { child.Name, "Election Cycle" }, _electionCyclesImageIndex)
                        {
                            Name = child.Name,
                            Tag  = child.Tag
                        };
                    }
                    else if (node.ImageIndex == _groupsImageIndex)
                    {
                        item = new ListViewItem(new[] { child.Name, "Security Group" }, _groupsImageIndex)
                        {
                            Name = child.Name
                        };
                    }
                    if (item != null)
                    {
                        treeNodeItems.Add(item);
                    }
                }
                items = treeNodeItems;
            }
            return(new ListViewContents()
            {
                Headers = headers, Items = items.OrderBy(i => i.Text).ToArray()
            });
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Renders the contents of the control to the specified writer. This method is used primarily by control developers.
        /// </summary>
        /// <param name="writer">A <see cref="HtmlTextWriter"/> that represents the output stream to render HTML content on the client.</param>
        protected override void RenderContents(HtmlTextWriter writer)
        {
            ActiveCandidate candidate = this.DataSource;

            if (candidate == null)
            {
                writer.Write(this.EmptyValueText);
                return;
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "CandidateProfileSummary");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            // header
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "header");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            if (candidate.IsTerminated)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "terminated");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.Write("Candidate Information");
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();

            // candidate ID
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Th);
            writer.Write("<label>ID</label>");
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write(ExpanderLinkTextFormat, candidate.ID, PageUrlManager.CandidateProfilePageUrl, "View Full Candidate Profile");
            writer.RenderEndTag();
            writer.RenderEndTag();

            // candidate name
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Th);
            writer.Write("<label>Name</label>");
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<span>{0}</span>", candidate.Name);
            writer.RenderEndTag();
            writer.RenderEndTag();

            // Cert/FR date
            if (candidate.HasCertified || candidate.HasRegistered)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                writer.RenderBeginTag(HtmlTextWriterTag.Th);
                writer.Write("<label>{0}</label>", candidate.HasCertified ? "Certification Date" : "Filer Registration Date");
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.Write("<span>{0:MMMM d, yyyy}</span>", candidate.HasCertified ? candidate.CertificationDate : candidate.FilerRegistrationDate);
                writer.RenderEndTag();
                writer.RenderEndTag();
            }

            // termination date
            if (candidate.IsTerminated)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                writer.RenderBeginTag(HtmlTextWriterTag.Th);
                writer.Write("<label>Termination Date</label>");
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.Write("<span>{0:MMMM d, yyyy}</span>", candidate.TerminationDate);
                writer.RenderEndTag();
                writer.RenderEndTag();
            }

            // office sought
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Th);
            writer.Write("<label>Office Sought</label>");
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<span>{0}</span>", Page.Server.HtmlEncode(candidate.Office.ToString()));
            writer.RenderEndTag();
            writer.RenderEndTag();

            // classification
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Th);
            writer.Write("<label>Classification</label>");
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<span>{0}</span>", CPConvert.ToString(candidate.Classification));
            writer.RenderEndTag();
            writer.RenderEndTag();

            // e-mail
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "bottom");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Th);
            writer.Write("<label>E-mail Address</label>");
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<span>{0}</span>", string.IsNullOrEmpty(candidate.Email) ? EmptyValueText : string.Format("<a href=\"mailto:{0}\">{0}</a>", candidate.Email));
            writer.RenderEndTag();
            writer.RenderEndTag();

            // principal committee
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "newSection top bottom");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Th);
            writer.Write("<label>Principal Committee</label>");
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write(ExpanderLinkTextFormat, string.IsNullOrEmpty(candidate.PrincipalCommittee) ? EmptyValueText : candidate.PrincipalCommittee, PageUrlManager.CommitteeProfilePageUrl, "View Full Committee Profile");
            writer.RenderEndTag();
            writer.RenderEndTag();

            // CSU liaison
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "newSection top");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Th);
            writer.Write("<label>CSU Liaison</label>");
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<span>{0}</span>", candidate.CsuLiaisonName ?? this.EmptyLiaisonText);
            writer.RenderEndTag();
            writer.RenderEndTag();

            // audit liaison
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "bottom");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Th);
            writer.Write("<label>Audit Liaison</label>");
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<span>{0}</span>", candidate.AuditorName ?? this.EmptyLiaisonText);
            writer.RenderEndTag();
            writer.RenderEndTag();

            // closing table tag
            writer.RenderEndTag();
        }
Ejemplo n.º 17
0
        public static FinancialSummaryViewModel FinancialSummaryFrom(FinancialSummary summary, ActiveCandidate candidate, Election election)
        {
            if (summary == null || candidate == null)
            {
                return(new FinancialSummaryViewModel());
            }
            var statement = election == null ? null : (from s in election.Statements
                                                       where s.Key == summary.LastStatementSubmitted
                                                       select s.Value).SingleOrDefault();

            return(new FinancialSummaryViewModel
            {
                IsTie = election != null && election.IsTIE,
                ElectionCycle = candidate.ElectionCycle,
                CandidateName = string.Format("{0} (ID: {1})", candidate.Name, candidate.ID),
                OfficeSought = candidate.Office.ToString(),
                Classification = candidate.Classification,
                LastFiledStatement = statement == null ? null : statement.ToDetailString(),
                NetContributions = summary.NetContributions,
                MiscReceipts = summary.MiscellaneousReceipts,
                LoansReceived = summary.LoansReceived,
                PublicFundsReceived = summary.PublicFundsReceived,
                NetExpenditures = summary.NetExpenditures,
                LoansPaid = summary.LoansPaid,
                OutstandingBills = summary.OutstandingBills,
                FundsReturned = summary.PublicFundsReturned,
                ContributorsNumber = summary.ContributorCount,
                MatchingClaims = summary.MatchingClaims
            });
        }