Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string NewLine = DictionaryHelper.RemoveStressMarks(lemma.Text) + " " + selectedRule.Text;
                int    StressPos;
                string messageText;
                string messageStyle;

                if (String.IsNullOrEmpty(lemma.Text))
                {
                    messageText  = "Введите слово.";
                    messageStyle = "messageError";
                }
                else if (!DictionaryHelper.CheckStressPosition(lemma.Text))
                {
                    messageText  = "Укажите ударение. Например: приве*т.";
                    messageStyle = "messageError";
                }
                else if (!int.TryParse(selectedRule.Text.Substring(0, selectedRule.Text.IndexOfAny(" ,.".ToCharArray())), out StressPos) || StressPos > DictionaryHelper.RemoveStressMarks(lemma.Text).Length)
                {
                    messageText  = "Позиция ударения в правиле превышает длину слова.";
                    messageStyle = "messageError";
                }
                else
                {
                    messageText  = "Статья \"" + NewLine + "\" добавлена в словарь.";
                    messageStyle = "messageSuccess";

                    lemma.Text        = String.Empty;
                    selectedRule.Text = String.Empty;

                    var fileBasedDictionary = new FileBasedDictionary(Server);

                    fileBasedDictionary.AddEntry(NewLine);

                    if (!Debugger.IsAttached)
                    {
                        var mailinglist = "*****@*****.**";

                        new SmtpClient().Send(new MailMessage("*****@*****.**", mailinglist, "Новая статья: " + NewLine,
                                                              string.Join(Environment.NewLine, FormGenerator.GetAccentedFormsWithCorrectCase(NewLine, delegate { })
                                                                          .Select(wordForm => wordForm.AccentedForm))));
                    }
                }

                message.Text = messageText;
                messageContainer.CssClass = "divMessage " + messageStyle;
            }
        }