Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Master.PageTitle = "Blog";
                if (CurrentAnnouncement == 0)
                {
                    LoadCircularsPublic();
                    LoadCircularsGroup();
                    uiPanelViewAll.Visible = true;
                    uiPanelCurrent.Visible = false;
                }
                else
                {
                    LoadCurrent();
                    uiPanelViewAll.Visible = false;
                    uiPanelCurrent.Visible = true;
                }
                MarkNotificationsAsRead();

                UsersProfiles userProf = new UsersProfiles();
                userProf.getUserByGUID(new Guid(Membership.GetUser(Page.User.Identity.Name).ProviderUserKey.ToString()));

                Groups grps = new Groups();
                grps.LoadByPrimaryKey(userProf.GroupID);
                lblTabGroup.Text = grps.GroupName + " Blogs";
            }
        }
        public void GetAvalName(string term)
        {
            UsersProfiles upro = new UsersProfiles();
            upro.getNamesList(term);

            List<NameListDetails> Nms = upro.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new NameListDetails
                {
                    label = row["FullName"].ToString(),
                    value = row["Email"].ToString()
                };

            }).ToList();

            SetContentResult(Nms);
        }
        protected void LinkButtonSendNotifications_Click(object sender, EventArgs e)
        {
            uiPanelSuccess.Visible = false;
            UsersProfiles up = new UsersProfiles();
            Groups gr = new Groups();
            List<string> GroupIDs = CheckBoxListGroups.Items.Cast<ListItem>()
                .Where(li => li.Selected)
                .Select(li => li.Value)
                .ToList();

            if(GroupIDs.Count>0)
                up.getuserEmails(GroupIDs);
            try
            {
                MailMessage msg = new MailMessage();
                string mail = GetLocalResourceObject("FromMail").ToString();
                for (int i = 0; i < up.RowCount; i++)
                {
                    msg.To.Add(up.Email);
                    up.MoveNext();
                }
                if (!string.IsNullOrEmpty(uiHiddenFieldmails.Value))
                    msg.To.Add(uiHiddenFieldmails.Value);
                msg.From = new MailAddress(mail);
                msg.Subject = GetLocalResourceObject("subject").ToString();
                msg.IsBodyHtml = true;
                msg.BodyEncoding = System.Text.Encoding.UTF8;
                msg.Body = uiRadEditorContnet.GetHtml(Telerik.Web.UI.EditorStripHtmlOptions.None);
                SmtpClient client = new SmtpClient(GetLocalResourceObject("Server").ToString(), Convert.ToInt32(GetLocalResourceObject("Port").ToString()));
                //SmtpClient client = new SmtpClient(GetLocalResourceObject("server").ToString(), 25);
                client.EnableSsl = false;
                client.UseDefaultCredentials = false;
                client.Credentials = new System.Net.NetworkCredential(mail, GetLocalResourceObject("Password").ToString());
                client.Send(msg);
                uiPanelSuccess.Visible = true;

            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #4
0
 private void LoadProfile()
 {
     try
     {
         if (userKey != null)
         {
             UsersProfiles up = new UsersProfiles();
             up.getUserByGUID(new Guid(userKey.ToString()));
             if (!up.IsColumnNull(UsersProfiles.ColumnNames.Photo))
                 userImg.Src = up.Photo;
             uiLabelFullName.Text = up.FullName;
             uiLabelEmail.Text = up.Email;
             uiLabelTele.Text = up.Telephone;
             uiLabelUsername.Text = Membership.GetUser(new Guid(userKey)).UserName;
             if(!up.IsColumnNull(UsersProfiles.ColumnNames.GroupID))
                 DropDownListGroups.SelectedValue = up.GroupID.ToString();
             uiLabelRoles.Text = string.Join(" - ", Roles.GetRolesForUser(Membership.GetUser(new Guid(userKey)).UserName));
         }
         else
         {
             UsersProfiles up = new UsersProfiles();
             up.getUserByGUID(new Guid(Membership.GetUser().ProviderUserKey.ToString()));
             if (!up.IsColumnNull(UsersProfiles.ColumnNames.Photo))
                 userImg.Src = up.Photo;
             uiLabelFullName.Text = up.FullName;
             uiLabelEmail.Text = up.Email;
             uiLabelTele.Text = up.Telephone;
             uiLabelUsername.Text = Membership.GetUser(new Guid(Membership.GetUser().ProviderUserKey.ToString())).UserName;
             if (!up.IsColumnNull(UsersProfiles.ColumnNames.GroupID))
                 DropDownListGroups.SelectedValue = up.GroupID.ToString();
             uiLabelRoles.Text = string.Join(" - ", Roles.GetRolesForUser(Membership.GetUser().UserName));
         }
     }
     catch (Exception)
     {
         Response.Redirect("~/dashboard.aspx");
     }
 }
Example #5
0
        private void LoadCircularsGroup()
        {
            UsersProfiles userProf = new UsersProfiles();
            userProf.getUserByGUID(new Guid(Membership.GetUser(Page.User.Identity.Name).ProviderUserKey.ToString()));

            Announcement all = new Announcement();
            all.GetAllBlogsGroups(userProf.GroupID);
            uiRadListViewCircularsGroup.DataSource = all.DefaultView;
            uiRadListViewCircularsGroup.DataBind();
        }
        protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            if (CurrentUser != null)
            {
                //CurrentUser.Email = uiTextBoxMail.Text;
                List<string> stringListToAdd = new List<string>();
                List<string> stringListToRemove = new List<string>();

                if (!CurrentUser.IsLockedOut)
                {
                    if (CurrentUser.GetPassword() != uiTextBoxPass.Text && !string.IsNullOrEmpty(uiTextBoxPass.Text))
                    {
                        CurrentUser.ChangePassword(CurrentUser.GetPassword(), uiTextBoxPass.Text);
                    }
                }

                foreach (ListItem item in uiCheckBoxListRoles.Items)
                {
                    if (item.Selected)
                    {
                        if (!Roles.IsUserInRole(CurrentUser.UserName, item.Text))
                        {
                            stringListToAdd.Add(item.Text);
                        }
                    }
                    else
                    {
                        if (Roles.IsUserInRole(CurrentUser.UserName, item.Text))
                        {
                            stringListToRemove.Add(item.Text);
                        }
                    }
                }

                string[] stringArrayToAdd = stringListToAdd.ToArray();
                string[] stringArrayToRemove = stringListToRemove.ToArray();
                if (stringArrayToAdd.Length > 0)
                    Roles.AddUserToRoles(CurrentUser.UserName, stringArrayToAdd);
                if (stringArrayToRemove.Length > 0)
                    Roles.RemoveUserFromRoles(CurrentUser.UserName, stringArrayToRemove);

                //
                UsersProfiles usPr = new UsersProfiles();
                usPr.getUserByGUID(new Guid(CurrentUser.ProviderUserKey.ToString()));

                usPr.FullName = txtFullName.Text;
                usPr.Email = txtEmail.Text;
                usPr.Telephone = txtTelephone.Text;
                usPr.GroupID = int.Parse(DropDownListGroups.SelectedValue);
                if (fileUploadPhoto.HasFile)
                {
                    Bitmap UpImg = (Bitmap)Bitmap.FromStream(fileUploadPhoto.PostedFile.InputStream);
                    string path = "/FileUploads/ProfilePics/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + fileUploadPhoto.FileName;
                    UpImg.Save(MapPath(path), System.Drawing.Imaging.ImageFormat.Png);
                    usPr.Photo= path;
                }
                usPr.Save();
            }
            else
            {
                List<string> stringListToAdd = new List<string>();
                MembershipCreateStatus obj;
                MembershipUser objUser = Membership.CreateUser(uiTextBoxUserName.Text, uiTextBoxPass.Text, "*****@*****.**", null, null, true, out obj);
                bool success = true;
                switch (obj)
                {
                    case MembershipCreateStatus.DuplicateUserName:
                        uiLabelError.Text = "duplicate username";
                        uiLabelError.Visible = true;
                        success = false;
                        break;
                    case MembershipCreateStatus.InvalidPassword:
                        uiLabelError.Text = "invalid password. password must be (6) characters or more.";
                        uiLabelError.Visible = true;
                        success = false;
                        break;
                    case MembershipCreateStatus.ProviderError:
                    case MembershipCreateStatus.UserRejected:
                        uiLabelError.Text = "an error occurred. please try again.";
                        uiLabelError.Visible = true;
                        success = false;
                        break;
                    default:
                        break;
                }
                if (success)
                {
                    foreach (ListItem item in uiCheckBoxListRoles.Items)
                    {
                        if (item.Selected)
                        {
                            if (!Roles.IsUserInRole(objUser.UserName, item.Text))
                            {
                                stringListToAdd.Add(item.Text);
                            }
                        }
                    }
                    string[] stringArrayToAdd = stringListToAdd.ToArray();
                    if (stringArrayToAdd.Length > 0)
                        Roles.AddUserToRoles(objUser.UserName, stringArrayToAdd);

                    //

                    UsersProfiles usPr = new UsersProfiles();
                    usPr.AddNew();
                    usPr.UserID = new Guid(objUser.ProviderUserKey.ToString());
                    usPr.FullName = txtFullName.Text;
                    usPr.Email = txtEmail.Text;
                    usPr.Telephone = txtTelephone.Text;
                    usPr.GroupID = int.Parse(DropDownListGroups.SelectedValue);
                    if (fileUploadPhoto.HasFile)
                    {
                        Bitmap UpImg = (Bitmap)Bitmap.FromStream(fileUploadPhoto.PostedFile.InputStream);
                        string path = "/FileUploads/ProfilePics/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + fileUploadPhoto.FileName;
                        UpImg.Save(MapPath(path), System.Drawing.Imaging.ImageFormat.Png);
                        usPr.Photo = path;
                    }
                    usPr.Save();
                }
            }
            uiPanelEdit.Visible = false;

            uiPanelAll.Visible = true;
            ClearFields();
            CurrentUser = null;
            BindData();
        }
 private void SearchByText()
 {
     UsersProfiles up = new UsersProfiles();
     up.SearchByText(uiTextBoxSearch.Text);
     uiRadGridUsers.DataSource = up.DefaultView;
     uiRadGridUsers.DataBind();
 }
        protected void uiRadGridUsers_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "EditUser")
            {
                MembershipUser ObjData = Membership.GetUser(e.CommandArgument.ToString());
                uiTextBoxUserName.Text = ObjData.UserName;
                uiTextBoxUserName.Enabled = false;
                if(!ObjData.IsLockedOut)
                    uiTextBoxPass.Text = ObjData.GetPassword();
                //uiTextBoxPass.Enabled = false;
               // uiCheckBoxIsLocked.Checked = ObjData.IsLockedOut;
                RequiredFieldValidator2.Enabled = false;
                RequiredFieldValidator6.Enabled = false;
                CompareValidator1.Enabled = false;
                uiTextBoxConfirm.Enabled = false;
                //uiLinkButtonEditPassword.Enabled = true;
                //uiTextBoxMail.Text = ObjData.Email;
                foreach (string role in Roles.GetRolesForUser(ObjData.UserName))
                {
                    foreach (ListItem item in uiCheckBoxListRoles.Items)
                    {
                        if (role == item.Text)
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                }
                uiPanelEdit.Visible = true;
                uiPanelAll.Visible = false;

                UsersProfiles usPr = new UsersProfiles();
                usPr.getUserByGUID(new Guid(ObjData.ProviderUserKey.ToString()));
                txtFullName.Text = usPr.FullName;
                txtEmail.Text = usPr.Email;
                txtTelephone.Text = usPr.Telephone;
                if (!usPr.IsColumnNull(UsersProfiles.ColumnNames.Photo))
                    userImg.Src = usPr.Photo;
                if (!usPr.IsColumnNull(UsersProfiles.ColumnNames.GroupID))
                    DropDownListGroups.SelectedValue = usPr.GroupID.ToString();

                CurrentUser = ObjData;

            }
            else if (e.CommandName == "DeleteUser")
            {
                MembershipUser ObjData = Membership.GetUser(e.CommandArgument.ToString());
                if (ObjData != null)
                {
                    UsersProfiles usPr = new UsersProfiles();
                    usPr.getUserByGUID(new Guid(ObjData.ProviderUserKey.ToString()));
                    usPr.MarkAsDeleted();
                    usPr.Save();

                    Membership.DeleteUser(ObjData.UserName, true);
                }
                BindData();
            }
        }