public ActionResult CorrectionProxyPassword(Models.HisAccountViewModel model) { if (!ModelState.IsValid) { return(View("Error")); } try { var GenAccount = DB_GEN_Repo.Where(w => w.chUserID == model.chUserID).FirstOrDefault(); if (GenAccount != null) { GenAccount.chXData = model.chXData; GenAccount.chXDataHosp = model.chXDataHosp; GenAccount.dtLastModified = DateTime.Now; DB_GEN_Repo.UnitOfWork.Commit(); } return(View("PasswordChanged")); } catch (Exception ex) { return(View("Error")); } }
public ActionResult Query(string UserID) { var myAccount = DB_GEN_Repo.GetUser(UserID);// DB_GEN.GenProxyAccount.Find(UserID); if (myAccount == null) { return(View("AccountNotFound")); } string connToHis = ""; switch (myAccount.chXDataHosp.Trim()) { case "HL": connToHis = "server=HLOPDSQL;user id=guid;password=gpwd;persistsecurityinfo=True;database=DB_GEN"; break; case "DL": connToHis = "server=DLOPDSQL;user id=guid;password=gpwd;persistsecurityinfo=True;database=DB_GEN"; break; case "XD": connToHis = "server=OPDSQL1;user id=guid;password=gpwd;persistsecurityinfo=True;database=DB_GEN"; break; case "TC": connToHis = "server=TCOPDSQL;user id=guid;password=gpwd;persistsecurityinfo=True;database=DB_GEN"; break; case "GS": connToHis = "server=GSSVR;user id=guid;password=gpwd;persistsecurityinfo=True;database=DB_GEN"; break; case "UL": connToHis = "server=ULSVR;user id=guid;password=gpwd;persistsecurityinfo=True;database=DB_GEN"; break; case "TL": connToHis = "server=TLSVR;user id=guid;password=gpwd;persistsecurityinfo=True;database=DB_GEN"; break; default: connToHis = ""; break; } Models.AccountDetailViewModel detail = new Models.AccountDetailViewModel(); detail.chUserID = myAccount.chUserID; detail.chUserName = myAccount.chUserName; detail.chDeptName = myAccount.chDeptName; detail.chEMail = myAccount.chEMail; detail.chEndDate = myAccount.chEndDate; detail.dtEndDate = myAccount.dtEndDate; detail.dtLastModified = myAccount.dtLastModified; detail.chXDataHosp = myAccount.chXDataHosp; detail.chUserType = myAccount.chUserType; detail.chXData = myAccount.chXData; detail.chUserID10 = myAccount.chUserID10; if (!string.IsNullOrWhiteSpace(connToHis)) { AccountSync.Models.HISAccount.EFUnitOfWork hisUOW = new Models.HISAccount.EFUnitOfWork(); hisUOW.ConnectionString = connToHis; HisAccountRepo = Models.HISAccount.RepositoryHelper.GetGenUserProfile1Repository(hisUOW); var hisUser = HisAccountRepo.Where(w => (w.chUserID == detail.chUserID10)).FirstOrDefault(); if (hisUser == null) { HisDoctorRepo = Models.HISAccount.RepositoryHelper.GetGenDoctorTblRepository(hisUOW); //拉出所有醫師代碼 var hisDoctors = HisDoctorRepo.Where(w => (w.chIDNo == detail.chUserID10)); foreach (var doctor in hisDoctors) { var docAccount = new Models.HisAccountViewModel(); docAccount.chUserID = detail.chUserID; docAccount.UserID = doctor.chDocNo; docAccount.UserName = doctor.chDocName; docAccount.isRightPassword = false; docAccount.chXData = "Empty"; docAccount.chXDataHosp = detail.chXDataHosp; var docResult = HisAccountRepo.Where(w => w.chUserID == doctor.chDocNo).FirstOrDefault(); if (docResult != null) { docAccount.chXData = docResult.chXData; if (docAccount.chXData == detail.chXData) { docAccount.isRightPassword = true; } else { docAccount.isRightPassword = false; } detail.HisAccounts.Add(docAccount); } } } else { var hisAccount = new Models.HisAccountViewModel(); hisAccount.chUserID = detail.chUserID; hisAccount.UserID = "非醫師"; hisAccount.UserName = detail.chUserName; hisAccount.isRightPassword = detail.chXData == hisUser.chXData ? true : false; hisAccount.chXData = hisUser.chXData; hisAccount.chXDataHosp = detail.chUserID; detail.HisAccounts.Add(hisAccount); } } else { detail.chHisXData = "密碼不是來自特定院區"; } //return View("AccountDetail", myAccount); return(View("QueryResult", detail)); }