Пример #1
0
 /// <summary>
 /// Sets the user account for the session. Also sets the candidate for the session to the one affiliated with the user.
 /// </summary>
 /// <param name="user">The <see cref="MembershipUser"/> to set.</param>
 protected void SetUser(MembershipUser user)
 {
     Page.Session[_userCacheKey] = _user = user;
     if (user != null)
     {
         SetCandidate(Cfis.GetCandidate(UserManagement.GetCfisId(user.UserName)));
     }
 }
Пример #2
0
        /// <summary>
        /// Populates a <see cref="DropDownList"/> with all known candidates.
        /// </summary>
        /// <param name="list">The <see cref="DropDownList"/> to fill.</param>
        protected void FillCandidates(DropDownList list)
        {
            list.Items.Clear();
            list.Items.Add(new ListItem("(Select a candidate below)", string.Empty));
            Dictionary <string, Candidate> candidates = Cfis.GetCandidates();

            foreach (Candidate c in candidates.Values)
            {
                list.Items.Add(new ListItem(string.Format("{0} (ID: {1})", c.Name, c.ID), c.ID));
            }
        }
Пример #3
0
        /// <summary>
        /// Handles candidate selection changes by showing a list of contacts for that candidate within the current election cycle.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        void SelectedCandidateChanged(object sender, EventArgs e)
        {
            Candidate selection = Cfis.GetCandidate(_candidatesList.SelectedValue);
            string    ec        = _electionCycle.Value;

            base.SetCandidate(selection);
            if (!string.IsNullOrEmpty(_candidatesList.SelectedValue) && (selection != null) && !string.IsNullOrEmpty(ec))
            {
                FillEligibleContacts(_contactsList, ec);
                SetView(RenderContactSelection);
            }
            else
            {
                SetView(RenderCandidateSelection);
            }
        }
Пример #4
0
        /// <summary>
        /// Occurs when the top-level account selection changes.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        void SelectedAccountChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_accountList.SelectedValue))
            {
                SetView(RenderSelectView);
                return;
            }
            if (_mode == ManagerMode.Create)
            {
                SetMode(ManagerMode.CreateByCandidate);
            }
            switch (_mode)
            {
            case ManagerMode.CreateByCandidate:
                // show creator for creating an account for the selected candidate
                Candidate selection = Cfis.GetCandidate(_accountList.SelectedValue);
                if (selection != null)
                {
                    _creator.SetCandidate(selection);
                    SetView(RenderCreatorView);
                }
                else
                {
                    this.ErrorMessage = "Unable to successfully retrieve information for the selected candidate.";
                }
                break;

            case ManagerMode.View:
                // display the selected account in viewer
                MembershipUser user = Membership.GetUser(_accountList.SelectedValue);
                if (user != null)
                {
                    _viewer.SetUser(user);
                    SetView(RenderViewerView);
                }
                else
                {
                    this.ErrorMessage = "Unable to successfully retrieve information for the selected account.";
                }
                break;
            }
        }
Пример #5
0
 /// <summary>
 /// Attempts to submit the current extension request.
 /// </summary>
 /// <returns>true if the extension request was successfully submitted; otherwise, false.</returns>
 private bool SubmitExtensionRequest()
 {
     try
     {
         byte     number;
         DateTime dueDate;
         DateTime requestedDate;
         if (TryParseReviewNumberListItemValue(_numberDropDown.SelectedValue, out number, out dueDate) && DateTime.TryParse(_dueDateDropDown.SelectedValue, out requestedDate))
         {
             Extension req = Extension.Add(CPProfile.Cid, _electionCycle.Text, CPConvert.ParseEnum <ExtensionType>(_types.SelectedValue), number, DateTime.Now, requestedDate, _reason.Text);
             if (req != null)
             {
                 // send e-mail notification
                 CPMailMessage message = new CPMailMessage();
                 message.Sender = CPProfile.GetMailAddress();
                 message.To.Add(CPApplication.AuditExtensionRequestsEmail);
                 message.IsBodyHtml = true;
                 message.Subject    = string.Format("Request for Extension to EC{0} {1} {2}", req.ElectionCycle, _typesValue.Text, req.ReviewNumber);
                 message.Body       = string.Format(EmailBodyFormat,
                                                    Cfis.GetCandidateName(CPProfile.Cid, true),
                                                    CPProfile.Cid,
                                                    message.Sender.DisplayName,
                                                    User.Identity.Name,
                                                    req.ElectionCycle,
                                                    _typesValue.Text,
                                                    _numberLabelText.Text,
                                                    _numberValue.Text,
                                                    _dueDateValue.Text);
                 message.Send();
                 return(true);
             }
         }
     }
     catch
     {
     }
     return(false);
 }
Пример #6
0
        /// <summary>
        /// Loads the <see cref="Candidate"/> specified in the current request.
        /// </summary>
        protected void LoadCandidate()
        {
            string cid = Page.Request[_candidateCacheKey];

            _candidate = !string.IsNullOrWhiteSpace(cid) ? Cfis.GetCandidate(cid) : null;
        }
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            // check to see if an iteration is already underway
            if (_accounts != null)
            {
                return;
            }
            DateTime lastRun = CPProviders.SettingsProvider.LastReminderDistributionDate.Date;

            // only run once each day
            if (lastRun.Date == DateTime.Today)
            {
                return;
            }
            _accounts = new Dictionary <string, IEnumerable <CPUser> >();
            try
            {
                // get all candidates/accounts
                foreach (string cid in Cfis.GetCandidates().Keys)
                {
                    List <CPUser> group = new List <CPUser>();
                    var           users = CPSecurity.Provider.GetCampaignUsers(cid, null, false);
                    foreach (var user in users)
                    {
                        if (!user.Enabled)
                        {
                            continue;
                        }
                        group.Add(user);
                    }
                    _accounts[cid] = group;
                }

                // prepare to collect failed addresses
                NameValueCollection failures = new NameValueCollection();

                // iterate through candidates
                foreach (string cid in _accounts.Keys)
                {
                    // retrieve this candidate's users
                    var group = _accounts[cid];
                    if (group == null || group.Count() == 0)
                    {
                        continue;
                    }
                    // retrieve this candidate's elections
                    foreach (string election in Elections.GetActiveElectionCycles(cid))
                    {
                        // retrieve events from WCF service
                        //ComplianceVisits cv = _dataProxy.GetComplianceVisits(cid, election);
                        //events.AddItems(cv.UpcomingVisits);
                        //events.AddItems(cv.UpcomingDeadlines);
                        //events.AddItems(_dataProxy.GetStatementReviews(cid, election).UpcomingDeadlines);
                        //events.AddItems(_dataProxy.GetFilingDeadlines(cid, election).Upcoming);
                        var dbEvents = GetDoingBusinessEvents(cid, election, lastRun);

                        // iterate through events
                        foreach (CPCalendarItem ev in dbEvents)
                        {
                            if (ev.StartDate.Date > lastRun)
                            {
                                // send e-mail
                                using (EventReminderMessage message = new EventReminderMessage(cid, election, ev))
                                {
                                    //CfbLogger.Write(new CfbLogEntry(string.Format("Sending e-mail for candidate {0}", cid), CfbLogCategory.Trace, 0, CfbEventID.Informational, TraceEventType.Information, "EventReminderMessage Tick Start", null));
                                    message.Recipients = group;
                                    NameValueCollection failed = message.Send();
                                    if (failed.Count > 0)
                                    {
                                        foreach (string recipient in failed.Keys)
                                        {
                                            failures[recipient] = failed[recipient];
                                        }
                                    }
                                }
                            }
                        }

                        int dbCount = dbEvents.Count();
                        if (dbCount > 0)
                        {
                            CfbLogger.Write(new CfbLogEntry(string.Format("Processed {0} upcoming Doing Business Review events for candidate ID: {1}, election cycle: {2}", dbCount, cid, election), CfbLogCategory.Email, 0, CfbEventID.Informational, TraceEventType.Information, "EventReminderMessage Processed Events", null));
                        }
                    }
                }

                // log failed addresses
                if (failures.Count > 0)
                {
                    StringBuilder errorMessage = new StringBuilder("The following error(s) occurred while sending reminder e-mails to the following C-Access users:\n\n");
                    foreach (string recipient in failures.Keys)
                    {
                        errorMessage.AppendFormat("{0}: {1}\n\n", recipient, failures[recipient]);
                    }
                    CfbLogger.Write(new CfbLogEntry(errorMessage, CfbLogCategory.Email, 0, CfbEventID.EmailFailure, TraceEventType.Warning, "EventReminderMessage Failure", null));
                }
            }
            catch (Exception ex)
            {
                if (CfbExceptionPolicy.LogException(ex))
                {
                    throw;
                }
            }
            finally
            {
                CPProviders.SettingsProvider.LastReminderDistributionDate = DateTime.Now;
                _accounts = null;
            }
        }