private void Login() { try { // @TrườngNX on 20120905 // Lựa chọn ngôn ngữ của phiên làm việc // Căn cứ vào ngôn ngữ, load file language resources tương ứng //this.Cursor = Cursors.Wait; //var process = new ZAMainAppProcess(); string userName = txtUsername.Text; string txtMD5 = LSecurity.MD5Encrypt(txtPassword.Password); //process.createSession(); string responseMessage = ""; NGON_NGU_DTO ngonNguDTO = null; bool ret = process.doLoginWithSession(userName, txtMD5, ref ngonNguDTO, ref responseMessage); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "ret value: " + ret.ToString()); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "responseMessage value: " + responseMessage); // Nếu thành công if (ret) { // Nếu yêu cầu cập nhật phiên bản if (responseMessage != null && responseMessage.Equals(ApplicationConstant.CommonResponseMessage.M_ResponseMessage_Common_NotLatestVersion.layGiaTri()) ) { //MessageBoxResult retQuestion = LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Question); //if (retQuestion == MessageBoxResult.Yes) //{ // // Cập nhật phiên bản //} //else //{ //} MessageBoxResult retMessage = LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Question); if (retMessage == MessageBoxResult.Yes) { UserControl p = null; bool stretchWindow = false; p = new PresentationWPF.QuanTriHeThong.PhienBan.ucPhienBanCapNhat(); if (p != null) { Window window = new Window { Title = LLanguage.SearchResourceByKey("MENU.152_CAP_NHAT_PB"), WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen, //Icon = (rmb.ImageSource == null ? this.Icon : rmb.ImageSource), Width = (Double.IsNaN(p.Width) ? 1024 : p.Width), Height = (Double.IsNaN(p.Height) ? 700 : p.Height), Content = p, }; if (stretchWindow == true) { window.WindowState = WindowState.Maximized; } window.Width = 500; window.Height = 150; window.ResizeMode = ResizeMode.NoResize; //Mouse.OverrideCursor = Cursors.Arrow; this.Close(); window.ShowDialog(); } else { Mouse.OverrideCursor = Cursors.Arrow; LMessage.ShowMessage("Không tìm thấy chức năng này", LMessage.MessageBoxType.Warning); } } } #region Ghi ngôn ngữ ra file UIResources if (ngonNguDTO != null) { List <string> lstResource_vi = new List <string>(); List <string> lstResource_en = new List <string>(); List <string> lstResource_gl = new List <string>(); List <string> lstMessage_vi = new List <string>(); List <string> lstMessage_en = new List <string>(); List <string> lstMessage_gl = new List <string>(); string pathFileResource_vi = ClientInformation.LanguagesDir + "\\UIResources_vi.xaml"; string pathFileResource_en = ClientInformation.LanguagesDir + "\\UIResources_en.xaml"; string pathFileResource_gl = ClientInformation.LanguagesDir + "\\UIResources_gl.xaml"; string pathFileMessage_vi = ClientInformation.LanguagesDir + "\\MessageResources_vi.xaml"; string pathFileMessage_en = ClientInformation.LanguagesDir + "\\MessageResources_en.xaml"; string pathFileMessage_gl = ClientInformation.LanguagesDir + "\\MessageResources_gl.xaml"; string begin = "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" + "\n " + "xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"" + "\n " + "xmlns:my=\"clr-namespace:System;assembly=mscorlib\">"; string end = "\n\n</ResourceDictionary>"; if (!ngonNguDTO.checkResource && ngonNguDTO.lstResource != null) { lstResource_vi.Add(begin); lstResource_en.Add(begin); lstResource_gl.Add(begin); foreach (var item in ngonNguDTO.lstResource) { lstResource_vi.Add("\n <my:String x:Key=\"" + item.MA + "\">" + item.VIET_NAM + "</my:String>"); lstResource_en.Add("\n <my:String x:Key=\"" + item.MA + "\">" + item.ENGLISH + "</my:String>"); lstResource_gl.Add("\n <my:String x:Key=\"" + item.MA + "\">" + item.GLOBAL + "</my:String>"); } lstResource_vi.Add(end); lstResource_en.Add(end); lstResource_gl.Add(end); LFile.DeleteFile(pathFileResource_vi); LFile.DeleteFile(pathFileResource_en); LFile.DeleteFile(pathFileResource_gl); LFile.WriteListTextToFile(pathFileResource_vi, true, lstResource_vi); LFile.WriteListTextToFile(pathFileResource_en, true, lstResource_en); LFile.WriteListTextToFile(pathFileResource_gl, true, lstResource_gl); } if (!ngonNguDTO.checkMessage && ngonNguDTO.lstMessage != null) { lstMessage_vi.Add(begin); lstMessage_en.Add(begin); lstMessage_gl.Add(begin); foreach (var item in ngonNguDTO.lstMessage) { lstMessage_vi.Add("\n <my:String x:Key=\"" + item.MA + "\">" + item.VIET_NAM + "</my:String>"); lstMessage_en.Add("\n <my:String x:Key=\"" + item.MA + "\">" + item.ENGLISH + "</my:String>"); lstMessage_gl.Add("\n <my:String x:Key=\"" + item.MA + "\">" + item.GLOBAL + "</my:String>"); } lstMessage_vi.Add(end); lstMessage_en.Add(end); lstMessage_gl.Add(end); LFile.DeleteFile(pathFileMessage_vi); LFile.DeleteFile(pathFileMessage_en); LFile.DeleteFile(pathFileMessage_gl); LFile.WriteListTextToFile(pathFileMessage_vi, true, lstMessage_vi); LFile.WriteListTextToFile(pathFileMessage_en, true, lstMessage_en); LFile.WriteListTextToFile(pathFileMessage_gl, true, lstMessage_gl); } ChangeLanguage(); } #endregion ClientInformation.NgonNgu = ((RadComboBoxItem)cboLanguage.SelectedItem).Tag.ToString(); // @Truonglq set Culture ngôn ngữ cho Coltrol (telerik) //CultureInfo culture = new CultureInfo(((RadComboBoxItem)cboLanguage.SelectedItem).Tag.ToString()); //System.Threading.Thread.CurrentThread.CurrentCulture = culture; //System.Threading.Thread.CurrentThread.CurrentUICulture = culture; InitializeCultures(); //InitializeCulturesTelerik(); LocalizationManager.Manager = new LocalizationManager() { ResourceManager = LocalizationRadControl.ResourceManager }; // Khởi tạo phiên làm việc, chọn đơn vị nghiệp vụ cần thao tác dữ liệu if (!ClientInformation.LoaiNguoiSuDung.Equals(BusinessConstant.LoaiNguoiSuDung.CAP_SA.layGiaTri())) { LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "BeforeInitSession"); InitSession initSession = new InitSession(ClientInformation.ListPhongGD); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "AfterInitSession"); initSession.ResizeMode = ResizeMode.NoResize; initSession.Height = 250; initSession.Width = 600; initSession.WindowStartupLocation = WindowStartupLocation.CenterScreen; initSession.lblNguoiDungValue.Content = "(" + ClientInformation.TenDangNhap + ") " + ClientInformation.HoTen; initSession.lblChiNhanhValue.Content = "(" + ClientInformation.MaDonVi + ") " + ClientInformation.TenDonVi; //initSession.ListPhongGD = ClientInformation.ListPhongGD; LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "BeforeInitSession Show"); initSession.Show(); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "AfterInitSession Show"); this.Cursor = Cursors.Arrow; Close(); } else { ClientInformation.TenDonViGiaoDich = ClientInformation.TenDonVi; ClientInformation.MaDonViGiaoDich = ClientInformation.MaDonVi; ClientInformation.IdDonViGiaoDich = ClientInformation.IdDonVi; ClientInformation.PhuongPhapHachToan = null; MainWindow mainwindow = new MainWindow(); mainwindow.Show(); this.Cursor = Cursors.Arrow; Close(); } } else { ImageBehavior.SetAnimatedSource(imgWaiting, null); // Nếu yêu cầu đổi mật khẩu if (responseMessage != null && ( responseMessage.Equals(ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_YeuCauDoiMatKhauLanDau.layGiaTri()) || responseMessage.Equals(ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_YeuCauDoiMatKhau.layGiaTri()) ) ) { LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "IF M_ResponseMessage_Login_YeuCauDoiMatKhau"); MessageBoxResult retQuestion = LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Question); if (retQuestion == MessageBoxResult.Yes) { txtPassword.Clear(); ChangePassword changePassword = new ChangePassword(); Window window = new Window(); window.ResizeMode = ResizeMode.NoResize; window.Height = 180; window.Width = 500; window.WindowStartupLocation = WindowStartupLocation.CenterScreen; window.Title = LLanguage.SearchResourceByKey("U.ZAMainApp.ChangePassword.Title"); window.Content = changePassword; changePassword.userName = userName; window.ShowDialog(); //LMessage.ShowMessage("Change pass", LMessage.MessageBoxType.Warning); } else { return; } } else { LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "ELSE M_ResponseMessage_Login_YeuCauDoiMatKhau"); LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Warning); } } } //else catch (Exception ex) { LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, "Login() Exception"); ImageBehavior.SetAnimatedSource(imgWaiting, null); //this.Close(); //Application.Current.Shutdown(); this.Cursor = Cursors.Arrow; if (ex.GetType() == typeof(CustomException)) { new frmThongBaoLoi(ex.Message, ex.InnerException).ShowDialog(); } else { if (ex.InnerException != null) { if (ex.InnerException.GetType() == typeof(CustomException)) { new frmThongBaoLoi(ex.InnerException.Message, ex.InnerException).ShowDialog(); } else { new frmThongBaoLoi("M.ResponseMessage.Login.KhongThanhCong", ex).ShowDialog(); } } else { new frmThongBaoLoi("M.ResponseMessage.Login.KhongThanhCong", ex).ShowDialog(); } } LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); } }
private void Login() { try { // @TrườngNX on 20120905 // Lựa chọn ngôn ngữ của phiên làm việc // Căn cứ vào ngôn ngữ, load file language resources tương ứng //this.Cursor = Cursors.Wait; //var process = new ZAMainAppProcess(); string userName = txtUsername.Text; string txtMD5 = LSecurity.MD5Encrypt(txtPassword.Password); //process.createSession(); string responseMessage = ""; NGON_NGU_DTO ngonNguDTO = null; bool ret = process.doLoginWithSession(userName, txtMD5, ref ngonNguDTO, ref responseMessage); // Nếu thành công if (ret) { // Nếu yêu cầu cập nhật phiên bản if (responseMessage != null && responseMessage.Equals(ApplicationConstant.CommonResponseMessage.M_ResponseMessage_Common_NotLatestVersion.layGiaTri()) ) { //MessageBoxResult retQuestion = LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Question); //if (retQuestion == MessageBoxResult.Yes) //{ // // Cập nhật phiên bản //} //else //{ //} MessageBoxResult retMessage = LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Question); if (retMessage == MessageBoxResult.Yes) { UserControl p = null; bool stretchWindow = false; p = new PresentationWPF.QuanTriHeThong.PhienBan.ucPhienBanCapNhat(); if (p != null) { Window window = new Window { Title = LLanguage.SearchResourceByKey("MENU.152_CAP_NHAT_PB"), WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen, //Icon = (rmb.ImageSource == null ? this.Icon : rmb.ImageSource), Width = (Double.IsNaN(p.Width) ? 1024 : p.Width), Height = (Double.IsNaN(p.Height) ? 700 : p.Height), Content = p, }; if (stretchWindow == true) { window.WindowState = WindowState.Maximized; } window.Width = 500; window.Height = 150; window.ResizeMode = ResizeMode.NoResize; //Mouse.OverrideCursor = Cursors.Arrow; this.Close(); window.ShowDialog(); } else { Mouse.OverrideCursor = Cursors.Arrow; LMessage.ShowMessage("Không tìm thấy chức năng này", LMessage.MessageBoxType.Warning); } } } ClientInformation.NgonNgu = ((RadComboBoxItem)cboLanguage.SelectedItem).Tag.ToString(); // @Truonglq set Culture ngôn ngữ cho Coltrol (telerik) //CultureInfo culture = new CultureInfo(((RadComboBoxItem)cboLanguage.SelectedItem).Tag.ToString()); //System.Threading.Thread.CurrentThread.CurrentCulture = culture; //System.Threading.Thread.CurrentThread.CurrentUICulture = culture; InitializeCultures(); //InitializeCulturesTelerik(); LocalizationManager.Manager = new LocalizationManager() { ResourceManager = LocalizationRadControl.ResourceManager }; // Khởi tạo phiên làm việc, chọn đơn vị nghiệp vụ cần thao tác dữ liệu if (!ClientInformation.LoaiNguoiSuDung.Equals(BusinessConstant.LoaiNguoiSuDung.CAP_SA.layGiaTri())) { InitSession initSession = new InitSession(ClientInformation.ListPhongGD); initSession.ResizeMode = ResizeMode.NoResize; initSession.Height = 250; initSession.Width = 600; initSession.WindowStartupLocation = WindowStartupLocation.CenterScreen; initSession.lblNguoiDungValue.Content = "(" + ClientInformation.TenDangNhap + ") " + ClientInformation.HoTen; initSession.lblChiNhanhValue.Content = "(" + ClientInformation.MaDonVi + ") " + ClientInformation.TenDonVi; //initSession.ListPhongGD = ClientInformation.ListPhongGD; initSession.Show(); this.Cursor = Cursors.Arrow; Close(); } else { ClientInformation.TenDonViGiaoDich = ClientInformation.TenDonVi; ClientInformation.MaDonViGiaoDich = ClientInformation.MaDonVi; ClientInformation.IdDonViGiaoDich = ClientInformation.IdDonVi; ClientInformation.PhuongPhapHachToan = null; MainWindow mainwindow = new MainWindow(); mainwindow.Show(); this.Cursor = Cursors.Arrow; Close(); } } else { ImageBehavior.SetAnimatedSource(imgWaiting, null); // Nếu yêu cầu đổi mật khẩu if (responseMessage != null && ( responseMessage.Equals(ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_YeuCauDoiMatKhauLanDau.layGiaTri()) || responseMessage.Equals(ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_YeuCauDoiMatKhau.layGiaTri()) ) ) { MessageBoxResult retQuestion = LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Question); if (retQuestion == MessageBoxResult.Yes) { txtPassword.Clear(); ChangePassword changePassword = new ChangePassword(); Window window = new Window(); window.ResizeMode = ResizeMode.NoResize; window.Height = 180; window.Width = 500; window.WindowStartupLocation = WindowStartupLocation.CenterScreen; window.Title = LLanguage.SearchResourceByKey("U.ZAMainApp.ChangePassword.Title"); window.Content = changePassword; changePassword.userName = userName; window.ShowDialog(); //LMessage.ShowMessage("Change pass", LMessage.MessageBoxType.Warning); } else { return; } } else { LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Warning); } } } //else catch (Exception ex) { ImageBehavior.SetAnimatedSource(imgWaiting, null); //this.Close(); //Application.Current.Shutdown(); this.Cursor = Cursors.Arrow; if (ex.GetType() == typeof(CustomException)) { new frmThongBaoLoi(ex.Message, ex.InnerException).ShowDialog(); } else { if (ex.InnerException != null) { if (ex.InnerException.GetType() == typeof(CustomException)) { new frmThongBaoLoi(ex.InnerException.Message, ex.InnerException).ShowDialog(); } else { new frmThongBaoLoi("M.ResponseMessage.Login.KhongThanhCong", ex).ShowDialog(); } } else { new frmThongBaoLoi("M.ResponseMessage.Login.KhongThanhCong", ex).ShowDialog(); } } LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); } }
public JsonResult CheckLogin(string user, string password, int width, int height) { try { if (fcnValidForm(user, password)) { ZAMainAppProcess obj = new ZAMainAppProcess(); string sMessage = ""; string ngongu = ""; NGON_NGU_DTO ngonNguDto = new NGON_NGU_DTO(); string sMatKhau = LSecurity.MD5Encrypt(password); if (UserInformation.Session_User.IsNullOrEmpty()) { UserInformation.Session_User = new Presentation.Process.Common.UserInformation(); } if (UserInformation.Session_User.NgonNgu.IsNullOrEmpty()) { UserInformation.Session_User.NgonNgu = "vi"; } else { ngongu = UserInformation.Session_User.NgonNgu; } UserInformation.Session_User.U_PhienBan = LanguageNode.GetValueUILanguage("U.PhienBan"); UserInformation.Session_User.M_PhienBan = LanguageNode.GetValueMessageLanguage("M.PhienBan"); System.Web.HttpContext.Current.Session["UserInformation"] = UserInformation.Session_User; bool isResult = obj.doLoginWithSession(user, sMatKhau, ref ngonNguDto, ref sMessage); UserInformation.Session_User = (Presentation.Process.Common.UserInformation)System.Web.HttpContext.Current.Session["UserInformation"]; UserInformation.Session_User.NgonNgu = ngongu; if (!ngonNguDto.IsNullOrEmpty()) { if (!ngonNguDto.lstResource.IsNullOrEmpty() && ngonNguDto.lstResource.Count() > 0) { LanguageNode.LoadUILanguage(ngonNguDto.lstResource.ToList()); } if (!ngonNguDto.lstMessage.IsNullOrEmpty() && ngonNguDto.lstMessage.Count() > 0) { LanguageNode.LoadMessageLanguage(ngonNguDto.lstMessage.ToList()); } } //if (sMessage != null && (sMessage.Equals(Utilities.Solution.ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_YeuCauDoiMatKhauLanDau.layGiaTri()) || sMessage.Equals(Utilities.Solution.ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_YeuCauDoiMatKhau.layGiaTri()))) //{ // ses.USER_ID = user; // ses.USER_NAME = objUser.USER_NAME; // ses.FULL_NAME = objUser.FULL_NAME; // ses.MAT_KHAU = password; // ses.PHAI_DOI_MK = 1; // SessionUser.Session_User = ses; // return Json(Common.ResultJson.Success.LayMa(), JsonRequestBehavior.AllowGet); //} if (isResult) { //ses.PHAI_DOI_MK = 0; //ses.USER_ID = user; //ses.USER_NAME = objUser.TenDangNhap; //ses.FULL_NAME = objUser.HoTen; //ses.DON_VI_TAO = objUser.DON_VI_QLY; //Presentation.Process.DanhMucServiceRef.DM_DON_VI objDV = objdmdv.getDonViByMa(objUser.DON_VI_QLY); //ses.ID_DON_VI_TAO = objDV.ID; //ses.DON_VI_QLY = objDV.MA_DVI_CHA; //ses.LOAI_DON_VI = objDV.LOAI_DVI; //ses.TEN_DON_VI = objDV.TEN_GDICH; //ses.MAT_KHAU = password; //ses.LIST_CHUC_NANG = objUser.ListChucNang; //double dbCount = double.Parse(Application["access_count"].ToString()); //dbCount = dbCount + 1; //Application["access_count"] = dbCount; //SessionUser.Session_User = ses; return(Json("", JsonRequestBehavior.AllowGet)); } else { return(Json(Common.ResultJson.Error.LayMa(), JsonRequestBehavior.AllowGet)); } } else { return(Json(Common.ResultJson.Error.LayMa(), JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(Common.ResultJson.Error.LayMa(), JsonRequestBehavior.AllowGet)); } }