public bool doLoginWithSession(string userName, string passWord, ref NGON_NGU_DTO ngonNguDTO, ref string responseMessage) { // Kiểm tra kết nối, server, service trước khi request Common.Utilities.IsRequestAllow(ApplicationConstant.SystemService.ZAMainAppService.layGiaTri()); // Khởi tạo và gán các giá trị cho request LoginRequest request = Common.Utilities.PrepareRequest(new LoginRequest()); request.License = ClientInformation.License; request.Version = ClientInformation.Version; request.UserName = userName.ToUpper(); request.PassWord = passWord; request.Module = DatabaseConstant.Module.QTHT; request.Function = DatabaseConstant.Function.HT_LOGIN; request.Action = DatabaseConstant.Action.DANG_NHAP; request.Company = ApplicationConstant.layDonViSuDung(ClientInformation.Company); if (ClientInformation.ClientType.Equals(ApplicationConstant.ClientType.DESKTOP.layGiaTri())) { request.PhienBanResource = LLanguage.SearchResourceByKey("U.PhienBan"); request.PhienBanMessage = LLanguage.SearchResourceByKey("M.PhienBan"); } if (ClientInformation.ClientType.Equals(ApplicationConstant.ClientType.WEB.layGiaTri())) { UserInformation userInfo = HttpContext.Current.Session["UserInformation"] as UserInformation; request.PhienBanResource = userInfo.U_PhienBan; request.PhienBanMessage = userInfo.M_PhienBan; } // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, "Login at Client : " + userName); LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.ERR, "Login at Client : " + userName); // Lấy kết quả trả về LoginResponse response = Client.doLoginWithSession(request); // Kiểm tra kết quả trả về LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.ERR, "Before ValidResponse"); Common.Utilities.ValidResponse(request, response); LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.ERR, "After ValidResponse"); // Xử lý dữ liệu trả về if (response.ResponseStatus == ApplicationConstant.ResponseStatus.KHONG_THANH_CONG) { responseMessage = response.ResponseMessage; return(false); } else { responseMessage = response.ResponseMessage; string sessionId = response.SessionId; if (ClientInformation.ClientType.Equals(ApplicationConstant.ClientType.DESKTOP.layGiaTri())) { ClientInformation.SessionId = sessionId; ClientInformation.TenDangNhap = response.NguoiSuDung.MA_DANG_NHAP; ClientInformation.ListChucNang = response.ListChucNang; if (response.NguoiSuDung != null) { ClientInformation.IdNguoiSuDung = response.NguoiSuDung.ID; ClientInformation.HoTen = response.NguoiSuDung.TEN_DAY_DU; ClientInformation.MaDonViQuanLy = response.NguoiSuDung.MA_DVI_QLY; ClientInformation.LoaiNguoiSuDung = response.NguoiSuDung.PHAN_LOAI_NSD; } if (response.DonViGiaoDich != null) { ClientInformation.IdDonViGiaoDich = response.DonViGiaoDich.ID; ClientInformation.MaDonViGiaoDich = response.DonViGiaoDich.MA_DVI; ClientInformation.TenDonViGiaoDich = response.DonViGiaoDich.TEN_GDICH; ClientInformation.PhuongPhapHachToan = response.DonViGiaoDich.MA_HACH_TOAN; } if (response.DonVi != null) { ClientInformation.IdDonVi = response.DonVi.ID; ClientInformation.MaDonVi = response.DonVi.MA_DVI; ClientInformation.TenDonVi = response.DonVi.TEN_GDICH; } if (response.DonViQuanLy != null) { ClientInformation.IdDonViQuanLy = response.DonViQuanLy.ID; ClientInformation.MaDonViQuanLy = response.DonViQuanLy.MA_DVI; ClientInformation.TenDonViQuanLy = response.DonViQuanLy.TEN_GDICH; } if (response.DonViRoot != null) { ClientInformation.IdToChu = response.DonViRoot.ID; ClientInformation.MaToChuc = response.DonViRoot.MA_DVI; ClientInformation.TenToChuc = response.DonViRoot.TEN_GDICH; } if (response.ListPhongGD != null) { ClientInformation.ListPhongGD = response.ListPhongGD.ToList(); } if (response.NgonNguDTO != null) { ngonNguDTO = response.NgonNguDTO; } if (response.ShowConfigDTO != null) { WriteShowConfig(response.ShowConfigDTO); } ClientInformation.NgayLamViecTruoc = response.NgayLamViecTruoc; ClientInformation.NgayLamViecHienTai = response.NgayLamViecHienTai; ClientInformation.NgayLamViecSau = response.NgayLamViecSau; ClientInformation.MaDongNoiTe = response.MaDongNoiTe; ClientInformation.MaQuocGiaBanDia = response.MaQuocGiaBanDia; } else { UserInformation userInfo = new UserInformation(); userInfo.SessionId = sessionId; userInfo.TenDangNhap = response.NguoiSuDung.MA_DANG_NHAP; userInfo.ListChucNang = response.ListChucNang; if (response.NguoiSuDung != null) { userInfo.IdNguoiSuDung = response.NguoiSuDung.ID; userInfo.HoTen = response.NguoiSuDung.TEN_DAY_DU; userInfo.MaDonViQuanLy = response.NguoiSuDung.MA_DVI_QLY; userInfo.LoaiNguoiSuDung = response.NguoiSuDung.PHAN_LOAI_NSD; } if (response.DonViGiaoDich != null) { userInfo.IdDonViGiaoDich = response.DonViGiaoDich.ID; userInfo.MaDonViGiaoDich = response.DonViGiaoDich.MA_DVI; userInfo.TenDonViGiaoDich = response.DonViGiaoDich.TEN_GDICH; userInfo.PhuongPhapHachToan = response.DonViGiaoDich.MA_HACH_TOAN; } if (response.DonVi != null) { userInfo.IdDonVi = response.DonVi.ID; userInfo.MaDonVi = response.DonVi.MA_DVI; userInfo.TenDonVi = response.DonVi.TEN_GDICH; } if (response.DonViQuanLy != null) { userInfo.IdDonViQuanLy = response.DonViQuanLy.ID; userInfo.MaDonViQuanLy = response.DonViQuanLy.MA_DVI; userInfo.TenDonViQuanLy = response.DonViQuanLy.TEN_GDICH; } if (response.DonViRoot != null) { userInfo.IdToChu = response.DonViRoot.ID; userInfo.MaToChuc = response.DonViRoot.MA_DVI; userInfo.TenToChuc = response.DonViRoot.TEN_GDICH; } if (response.ListPhongGD != null) { userInfo.ListPhongGD = response.ListPhongGD.ToList(); } if (response.NgonNguDTO != null) { ngonNguDTO = response.NgonNguDTO; } userInfo.NgayLamViecTruoc = response.NgayLamViecTruoc; userInfo.NgayLamViecHienTai = response.NgayLamViecHienTai; userInfo.NgayLamViecSau = response.NgayLamViecSau; userInfo.MaDongNoiTe = response.MaDongNoiTe; userInfo.MaQuocGiaBanDia = response.MaQuocGiaBanDia; HttpContext.Current.Session["UserInformation"] = userInfo; } ClientInformation.Company = ApplicationConstant.layGiaTri(response.Company); return(true); } }
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); } }
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); } }
public bool doLoginWithSession(string userName, string passWord, ref NGON_NGU_DTO ngonNguDTO, ref string responseMessage, UserInformation userInfomation) { // Kiểm tra kết nối, server, service trước khi request Common.WebUtilities.IsRequestAllow(userInformation.ServerIP, userInformation.ServerPort, ApplicationConstant.SystemService.ZAMainAppService.layGiaTri()); // Khởi tạo và gán các giá trị cho request LoginRequest request = Common.WebUtilities.PrepareRequest(new LoginRequest(), userInformation); request.License = userInformation.License; request.Version = userInformation.Version; request.UserName = userName.ToUpper(); request.PassWord = passWord; request.Module = DatabaseConstant.Module.QTHT; request.Function = DatabaseConstant.Function.HT_LOGIN; request.Action = DatabaseConstant.Action.DANG_NHAP; request.Company = ApplicationConstant.layDonViSuDung(userInformation.Company); // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, "Login at Client : " + userName); // Lấy kết quả trả về LoginResponse response = Client.doLoginWithSession(request); // Kiểm tra kết quả trả về Common.WebUtilities.ValidResponse(request, response, userInformation); // Xử lý dữ liệu trả về if (response.ResponseStatus == ApplicationConstant.ResponseStatus.KHONG_THANH_CONG) { responseMessage = response.ResponseMessage; return(false); } else { responseMessage = response.ResponseMessage; string sessionId = response.SessionId; userInformation.SessionId = sessionId; userInformation.TenDangNhap = response.NguoiSuDung.MA_DANG_NHAP; userInformation.ListChucNang = response.ListChucNang; if (response.NguoiSuDung != null) { userInformation.IdNguoiSuDung = response.NguoiSuDung.ID; userInformation.HoTen = response.NguoiSuDung.TEN_DAY_DU; userInformation.MaDonViQuanLy = response.NguoiSuDung.MA_DVI_QLY; userInformation.LoaiNguoiSuDung = response.NguoiSuDung.PHAN_LOAI_NSD; } if (response.DonViGiaoDich != null) { userInformation.IdDonViGiaoDich = response.DonViGiaoDich.ID; userInformation.MaDonViGiaoDich = response.DonViGiaoDich.MA_DVI; userInformation.TenDonViGiaoDich = response.DonViGiaoDich.TEN_GDICH; userInformation.PhuongPhapHachToan = response.DonViGiaoDich.MA_HACH_TOAN; } if (response.DonVi != null) { userInformation.IdDonVi = response.DonVi.ID; userInformation.MaDonVi = response.DonVi.MA_DVI; userInformation.TenDonVi = response.DonVi.TEN_GDICH; } if (response.DonViQuanLy != null) { userInformation.IdDonViQuanLy = response.DonViQuanLy.ID; userInformation.MaDonViQuanLy = response.DonViQuanLy.MA_DVI; userInformation.TenDonViQuanLy = response.DonViQuanLy.TEN_GDICH; } if (response.DonViRoot != null) { userInformation.IdToChu = response.DonViRoot.ID; userInformation.MaToChuc = response.DonViRoot.MA_DVI; userInformation.TenToChuc = response.DonViRoot.TEN_GDICH; } if (response.ListPhongGD != null) { userInformation.ListPhongGD = response.ListPhongGD.ToList(); } if (response.NgonNguDTO != null) { ngonNguDTO = response.NgonNguDTO; } userInformation.NgayLamViecTruoc = response.NgayLamViecTruoc; userInformation.NgayLamViecHienTai = response.NgayLamViecHienTai; userInformation.NgayLamViecSau = response.NgayLamViecSau; userInformation.MaDongNoiTe = response.MaDongNoiTe; userInformation.MaQuocGiaBanDia = response.MaQuocGiaBanDia; userInformation.Company = ApplicationConstant.layGiaTri(response.Company); return(true); } }
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)); } }