Example #1
0
            protected override ActionResult DoTask(string data)
            {
                string[] param = StringUtility.Split(data, "%27");
                string usernum = Escape.JsUnEscape(param[0]);
                string username = Escape.JsUnEscape(param[1]);
                string password = EncryptMD5.MD5to16Code(Escape.JsUnEscape(param[2]));
                UserLevelType usertype = (UserLevelType)int.Parse(Escape.JsUnEscape(param[3]));

                UserEntity entity = new UserEntity();
                if (usertype == UserLevelType.Student)
                {
                    entity.FillIdentityStudentUserId();
                }
                else
                {
                    entity.UserNo = usernum;
                    entity.FillByUserNo();
                    if (entity.EntityState == DataFrameworkLibrary.Core.EntityState.Inserted)
                        throw new ActionParseException("系统中已存在相同编号的用户<br>请更换别的编号");
                }
                entity.UserName = username;
                entity.Password = password;
                entity.UserLevel = usertype;
                entity.IsLogin = false;
                entity.DoTest = true;
                entity.Save();

                UserCollection collection = new UserCollection();
                collection.PageSize = 6;
                collection.AbsolutePage = 1;
                collection.IsReturnDataTable = true;
                collection.Fill();
                ActionResult result = new ActionResult();
                result.IsSuccess = true;
                StringBuilder response = new StringBuilder();
                response.Append(ActionTaskUtility.ReturnClientDataArray(collection.GetFillDataTable()));
                response.Append(string.Format("TmpStr={0};", collection.PageCount));
                result.ResponseData = response.ToString();
                return result;
            }
Example #2
0
            protected override ActionResult DoTask(string data)
            {
                ActionResult result = new ActionResult();
                result.IsSuccess = false;

                string[] param = data.Split('\'');
                string number = param[0];
                string password = EncryptMD5.MD5to16Code(param[1]);
                string validateCode = param[2];

                if (!SessionManager.ValidateCode.Equals(validateCode))
                    throw new ActionParseException("您的验证码输入有误");

                UserEntity entity = new UserEntity();
                entity.UserNo = number;
                entity.Password = password;
                entity.FillByUserNoAndPassword();
                if (entity.EntityState != DataFrameworkLibrary.Core.EntityState.Inserted)
                    throw new ActionParseException("用户编号或者对应密码错误");

                if (entity.IsLogin == false || entity.UserLevel == UserLevelType.Admin)
                {
                    entity.IsLogin = true;
                    entity.Save();

                    SessionManager.User = entity;
                    SessionManager.UserExp = "";
                    SessionManager.ClientIp = getUserClientIP();

                    StringBuilder response = new StringBuilder();
                    response.Append("Lock = false;");
                    response.Append("top.location.href = 'welcome.aspx';");
                    result.ResponseData = response.ToString();
                    result.IsSuccess = true;
                }
                else
                    throw new ActionParseException("您的帐号已在登陆状态,请不要连续登陆系统!");
                return result;
            }
Example #3
0
            protected override ActionResult DoTask(string data)
            {
                string[] param = StringUtility.Split(data, "%27");
                int userid = int.Parse(Escape.JsUnEscape(param[0]));
                string usernum = Escape.JsUnEscape(param[1]);
                string username = Escape.JsUnEscape(param[2]);
                UserLevelType usertype = (UserLevelType)int.Parse(Escape.JsUnEscape(param[3]));
                bool userlogin = StringUtility.ConvertBool(Escape.JsUnEscape(param[4]));
                bool usertest = StringUtility.ConvertBool(Escape.JsUnEscape(param[5]));
                string password = EncryptMD5.MD5to16Code(Escape.JsUnEscape(param[6]));

                UserEntity entity = new UserEntity();
                if (!string.IsNullOrEmpty(usernum))
                {
                    entity.UserNo = usernum;
                    entity.FillByUserNo();
                    if (entity.EntityState == DataFrameworkLibrary.Core.EntityState.Inserted)
                        throw new ActionParseException("系统不允许定义<br>两个编号相同的用户");
                }

                bool isChange = false;
                if (usertype == UserLevelType.Admin)
                    isChange = true;
                else
                {
                    UserCollection userCollection = new UserCollection();
                    userCollection.FillByUserLevel(UserLevelType.Admin);
                    if (userCollection.Count == 1)
                    {
                        if (userCollection[0].UserId == userid)
                            throw new ActionParseException("系统不允许移出最后一位<br>进行人员管理的用户权限");
                        else
                            isChange = true;
                    }
                    else
                        isChange = true;
                }
                if (isChange)
                {
                    entity = new UserEntity();
                    entity.UserId = userid;
                    entity.Fill();
                    if (entity.EntityState == DataFrameworkLibrary.Core.EntityState.Inserted)
                    {
                        if (!string.IsNullOrEmpty(usernum))
                            entity.UserNo = usernum;
                        if (!string.IsNullOrEmpty(password))
                            entity.Password = password;
                        entity.UserName = username;
                        entity.UserLevel = usertype;
                        entity.IsLogin = userlogin;
                        entity.DoTest = usertest;
                        entity.Save();

                        UserEntity sessionEntity = SessionManager.User;
                        if (sessionEntity != null && sessionEntity.UserId == entity.UserId)
                        {
                            SessionManager.User = entity;
                        }
                    }
                }
                ActionResult result = new ActionResult();
                result.IsSuccess = true;
                return result;
            }