private void AcceptButton_Click(object sender, EventArgs e) { try { HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory(); Hepsa.Core.BLL.BLLUserLogin_T UserLogin = new Hepsa.Core.BLL.BLLUserLogin_T(); UserLogin.UserName_nvc = this.UserName_nvcTextBox.Text; UserLogin.Password_nvc = Hepsa.Core.Common.Security.MD5(this.Password_nvcTextBox.Text); HPS.BLL.UserBLL.BLLUser_T UserEntity = UserFactory.Login(UserLogin); var OnlineUserEntity = new HPS.BLL.OnlineUserBLL.BLLOnlineUser_T(); var OnlineUserFactory = new HPS.BLL.OnlineUserBLL.BLLOnlineUser_TFactory(); if (!CheckComputerRegistration(UserEntity)) { throw new ApplicationException("این کامپیوتر مجاز به استفاده از سیستم نمی باشد"); } if (UserEntity != null) { HPS.Common.CurrentUser.user = UserEntity; if (Hepsa.Core.Common.ApplicationInfo.MainForm != null) { this.SaveSetting(); this.makeLog(); //--hp> var onlineUsertable = new DataTable(); OnlineUserFactory.GetAllByCondition(string.Format("[OnlineUser_T].[UserName_nvc]='{0}' and LoginDate_vc='{1}' AND LogOutDate_vc IS NULL ", HPS.Common.CurrentUser.user.UserName_nvc, OnlineUserFactory.ServerJalaliDate), ref onlineUsertable); if (onlineUsertable != null && onlineUsertable.Rows.Count > 1 && (UserEntity.MultiAccess_bit == false)) { throw new ApplicationException("حساب کاربری شما در سیستم دیگر در حال استفاده می باشد "); } //--<hp OnlineUserEntity.UserName_nvc = UserEntity.UserName_nvc; OnlineUserEntity.LoginDate_vc = OnlineUserFactory.ServerJalaliDate; OnlineUserEntity.LoginTime_vc = OnlineUserFactory.ServerTime; OnlineUserEntity.MacAddress_nvc = Hepsa.Core.Common.ApplicationInfo.MacAddress; OnlineUserFactory.Insert(OnlineUserEntity); HPS.Common.CurrentUser.user.OnlineUserID_int = OnlineUserEntity.OnlineUserID_int; this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
public BLL.UserBLL.BLLUser_T Login(Hepsa.Core.BLL.BLLUserLogin_T userLoin) { try { if (userLoin.IsValid == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(userLoin.BrokenRulesList.ToString()); } BLL.UserBLL.BLLUser_T UserEntity = new BLLUser_T(); BLL.UserBLL.BLLUser_TKeys UserKey = new BLLUser_TKeys(); UserKey.UserName_nvc = userLoin.UserName_nvc; UserEntity = this.GetBy(UserKey); if (UserEntity != null && UserEntity.Password_nvc == userLoin.Password_nvc) { if (UserEntity.Active_bit == true) { string ServerDate = this.ServerJalaliDate; if (string.IsNullOrEmpty(UserEntity.StartDate_vc) == false && UserEntity.StartDate_vc.CompareTo(ServerDate) > 0) { throw new Hepsa.Core.Exception.UserStartDateError(UserEntity.StartDate_vc); } else if (string.IsNullOrEmpty(UserEntity.ExpireDate_vc) == false && UserEntity.ExpireDate_vc.CompareTo(ServerDate) < 0) { throw new Hepsa.Core.Exception.UserStartDateError(UserEntity.ExpireDate_vc); } else { return(UserEntity); } } else { throw new Hepsa.Core.Exception.UserIsNotActive(); } } else { throw new ApplicationException("نام کاربری یا رمز عبور اشتباه است یا گروه کاربر غیر فعال میباشد"); } } catch (Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); // Hepsa.Core.throw Exception.HandleException.ChangeExceptionLanguage(ex, this); } }