Exemplo n.º 1
0
        // it will be deleted
        public bool checkId(Data data)
        {
            if (!Text.isAble(data.getString("UserID"), 32))
            {
                return false;
            }
            Data param = new Data();
            param.add("UserID", data.get("UserID"));
            Data result = new Data();
            UserData ud = new UserData();
            result = ud.checkId(param);

            if (result.Count == 0)
            {
                return true;
            }

            return false;
        }
Exemplo n.º 2
0
        // it will be deleted
        public override Data list(Data data)
        {
            Data param = new Data();
            UserData ud = new UserData();
            param.add("searchField", Text.ifEmpty(data.get("searchField"), ""));
            param.add("searchValue", Text.ifEmpty(data.get("searchValue"), ""));
            param.Now = data.Now;

            return ud.list(param);
        }
Exemplo n.º 3
0
 /// <summary>
 /// get a list of default information including state, sex, job and etc
 /// </summary>
 /// <returns></returns>
 public List<Data> getDefaultInfo()
 {
     UserData ud = new UserData();
     return ud.defaultData(new Data());
 }
Exemplo n.º 4
0
 /// <summary>
 /// delete user information
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public override bool delete(Data data)
 {
     UserData ud = new UserData();
     return ud.delete(data);
 }
Exemplo n.º 5
0
        /// <summary>
        /// get a user information using user id
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public Data view(Data data)
        {
            Data param = new Data();
            if (Text.isEmpty(data.getString("userId")))
            {
                param.add("userId", data.getString("UserID"));
            }
            else
            {
                param.add("userId", data.getString("userId"));
            }

            UserData ud = new UserData();

            //result.add("question", Cryptograph.Decrypt( result.getString("question") ));
            //result.add("answer", Cryptograph.Decrypt(result.getString("answer")));
            return ud.view(param);
        }
Exemplo n.º 6
0
 /// <summary>
 /// update patient information
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public bool updatePatient(Data data)
 {
     UserData ud = new UserData();
     return ud.updatePatient(data);
 }
Exemplo n.º 7
0
 /// <summary>
 /// update uesr information
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public override bool update(Data data)
 {
     UserData ud = new UserData();
     return ud.update(data);
 }
Exemplo n.º 8
0
        /// <summary>
        /// get a user information using user id
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public override DataTable select(Data data)
        {
            Data param = new Data();
            param.add("userId", data.getString("userId"));
            UserData ud = new UserData();

            //result.add("question", Cryptograph.Decrypt( result.getString("question") ));
            //result.add("answer", Cryptograph.Decrypt(result.getString("answer")));
            return ud.view(param).Source;
        }
Exemplo n.º 9
0
        /// <summary>
        /// create a new user
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public String registration(Data data)
        {
            if (!checkId(data))
            {
                return "Please, choose another ID";
            }

            if (data.getString("CPassword").Equals(data.getString("Password")))
            {
                String pwd = Cryptograph.Encrypt(data.getString("Password"));
                data.add("Password", pwd);
                UserData ud = new UserData();
                ud.create(data);
            }

            return "OK";
        }
Exemplo n.º 10
0
        /// <summary>
        /// login using id and password
        /// </summary>
        /// <param name="data"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public HttpSessionState login(Data data, HttpSessionState session)
        {
            Data result = new Data();
            Data param = new Data();
            //check the id
            if (!Text.isAble(data.getString("id"), 32))
            {
                result.add(UserInfo.loginState, "Please, check your ID.");
                session = UserInfo.setInfo(session, result);
                return session;
            }
            // check the password
            else if (!Text.isAble(data.getString("pwd"), 32))
            {
                result.add(UserInfo.loginState, "Forgot your password?");
                session = UserInfo.setInfo(session, result);
                return session;
            }

            param.add("id", data.getString("id"));
            param.add("pwd", Cryptograph.Encrypt(data.getString("pwd")));

            UserData ud = new UserData();

            result = ud.logIn(param);

            if( result.Count == 0) {
                result.add(UserInfo.loginState, "Forgot your password or ID?");
                session = UserInfo.setInfo(session, result);
                return session;
            }
            result.add(UserInfo.loginState, "OK");
            return UserInfo.setInfo(session, result);
        }