Exemple #1
0
        private void SendMail(MailMessage msg)
        {
            SmtpClient client = new SmtpClient(LocalUser.GetPropertyValue(SystemProperties.SMTP_SERVER));

            client.Credentials = new NetworkCredential(LocalUser.GetPropertyValue(SystemProperties.SMTP_LOGIN),
                                                       LocalUser.GetPropertyValue(SystemProperties.SMTP_PASSWORD));
            client.Send(msg);
        }
Exemple #2
0
        private void LoadLoginView()
        {
            CheckBoxAllowIntranet.Checked = LocalUser.GetPropertyValue(SystemProperties.SESSION_ALLOW_INTRANET) == SystemProperties.SESSION_TRUE;
            CheckBoxAllowPublic.Checked   = LocalUser.GetPropertyValue(SystemProperties.SESSION_ALLOW_PUBLIC) == SystemProperties.SESSION_TRUE;
            TextBoxFrom.Text          = LocalUser.GetPropertyValue(SystemProperties.SMTP_FROM);
            TextBoxSmtpServer.Text    = LocalUser.GetPropertyValue(SystemProperties.SMTP_SERVER);
            TextBoxSmtpLogin.Text     = LocalUser.GetPropertyValue(SystemProperties.SMTP_LOGIN);
            TextBoxLocalNetworks.Text = LocalUser.GetPropertyValue(SystemProperties.SESSION_LOCAL_NETWORKS);

            TextBoxRegMailContext.Text = LocalUser.GetPropertyValue(SystemProperties.REGISTER_MAIL);
            TextBoxRegRestore.Text     = LocalUser.GetPropertyValue(SystemProperties.RESTORE_MAIL);
        }
Exemple #3
0
        private void SendActivationMail(string mailTo, string code, string userName)
        {
            MailMessage msg = new MailMessage(LocalUser.GetPropertyValue(SystemProperties.SMTP_FROM), mailTo);

            msg.Subject = "Активация аккаунта";
            string        url  = Request.Url + "?Activate=" + code;
            string        href = String.Format("<a href=\"{0}\">{0}</a>", url);
            AlternateView av   = AlternateView.CreateAlternateViewFromString(String.Format(LocalUser.GetPropertyValue(SystemProperties.REGISTER_MAIL), userName, href),
                                                                             null, MediaTypeNames.Text.Html);

            msg.AlternateViews.Add(av);
            msg.IsBodyHtml = true;
            SendMail(msg);
        }
Exemple #4
0
        private bool IsIntranetTest()
        {
            if (CoreConfiguration.GetPropertyValue(SystemProperties.SESSION_ALLOW_INTRANET) == SystemProperties.SESSION_FALSE)
            {
                return(false);
            }
            if (CoreConfiguration.GetPropertyValue(SystemProperties.SESSION_ALLOW_PUBLIC) == SystemProperties.SESSION_FALSE)
            {
                return(true);
            }
            string userIP = HttpContext.Current.Request.UserHostAddress;

            string[] localNetworks = LocalUser.GetPropertyValue(SystemProperties.SESSION_LOCAL_NETWORKS).Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var network in localNetworks)
            {
                if (userIP.StartsWith(network))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #5
0
        protected void postButton_Click(object sender, EventArgs e)
        {
            var activeView = MultiViewMain.GetActiveView();

            if (activeView == ViewLogin)
            {
                LocalUser.SetPropertyValue(SystemProperties.SESSION_ALLOW_INTRANET, CheckBoxAllowIntranet.Checked ? SystemProperties.SESSION_TRUE : SystemProperties.SESSION_FALSE);
                LocalUser.SetPropertyValue(SystemProperties.SESSION_ALLOW_PUBLIC, CheckBoxAllowPublic.Checked ? SystemProperties.SESSION_TRUE : SystemProperties.SESSION_FALSE);

                LocalUser.SetPropertyValue(SystemProperties.SMTP_FROM, TextBoxFrom.Text.Trim());
                LocalUser.SetPropertyValue(SystemProperties.SMTP_SERVER, TextBoxSmtpServer.Text.Trim());
                LocalUser.SetPropertyValue(SystemProperties.SMTP_LOGIN, TextBoxSmtpLogin.Text.Trim());
                if (TextBoxSmtpPassword.Text.Trim() != String.Empty)
                {
                    LocalUser.SetPropertyValue(SystemProperties.SMTP_PASSWORD, TextBoxSmtpPassword.Text);
                }
                if (LocalUser.GetPropertyValue(SystemProperties.SESSION_LOCAL_NETWORKS) != TextBoxLocalNetworks.Text.Trim())
                {
                    LocalUser.SetPropertyValue(SystemProperties.SESSION_LOCAL_NETWORKS, TextBoxLocalNetworks.Text.Trim());
                }

                LocalUser.SetPropertyValue(SystemProperties.REGISTER_MAIL, TextBoxRegMailContext.Text.Trim());
                LocalUser.SetPropertyValue(SystemProperties.RESTORE_MAIL, TextBoxRegRestore.Text.Trim());
            }
            else if (activeView == ViewAnonym)
            {
                string value = String.Empty;
                if (radioButtonNone.Checked)
                {
                    value = "-1";
                }
                else if (radioButtonAll.Checked)
                {
                    value = "0";
                }
                else
                {
                    TestorTreeItem selFolder = (ViewState["SelectedFolder"] as TestorTreeItem);
                    if (selFolder == null)
                    {
                        value = "-1";
                    }
                    else
                    {
                        value = selFolder.ItemId.ToString();
                    }
                }
                LocalUser.HelperService.SetPropertyValue(SystemProperties.ANONYMOUS_POLICY, value);
            }
            else if (activeView == ViewUserDetails)
            {
                if (TextBoxPassword.Text != String.Empty || TextBoxSecondPassword.Text != String.Empty)
                {
                    if (TextBoxPassword.Text != TextBoxSecondPassword.Text)
                    {
                        aspErrorMessage.Text    = "Пароли не совпадают";
                        aspErrorMessage.Visible = true;
                        return;
                    }
                    else
                    {
                        using (DataClassesTestorCoreDataContext dataContext = new DataClassesTestorCoreDataContext(TestorSecurityProvider.ConnectionString))
                        {
                            var user = dataContext.Users.Where(c => c.UserId == (int)GridViewUsers.SelectedValue).FirstOrDefault();
                            if (user == null || user.UserRole != (short)TestorUserRole.Student)
                            {
                                aspErrorMessage.Text    = "Ошибка. Не выбран пользователь";
                                aspErrorMessage.Visible = true;
                                return;
                            }
                            user.Password = TextBoxPassword.Text;
                            dataContext.SubmitChanges();
                        }
                    }
                }
            }
            changesIndicator.Text    = String.Format(" Изменения сохранены [{0}]", DateTime.Now.ToShortTimeString());
            changesIndicator.Visible = true;
        }