예제 #1
0
        public STUserVP GetParam(UserModelsViewParam prm)
        {
            STUserVP ret = new STUserVP();
            string   msg;

            CCondition  clCondition  = new CCondition();
            CPermission clPermission = new CPermission();

            try
            {
                ret.strdata = null;

                if (prm.UserName != null)
                {
                    ret.maskusername = prm.UserName;
                    ret.strdata     += string.Format("<UserName={0}>", ret.maskusername);
                }
                if (prm.Permission != null)
                {
                    ret.permission = clPermission.GetId(prm.Permission);
                    ret.strdata   += string.Format("<Permission={0}>", prm.Permission);
                }
                if (prm.Condition != null)
                {
                    ret.condition = clCondition.GetId(prm.Condition);
                    ret.strdata  += string.Format("<Condition={0}>", prm.Condition);
                }

                if (prm.Email != null)
                {
                    ret.maskemail = prm.Email;
                    ret.strdata  += string.Format("<Email={0}>", ret.maskemail);
                }

                if (prm.Login != null)
                {
                    ret.masklogin = prm.Login;
                    ret.strdata  += string.Format("<Login={0}>", ret.masklogin);
                }
                if (prm.IsAll)
                {
                    ret.isall = true;
                }
                else
                {
                    ret.isall = false;
                }
            }
            catch (Exception ex) { msg = ex.Message; }
            return(ret);
        }
예제 #2
0
        public int UpdateUser(UserModels model, out string msg)
        {
            int ret = 0;

            msg = null;
            STUser      data         = new STUser();
            CCondition  clCondition  = new CCondition();
            CPermission clPermission = new CPermission();

            try
            {
                CUser clUser = new CUser(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());

                data.comments     = model.Comments;
                data.condition    = clCondition.GetId(model.Condition);
                data.email        = model.Email;
                data.login        = model.Login;
                data.modifieddate = DateTime.Now;
                data.passwordsalt = CreateSalt();
                //      data.password = CreatePasswordHash(model.Password, data.passwordsalt);
                data.permission = clPermission.GetId(model.Permission);
                data.username   = model.UserName;

                string[] arr = new[] { "'", "\"", "--" };
                if (CheckerField.CheckField(arr, data.comments, data.email, data.login, data.username))
                {
                    msg = "One or more fields contain invalid characters.";
                    return(2);
                }

                ret = clUser.Update(model.UserId, data, out msg);

                if (ret == 0)
                {
                    CAction clAction = new CAction(LocalData.UserId(), LocalData.CSDbUsers(), LocalData.LogPath());
                    clAction.AddAction(ActionType.EditUser, string.Format("Edit user {0}, {1}", data.username,
                                                                          data.login), out msg);
                }
            }
            catch (Exception ex) { msg = ex.Message; ret = -1; }

            return(ret);
        }