Exemplo n.º 1
0
 /// <summary>
 /// Updates this instance in the persistence storage medium by overwriting the existing record.
 /// </summary>
 /// <param name="settings">The settings to update.</param>
 /// <returns>true if this instance was saved successfuly; otherwise, false.</returns>
 public bool Update(CmoSettings settings)
 {
     using (DataClient client = new DataClient())
     {
         return(client.UpdateCmoSettings(settings));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Saves a CMO message in the persistence storage medium by overwriting the existing record.
 /// </summary>
 /// <param name="settings">The CMO settings to update.</param>
 /// <returns>true if this instance was saved successfuly; otherwise, false.</returns>
 public bool Update(CmoSettings settings)
 {
     if (settings == null)
     {
         return(false);
     }
     using (CmoSettingsTableAdapter ta = new CmoSettingsTableAdapter())
     {
         return((Convert.ToInt32(ta.SetData(settings.CandidateID, settings.IsPaperless, settings.UpdaterUserName, settings.Version)) > 0) ? true : false);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Converts data from a persistence storage record into its CMO settings equivalent. A return value indicates whether the operation succeeded.
 /// </summary>
 /// <param name="row">A row containing the data to convert.</param>
 /// <param name="settings">When this method returns, contains the CMO settings equivalent to the data contained in <paramref name="row"/>, if the parse succeeded, or null if the parse failed. The parse fails if the <paramref name="row"/> parameter is null or is not of the correct format. This parameter is passed uninitialized.</param>
 /// <returns>true if <paramref name="row"/> was parsed successfully; otherwise, false.</returns>
 private bool TryParse(CmoSettingsTds.CmoSettingsRow row, out CmoSettings settings)
 {
     settings = null;
     if (row != null)
     {
         settings = new CmoSettings(row.CandidateId, row.Version)
         {
             IsPaperless     = row.IsPaperless,
             UpdaterUserName = row.UpdaterUserName,
             UpdatedDate     = row.UpdatedDate,
         };
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Handles the <see cref="Control.OnLoad" /> event that occurs as an instance of the page is being created.
 /// </summary>
 /// <param name="e">An <see cref="EventArgs" /> that contains the event data.</param>
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     Response.Expires = 0;
     Response.Cache.SetCacheability(HttpCacheability.NoCache);
     _settings = CmoSettings.GetSettings(CPProfile.Cid);
     _forceSelectionPanel.Visible = _settings == null;
     // determine which initial view to show depending on paperless setting
     if (!Page.IsPostBack)
     {
         if (_settings == null)
         {
             ShowOptInStart(true);
         }
         else if (_settings.IsPaperless)
         {
             ShowResumePaper();
         }
         else
         {
             ShowOptInStart(false);
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Handles paper delivery setting changes and updates page contents accordingly.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">An <see cref="CommandEventArgs" /> that contains the event data.</param>
        protected void SubmitChange(object sender, CommandEventArgs e)
        {
            if (Page.IsPostBack)
            {
                // check what action was just requested
                switch (e.CommandName)
                {
                case StopPaperCommandName:
                    switch (e.CommandArgument as string)
                    {
                    case StopPaperCommandArgument:
                        // check for verification options and stop paper
                        if (Page.IsValid)
                        {
                            bool success = false;
                            if (_settings == null)
                            {
                                _settings = CmoSettings.Add(CPProfile.Cid, true, User.Identity.Name);
                                success   = _settings != null;
                            }
                            else
                            {
                                _settings.IsPaperless     = true;
                                _settings.UpdaterUserName = User.Identity.Name;
                                success = _settings.Update();
                            }
                            if (success)
                            {
                                ShowPaperStopped();
                            }
                            else
                            {
                                this.ShowSaveError();
                            }
                        }
                        else
                        {
                            _validationSummary.Visible = true;
                        }
                        break;

                    default:
                        // show verification options
                        ShowStopPaperVerification();
                        break;
                    }
                    break;

                case ResumePaperCommandName:
                    // resume paper
                    if (_settings == null)
                    {
                        _settings = CmoSettings.Add(CPProfile.Cid, false, User.Identity.Name);
                        if (_settings != null)
                        {
                            ShowDeferComplete();
                        }
                        else
                        {
                            this.ShowSaveError();
                        }
                    }
                    else
                    {
                        _settings.IsPaperless     = false;
                        _settings.UpdaterUserName = User.Identity.Name;
                        if (_settings.Update())
                        {
                            ShowPaperResumed();
                        }
                        else
                        {
                            this.ShowSaveError();
                        }
                    }
                    break;
                }
                // TODO: send confirmation e-mail
                CPMailMessage message = new CPMailMessage();
                MailAddress   email   = CPProfile.GetMailAddress();
                message.Recipient = email;
                message.Subject   = _emailSubject;
                message.Body      = string.Format(_optInBodyFormat, email.DisplayName, CPProviders.SettingsProvider.ApplicationName, CPApplication.SiteUrl);
                //message.Send();
            }
        }