Exemple #1
0
        /// <summary>
        /// Retrieves the selected extension type.
        /// </summary>
        /// <returns>The currently selected extension type if valid; otherwise, null.</returns>
        /// <exception cref="InvalidOperationException">The selected extension type is invalid.</exception>
        private ExtensionType?GetSelectedExtensionType()
        {
            string value = _types.SelectedValue;

            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            if (!Enum.IsDefined(typeof(ExtensionType), value))
            {
                throw new InvalidOperationException("Selected extension type cannot be null.");
            }
            return(CPConvert.ParseEnum <ExtensionType>(value));
        }
Exemple #2
0
 /// <summary>
 /// Parses and sets properties from values in a query string.
 /// </summary>
 /// <param name="queryString">The query string to parse.</param>
 public void ParseQueryString(NameValueCollection queryString)
 {
     if (queryString != null)
     {
         string view = queryString[ViewParameter];
         try
         {
             this.View = CPConvert.ParseEnum <CmoMailboxView>(queryString[ViewParameter]);
         }
         catch { }
         try
         {
             this.SortType = CPConvert.ParseEnum <CmoMailboxSortType>(queryString[SortByParameter]);
         }
         catch { }
         this.SortDescending = !AscendingSortValue.Equals(queryString[SortDirectionParameter], StringComparison.InvariantCultureIgnoreCase);
     }
 }
Exemple #3
0
        /// <summary>
        /// Raises the <see cref="Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // check if a view is defined
            string viewName = Page.Request.QueryString[CmoMailbox.ViewParameter];

            _view = !string.IsNullOrEmpty(viewName) && Enum.IsDefined(typeof(CmoMailboxView), viewName) ? CPConvert.ParseEnum <CmoMailboxView>(viewName) : CmoMailbox.DefaultView;
        }
Exemple #4
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);
 }