protected void Page_Load(object sender, EventArgs e)
        {
            // Die Daten abfüllen, bzw. aus dem Viewstate laden.
            if (!ControlPostback)
            {
                // Lokalisierung der Spaltentitel.
                foreach (DataControlField column in _fieldValidators.Columns)
                {
                    column.HeaderText = Portal.API.Language.GetText(this, column.HeaderText);
                }

                // Daten abfüllen.
                ModuleConfig config = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (config == null)
                {
                    config = new ModuleConfig();
                }

                _validators = config.FormValidation;
                ViewState["ValidatorData"] = _validators;
            }
            else
            {
                _validators = (List <ModuleConfig.ValidationData>)ViewState["ValidatorData"];
            }

            _fieldValidators.DataSource = _validators;
            _fieldValidators.DataBind();
        }
Ejemplo n.º 2
0
        protected void Save()
        {
            lock (ModuleConfig.ConfigLock)
            {
                ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (cfg == null)
                {
                    cfg = new ModuleConfig();
                }

                cfg.SendEmail                  = _sendEmailCheck.Checked;
                cfg.EmailConfig.Server         = _serverEdit.Text;
                cfg.EmailConfig.ServerNeedAuth = _serverNeedAuthCheck.Checked;
                cfg.EmailConfig.LoginUser      = _userNameEdit.Text;
                if (!string.IsNullOrEmpty(_passwordEdit.Text))
                {
                    cfg.EmailConfig.LoginPassword = _passwordEdit.Text;
                }
                cfg.EmailConfig.Sender     = _senderEdit.Text;
                cfg.EmailConfig.Subject    = _subjectEdit.Text;
                cfg.EmailConfig.Body       = _body.Text;
                cfg.EmailConfig.BodyIsHtml = _bodyAsHtmlCheck.Checked;

                cfg.EmailConfig.ToRecipient.Clear();
                string[] allAddress = _toEdit.Text.Split(';');
                foreach (string address in allAddress)
                {
                    string trimAddress = address.Trim();
                    if (!string.IsNullOrEmpty(trimAddress))
                    {
                        cfg.EmailConfig.ToRecipient.Add(trimAddress);
                    }
                }

                cfg.EmailConfig.CcRecipient.Clear();
                allAddress = _ccEdit.Text.Split(';');
                foreach (string address in allAddress)
                {
                    string trimAddress = address.Trim();
                    if (!string.IsNullOrEmpty(trimAddress))
                    {
                        cfg.EmailConfig.CcRecipient.Add(trimAddress);
                    }
                }

                cfg.EmailConfig.BccRecipient.Clear();
                allAddress = _bccEdit.Text.Split(';');
                foreach (string address in allAddress)
                {
                    string trimAddress = address.Trim();
                    if (!string.IsNullOrEmpty(trimAddress))
                    {
                        cfg.EmailConfig.BccRecipient.Add(trimAddress);
                    }
                }

                WriteConfig(cfg);
            }
        }
Ejemplo n.º 3
0
        private ModuleConfig LoadConfig()
        {
            ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));

            if (cfg == null)
            {
                cfg = new ModuleConfig();
            }
            return(cfg);
        }
    protected void Save()
    {
      lock (ModuleConfig.ConfigLock)
      {
        ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
        if (cfg == null)
          cfg = new ModuleConfig();

        cfg.FormContent = FCKeditor1.Value;

        WriteConfig(cfg);
      }
    }
    protected void Save()
    {
      lock (ModuleConfig.ConfigLock)
      {
        ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
        if (cfg == null)
          cfg = new ModuleConfig();

        cfg.SuccessContent = FCKeditor1.Value;
        cfg.ShowSuccessPage = _showSuccess.Checked;

        WriteConfig(cfg);
      }
    }
Ejemplo n.º 6
0
        protected void Save()
        {
            lock (ModuleConfig.ConfigLock)
            {
                ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (cfg == null)
                {
                    cfg = new ModuleConfig();
                }

                cfg.FormContent = FCKeditor1.Value;

                WriteConfig(cfg);
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
   // FCK Editor konfigurieren.
   string applicationDir = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
   FCKeditor1.BasePath = Path.Combine(applicationDir, "FCKeditor/");
   FCKeditor1.EditorAreaCSS = Portal.Helper.CssEditPath;
   if (!ControlPostback)
   {
     // Daten abfüllen.
     ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
     if (cfg == null)
       cfg = new ModuleConfig();
     FCKeditor1.Value = cfg.FormContent;
   }
 }
    protected void OnSave(object sender, EventArgs e)
    {
      lock (ModuleConfig.ConfigLock)
      {
        // Bestehende Konfiguration einlesen.
        ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
        if (cfg == null)
          cfg = new ModuleConfig();

        cfg.FormValidation = _validators;
        
        WriteConfig(cfg);
      }

      ProcessEvent((int)StateEvent.Save);
    }
        protected void Save()
        {
            lock (ModuleConfig.ConfigLock)
            {
                ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (cfg == null)
                {
                    cfg = new ModuleConfig();
                }

                cfg.SuccessContent  = FCKeditor1.Value;
                cfg.ShowSuccessPage = _showSuccess.Checked;

                WriteConfig(cfg);
            }
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // FCK Editor konfigurieren.
            string applicationDir = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;

            FCKeditor1.BasePath      = Path.Combine(applicationDir, "FCKeditor/");
            FCKeditor1.EditorAreaCSS = Portal.Helper.CssEditPath;
            if (!ControlPostback)
            {
                // Daten abfüllen.
                ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (cfg == null)
                {
                    cfg = new ModuleConfig();
                }
                FCKeditor1.Value = cfg.FormContent;
            }
        }
        protected void OnSave(object sender, EventArgs e)
        {
            lock (ModuleConfig.ConfigLock)
            {
                // Bestehende Konfiguration einlesen.
                ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (cfg == null)
                {
                    cfg = new ModuleConfig();
                }

                cfg.FormValidation = _validators;

                WriteConfig(cfg);
            }

            ProcessEvent((int)StateEvent.Save);
        }
    protected void Save()
    {
      lock (ModuleConfig.ConfigLock)
      {
        ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
        if (cfg == null)
          cfg = new ModuleConfig();

        cfg.ErrorContent = FCKeditor1.Value;
        
        // Falls der Platzhalter nicht enthalten ist, wird er vorangestellt.
        if (-1 == cfg.ErrorContent.IndexOf(ModuleConfig.Messageplaceholder))
          cfg.ErrorContent = ModuleConfig.Messageplaceholder + cfg.ErrorContent;

        cfg.CommonErrorMsg = _commonErrorMsg.Text;

        WriteConfig(cfg);
      }
    }
Ejemplo n.º 13
0
 /// <summary>
 /// Validiert den Request.
 /// </summary>
 /// <param name="cfg"></param>
 /// <param name="validatorId"></param>
 /// <returns></returns>
 private bool ValidateRequest(ModuleConfig cfg, out Guid validatorId)
 {
     foreach (ModuleConfig.ValidationData validatorData in cfg.FormValidation)
     {
         IValidator validatorObj = ValidatorFactory.CreateValidator(validatorData);
         if (validatorObj != null)
         {
             // Wert validieren.
             if (!validatorObj.Validate(Request.Form[validatorData.FieldName]))
             {
                 // Validierung fehlgeschlagen.
                 validatorId = validatorData.Id;
                 return(false);
             }
         }
     }
     validatorId = Guid.Empty;
     return(true);
 }
    protected void Page_Load(object sender, EventArgs e)
    {
       // FCK Editor konfigurieren.
      string applicationDir = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
      FCKeditor1.BasePath = Path.Combine(applicationDir, "FCKeditor/");
      FCKeditor1.EditorAreaCSS = Portal.Helper.CssEditPath;
      if (!ControlPostback)
      {
        // Daten abfüllen.
        ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
        if (cfg == null)
          cfg = new ModuleConfig();

        FCKeditor1.Value = cfg.ErrorContent;
        _commonErrorMsg.Text = cfg.CommonErrorMsg;

        _descriptionLbl.Text = string.Format(Portal.API.Language.GetText(this, "ErrorContentDescription"),
                                             ModuleConfig.Messageplaceholder);
      }
    }
Ejemplo n.º 15
0
 /// <summary>
 /// Erzeugt einen Validator vom entsprechenden Typ.
 /// </summary>
 /// <param name="validatorType"></param>
 /// <returns></returns>
 public static IValidator CreateValidator(ModuleConfig.ValidationData validator)
 {
   switch (validator.FieldType)
   {
   	case ModuleConfig.ValidationData.ValidationType.Text:
       return new ValidatorText(validator);
       break;
   	case ModuleConfig.ValidationData.ValidationType.Email:
       return new ValidatorEmail(validator);
   		break;
     case ModuleConfig.ValidationData.ValidationType.Number:
       return new ValidatorNumber(validator);
       break;
     case ModuleConfig.ValidationData.ValidationType.RegularExpression:
       return new ValidatorRegex(validator);
       break;
   	default:
       return null;
   		break;
   }
 }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // FCK Editor konfigurieren.
            string applicationDir = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;

            FCKeditor1.BasePath      = Path.Combine(applicationDir, "FCKeditor/");
            FCKeditor1.EditorAreaCSS = Portal.Helper.CssEditPath;
            if (!ControlPostback)
            {
                // Daten abfüllen.
                ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (cfg == null)
                {
                    cfg = new ModuleConfig();
                }

                FCKeditor1.Value     = cfg.ErrorContent;
                _commonErrorMsg.Text = cfg.CommonErrorMsg;

                _descriptionLbl.Text = string.Format(Portal.API.Language.GetText(this, "ErrorContentDescription"),
                                                     ModuleConfig.Messageplaceholder);
            }
        }
        protected void OnNameComboDataBind(object sender, EventArgs e)
        {
            DropDownList ddList = ((DropDownList)sender);

            // Verfügbare Felder laden.
            ModuleConfig config = (ModuleConfig)ReadConfig(typeof(ModuleConfig));

            if (config == null)
            {
                config = new ModuleConfig();
            }

            string[] fields = Portal.API.HtmlAnalyzer.GetInputNames(config.FormContent);

            // Falls der gewählte Eintrag nicht mehr existiert, wird der erste Wert ausgewählt.
            ModuleConfig.ValidationData validationData = (ModuleConfig.ValidationData)((GridViewRow)((Control)sender).BindingContainer).DataItem;
            if (null == Array.Find <string>(fields, delegate(string test) { return(test == validationData.FieldName); }))
            {
                ddList.SelectedValue = fields[0];
            }

            ddList.DataSource = fields;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
      // Die Daten abfüllen, bzw. aus dem Viewstate laden.
      if (!ControlPostback)
      {
        // Lokalisierung der Spaltentitel.
        foreach (DataControlField column in _fieldValidators.Columns)
          column.HeaderText = Portal.API.Language.GetText(this, column.HeaderText);

        // Daten abfüllen.
        ModuleConfig config = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
        if (config == null)
          config = new ModuleConfig();

        _validators = config.FormValidation;
        ViewState["ValidatorData"] = _validators;
      }
      else
        _validators = (List<ModuleConfig.ValidationData>) ViewState["ValidatorData"];

      _fieldValidators.DataSource = _validators;
      _fieldValidators.DataBind();
    }
Ejemplo n.º 19
0
        protected void Save()
        {
            lock (ModuleConfig.ConfigLock)
            {
                ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (cfg == null)
                {
                    cfg = new ModuleConfig();
                }

                cfg.ErrorContent = FCKeditor1.Value;

                // Falls der Platzhalter nicht enthalten ist, wird er vorangestellt.
                if (-1 == cfg.ErrorContent.IndexOf(ModuleConfig.Messageplaceholder))
                {
                    cfg.ErrorContent = ModuleConfig.Messageplaceholder + cfg.ErrorContent;
                }

                cfg.CommonErrorMsg = _commonErrorMsg.Text;

                WriteConfig(cfg);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Ermittelt das aktuelle HTML zum anzeigen.
        /// </summary>
        /// <param name="reqState"></param>
        /// <param name="cfg"></param>
        /// <returns></returns>
        private string GetCurrentHtml(FormState reqState, ModuleConfig cfg)
        {
            if (reqState == FormState.Success)
            {
                return(cfg.SuccessContent);
            }
            else
            {
                string html     = cfg.ErrorContent;
                string errorMsg = null;

                // Suche nach dem Validator.
                string Id = Request.QueryString["Id"];
                if (!string.IsNullOrEmpty(Id))
                {
                    Guid validatorId = new Guid(Id);
                    if (Guid.Empty != validatorId)
                    {
                        // Suche den Validator.
                        foreach (ModuleConfig.ValidationData validatorData in cfg.FormValidation)
                        {
                            if (validatorData.Id == validatorId)
                            {
                                errorMsg = validatorData.ErrorMessage;
                                break;
                            }
                        }
                    }
                    if (errorMsg == null)
                    {
                        errorMsg = cfg.CommonErrorMsg;
                    }
                    html = html.Replace(ModuleConfig.Messageplaceholder, errorMsg);
                }
                return(html);
            }
        }
    protected void OnNameComboDataBind(object sender, EventArgs e)
    {
      DropDownList ddList = ((DropDownList)sender);

      // Verfügbare Felder laden.
      ModuleConfig config = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
      if (config == null)
        config = new ModuleConfig();

      string[] fields = Portal.API.HtmlAnalyzer.GetInputNames(config.FormContent);
    
      // Falls der gewählte Eintrag nicht mehr existiert, wird der erste Wert ausgewählt.
      ModuleConfig.ValidationData validationData = (ModuleConfig.ValidationData)((GridViewRow)((Control)sender).BindingContainer).DataItem;
      if (null == Array.Find<string>(fields, delegate(string test) { return test == validationData.FieldName; }))
        ddList.SelectedValue = fields[0];

      ddList.DataSource = fields;
    }
Ejemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!ControlPostback)
            {
                // Konfiguration laden.
                ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
                if (cfg == null)
                {
                    cfg = new ModuleConfig();
                }

                _sendEmailCheck.Checked      = cfg.SendEmail;
                _serverEdit.Text             = cfg.EmailConfig.Server;
                _serverNeedAuthCheck.Checked = cfg.EmailConfig.ServerNeedAuth;
                _userNameEdit.Text           = cfg.EmailConfig.LoginUser;
                _senderEdit.Text             = cfg.EmailConfig.Sender;
                _subjectEdit.Text            = cfg.EmailConfig.Subject;
                _body.Text = cfg.EmailConfig.Body;
                _bodyAsHtmlCheck.Checked = cfg.EmailConfig.BodyIsHtml;

                string allAddress = "";
                foreach (string address in cfg.EmailConfig.ToRecipient)
                {
                    allAddress += address + ";";
                }
                _toEdit.Text = allAddress;

                allAddress = "";
                foreach (string address in cfg.EmailConfig.CcRecipient)
                {
                    allAddress += address + ";";
                }
                _ccEdit.Text = allAddress;

                allAddress = "";
                foreach (string address in cfg.EmailConfig.BccRecipient)
                {
                    allAddress += address + ";";
                }
                _bccEdit.Text = allAddress;

                // Die Namen der Platzhalter in die Liste mit der Auswahl abfüllen.
                string[] placeHolderNames = Portal.API.HtmlAnalyzer.GetInputNames(cfg.FormContent);
                _availablePlaceholder.DataSource = placeHolderNames;
                _availablePlaceholder.DataBind();

                // Die Client-Seitige Aktion zum Hinzufügen eines Platzhalters ermöglichen.
                if (placeHolderNames.Length > 0)
                {
                    string jsInsert = "InsertText('{{' + document.getElementById('{0}').value + '}}', '{1}');return false;";

                    _insertBodyBtn.Enabled       = true;
                    _insertBodyBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _body.ClientID);

                    _insertSubjectBtn.Enabled       = true;
                    _insertSubjectBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _subjectEdit.ClientID);

                    _insertBccBtn.Enabled       = true;
                    _insertBccBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _bccEdit.ClientID);

                    _insertCcBtn.Enabled       = true;
                    _insertCcBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _ccEdit.ClientID);

                    _insertToBtn.Enabled       = true;
                    _insertToBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _toEdit.ClientID);

                    _insertSenderBtn.Enabled       = true;
                    _insertSenderBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _senderEdit.ClientID);
                }
            }

            AddInsertScript();
        }
Ejemplo n.º 23
0
 public ValidatorEmail(ModuleConfig.ValidationData data)
   : base(data)
 {
 }
Ejemplo n.º 24
0
 public ValidatorText(ModuleConfig.ValidationData data)
   : base(data)
 {
 }
    private static void ApplyData(GridViewRow row, ModuleConfig.ValidationData data)
    {
      data.FieldName = ((DropDownList)row.FindControl("_fieldName")).Text;
      data.FieldType = (ModuleConfig.ValidationData.ValidationType)Enum.Parse(typeof(ModuleConfig.ValidationData.ValidationType), ((DropDownList)row.FindControl("_fieldType")).SelectedValue);
      data.ErrorMessage = ((TextBox)row.FindControl("_errorMessage")).Text;
      data.IsMandatory = ((CheckBox)row.FindControl("_mandatoryCheck")).Checked;

      IValidator validatorObj = ValidatorFactory.CreateValidator(data);
      if (validatorObj != null)
        validatorObj.SaveValidatorSettings(row.FindControl("_detailsEdit"));
    }
Ejemplo n.º 26
0
 private ModuleConfig LoadConfig()
 {
   ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
   if (cfg == null)
     cfg = new ModuleConfig();
   return cfg;
 }
Ejemplo n.º 27
0
    /// <summary>
    /// Ermittelt das aktuelle HTML zum anzeigen.
    /// </summary>
    /// <param name="reqState"></param>
    /// <param name="cfg"></param>
    /// <returns></returns>
    private string GetCurrentHtml(FormState reqState, ModuleConfig cfg)
    {
      if(reqState == FormState.Success)
      {
        return cfg.SuccessContent;
      }
      else
      {
        string html = cfg.ErrorContent;
        string errorMsg = null;

        // Suche nach dem Validator.
        string Id = Request.QueryString["Id"];
        if(!string.IsNullOrEmpty(Id))
        {
          Guid validatorId = new Guid(Id);
          if (Guid.Empty != validatorId)
          {
            // Suche den Validator.
            foreach(ModuleConfig.ValidationData validatorData in cfg.FormValidation)
            {
              if (validatorData.Id == validatorId)
              {
                errorMsg = validatorData.ErrorMessage;
                break;
              }
            }
          }
          if (errorMsg == null)
            errorMsg = cfg.CommonErrorMsg;
          html = html.Replace(ModuleConfig.Messageplaceholder, errorMsg);
        }
        return html;
      }
    }
Ejemplo n.º 28
0
 public ValidatorNumber(ModuleConfig.ValidationData data)
   : base(data)
 {
 }
Ejemplo n.º 29
0
 public ValidatorRegex(ModuleConfig.ValidationData data)
   : base(data)
 {
 }
Ejemplo n.º 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FormState reqState = RequestedState;

            // Konfiguration einlesen.
            ModuleConfig cfg = LoadConfig();

            if (reqState == FormState.Form)
            {
                // Wurde das Formular bereits übermittelt?
                if (IsPostBack && IsSubmitted(cfg.FormContent))
                {
                    // Eingabedaten auswerten.
                    Guid errorValidator = Guid.Empty;
                    bool success        = ValidateRequest(cfg, out errorValidator);
                    bool redirect       = true;

                    if (success)
                    {
                        if (cfg.SendEmail)
                        {
                            EmailSender emailSender = new EmailSender();
                            try
                            {
                                emailSender.Process(cfg);
                            }
                            catch (System.Exception ex)
                            {
                                // Falls der Benutzer Edit-Rechte hat, wird die Meldung aus der Exception angezeigt.
                                if (ModuleHasEditRights)
                                {
                                    _content.Text = "Error: " + ex.Message;
                                    redirect      = false;
                                }

                                success = false;
                            }
                        }
                    }

                    if (redirect)
                    {
                        // Falls die Erfolgsseite angezeigt werden soll, wird diese eingeblendet.
                        if (success && cfg.ShowSuccessPage)
                        {
                            _content.Text = cfg.SuccessContent;
                            NavigateTo(FormState.Success);
                        }
                        else if (!success)
                        {
                            _content.Text = cfg.ErrorContent;
                            NavigateTo(FormState.Error, errorValidator);
                        }
                        else
                        {
                            // Die eigene Seite wieder laden, damit die Formulardaten nicht ein zweites mal übermittelt werden können.
                            NavigateTo(FormState.Form);
                        }
                    }
                }
                else
                {
                    // Formular anzeigen.
                    _content.Text = cfg.FormContent;
                }
            }
            else
            {
                // Html ermitteln.
                string html = GetCurrentHtml(reqState, cfg);

                // Wurde bereits die Meldung quittiert?
                if (IsPostBack && IsSubmitted(html))
                {
                    // Zurück zum Formular.
                    NavigateTo(FormState.Form);
                }
                else
                {
                    // Meldung anzeigen.
                    _content.Text = html;
                }
            }
        }
    protected void Save()
    {
      lock (ModuleConfig.ConfigLock)
      {
        ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
        if (cfg == null)
          cfg = new ModuleConfig();

        cfg.SendEmail = _sendEmailCheck.Checked;
        cfg.EmailConfig.Server = _serverEdit.Text;
        cfg.EmailConfig.ServerNeedAuth = _serverNeedAuthCheck.Checked;
        cfg.EmailConfig.LoginUser = _userNameEdit.Text;
        if (!string.IsNullOrEmpty(_passwordEdit.Text))
          cfg.EmailConfig.LoginPassword = _passwordEdit.Text;
        cfg.EmailConfig.Sender = _senderEdit.Text;
        cfg.EmailConfig.Subject = _subjectEdit.Text;
        cfg.EmailConfig.Body = _body.Text;
        cfg.EmailConfig.BodyIsHtml = _bodyAsHtmlCheck.Checked;

        cfg.EmailConfig.ToRecipient.Clear();
        string[] allAddress = _toEdit.Text.Split(';');
        foreach (string address in allAddress)
        {
          string trimAddress = address.Trim();
          if (!string.IsNullOrEmpty(trimAddress))
            cfg.EmailConfig.ToRecipient.Add(trimAddress);
        }

        cfg.EmailConfig.CcRecipient.Clear();
        allAddress = _ccEdit.Text.Split(';');
        foreach (string address in allAddress)
        {
          string trimAddress = address.Trim();
          if (!string.IsNullOrEmpty(trimAddress))
            cfg.EmailConfig.CcRecipient.Add(trimAddress);
        }

        cfg.EmailConfig.BccRecipient.Clear();
        allAddress = _bccEdit.Text.Split(';');
        foreach (string address in allAddress)
        {
          string trimAddress = address.Trim();
          if (!string.IsNullOrEmpty(trimAddress))
            cfg.EmailConfig.BccRecipient.Add(trimAddress);
        }

        WriteConfig(cfg);
      }
    }
Ejemplo n.º 32
0
    /// <summary>
    /// Verarbeitet die Daten.
    /// </summary>
    /// <param name="config">Die Konfiguration zum senden des Emails.</param>
   
    public void Process(ModuleConfig config)
    {
      if (config == null)
        throw new ArgumentNullException("config");

      // Validierung der Konfiguration.
      bool readyToSend = true;

      // Es wird nur eine Email versendet, wenn auch mindestens ein Empfänger angegeben ist.
      readyToSend = readyToSend && (config.EmailConfig.ToRecipient.Count > 0) 
                                || (config.EmailConfig.CcRecipient.Count > 0)
                                || (config.EmailConfig.BccRecipient.Count > 0);

      if (readyToSend)
      {
        // Hilfsobjekt zum ersetzen der Platzhalter erzeugen.
        PlaceholderReplacer.ReplacePlaceholder replaceDelegate =
                                                          new PlaceholderReplacer.ReplacePlaceholder(ReplacePlaceholder);
        PlaceholderReplacer replacer = new PlaceholderReplacer(replaceDelegate);


        try
        {
          // Email konfigurieren.
          MailMessage message = new MailMessage();
          message.From = new MailAddress(replacer.Replace(config.EmailConfig.Sender));

          foreach (string address in config.EmailConfig.ToRecipient)
            message.To.Add(replacer.Replace(address));

          foreach (string address in config.EmailConfig.CcRecipient)
            message.CC.Add(replacer.Replace(address));

          foreach (string address in config.EmailConfig.BccRecipient)
            message.Bcc.Add(replacer.Replace(address));

          message.Subject = replacer.Replace(config.EmailConfig.Subject);

          message.IsBodyHtml = config.EmailConfig.BodyIsHtml;
          message.Body = replacer.Replace(config.EmailConfig.Body);

          // Smtp Client konfigurieren.
          SmtpClient smtpClient = new SmtpClient();
          smtpClient.Host = config.EmailConfig.Server;
          smtpClient.Port = 25;
          if (config.EmailConfig.ServerNeedAuth)
          {
            smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtpClient.Credentials = new NetworkCredential(config.EmailConfig.LoginUser, 
                                                           config.EmailConfig.LoginPassword);
          }

          // Email versenden.
          smtpClient.Send(message);
        }
        catch (Exception ex)
        {
          // TODO: Detailliertere Fehlerbehandlung.
          throw;
        }
      }     
    }
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!ControlPostback)
      {
        // Konfiguration laden.
        ModuleConfig cfg = (ModuleConfig)ReadConfig(typeof(ModuleConfig));
        if (cfg == null)
          cfg = new ModuleConfig();

        _sendEmailCheck.Checked = cfg.SendEmail;
        _serverEdit.Text = cfg.EmailConfig.Server;
        _serverNeedAuthCheck.Checked = cfg.EmailConfig.ServerNeedAuth;
        _userNameEdit.Text = cfg.EmailConfig.LoginUser;
        _senderEdit.Text = cfg.EmailConfig.Sender;
        _subjectEdit.Text = cfg.EmailConfig.Subject;
        _body.Text = cfg.EmailConfig.Body;
        _bodyAsHtmlCheck.Checked = cfg.EmailConfig.BodyIsHtml;

        string allAddress = "";
        foreach(string address in cfg.EmailConfig.ToRecipient)
          allAddress += address + ";";
        _toEdit.Text = allAddress;

        allAddress = "";
        foreach(string address in cfg.EmailConfig.CcRecipient)
          allAddress += address + ";";
        _ccEdit.Text = allAddress;

        allAddress = "";
        foreach(string address in cfg.EmailConfig.BccRecipient)
          allAddress += address + ";";
        _bccEdit.Text = allAddress;

        // Die Namen der Platzhalter in die Liste mit der Auswahl abfüllen.
        string[] placeHolderNames = Portal.API.HtmlAnalyzer.GetInputNames(cfg.FormContent);
        _availablePlaceholder.DataSource = placeHolderNames;
        _availablePlaceholder.DataBind();

        // Die Client-Seitige Aktion zum Hinzufügen eines Platzhalters ermöglichen.
        if(placeHolderNames.Length > 0)
        {
          string jsInsert = "InsertText('{{' + document.getElementById('{0}').value + '}}', '{1}');return false;";

          _insertBodyBtn.Enabled = true;
          _insertBodyBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _body.ClientID);

          _insertSubjectBtn.Enabled = true;
          _insertSubjectBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _subjectEdit.ClientID);

          _insertBccBtn.Enabled = true;
          _insertBccBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _bccEdit.ClientID);

          _insertCcBtn.Enabled = true;
          _insertCcBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _ccEdit.ClientID);

          _insertToBtn.Enabled = true;
          _insertToBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _toEdit.ClientID);

          _insertSenderBtn.Enabled = true;
          _insertSenderBtn.OnClientClick = string.Format(jsInsert, _availablePlaceholder.ClientID, _senderEdit.ClientID);
        }
      }

      AddInsertScript();
    }
Ejemplo n.º 34
0
 /// <summary>
 /// Validiert den Request.
 /// </summary>
 /// <param name="cfg"></param>
 /// <param name="validatorId"></param>
 /// <returns></returns>
 private bool ValidateRequest(ModuleConfig cfg, out Guid validatorId)
 {
   foreach(ModuleConfig.ValidationData validatorData in cfg.FormValidation)
   {
     IValidator validatorObj = ValidatorFactory.CreateValidator(validatorData);
     if(validatorObj != null)
     {
       // Wert validieren.
       if(!validatorObj.Validate(Request.Form[validatorData.FieldName]))
       {
         // Validierung fehlgeschlagen.
         validatorId = validatorData.Id;
         return false;
       }
     }
   }
   validatorId = Guid.Empty;
   return true;
 }
Ejemplo n.º 35
0
        /// <summary>
        /// Verarbeitet die Daten.
        /// </summary>
        /// <param name="config">Die Konfiguration zum senden des Emails.</param>

        public void Process(ModuleConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            // Validierung der Konfiguration.
            bool readyToSend = true;

            // Es wird nur eine Email versendet, wenn auch mindestens ein Empfänger angegeben ist.
            readyToSend = readyToSend && (config.EmailConfig.ToRecipient.Count > 0) ||
                          (config.EmailConfig.CcRecipient.Count > 0) ||
                          (config.EmailConfig.BccRecipient.Count > 0);

            if (readyToSend)
            {
                // Hilfsobjekt zum ersetzen der Platzhalter erzeugen.
                PlaceholderReplacer.ReplacePlaceholder replaceDelegate =
                    new PlaceholderReplacer.ReplacePlaceholder(ReplacePlaceholder);
                PlaceholderReplacer replacer = new PlaceholderReplacer(replaceDelegate);


                try
                {
                    // Email konfigurieren.
                    MailMessage message = new MailMessage();
                    message.From = new MailAddress(replacer.Replace(config.EmailConfig.Sender));

                    foreach (string address in config.EmailConfig.ToRecipient)
                    {
                        message.To.Add(replacer.Replace(address));
                    }

                    foreach (string address in config.EmailConfig.CcRecipient)
                    {
                        message.CC.Add(replacer.Replace(address));
                    }

                    foreach (string address in config.EmailConfig.BccRecipient)
                    {
                        message.Bcc.Add(replacer.Replace(address));
                    }

                    message.Subject = replacer.Replace(config.EmailConfig.Subject);

                    message.IsBodyHtml = config.EmailConfig.BodyIsHtml;
                    message.Body       = replacer.Replace(config.EmailConfig.Body);

                    // Smtp Client konfigurieren.
                    SmtpClient smtpClient = new SmtpClient();
                    smtpClient.Host = config.EmailConfig.Server;
                    smtpClient.Port = 25;
                    if (config.EmailConfig.ServerNeedAuth)
                    {
                        smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                        smtpClient.Credentials    = new NetworkCredential(config.EmailConfig.LoginUser,
                                                                          config.EmailConfig.LoginPassword);
                    }

                    // Email versenden.
                    smtpClient.Send(message);
                }
                catch (Exception ex)
                {
                    // TODO: Detailliertere Fehlerbehandlung.
                    throw;
                }
            }
        }