Example #1
0
        /// <summary>
        /// Speichert einen vom Administrator geänderten Eintrag.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnEditSave(object sender, System.EventArgs e)
        {
            // TODO: Aktuellen Eintrag speichern.
            string id = ((Portal.API.Controls.LinkButton)sender).CommandArgument;

            GuestbookData data = ReadData();

            GuestbookData.GuestbookRow row = (GuestbookData.GuestbookRow)data.Guestbook.Select("ID = '" + id + "'")[0];
            row.Name    = HttpUtility.HtmlEncode(m_FromTB.Text);
            row.Email   = HttpUtility.HtmlEncode(m_EmailTB.Text);
            row.Url     = HttpUtility.HtmlEncode(m_UrlTB.Text);
            row.Title   = HttpUtility.HtmlEncode(m_TitleTB.Text);
            row.Message = HttpUtility.HtmlEncode(m_MessageTB.Text).Replace("\n", "<br/>");
            row.Comment = HttpUtility.HtmlEncode(m_CommentTB.Text).Replace("\n", "<br/>");
            WriteData(data);

            // Die Darstellung wird auf "Benutzermodus" gesetzt.
            SetVisualMode(false);

            // Zurücksetzen der Eingabefelder.
            Clear();

            // Darstellen der Gästebuchdaten mit Hilfe des Repeaters.
            Bind();
        }
Example #2
0
 /// <summary>
 ///  Schreibt die Daten des Gästebuches.
 /// </summary>
 /// <param name="data"></param>
 override public void WriteData(GuestbookData data)
 {
     try
     {
         data.WriteXml(GuestbookConfigFile);
     }
     catch (Exception e)
     {
         // Do not throw exceptions
         Trace.Warn("Module", "Error writing Modules Config Dataset", e);
     }
 }
Example #3
0
        /// <summary>
        /// Fügt den Eintrag ins Gästebuch ein.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnAdd(Object sender, EventArgs args)
        {
            try
            {
                // Prüfen, ob gültige Daten vorliegen. Falls nicht, speichern wir den eintrag nicht ab.
                m_MessageTB.Text = m_MessageTB.Text.Trim();
                if (m_MessageTB.Text == "")
                {
                    return;
                }
                m_FromTB.Text = m_FromTB.Text.Trim();
                if (m_FromTB.Text == "")
                {
                    return;
                }

                // Speichern des Eintrages.
                GuestbookData data             = ReadData();
                GuestbookData.GuestbookRow row = data.Guestbook.NewGuestbookRow();
                row.Created = DateTime.Now;
                row.Name    = HttpUtility.HtmlEncode(m_FromTB.Text);
                row.Email   = HttpUtility.HtmlEncode(m_EmailTB.Text);
                row.Url     = HttpUtility.HtmlEncode(m_UrlTB.Text.Trim());
                if ((((string)row.Url).Length > 0) && !((string)row.Url).StartsWith("http://"))
                {
                    row.Url = "http://" + (string)row.Url;
                }
                row.Title   = HttpUtility.HtmlEncode(m_TitleTB.Text);
                row.Message = HttpUtility.HtmlEncode(m_MessageTB.Text).Replace("\n", "<br/>");
                row.Id      = Guid.NewGuid();
                row.Comment = "";

                data.Guestbook.Rows.Add(row);
                WriteData(data);

                // Wenn gewünscht, senden wir hier ein Notifizierungsmail.
                if ((bool)m_ConfigData.Tables["Guestbook"].Rows[0]["SendNotification"])
                {
                    SendMail();
                }

                // Zurücksetzen der Eingabefelder.
                Clear();

                // Darstellen der Gästebuchdaten mit Hilfe des Repeaters.
                Bind();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Example #4
0
        /// <summary>
        /// Verbindet den Repeater mit den Gästebuchdaten.
        /// </summary>
        private void Bind()
        {
            // Die Felder für die Eingabe von Email und URL werden nur bei Bedarf dargestellt.
            m_EmailTR.Visible = ((bool)m_ConfigData.Tables["Guestbook"].Rows[0]["UseEmail"]);
            m_UrlTR.Visible   = ((bool)m_ConfigData.Tables["Guestbook"].Rows[0]["UseUrl"]);

            // Schema exists - cannot be null!
            GuestbookData data = ReadData();

            // Abfüllen der Tabelle.
            data.Guestbook.DefaultView.Sort = "Created DESC";
            DataGrid.DataSource             = data.Guestbook.DefaultView;
            DataGrid.DataBind();
        }
Example #5
0
        /// <summary>
        /// Liest das Guestbook-File.
        /// </summary>
        /// <returns>
        /// Null, falls das Guestbook-File nicht existiert oder kein Schema verfügbar ist.
        /// Existiert ein Schema, wird es gelesen und ein leeres Datenset zurückgegeben.
        /// </returns>
        override public GuestbookData ReadData()
        {
            GuestbookData data = new GuestbookData();

            try
            {
                if (System.IO.File.Exists(GuestbookConfigFile))
                {
                    data.ReadXml(GuestbookConfigFile);
                }
            }
            catch (Exception e)
            {
                // Do not throw exceptions
                Trace.Warn("Module", "Error loading Guestbook data as Dataset", e);
                return(null);
            }

            return(data);
        }
Example #6
0
        /// <summary>
        /// Bearbeiten des gewählten Eintrages.
        /// </summary>
        /// <param name="id"></param>
        private void OnEdit(Guid id)
        {
            // Setzen der ID als CommandArgument des Speicher-Buttons.
            m_EditSaveBtn.CommandArgument = id.ToString();

            GuestbookData data = ReadData();

            GuestbookData.GuestbookRow row = (GuestbookData.GuestbookRow)data.Guestbook.Select("ID = '" + id + "'")[0];
            m_FromTB.Text    = HttpUtility.HtmlDecode(row.Name);
            m_EmailTB.Text   = HttpUtility.HtmlDecode(row.Email);
            m_UrlTB.Text     = HttpUtility.HtmlDecode(row.Url);
            m_TitleTB.Text   = HttpUtility.HtmlDecode(row.Title);
            m_MessageTB.Text = HttpUtility.HtmlDecode(row.Message.Replace("<br/>", "\n"));
            if (!string.IsNullOrEmpty(row.Comment))
            {
                m_CommentTB.Text = HttpUtility.HtmlDecode(row.Comment.Replace("<br/>", "\n"));
            }

            // Die Darstellung wird auf "Editmodus" gesetzt.
            SetVisualMode(true);
        }
Example #7
0
        void OnItemCommand(object sender, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                GuestbookData data = ReadData();
                foreach (GuestbookData.GuestbookRow row in data.Guestbook.Rows)
                {
                    if (row.Id == new Guid((string)e.CommandArgument))
                    {
                        row.Delete();
                        WriteData(data);
                        break;
                    }
                }

                // Darstellen der Gästebuchdaten mit Hilfe des Repeaters.
                Bind();
            }
            else if (e.CommandName == "Edit")
            {
                OnEdit(new Guid((string)e.CommandArgument));
            }
        }
 /// <summary>
 ///  Schreibt die Daten des Gästebuches.
 /// </summary>
 /// <param name="data"></param>
 override public void WriteData(GuestbookData data)
 {
     try
     {
         data.WriteXml(GuestbookConfigFile);
     }
     catch (Exception e)
     {
         // Do not throw exceptions
         Trace.Warn("Module", "Error writing Modules Config Dataset", e);
     }
 }
        /// <summary>
        /// Liest das Guestbook-File.
        /// </summary>
        /// <returns>
        /// Null, falls das Guestbook-File nicht existiert oder kein Schema verfügbar ist.
        /// Existiert ein Schema, wird es gelesen und ein leeres Datenset zurückgegeben.
        /// </returns>
        override public GuestbookData ReadData()
        {
            GuestbookData data = new GuestbookData();
            try
            {
                if (System.IO.File.Exists(GuestbookConfigFile))
                {
                    data.ReadXml(GuestbookConfigFile);
                }
            }
            catch (Exception e)
            {
                // Do not throw exceptions
                Trace.Warn("Module", "Error loading Guestbook data as Dataset", e);
                return null;
            }

            return data;
        }
Example #10
0
 abstract public void WriteData(GuestbookData ds);
Example #11
0
 abstract public void WriteData(GuestbookData ds);