Exemplo n.º 1
0
        public int UpdateProfileForUser(user mUser, string[] PropertyNames, object[] PropertyValues)
        {
            for (int i = 0; i < PropertyNames.Length; i++)
            {
                object value = i >= PropertyValues.Length ? "" : PropertyValues[i];
                if (mUser.UserProfiles.ContainsKey(PropertyNames[i]))
                {
                    if (value is byte[])
                    {
                        mUser.UserProfiles[PropertyNames[i]].PropertyValuesBinary = value as byte[];
                    }
                    else
                    {
                        mUser.UserProfiles[PropertyNames[i]].PropertyValuesString = value.ToString();
                    }
                }
                else
                {
                    UserProfile uf = new UserProfile(PropertyNames[i], value);
                    mUser.UserProfiles.Add(PropertyNames[i], uf);
                }
            }
            IuserService _service = new userService(this.SessionFactoryConfigPath);

            try
            {
                _service.Update(mUser);
                return(1);
            }
            catch (Exception ex)
            {
                log.Error("Update profile Error.", ex);
                return(-1);
            }
        }
Exemplo n.º 2
0
        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            if (_App == null)
            {
                return;
            }
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            IroleService RoleSrv = new roleService(SessionFactoryConfigPath);

            foreach (string UN in usernames)
            {
                user mUser = UserSrv.GetByName(UN, _App.AppID);
                if (mUser != null)
                {
                    string[] currentRoles = (from r in mUser.Roles where r.AppID == _App.AppID select r.name).ToArray();
                    foreach (string r in roleNames)
                    {
                        if (!currentRoles.Contains(r))
                        {
                            role mRole = RoleSrv.GetByName(r, _App.AppID);
                            if (mRole != null)
                            {
                                mUser.Roles.Add(mRole);
                            }
                        }
                    }
                    UserSrv.Save(mUser);
                }
            }
            UserSrv.CommitChanges();
        }
Exemplo n.º 3
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txt_UserName.Text) && !string.IsNullOrEmpty(txtPassword.Text))
            {
                userService userService = new userService();
                user        userControl = userService.userControl(txt_UserName.Text, txtPassword.Text);

                if (userControl != null)
                {
                    Form     mainForm     = Application.OpenForms["Form1"];
                    Panel    leftPanel    = (Panel)mainForm.Controls["pnlIslemList"];
                    GroupBox grpIslemList = (GroupBox)leftPanel.Controls["grpOperationList"];
                    foreach (Control item in grpIslemList.Controls)
                    {
                        if (item is Button)
                        {
                            item.Enabled = true;
                        }
                    }
                    MessageBox.Show("Welcome to TO DO...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Wrong username or password", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Enter your user name or password.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        public void DeassignUserToRole(string mUser, string mRole)
        {
            if (_App == null)
            {
                return;
            }
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            IroleService RoleSrv  = new roleService(SessionFactoryConfigPath);
            user         TempUser = UserSrv.GetByName(mUser, _App.AppID);

            if (TempUser == null)
            {
                return;
            }
            role TempRole = RoleSrv.GetByName(mRole, _App.AppID);

            if (TempRole == null)
            {
                return;
            }
            if (TempUser.Roles.Contains(TempRole))
            {
                TempUser.Roles.Remove(TempRole);
            }
            UserSrv.CommitChanges();
        }
Exemplo n.º 5
0
        //System.Web.Profile.SqlProfileProvider
        #endregion
        public user CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out string status)
        {
            log.Info("Create new User: "******" in Application " + _App.AppName);
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            user         TempUser = UserSrv.GetByName(username);

            if (TempUser != null)
            {
                status = "DuplicateUserName"; return(null);
            }
            TempUser                  = new user();
            TempUser.username         = username;
            TempUser.password         = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            TempUser.PasswordSalt     = "MD5";
            TempUser.PasswordFormat   = (int)PasswordFormat;
            TempUser.email            = email;
            TempUser.PasswordQuestion = passwordQuestion;
            TempUser.PasswordAnswer   = passwordAnswer;
            TempUser.IsApproved       = isApproved;
            TempUser.ApplicationList  = new List <Applications>();
            TempUser.ApplicationList.Add(_App);
            try
            {
                TempUser = UserSrv.CreateNew(TempUser);
                UserSrv.CommitChanges();
                status = "Success";
                return(TempUser);
            }
            catch (Exception ex)
            {
                log.Error("CreateUser Error", ex);
                status = "ProviderError";
                return(null);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="username">a username</param>
        /// <param name="password">the password</param>
        /// <param name="newPasswordQuestion">new question</param>
        /// <param name="newPasswordAnswer">new answer</param>
        /// <returns>true or false</returns>
        public bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
        {
            log.Info("ChangePasswordQuestionAndAnswer user: "******" in Application: " + _App.AppName);
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            user         TempUser = UserSrv.GetByName(username, _App.AppID);

            if (TempUser == null)
            {
                return(false);
            }

            try
            {
                TempUser.password         = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
                TempUser.PasswordQuestion = newPasswordQuestion;
                TempUser.PasswordAnswer   = newPasswordAnswer;
                UserSrv.Update(TempUser);
                UserSrv.CommitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("ERR in ChangePasswordQuestionAndAnswer user: "******" in Application " + _App.AppName, ex);
                return(false);
            }
        }
        public ActionResult Datos(FormCollection collection)
        {
            try
            {
                personaModel persona = new personaModel();
                persona = (personaModel)Session["personaLogedIn" + Session.SessionID];

                int  oldDNI = persona.dni;
                long oldId  = persona.id;
                persona.nombre          = Request.Form["nombre"];
                persona.apellido        = Request.Form["apellido"];
                persona.dni             = int.Parse(Request.Form["dni"]);
                persona.fechaNacimiento = DateTime.ParseExact(Request.Form["fechaNacimiento"], "dd/MM/yyyy", null);
                persona.user.mail       = Request.Form["user.mail"];
                persona.user.password   = Request.Form["user.password"];
                persona.user.profile    = Request.Form["user.profile"];

                personaService pServ = new personaService();
                userService    uServ = new userService();
                if ((pServ.updatePersonaByIdAndDNI(persona, oldDNI, oldId) == true) && (uServ.updateUsuarioByID(persona.user)))
                {
                    return(RedirectToAction("ModificacionOK"));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Removes the specified user names from the specified roles for the configured applicationName
        /// </summary>
        /// <param name="usernames"> A string array of user names to be removed from the specified roles.</param>
        /// <param name="roleNames">A string array of role names to remove the specified user names from.</param>
        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            if (_App == null)
            {
                return;
            }
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            IroleService RoleSrv  = new roleService(SessionFactoryConfigPath);
            string       hql      = "from user u where u.username in (:usernames)";
            IList <user> UserList = UserSrv.GetbyHQuery(hql, new SQLParam("usernames", usernames.ToString()));
            string       hql2     = "from role r where r.name in (:roleNames) AND r.AppID = :AppID";
            IList <role> RoleList = RoleSrv.GetbyHQuery(hql2, new SQLParam("roleNames", roleNames.ToString()), new SQLParam("AppID", _App.AppID));

            foreach (user u in UserList)
            {
                foreach (role r in RoleList)
                {
                    if (u.Roles.Contains(r))
                    {
                        u.Roles.Remove(r);
                    }
                }
            }
            UserSrv.CommitChanges();
        }
Exemplo n.º 9
0
 public int DeleteProfiles(string usernames)
 {
     IuserService UserSrv = new userService(SessionFactoryConfigPath);
     user mUser= UserSrv.GetByName(usernames);
     if (mUser == null) return 0;
     string Hql = "Delete UserProfile where UserId =:UserId";
     return (int)UserSrv.ExcuteNonQuery(Hql,true, new SQLParam("UserId", mUser.userid));
 }
Exemplo n.º 10
0
        public void UpdateUsersToRoles(int userid, string[] roleNames)
        {
            if (_App == null)
            {
                return;
            }
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            user         mUser   = UserSrv.Getbykey(userid);

            updateRolesForUser(mUser, roleNames);
        }
Exemplo n.º 11
0
        public int UpdateProfileForUser(string UserName, string[] PropertyNames, object[] PropertyValues)
        {
            IuserService _service = new userService(this.SessionFactoryConfigPath);
            user         mUser    = _service.GetByName(UserName);

            if (mUser != null)
            {
                return(UpdateProfileForUser(mUser, PropertyNames, PropertyValues));
            }
            return(0);
        }
Exemplo n.º 12
0
        public void UpdateUsersToRoles(string username, string[] roleNames)
        {
            if (_App == null)
            {
                return;
            }
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            IroleService RoleSrv = new roleService(SessionFactoryConfigPath);
            user         mUser   = UserSrv.GetByName(username, _App.AppID);

            updateRolesForUser(mUser, roleNames);
        }
Exemplo n.º 13
0
        public int DeleteProfiles(string usernames)
        {
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            user         mUser   = UserSrv.GetByName(usernames);

            if (mUser == null)
            {
                return(0);
            }
            string Hql = "Delete UserProfile where UserId =:UserId";

            return((int)UserSrv.ExcuteNonQuery(Hql, true, new SQLParam("UserId", mUser.userid)));
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            string email, password;

            Console.Write("Email : ");
            email = Console.ReadLine();
            Console.Write("Password : ");
            password = Console.ReadLine();
            userService data = new userService(email, password);

            data.login();
            Console.ReadKey();
        }
Exemplo n.º 15
0
 /// <summary>
 /// required implementation
 /// </summary>
 /// <param name="providerUserKey">required implementation</param>
 /// <param name="userIsOnline">required implementation</param>
 /// <returns>required implementation</returns>
 public user GetUser(object providerUserKey, bool userIsOnline)
 {
     if (providerUserKey is int)
     {
         IuserService UserSrv = new userService(SessionFactoryConfigPath);
         int          userID  = (int)providerUserKey;
         return(UserSrv.Getbykey(userID));
     }
     else
     {
         return(null);
     }
     //throw new Exception("have not implement.");
 }
Exemplo n.º 16
0
        public IDictionary <string, UserProfile> FindProfilesByUserName(string UserName)
        {
            IuserService _service = new userService(this.SessionFactoryConfigPath);
            user         mUser    = _service.GetByName(UserName);

            if (mUser == null)
            {
                return(null);
            }
            else
            {
                return(mUser.UserProfiles);
            }
        }
Exemplo n.º 17
0
        public user AuthenUser(string mUserName, string mPassword)
        {
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            user         TempUser = UserSrv.GetByName(mUserName, _App.AppID);

            if (TempUser != null && TempUser.IsApproved && (!TempUser.IsLockedOut))
            {
                string _PassHash = FormsAuthentication.HashPasswordForStoringInConfigFile(mPassword, "MD5");
                if (TempUser.password == _PassHash)
                {
                    return(TempUser);
                }
            }
            return(null);
        }
Exemplo n.º 18
0
        public int DeleteProfiles(string[] usernames)
        {
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            int          ret     = 0;

            foreach (string UN in usernames)
            {
                user mUser = UserSrv.GetByName(UN);
                if (mUser != null)
                {
                    string Hql = "Delete UserProfile where UserId =:UserId";
                    ret += (int)UserSrv.ExcuteNonQuery(Hql, true, new SQLParam("UserId", mUser.userid));
                }
            }
            return(ret);
        }
Exemplo n.º 19
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="username">required implementation</param>
        /// <param name="userIsOnline">required implementation</param>
        /// <returns>required implementation</returns>
        public user GetUser(string username, bool userIsOnline)
        {
            log.Info("GetNumberOfUsersOnline Application: " + _App.AppName);

            try
            {
                IuserService UserSrv  = new userService(SessionFactoryConfigPath);
                user         TempUser = UserSrv.GetByName(username, _App.AppID);
                return(TempUser);
            }
            catch (Exception ex)
            {
                log.Error("GetNumberOfUsersOnline Error Application " + _App.AppName, ex);
                return(null);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// required implementation
 /// </summary>
 /// <param name="email">required implementation</param>
 /// <returns>required implementation</returns>
 public string GetUserNameByEmail(string email)
 {
     log.Info("GetUserNameByEmail:" + email + " in Application: " + _App.AppName);
     //string HQL = "select u from user u join u.ApplicationList app where u.email = :email AND app.AppID = :AppID  ";
     try
     {
         IuserService UserSrv = new userService(SessionFactoryConfigPath);
         //IList<user> lst = UserSrv.GetbyHQuery(HQL, new SQLParam("email", email), new SQLParam("AppID", _App.AppID));
         IList <user> lst = UserSrv.SearchUser("", email, _App.AppID);
         return((lst == null || lst.Count == 0) ? null : lst[0].username);
     }
     catch (Exception ex)
     {
         log.Error("Error GetUserNameByEmail: " + email + " in Application: " + _App.AppName, ex);
         return("");
     }
 }
Exemplo n.º 21
0
        public override bool IsUserInRole(string username, string roleName)
        {
            if (_App == null)
            {
                return(false);
            }
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            user         mUser   = UserSrv.GetByName(username, _App.AppID);

            if (mUser == null)
            {
                return(false);
            }
            role mRole = (from r in mUser.Roles where r.AppID == _App.AppID && r.name == roleName select r).SingleOrDefault();

            return(mRole != null);
        }
Exemplo n.º 22
0
        private void updateRolesForUser(user mUser, string[] roleNames)
        {
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            IroleService RoleSrv = new roleService(SessionFactoryConfigPath);

            if (mUser != null)
            {
                if (roleNames == null || roleNames.Length <= 0)
                {
                    if (mUser.Roles != null)
                    {
                        mUser.Roles.Clear();
                    }
                }
                else
                {
                    if (mUser.Roles == null)
                    {
                        mUser.Roles = new List <role>();
                    }
                    string[] currentRoles = (from r in mUser.Roles where r.AppID == _App.AppID select r.name).ToArray();
                    string[] RemoveRoles  = (from rl in currentRoles where !roleNames.Contains(rl) select rl).ToArray();
                    string[] InsertRoles  = (from rl in roleNames where !currentRoles.Contains(rl) select rl).ToArray();
                    //remove role
                    foreach (string r in RemoveRoles)
                    {
                        role mRole = RoleSrv.GetByName(r, _App.AppID);
                        if (mRole != null)
                        {
                            mUser.Roles.Remove(mRole);
                        }
                    }

                    foreach (string r in InsertRoles)
                    {
                        role mRole = RoleSrv.GetByName(r, _App.AppID);
                        if (mRole != null)
                        {
                            mUser.Roles.Add(mRole);
                        }
                    }
                }
                UserSrv.Save(mUser);
                UserSrv.CommitChanges();
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="usernameToMatch">required implementation</param>
        /// <param name="pageIndex">required implementation</param>
        /// <param name="pageSize">required implementation</param>
        /// <param name="totalRecords">required implementation</param>
        /// <returns>required implementation</returns>
        public IList <user> FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            log.Info("FinUserByName Application " + _App.AppName);
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            string       hql     = "select u from user u join u.ApplicationList app where u.username like %:username% AND app.AppID = :AppID  ";

            try
            {
                IList <user> lst = UserSrv.GetbyHQuery(hql, pageIndex, pageSize, out totalRecords, new SQLParam("username", usernameToMatch), new SQLParam("AppID", _App.AppID));
                return(lst);
            }
            catch (Exception ex)
            {
                log.Error("FindUsersByName Error Application " + _App.AppName, ex);
                totalRecords = 0;
                return(null);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="pageIndex">required implementation</param>
        /// <param name="pageSize">required implementation</param>
        /// <param name="totalRecords">required implementation</param>
        /// <returns>required implementation</returns>
        public IList <user> GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            log.Info("GetAllUsers Application " + _App.AppName);
            IuserService UserSrv = new userService(SessionFactoryConfigPath);

            try
            {
                string       HQL = "select u from user u join u.ApplicationList app where app.AppID = :appid order by u.CreateDate ";
                IList <user> lst = UserSrv.GetbyHQuery(HQL, pageIndex, pageSize, out totalRecords, new SQLParam("appid", _App.AppID));
                return(lst);
            }
            catch (Exception ex)
            {
                log.Error("GetAllUsers Error Application " + _App.AppName, ex);
                totalRecords = 0;
                return(null);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="userName">required implementation</param>
        /// <returns>required implementation</returns>
        public bool UnlockUser(string userName)
        {
            log.Info("UnlockUser:"******" in Application: " + _App.AppName);
            string HQL = "update user u set u.IsLockedOut = false join u.Applications app where u.username = :username AND app.AppID=:AppID";

            try
            {
                IuserService UserSrv = new userService(SessionFactoryConfigPath);
                object       ret     = UserSrv.ExcuteNonQuery(HQL, true, new SQLParam("username", userName), new SQLParam("AppID", _App.AppID));
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("Error UnlockUser: "******" in Application: " + _App.AppName, ex);
                return(false);
            }
            //throw new Exception("have not implement.");
        }
Exemplo n.º 26
0
        public override string[] GetRolesForUser(string username)
        {
            if (_App == null)
            {
                return(null);
            }
            IuserService UserSrv = new userService(SessionFactoryConfigPath);
            user         mUser   = UserSrv.GetByName(username, _App.AppID);

            if (mUser == null || mUser.Roles == null || mUser.Roles.Count == 0)
            {
                return new string[] { }
            }
            ;
            else
            {
                return((from r in mUser.Roles where r.AppID == _App.AppID select r.name).ToArray());
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// required implementation
 /// </summary>
 /// <param name="user">required implementation</param>
 public void UpdateUser(user muser)
 {
     log.Info("UpdateUser:"******" in Application: " + _App.AppName);
     try
     {
         if (muser == null)
         {
             return;
         }
         IuserService UserSrv = new userService(SessionFactoryConfigPath);
         UserSrv.Update(muser);
         UserSrv.CommitChanges();
     }
     catch (Exception ex)
     {
         log.Error("Error UpdateUser: "******" in Application: " + _App.AppName, ex);
         return;
     }
 }
Exemplo n.º 28
0
        public bool DeleteUser(user mUser, bool deleteAllRelatedData)
        {
            IuserService UserSrv = new userService(SessionFactoryConfigPath);

            if (mUser == null)
            {
                return(false);
            }
            try
            {
                UserSrv.Delete(mUser);
                UserSrv.CommitChanges();
                log.Info("Delete User: "******"Error  Delete User: " + mUser.username, ex);
                return(false);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="username">required implementation</param>
        /// <param name="answer">required implementation</param>
        /// <returns>required implementation</returns>
        public string ResetPassword(string username, string answer)
        {
            log.Info("ResetPassword:"******" in Application: " + _App.AppName);

            if (!EnablePasswordReset)
            {
                throw new NotSupportedException("Password reset is not enabled.");
            }

            if (answer == null && RequiresQuestionAndAnswer)
            {
                UpdateFailureCount(username, "passwordAnswer");
                throw new System.Configuration.Provider.ProviderException("Password answer required for password reset.");
            }
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            user         TempUser = UserSrv.GetByName(username, _App.AppID);

            if (TempUser.PasswordAnswer.ToUpper() != answer.ToUpper())
            {
                return("");
            }
            else
            {
                string pass = CreateRandomPassword(MinRequiredPasswordLength > 7 ? MinRequiredPasswordLength : 7);
                TempUser.password = FormsAuthentication.HashPasswordForStoringInConfigFile(pass, "MD5");
                try
                {
                    UserSrv.Update(TempUser);
                    UserSrv.CommitChanges();
                    return(pass);
                }
                catch (Exception ex)
                {
                    log.Error("Error ResetPassword: "******" in Application: " + _App.AppName, ex);
                    return("");
                }
            }
        }
Exemplo n.º 30
0
 /// <summary>
 /// required implementation
 /// </summary>
 /// <param name="username">required implementation</param>
 /// <param name="password">required implementation</param>
 /// <returns>required implementation</returns>
 public bool ValidateUser(string username, string password)
 {
     log.Info("ValidateUser:"******" in Application: " + _App.AppName);
     try
     {
         IuserService UserSrv  = new userService(SessionFactoryConfigPath);
         user         TempUser = UserSrv.GetByName(username, _App.AppID);
         string       pass     = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
         if (TempUser != null && TempUser.password == pass && TempUser.IsApproved && (!TempUser.IsLockedOut))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         log.Error("Error ValidateUser: "******" in Application: " + _App.AppName, ex);
         return(false);
     }
 }
Exemplo n.º 31
0
        /// <summary>
        /// required implementation
        /// </summary>
        /// <param name="username">a username</param>
        /// <param name="oldPassword">original password</param>
        /// <param name="newPassword">new password</param>
        /// <returns>true or false</returns>
        public bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            log.Info("ChangePassword user: "******" in Application: " + _App.AppName);
            IuserService UserSrv = new userService(SessionFactoryConfigPath);

            if (_App == null)
            {
                return(false);
            }
            user TemUser = UserSrv.GetByName(username, _App.AppID);

            if (TemUser == null)
            {
                return(false);
            }
            string OldPassWordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(oldPassword, "MD5");

            if (TemUser.password != OldPassWordHash)
            {
                return(false);
            }
            string NewPassWordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword, "MD5");

            TemUser.password = NewPassWordHash;

            try
            {
                UserSrv.Update(TemUser);
                UserSrv.CommitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("ERR in ChangePassword user: "******" in Application " + _App.AppName, ex);
                return(false);
            }
        }
Exemplo n.º 32
0
 public IDictionary<string, UserProfile> FindProfilesByUserName(string UserName)
 {
     IuserService _service = new userService(this.SessionFactoryConfigPath);
     user mUser = _service.GetByName(UserName);
     if (mUser == null) return null;
     else return mUser.UserProfiles;
 }
Exemplo n.º 33
0
 public int DeleteProfiles(string[] usernames)
 {
     IuserService UserSrv = new userService(SessionFactoryConfigPath);
     int ret = 0;
     foreach (string UN in usernames)
     {
         user mUser = UserSrv.GetByName(UN);
         if (mUser != null)
         {
             string Hql = "Delete UserProfile where UserId =:UserId";
             ret += (int)UserSrv.ExcuteNonQuery(Hql, true,new SQLParam("UserId", mUser.userid));
         }
     }
     return ret;
 }
Exemplo n.º 34
-12
 public int UpdateProfileForUser(user mUser, string[] PropertyNames, object[] PropertyValues)
 {
     for (int i = 0; i < PropertyNames.Length; i++)
     {
         object value = i >= PropertyValues.Length ? "" : PropertyValues[i];
         if (mUser.UserProfiles.ContainsKey(PropertyNames[i]))
         {
             if (value is byte[]) mUser.UserProfiles[PropertyNames[i]].PropertyValuesBinary = value as byte[];
             else mUser.UserProfiles[PropertyNames[i]].PropertyValuesString = value.ToString();
         }
         else
         {
             UserProfile uf = new UserProfile(PropertyNames[i], value);
             mUser.UserProfiles.Add(PropertyNames[i],uf);
         }
     }
     IuserService _service = new userService(this.SessionFactoryConfigPath);
     try
     {
         _service.Update(mUser);
         return 1;
     }
     catch (Exception ex)
     {
         log.Error("Update profile Error.", ex);
         return -1;
     }
 }