Esempio n. 1
0
        public UserProfileManager(MembershipUser _user)
        {
            if (_user == null)
            {
                throw new ArgumentNullException("_user");
            }

            UserProfile      newProfile   = new UserProfile(_user.UserName);
            ProfileBase      userProfile  = ProfileBase.Create(_user.UserName);
            ProfileGroupBase addressGroup = userProfile.GetProfileGroup("Address");

            userProfile.Initialize(_user.UserName, true);

            newProfile.Properties.Add(new ProfileProperty("Nome", "Name", userProfile["Name"].ToString()));

            newProfile.Properties.Add(new ProfileProperty("Telefone", "Phone", addressGroup["Phone"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("CEP", "CEP", addressGroup["CEP"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("Endereço", "Street", addressGroup["Street"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("Bairro", "Area", addressGroup["Area"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("Estado", "State", addressGroup["State"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("Cidade", "City", addressGroup["City"].ToString()));

            /*newProfile.Properties.Add(new ProfileProperty("FTP: Host", "FtpHost", ftpInfoGroup["FtpHost"].ToString()));
             * newProfile.Properties.Add(new ProfileProperty("FTP: Usuário", "FtpUserName", ftpInfoGroup["FtpUserName"].ToString()));
             * newProfile.Properties.Add(new ProfileProperty("FTP: Senha", "FtpPassword", ftpInfoGroup["FtpPassword"].ToString()));*/

            this.UserProfile = newProfile;
        }
Esempio n. 2
0
        public IDictionary <string, object> GetProfileDictionary(string[] properties)
        {
            var ret = new Dictionary <string, object> ();

            int len = properties != null ? properties.Length : 0;

            if (len <= 0)
            {
                return(ret);
            }

            ProfileBase profile = HttpContext.Current.Profile;
            string      name;
            int         dot;
            object      value;

            for (int i = 0; i < len; i++)
            {
                name  = properties [i];
                dot   = name.IndexOf('.');
                value = (dot > 0) ? profile.GetProfileGroup(name.Substring(0, dot)).GetPropertyValue(name.Substring(dot + 1)) : profile.GetPropertyValue(name);
                ret.Add(name, value);
            }

            return(ret);
        }
Esempio n. 3
0
        public DataSet GetAllUsers(string RoleName)
        {
            DataSet   dsMembership = new DataSet("Membership");
            DataTable dtUsers      = dsMembership.Tables.Add("Users");

            dtUsers.Columns.Add("IsOnline", Type.GetType("System.Boolean"));
            dtUsers.Columns.Add("UserName", Type.GetType("System.String"));
            dtUsers.Columns.Add("PasswordQuestion", Type.GetType("System.String"));
            dtUsers.Columns.Add("IsLockedOut", Type.GetType("System.Boolean"));
            dtUsers.Columns.Add("Email", Type.GetType("System.String"));
            dtUsers.Columns.Add("LastLoginDate", Type.GetType("System.DateTime"));
            dtUsers.Columns.Add("CreationDate", Type.GetType("System.DateTime"));
            dtUsers.Columns.Add("DisplayValue", Type.GetType("System.String"));
            MembershipUserCollection mu = Membership.GetAllUsers();
            //Add blank row.
            DataRow r;

            r                 = dtUsers.NewRow();
            r["Username"]     = "";
            r["DisplayValue"] = "";
            dtUsers.Rows.Add(r);
            foreach (MembershipUser u in mu)
            {
                if ((CheckRole(u.UserName, RoleName) || RoleName == String.Empty) && u.UserName != "MMDBAdministrator")
                {
                    ProfileBase p = ProfileBase.Create(u.UserName, true);
                    r                     = dtUsers.NewRow();
                    r["IsOnline"]         = u.IsOnline;
                    r["UserName"]         = u.UserName;
                    r["PasswordQuestion"] = u.PasswordQuestion;
                    r["IsLockedOut"]      = u.IsLockedOut;
                    r["Email"]            = u.Email;
                    r["CreationDate"]     = u.CreationDate;
                    r["LastLoginDate"]    = u.LastLoginDate;
                    r["DisplayValue"]     = u.UserName
                                            + "(" + p.GetProfileGroup("Demographics")["FirstName"].ToString()
                                            + " "
                                            + p.GetProfileGroup("Demographics")["LastName"].ToString()
                                            + ")-" + u.Email;
                    dtUsers.Rows.Add(r);
                }
            }
            return(dsMembership);
        }
Esempio n. 4
0
        public void SetUserProfileProperty(string key, string value)
        {
            ProfileBase profileSettings = ProfileBase.Create(this.UserProfile.UserName, true);

            // TODO: Fix this crap!
            try {
                profileSettings[key] = value;
            }
            catch (SettingsPropertyNotFoundException) {
                ProfileGroupBase addressGroup = null;

                addressGroup      = profileSettings.GetProfileGroup("Address");
                addressGroup[key] = value;
            }

            profileSettings.Save();
        }
        public string [] SetPropertiesForCurrentUser(Dictionary <string, object> values, bool authenticatedUserOnly)
        {
            if (values == null)
            {
                return new string [] { }
            }
            ;

            string [] waProps = ScriptingProfileServiceSection.WriteAccessPropertiesNoCopy;

            List <string> list    = new List <string> ();
            ProfileBase   profile = HttpContext.Current.Profile;

            foreach (KeyValuePair <string, object> pair in values)
            {
                try
                {
                    string name = pair.Key;
                    if (!IsPropertyConfigured(waProps, name))
                    {
                        continue;
                    }

                    int dot = name.IndexOf('.');
                    if (dot > 0)
                    {
                        profile.GetProfileGroup(name.Substring(0, dot))
                        .SetPropertyValue(name.Substring(dot + 1), pair.Value);
                    }
                    else
                    {
                        profile.SetPropertyValue(name, pair.Value);
                    }
                }
                catch
                {
                    list.Add(pair.Key);
                }
            }

            return(list.ToArray());
        }
Esempio n. 6
0
 public ProfileGroupBase GetProfileGroup(string groupName)
 {
     return(_profileBase.GetProfileGroup(groupName));
 }