/*将DoctorInfo对应的Entity翻译为数据契约*/ private void TranslateDoctorInfoEntityToDoctorInfoContractData( DoctorInfoEntity doctorInfoEntity, DoctorInfo doctorInfo) { doctorInfo.ErrorMessage = doctorInfoEntity.ErrorMessage; doctorInfo.SectionID = doctorInfoEntity.SectionID; doctorInfo.DoctorID = doctorInfoEntity.DoctorID; doctorInfo.UserID = doctorInfoEntity.UserID; doctorInfo.LastName = doctorInfoEntity.LastName; doctorInfo.FirstName = doctorInfoEntity.FirstName; doctorInfo.Designation = doctorInfoEntity.Designation; doctorInfo.Resume = doctorInfoEntity.Resume; doctorInfo.Phone = doctorInfoEntity.Phone; doctorInfo.Fax = doctorInfoEntity.Fax; doctorInfo.Email = doctorInfoEntity.Email; doctorInfo.Vocation = doctorInfoEntity.Vocation; doctorInfo.Portrait = doctorInfoEntity.Portrait; doctorInfo.LastLoginDate = doctorInfoEntity.LastLoginDate; }
/*医生登录:若ID和Password均不为空,则转发至DL,将结果翻译为数据契约*/ public DoctorInfo Login(string doctorID, string password) { DoctorInfoEntity doctorInfoEntity = null; if (doctorID == null) { doctorInfoEntity = new DoctorInfoEntity(); doctorInfoEntity.ErrorMessage = "301 Empty DoctorID! @Service"; } else if (password == null) { doctorInfoEntity = new DoctorInfoEntity(); doctorInfoEntity.ErrorMessage = "302 Empty password! @Service"; } else { doctorInfoEntity = doctorLogic.Login(doctorID, password); } DoctorInfo doctorInfo = new DoctorInfo(); TranslateDoctorInfoEntityToDoctorInfoContractData(doctorInfoEntity, doctorInfo); return doctorInfo; }
/*医生登录:接受并转发ID和Password,探测或解读错误*/ public DoctorInfoEntity Login(string doctorID, string password) { DoctorInfoEntity doctorInfoEntity = null; if ((confirmed == true) && (confirmedDoctorID == doctorID)) { doctorInfoEntity = new DoctorInfoEntity(); doctorInfoEntity.ErrorMessage = "303 " + doctorID + " Already Logged In! @Logic"; } else { doctorInfoEntity = doctorDAO.Login(doctorID, password); if (doctorInfoEntity == null) { doctorInfoEntity = new DoctorInfoEntity(); doctorInfoEntity.ErrorMessage = "304 Wrong DoctorID or Password! @Logic"; } else { confirmed = true; confirmedDoctorID = doctorInfoEntity.DoctorID; } } return doctorInfoEntity; }
/*医生登录:校验(ID,Password)是否与数据库记录匹配*/ public DoctorInfoEntity Login(string doctorID, string password) { /*数据库访问实例*/ DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities(); /*查询(DoctorID,password)对是否匹配*/ Doctor doctor = (from d in DEntities.Doctors where ((d.DoctorID == doctorID) && (d.Password == password)) select d).FirstOrDefault(); /*将结果转写为Entity,仅转写必要登录信息*/ DoctorInfoEntity doctorInfoEntity = null; if (doctor != null) { doctorInfoEntity = new DoctorInfoEntity() { DoctorID = doctor.DoctorID, LastName = doctor.LastName, FirstName = doctor.FirstName, SectionID = doctor.SectionID, Designation = doctor.Designation, LastLoginDate = doctor.LastLoginDate }; /*更新该User的LastLoginDate域*/ doctor.LastLoginDate = DateTime.Now; DEntities.SaveChanges(); } return doctorInfoEntity; }
/*获取特定医师信息:提交DoctorID,返回该医师的信息*/ public DoctorInfoEntity GetDoctorInfo(string doctorID) { DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities(); /*查询Doctor域为doctorID的Doctor记录*/ var doctor = (from d in DEntities.Doctors where d.DoctorID == doctorID select d).FirstOrDefault(); DoctorInfoEntity doctorInfoEntity = null; if (doctor != null) { doctorInfoEntity = new DoctorInfoEntity(); doctorInfoEntity.SectionID = doctor.SectionID; doctorInfoEntity.DoctorID = doctor.DoctorID; doctorInfoEntity.UserID = doctor.UserID; doctorInfoEntity.LastName = doctor.LastName; doctorInfoEntity.FirstName = doctor.FirstName; doctorInfoEntity.Designation = doctor.Designation; doctorInfoEntity.Resume = doctor.Resume; doctorInfoEntity.Phone = doctor.Phone; doctorInfoEntity.Fax = doctor.Fax; doctorInfoEntity.Email = doctor.Email; doctorInfoEntity.Vocation = doctor.Vocation; doctorInfoEntity.Portrait = doctor.Portrait; } return doctorInfoEntity; }
/*获取特定医师信息:提交DoctorID,返回该医师的信息*/ public DoctorInfoEntity GetDoctorInfo(string doctorID) { DoctorInfoEntity doctorInfoEntity = openAccessDAO.GetDoctorInfo(doctorID); if (doctorInfoEntity == null) { doctorInfoEntity = new DoctorInfoEntity(); doctorInfoEntity.ErrorMessage = "143 No Doctor of " + doctorID + "! @Logic"; } return doctorInfoEntity; }
/*获取特定医师信息:提交DoctorID,返回该医师的信息*/ public DoctorInfo GetDoctorInfo(string doctorID) { DoctorInfoEntity doctorInfoEntity = null; if (doctorID == null) { doctorInfoEntity = new DoctorInfoEntity(); doctorInfoEntity.ErrorMessage = "113 Empty doctorID! @Service"; } else { doctorInfoEntity = openAccessLogic.GetDoctorInfo(doctorID); } DoctorInfo doctorInfo = new DoctorInfo(); TranslateDoctorInfoEntityToDoctorInfoContractData(doctorInfoEntity, doctorInfo); return doctorInfo; }