Пример #1
0
        /*用户登录:接受并转发ID和Password,探测或解读错误*/
        public UserInfoEntity Login(string userID, string password) {

            UserInfoEntity userInfoEntity = null;

            if ((confirmed == true) && (confirmedUserID == userID)) {
                userInfoEntity = new UserInfoEntity();
                userInfoEntity.ErrorMessage = "403 User" + userID + " Already Logged In! @Logic";
            }
            else {
                userInfoEntity = userDAO.Login(userID, password);

                if (userInfoEntity == null) {
                    userInfoEntity = new UserInfoEntity();
                    userInfoEntity.ErrorMessage = "404 Wrong UserID or password! @Logic";
                }
                else {
                    confirmed       = true;
                    confirmedUserID = userInfoEntity.UserID;
                }
            }

            return userInfoEntity;
        }
        /*将UserInfo对应的Entity翻译为数据契约*/
        private void TranslateUserInfoEntityToUserInfoContractData(
            UserInfoEntity userInfoEntity,
            UserInfo userInfo) {

            userInfo.ErrorMessage = userInfoEntity.ErrorMessage;

            userInfo.UserID = userInfoEntity.UserID;
            userInfo.LastName = userInfoEntity.LastName;
            userInfo.FirstName = userInfoEntity.FirstName;
            userInfo.Nationality = userInfoEntity.Nationality;
            userInfo.Gender = userInfoEntity.Gender;
            userInfo.ABO = userInfoEntity.ABO;
            userInfo.Rh = userInfoEntity.Rh;
            userInfo.Birthplace = userInfoEntity.Birthplace;
            userInfo.Birthday = userInfoEntity.Birthday;
            userInfo.Deathplace = userInfoEntity.Deathplace;
            userInfo.Deathday = userInfoEntity.Deathday;
            userInfo.Balance = userInfoEntity.Balance;
            userInfo.LastLoginDate = userInfoEntity.LastLoginDate;
            userInfo.City = userInfoEntity.City;
            userInfo.Address = userInfoEntity.Address;
            userInfo.Phone = userInfoEntity.Phone;
            userInfo.Email = userInfoEntity.Email;
            userInfo.EmergencyContactPerson = userInfoEntity.EmergencyContactPerson;
        }
        /*获取用户资料:将不为空的ID请求转发至DL,并将反馈结果翻译为数据契约*/
        public UserInfo GetUserInfo(string userID) {

            UserInfoEntity userInfoEntity = null;

            if (userID == null) {
                userInfoEntity = new UserInfoEntity();
                userInfoEntity.ErrorMessage = "314 Empty UserID! @Service";
            }
            else {
                userInfoEntity = doctorLogic.GetUserInfo(userID);
            }

            UserInfo userInfo = new UserInfo();
            TranslateUserInfoEntityToUserInfoContractData(userInfoEntity, userInfo);

            return userInfo;
        }
Пример #4
0
        /*获取用户\患者信息*/
        public UserInfoEntity GetUserInfo(string userID) {
            /*数据库访问实例*/
            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            /*查询UserID是否有匹配*/
            User user = (from u in DEntities.Users
                         where u.UserID == userID
                         select u).FirstOrDefault();

            /*将结果转写为Entity,未转写密码等敏感信息*/
            UserInfoEntity userInfoEntity = null;
            if (user != null) {
                userInfoEntity = new UserInfoEntity() {
                    UserID = user.UserID,
                    LastName = user.LastName,
                    FirstName = user.FirstName,
                    Nationality = user.Nationality,
                    Gender = user.Gender,
                    ABO = user.ABO,
                    Rh = user.Rh,
                    Birthplace = user.Birthplace,
                    Birthday = user.Birthday,
                    Deathplace = user.Deathplace,
                    Deathday = user.Deathday,
                    Balance = user.Balance,
                    //LastLoginDate = user.LastLoginDate,
                    City = user.City,
                    Address = user.Address,
                    Phone = user.Phone,
                    Email = user.Email,
                    EmergencyContactPerson = user.EmergencyContactPerson
                };
            }

            return userInfoEntity;
        }
Пример #5
0
        /*获取用户\患者信息*/
        public UserInfoEntity GetUserInfo(string userID) {
            UserInfoEntity userInfoEntity = null;
            if (confirmed == false) {
                userInfoEntity = new UserInfoEntity();
                userInfoEntity.ErrorMessage = "315 Not Logged in Yet! @Logic";
            }
            else {
                userInfoEntity = doctorDAO.GetUserInfo(userID);

                if (userInfoEntity == null) {
                    userInfoEntity = new UserInfoEntity();
                    userInfoEntity.ErrorMessage = "316 Wrong UserID! @Logic";
                }
            }

            return userInfoEntity;
        }
Пример #6
0
        /*获取用户资料:判断是否登录、授权,向DAL提交请求并解读错误*/
        public UserInfoEntity GetUserInfo(string userID) {

            UserInfoEntity userInfoEntity = null;

            if (confirmed == false) {
                userInfoEntity = new UserInfoEntity();
                userInfoEntity.ErrorMessage = "Not Logged in Yet! @Logic";
            }
            else if (confirmedUserID != userID) {
                userInfoEntity = new UserInfoEntity();
                userInfoEntity.ErrorMessage = "Not Authorized to Get This Profile! @Logic";
            }
            else {
                userInfoEntity = userDAO.GetUserInfo(userID);

                if (userInfoEntity == null) {
                    userInfoEntity = new UserInfoEntity();
                    userInfoEntity.ErrorMessage = "Wrong UserID! @Logic";
                }
            }

            return userInfoEntity;
        }
Пример #7
0
        /*用户登录:若ID和Password均不为空,则转发至DL,将结果翻译为数据契约*/
        public UserInfo Login(string userID, string password) {

            UserInfoEntity userInfoEntity = null;

            if (userID == null) {
                userInfoEntity = new UserInfoEntity();
                userInfoEntity.ErrorMessage = "401 Empty UserID! @Service";
            }
            else if (password == null) {
                userInfoEntity = new UserInfoEntity();
                userInfoEntity.ErrorMessage = "402 Empty password! @Service";
            }
            else {
                userInfoEntity = userLogic.Login(userID, password);
            }

            UserInfo userInfo = new UserInfo();
            TranslateUserInfoEntityToUserInfoContractData(userInfoEntity, userInfo);

            return userInfo;
        }