public ActionResult Delete(int acid, int UserInfoId, InsiderTrading.Models.COUserInfoModel objUserInfoModel) { UserInfoSL objUserInfoSL = new UserInfoSL(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); try { objUserInfoSL.DeleteUserDetails(objLoginUserDetails.CompanyDBConnectionString, UserInfoId, objLoginUserDetails.LoggedInUserID); return(RedirectToAction("Index", "UserDetails", new { acid = Common.ConstEnum.UserActions.CRUSER_COUSER_VIEW })); } catch (Exception exp) { string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); ViewBag.StatusDropDown = FillComboValues(ConstEnum.ComboType.ListOfCode, Convert.ToInt32(ConstEnum.CodeGroup.UserStatus).ToString(), null, null, null, null, false); ViewBag.CompanyDropDown = FillComboValues(ConstEnum.ComboType.CompanyList, null, null, null, null, null, true); objUserInfoModel.DefaultRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.COUserType.ToString(), null, null, null, null, true); objUserInfoModel.AssignedRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.COUserType.ToString(), objUserInfoModel.UserInfoId.ToString(), null, null, null, false); ViewBag.UserAction = InsiderTrading.Common.ConstEnum.UserActions.CRUSER_COUSER_EDIT; return(View("Create", objUserInfoModel)); } finally { objUserInfoSL = null; objLoginUserDetails = null; } }
/// <summary> /// /// </summary> /// <param name="acid"></param> /// <param name="PreClearanceRequestID"></param> /// <param name="PreClearanceRequestStatus"></param> /// <param name="TradeDetailsID"></param> /// <returns></returns> public ActionResult Index(int acid, string LetterStatus = null) { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); UserInfoSL objUserInfoSL = new UserInfoSL(); UserInfoDTO objUserInfoDTO = null; PreclearanceRequestSL objPreclearanceRequestSL = new PreclearanceRequestSL(); try { ViewBag.LetterStatus = LetterStatus; ViewBag.NSEGroupNo = FillComboValues(ConstEnum.ComboType.NSEGroupNumber, InsiderTrading.Common.ConstEnum.CodeGroup.NSEDownloadOptions, null, null, null, null, true); ViewBag.GroupSubmissionStatus = FillComboValues(ConstEnum.ComboType.EventGroupStatusList, InsiderTrading.Common.ConstEnum.CodeGroup.NSEDownloadOptions, null, null, null, null, true); ViewBag.Param1 = objLoginUserDetails.LoggedInUserID; FillGrid(Common.ConstEnum.GridType.NSEDownload, "0", null, null); objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); return(View("Index")); } catch (Exception exp) { return(View("Index")); } finally { objLoginUserDetails = null; objUserInfoSL = null; objUserInfoDTO = null; objPreclearanceRequestSL = null; } }
public ActionResult ClawBackReportEmployeeWise(int acid, int nUserInfoID = 0, int nTransactionMasterID = 0, int nSecurityTypeID = 0, int nTransactionTypeID = 0) { LoginUserDetails objLoginUserDetails = null; UserInfoDTO objUserInfoDTO = null; try { objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); ViewBag.GridType = ConstEnum.GridType.Report_ClawBack_Individual; ViewBag.ActivityID = acid; ViewBag.UserID = nUserInfoID; ViewBag.TransactionMasterID = nTransactionMasterID; ViewBag.SecurityTypeID = nSecurityTypeID; ViewBag.TransactionTypeID = nTransactionTypeID; using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, nUserInfoID); ViewBag.EmployeePAN = objUserInfoDTO.PAN; ViewBag.InsiderName = (objUserInfoDTO.UserTypeCodeId == ConstEnum.Code.CorporateUserType) ? objUserInfoDTO.CompanyName : objUserInfoDTO.FirstName + " " + objUserInfoDTO.LastName; } } catch (Exception ex) { } finally { objLoginUserDetails = null; } return(View()); }
public JsonResult DeleteFromGrid(int UserInfoId, int acid) { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); bool statusFlag = false; var ErrorDictionary = new Dictionary <string, string>(); UserInfoSL objUserInfoSL = new UserInfoSL(); try { objUserInfoSL.DeleteUserDetails(objLoginUserDetails.CompanyDBConnectionString, UserInfoId, objLoginUserDetails.LoggedInUserID); statusFlag = true; ErrorDictionary.Add("success", Common.Common.getResource("usr_msg_11267"));//"User deleted Successfully."); } catch (Exception exp) { ModelState.Remove("KEY"); ModelState.Add("KEY", new ModelState()); ModelState.Clear(); string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("error", sErrMessage); ErrorDictionary = GetModelStateErrorsAsString(); } finally { objLoginUserDetails = null; objUserInfoSL = null; } return(Json(new { status = statusFlag, Message = ErrorDictionary }, JsonRequestBehavior.AllowGet)); }
public ActionResult Accept(EULAAcceptanceModel objEulaAcceptanceModel, int acid) { bool bReturn = false; UserInfoSL objUserInfoSL = new UserInfoSL(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); try { objEulaAcceptanceModel.EULAAcceptanceFlag = true; bReturn = objUserInfoSL.SaveUserEulaAcceptance(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, objEulaAcceptanceModel.DocumentID, objEulaAcceptanceModel.EULAAcceptanceFlag); if (bReturn) { return(RedirectToAction("Index", "InsiderDashboard", new { acid = Common.ConstEnum.UserActions.DASHBOARD_INSIDERUSER })); } else { return(RedirectToAction("ShowUserConsent", "UserDetails", new { acid = Common.ConstEnum.UserActions.USER_EULACONSENT, nDocumentId = objEulaAcceptanceModel.DocumentID })); } } catch { return(View()); } finally { objUserInfoSL = null; objLoginUserDetails = null; } }
/// <summary> /// /// </summary> /// <returns></returns> public ActionResult Create(int nUserInfoID = 0) { LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); EmployeeModel objEmployeeModel = new EmployeeModel(); UserInfoModel objUserInfoModel = new UserInfoModel(); DMATDetailsModel objDMATDetailsModel = new DMATDetailsModel(); DocumentDetailsModel objDocumentDetailsModel = new DocumentDetailsModel(); UserInfoSL objUserInfoSL = new UserInfoSL(); try { if (nUserInfoID != 0) { UserInfoDTO objUserInfoDTO = new UserInfoDTO(); objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, nUserInfoID); string sPwdMask = "●●●●●●●●●●●●●"; objUserInfoDTO.Password = sPwdMask.PadRight(15, '●'); Common.Common.CopyObjectPropertyByName(objUserInfoDTO, objUserInfoModel); objDMATDetailsModel.UserInfoID = nUserInfoID; } objEmployeeModel.userInfoModel = objUserInfoModel; objEmployeeModel.dmatDetailsModel = objDMATDetailsModel; objEmployeeModel.documentDetailsModel = objDocumentDetailsModel; PopulateCombo(); return(View("Create", objEmployeeModel)); } catch (Exception exp) { string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); return(View("Create", objEmployeeModel)); } finally { objLoginUserDetails = null; objEmployeeModel = null; objUserInfoModel = null; objDMATDetailsModel = null; objDocumentDetailsModel = null; objUserInfoSL = null; } }
public ActionResult ForgetPassword(PasswordManagementModel objPwdMgmtModel) { ModelState.Remove("KEY"); ModelState.Add("KEY", new ModelState()); ModelState.Clear(); Session["UserCaptchaTextForgotPwd"] = (objPwdMgmtModel.sCaptchaText == null) ? string.Empty : objPwdMgmtModel.sCaptchaText; LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); try { if (objLoginUserDetails == null) { objLoginUserDetails = new LoginUserDetails(); } PasswordManagementDTO objPwdMgmtDTO = new PasswordManagementDTO(); UserInfoSL objUserInfoSL = new UserInfoSL(); CompaniesSL objCompanySL = new CompaniesSL(); if (System.Configuration.ConfigurationManager.AppSettings["CompanyType"] == "Textbox") { Dictionary <string, string> objCompaniesDictionary = null; objCompaniesDictionary = new Dictionary <string, string>(); foreach (InsiderTradingDAL.CompanyDTO objCompanyDTO in objCompanySL.getAllCompanies(Common.Common.getSystemConnectionString())) { objCompaniesDictionary.Add(objCompanyDTO.sCompanyDatabaseName, objCompanyDTO.sCompanyName.ToLower()); } if (objCompaniesDictionary.ContainsValue(objPwdMgmtModel.CompanyID.ToLower())) { objPwdMgmtModel.CompanyID = (from entry in objCompaniesDictionary where entry.Value.ToLower() == objPwdMgmtModel.CompanyID.ToLower() select entry.Key).FirstOrDefault(); } } InsiderTradingDAL.CompanyDTO objSelectedCompany = objCompanySL.getSingleCompanies(Common.Common.getSystemConnectionString(), objPwdMgmtModel.CompanyID); string SaltValue = Common.ConstEnum.User_Password_Encryption_Key; InsiderTradingEncryption.DataSecurity objPwdHash = new InsiderTradingEncryption.DataSecurity(); string sHashCode = objPwdHash.CreateHash(objPwdMgmtModel.LoginID.ToString() + objPwdMgmtModel.CompanyID.ToString(), SaltValue); objPwdMgmtModel.HashValue = sHashCode; var CallBackUrl = Url.Action("SetPassword", "Account", new { @code = sHashCode }); string sLoginID = string.Empty; string sEmailID = string.Empty; string javascriptEncryptionKey = Common.ConstEnum.Javascript_Encryption_Key; sLoginID = DecryptStringAES(objPwdMgmtModel.LoginID, javascriptEncryptionKey, javascriptEncryptionKey); sEmailID = DecryptStringAES(objPwdMgmtModel.EmailID, javascriptEncryptionKey, javascriptEncryptionKey); if (!string.IsNullOrEmpty(sEmailID)) { string emailRegex = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$"; Regex re = new Regex(emailRegex); if (!re.IsMatch(sEmailID)) { ModelState.AddModelError("EmailID", "Please provide valid Email ID"); } } objPwdMgmtModel.LoginID = sLoginID; objPwdMgmtModel.EmailID = sEmailID; InsiderTrading.Common.Common.CopyObjectPropertyByName(objPwdMgmtModel, objPwdMgmtDTO); objPwdMgmtDTO = objUserInfoSL.ForgetPassword(objSelectedCompany.CompanyConnectionString, objPwdMgmtDTO); if (objPwdMgmtDTO.EmailID != null) { if (objPwdMgmtModel.sCaptchaText != Session["CaptchaValueForgotPwd"].ToString()) { TempData["ShowCaptchaForgotPwd"] = true; TempData["ErrorMessageForgotPwd"] = "Please provide valid Text"; @ViewBag.ErrorMessage = "Please provide valid Text"; objLoginUserDetails.ErrorMessage = "Please provide valid Text"; return(RedirectToAction("ForgetPassword", "Account")); } Common.Common.SendMail(CallBackUrl, objPwdMgmtDTO, objSelectedCompany.sCompanyDatabaseName); } objLoginUserDetails.SuccessMessage = Common.Common.getResourceForGivenCompany("usr_msg_11270", objSelectedCompany.sCompanyDatabaseName); Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); return(RedirectToAction("Login", "Account"));//.Success(Common.Common.getResourceForGivenCompany("usr_msg_11270", objSelectedCompany.sCompanyDatabaseName)); } catch (Exception exp) { string sErrMessage = exp.Message; if (exp.InnerException != null && exp.InnerException.Data != null && exp.InnerException.Data.Count > 0) { sErrMessage = Common.Common.getResourceForGivenCompany(exp.InnerException.Data[0].ToString(), objPwdMgmtModel.CompanyID); } @ViewBag.ErrorMessage = sErrMessage; objPwdMgmtModel.LoginID = null; objPwdMgmtModel.EmailID = null; Dictionary <string, string> objCompaiesDictionary = new Dictionary <string, string>(); objCompaiesDictionary.Add("", "Select Company"); CompaniesSL objCompanySL = new CompaniesSL(); List <InsiderTradingDAL.CompanyDTO> lstCompanies = new List <InsiderTradingDAL.CompanyDTO>(); lstCompanies = objCompanySL.getAllCompanies(Common.Common.getSystemConnectionString()); foreach (InsiderTradingDAL.CompanyDTO objCompanyDTO in lstCompanies) { objCompaiesDictionary.Add(objCompanyDTO.sCompanyDatabaseName, objCompanyDTO.sCompanyName); } ViewBag.CompaniesDropDown = objCompaiesDictionary; objLoginUserDetails.ErrorMessage = sErrMessage; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); return(RedirectToAction("ForgetPassword", "Account")); } }
public ActionResult LogOut() { LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); if (objLoginUserDetails != null) { Dictionary <string, DocumentDetailsDTO> dicDocumentDetailsDTO = objLoginUserDetails.DocumentDetails; if (dicDocumentDetailsDTO != null && dicDocumentDetailsDTO.Count > 0) { string directory = ConfigurationManager.AppSettings["Document"]; foreach (KeyValuePair <string, DocumentDetailsDTO> objDocumentDetailsDTO in dicDocumentDetailsDTO) { if (System.IO.File.Exists(Path.Combine(directory, "temp", objDocumentDetailsDTO.Key))) { FileInfo file = new FileInfo(Path.Combine(directory, "temp", objDocumentDetailsDTO.Key)); file.Delete(); } } } using (SessionManagement sessionManagement = new SessionManagement()) { //sessionManagement.CheckCookiesSessions(objLoginUserDetails, false, (System.Web.HttpRequest)System.Web.HttpContext.Current.Request, (System.Web.HttpResponse)System.Web.HttpContext.Current.Response, "LOGOUT"); sessionManagement.BindCookiesSessions(objLoginUserDetails, false, (System.Web.HttpRequest)System.Web.HttpContext.Current.Request, (System.Web.HttpResponse)System.Web.HttpContext.Current.Response, "LOGOUT"); } using (var objUserInfoSL = new UserInfoSL()) { objUserInfoSL.DeleteFormToken(objLoginUserDetails.CompanyDBConnectionString, Convert.ToInt32(objLoginUserDetails.LoggedInUserID), 0); objUserInfoSL.DeleteCookiesStatus(objLoginUserDetails.CompanyDBConnectionString, Convert.ToInt32(objLoginUserDetails.LoggedInUserID), "Delete"); } } //expire cookies use for validation Response.Cookies[ConstEnum.CookiesValue.ValidationCookies].Expires = DateTime.Now.AddYears(-1); //expire all other cookies, if any if (Response.Cookies.Count > 0) { foreach (string cookies_name in Response.Cookies.AllKeys) { if (cookies_name != ConstEnum.CookiesValue.ValidationCookies) { Response.Cookies[cookies_name].Expires = DateTime.Now.AddYears(-1); } } } if (Session["IsSSOActivated"] != null && Session["IsSSOActivated"].ToString() == "1") { CompanyDTO objSelectedCompany = null; using (CompaniesSL objCompanySL = new CompaniesSL()) { objSelectedCompany = objCompanySL.getSingleCompanies(Common.Common.getSystemConnectionString(), objLoginUserDetails.CompanyName); ViewBag.SSOUrl = objSelectedCompany.sSSOUrl; } ClearAllSessions(); return(View("Logout")); } ClearAllSessions(); TempData["ShowCaptcha"] = false; TempData.Remove("ContactDetails"); TempData.Remove("RelativeMobileDetail"); return(RedirectToAction("Login", "Account")); }
public async Task <ActionResult> Login(UserDetailsModel model) { LoginUserDetails objLoginUserDetails = null; InsiderTradingEncryption.DataSecurity objPwdHash = null; CompanyDTO objSelectedCompany = null; DataSecurity objDataSecurity = new DataSecurity(); PasswordConfigDTO objPasswordConfig = null; int loginCount = 0; Common.Common.WriteLogToFile("Start Method", System.Reflection.MethodBase.GetCurrentMethod()); bool IsEmailOTPActive = false; try { Session["UserCaptchaText"] = (model.sCaptchaText == null) ? string.Empty : model.sCaptchaText; TempData["ShowDupTransPopUp"] = 1; objLoginUserDetails = new LoginUserDetails(); string formUsername = string.Empty; string formPassword = string.Empty; string formEncryptedUsername = string.Empty; string formEncryptedPassword = string.Empty; string sPasswordHash = string.Empty; string javascriptEncryptionKey = Common.ConstEnum.Javascript_Encryption_Key; string userPasswordHashSalt = Common.ConstEnum.User_Password_Encryption_Key; string EncryptedRandomNo = string.Empty; if (model.sCalledFrom != objDataSecurity.CreateHash(string.Format(Common.ConstEnum.s_SSO, Convert.ToString(DateTime.Now.Year)), userPasswordHashSalt)) { objPwdHash = new InsiderTradingEncryption.DataSecurity(); formEncryptedUsername = model.sUserName; formEncryptedPassword = model.sPassword; formEncryptedUsername = DecryptStringAES(formEncryptedUsername, javascriptEncryptionKey, javascriptEncryptionKey); formEncryptedPassword = DecryptStringAES(formEncryptedPassword, javascriptEncryptionKey, javascriptEncryptionKey); EncryptedRandomNo = formEncryptedUsername.Split('~')[1].ToString(); if (EncryptedRandomNo != Convert.ToString(Session["randomNumber"])) { throw new System.Web.HttpException(401, "Unauthorized access"); } formUsername = formEncryptedUsername.Split('~')[0].ToString(); formPassword = formEncryptedPassword.Split('~')[0].ToString(); } else { Session["IsSSOActivated"] = "1"; formUsername = model.sUserName; sPasswordHash = string.IsNullOrEmpty(model.sPassword) ? "" : model.sPassword; } using (CompaniesSL objCompanySL = new CompaniesSL()) { if (System.Configuration.ConfigurationManager.AppSettings["CompanyType"] == "Textbox") { Dictionary <string, string> objCompaniesDictionary = null; objCompaniesDictionary = new Dictionary <string, string>(); foreach (InsiderTradingDAL.CompanyDTO objCompanyDTO in objCompanySL.getAllCompanies(Common.Common.getSystemConnectionString())) { objCompaniesDictionary.Add(objCompanyDTO.sCompanyDatabaseName, objCompanyDTO.sCompanyName); } if (objCompaniesDictionary.ContainsValue(model.sCompanyName.ToLower())) { model.sCompanyName = (from entry in objCompaniesDictionary where entry.Value.ToLower() == model.sCompanyName.ToLower() select entry.Key).FirstOrDefault(); } else { objLoginUserDetails.ErrorMessage = "Invalid company name"; objLoginUserDetails.IsAccountValidated = false; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); Common.Common.WriteLogToFile("Invalid company name"); Session["IsSSOActivated"] = null; return(RedirectToAction("Login", "Account")); } } objSelectedCompany = objCompanySL.getSingleCompanies(Common.Common.getSystemConnectionString(), model.sCompanyName); if (model.sCalledFrom != objDataSecurity.CreateHash(string.Format(Common.ConstEnum.s_SSO, Convert.ToString(DateTime.Now.Year)), userPasswordHashSalt)) { string saltValue = string.Empty; string calledFrom = "Login"; using (UserInfoSL ObjUserInfoSL = new UserInfoSL()) { List <AuthenticationDTO> lstUserDetails = ObjUserInfoSL.GetUserLoginDetails(objSelectedCompany.CompanyConnectionString, formUsername, calledFrom); foreach (var UserDetails in lstUserDetails) { saltValue = UserDetails.SaltValue; } } using (TwoFactorAuthSL objIsOTPEnable = new TwoFactorAuthSL()) { IsEmailOTPActive = objIsOTPEnable.CheckIsOTPActived(objSelectedCompany.CompanyConnectionString, formUsername); } string usrSaltValue = (saltValue == null || saltValue == string.Empty) ? userPasswordHashSalt : saltValue; if (saltValue != null && saltValue != "") { sPasswordHash = objPwdHash.CreateHashToVerify(formPassword, usrSaltValue); } else { sPasswordHash = objPwdHash.CreateHash(formPassword, usrSaltValue); } } objLoginUserDetails.UserName = formUsername; objLoginUserDetails.Password = sPasswordHash; objLoginUserDetails.CompanyDBConnectionString = objSelectedCompany.CompanyConnectionString; objLoginUserDetails.CompanyName = model.sCompanyName; objLoginUserDetails.IsUserLogin = false; //this flag indicate that user is not yet login sucessfully Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); using (var objPassConfigSL = new PasswordConfigSL()) { objPasswordConfig = objPassConfigSL.GetPasswordConfigDetails(objSelectedCompany.CompanyConnectionString); loginCount = (Session["UserLgnCount"] == null) ? 0 : Convert.ToInt32(Session["UserLgnCount"].ToString()); TempData["ShowCaptcha"] = false; if (loginCount >= (objPasswordConfig.LoginAttempts - 1)) { TempData["ShowCaptcha"] = true; Session["DisplayCaptcha"] = true; } if ((loginCount >= objPasswordConfig.LoginAttempts && model.sCaptchaText == "") || loginCount >= objPasswordConfig.LoginAttempts && model.sCaptchaText != Session["CaptchaValue"].ToString()) { TempData["ShowCaptcha"] = true; TempData["ErrorMessage"] = "Please provide valid text"; } } } } catch (Exception exp) { //If User is trying to login with a loginID which is being logged-in into the system. Then show the message and don't allow to login. string sErrMessage = exp.Message; objLoginUserDetails.ErrorMessage = sErrMessage; objLoginUserDetails.IsAccountValidated = false; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); Common.Common.WriteLogToFile("Exception occurred ", System.Reflection.MethodBase.GetCurrentMethod(), exp); Session["IsSSOActivated"] = null; ClearAllSessions(); return(RedirectToAction("Login", "Account")); } finally { objLoginUserDetails = null; objPwdHash = null; objSelectedCompany = null; } if (IsEmailOTPActive) { Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod()); Session["TwoFactor"] = 1; Session["IsOTPAuthPage"] = "TwoFactorAuthentication"; return(RedirectToAction("Index", "TwoFactorAuth", new { acid = Convert.ToString(0), calledFrom = "" })); } else { Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod()); Session["loginStatus"] = 1; return(RedirectToAction("Index", "Home", new { acid = Convert.ToString(0), calledFrom = "Login" })); } }
public ActionResult Create(int acid, int nUserInfoID = 0, bool isPPD_Details_Saved = false, bool isNonEmployee = true) { bool show_create_role_link = true; bool show_not_login_user_details = true; UserInfoDTO objUserInfoDTO = null; bool show_confirm_personal_details_btn = false; bool showMsgConfirmPersonalDetails = false; int user_action_ViewDetails = 0; ViewBag.UserDetailsSaved = false; LoginUserDetails objLoginUserDetails = null; EmployeeModel objEmployeeModel = new EmployeeModel(); UserInfoModel objUserInfoModel = new UserInfoModel(); DMATDetailsModel objDMATDetailsModel = new DMATDetailsModel(); DocumentDetailsModel objDocumentDetailsModel = new DocumentDetailsModel(); ImplementedCompanyDTO objImplementedCompanyDTO = new ImplementedCompanyDTO(); try { objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); using (CompaniesSL objCompaniesSL = new CompaniesSL()) { objImplementedCompanyDTO = objCompaniesSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, 0, 1); } objUserInfoDTO = new UserInfoDTO(); if (nUserInfoID != 0) { using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, nUserInfoID); } Common.Common.CopyObjectPropertyByName(objUserInfoDTO, objUserInfoModel); objDMATDetailsModel.UserInfoID = nUserInfoID; objDocumentDetailsModel.MapToTypeCodeId = ConstEnum.Code.UserDocument; objDocumentDetailsModel.MapToId = nUserInfoID; objDocumentDetailsModel.PurposeCodeId = null; } else { ViewBag.NewNonEmpRegistration = true; } ViewBag.EmpPANNumber = objUserInfoModel.PAN; PopulateCombo(objImplementedCompanyDTO.CompanyId); objUserInfoModel.UPSIAccessOfCompanyID = objImplementedCompanyDTO.CompanyId; objUserInfoModel.UPSIAccessOfCompanyName = objImplementedCompanyDTO.CompanyName; objEmployeeModel.userInfoModel = objUserInfoModel; objEmployeeModel.dmatDetailsModel = objDMATDetailsModel; objEmployeeModel.documentDetailsModel = objDocumentDetailsModel; objUserInfoModel.DefaultRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.NonEmployeeType.ToString(), null, null, null, null, true); objUserInfoModel.AssignedRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.NonEmployeeType.ToString(), nUserInfoID.ToString(), null, null, null, false); //set flag to show applicability define or not msg if (nUserInfoID != 0 && nUserInfoID != objLoginUserDetails.LoggedInUserID) { //check if user has policy document and trading policy appliable by checking count and set flag to show warning msg if applicabiliyt not define using (ApplicabilitySL objApplicabilitySL = new ApplicabilitySL()) { int pcount = objApplicabilitySL.UserApplicabilityCount(objLoginUserDetails.CompanyDBConnectionString, nUserInfoID, ConstEnum.Code.PolicyDocument); int tcount = objApplicabilitySL.UserApplicabilityCount(objLoginUserDetails.CompanyDBConnectionString, nUserInfoID, ConstEnum.Code.TradingPolicy); bool showMsgPolicyDocNotApplicable = (pcount <= 0) ? true : false; bool showMsgTradingPolicyNotApplicable = (tcount <= 0) ? true : false; ViewBag.IsShowMsgPDocNotApp = showMsgPolicyDocNotApplicable; ViewBag.IsShowMsgTPocNotApp = showMsgTradingPolicyNotApplicable; } } else { ViewBag.IsShowMsgPDocNotApp = false; ViewBag.IsShowMsgTPocNotApp = false; } //check if details being shown for login user then set flag to do not show create role link if (nUserInfoID != 0 && nUserInfoID == objLoginUserDetails.LoggedInUserID) { show_create_role_link = false; show_not_login_user_details = false; //check if login user has already confirm personal details - if user has confirm personal details then do not show confirm button if (objUserInfoDTO.IsRequiredConfirmPersonalDetails != null && (bool)objUserInfoDTO.IsRequiredConfirmPersonalDetails) { show_confirm_personal_details_btn = true; showMsgConfirmPersonalDetails = true; } } ViewBag.show_create_role_link = show_create_role_link; ViewBag.show_not_login_user_details = show_not_login_user_details; ViewBag.user_action = acid; ViewBag.IsShowMsgConfirmDetails = showMsgConfirmPersonalDetails; ViewBag.show_confirm_personal_details_btn = show_confirm_personal_details_btn; switch (objLoginUserDetails.UserTypeCodeId) { case ConstEnum.Code.Admin: case ConstEnum.Code.COUserType: user_action_ViewDetails = ConstEnum.UserActions.INSIDER_INSIDERUSER_VIEW; break; case ConstEnum.Code.NonEmployeeType: user_action_ViewDetails = ConstEnum.UserActions.VIEW_DETAILS_PERMISSION_FOR_NON_EMPLOYEE_USER; break; } ViewBag.user_action_ViewDetails = user_action_ViewDetails; Session["UserInfoId"] = objUserInfoModel.UserInfoId; Session["Confirm_PersonalDetails_Required"] = objUserInfoModel.IsRequiredConfirmPersonalDetails; Session["show_confirm_personal_details_btn"] = ViewBag.show_confirm_personal_details_btn; Session["NonEmployeeType"] = isNonEmployee; Session["EmployeeType"] = false; WorkandEducationDetailsConfigurationDTO objWorkandEducationDetailsConfigurationDTO = new WorkandEducationDetailsConfigurationDTO(); using (var objCompaniesSL = new CompaniesSL()) { objWorkandEducationDetailsConfigurationDTO = objCompaniesSL.GetWorkandeducationDetailsConfiguration(objLoginUserDetails.CompanyDBConnectionString, 1); } ViewBag.WorkandEducationDetailsConfiguration = objWorkandEducationDetailsConfigurationDTO.WorkandEducationDetailsConfigurationId; Session["WorkandEducationConfiguration"] = ViewBag.WorkandEducationDetailsConfiguration; if (isPPD_Details_Saved) { ViewBag.UserDetailsSaved = true; return(View("NonEmployeeDmatDetails", objEmployeeModel)); } else { return(View(objEmployeeModel)); } } catch (Exception exp) { } finally { objLoginUserDetails = null; objUserInfoDTO = null; objEmployeeModel = null; objUserInfoModel = null; objDMATDetailsModel = null; objDocumentDetailsModel = null; objImplementedCompanyDTO = null; } return(View("Create")); }
public ActionResult Create(UserInfoModel objUserInfoModel, string OldPassword, int acid, bool IsConfirmDetails = false) { int nUserInfoID = 0; LoginUserDetails objLoginUserDetails = null; UserInfoDTO objUserInfoDTO = new UserInfoDTO(); ImplementedCompanyDTO objImplementedCompanyDTO = new ImplementedCompanyDTO(); bool show_create_role_link = true; bool show_not_login_user_details = true; bool show_confirm_personal_details_btn = false; bool showMsgConfirmPersonalDetails = false; List <PopulateComboDTO> lstSelectedRole = null; UserInfoModel objNewUserInfoModel = new UserInfoModel(); bool isError = false; //flag to check for validation error string sMsgDOJ = ""; string sMsgDOBI = ""; string sMsgDateCompare = ""; string sMsgException = ""; UserPolicyDocumentEventLogDTO objUserPolicyDocumentEventLogDTO = null; EmployeeModel objEmployeeModel = new EmployeeModel(); string strConfirmMessage = ""; try { //check if details being shown for login user then set flag to do not show create role link objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); if (objUserInfoModel.UserInfoId != 0 && objUserInfoModel.UserInfoId == objLoginUserDetails.LoggedInUserID) { show_create_role_link = false; show_not_login_user_details = false; //check if login user has already confirm personal details - if user has confirm personal details then do not show confirm button if (objUserInfoModel.IsRequiredConfirmPersonalDetails != null && (bool)objUserInfoModel.IsRequiredConfirmPersonalDetails) { show_confirm_personal_details_btn = true; showMsgConfirmPersonalDetails = true; } } ViewBag.show_create_role_link = show_create_role_link; ViewBag.show_not_login_user_details = show_not_login_user_details; ViewBag.IsShowMsgConfirmDetails = showMsgConfirmPersonalDetails; ViewBag.show_confirm_personal_details_btn = show_confirm_personal_details_btn; ViewBag.user_action = acid; switch (objLoginUserDetails.UserTypeCodeId) { case ConstEnum.Code.Admin: case ConstEnum.Code.COUserType: if (objUserInfoModel.UserInfoId > 0) { ViewBag.user_action = ConstEnum.UserActions.INSIDER_INSIDERUSER_EDIT; } else { ViewBag.user_action = ConstEnum.UserActions.INSIDER_INSIDERUSER_CREATE; } break; case ConstEnum.Code.NonEmployeeType: if (objUserInfoModel.UserInfoId > 0) { ViewBag.user_action = ConstEnum.UserActions.INSIDER_INSIDERUSER_EDIT; } else { ViewBag.user_action = ConstEnum.UserActions.INSIDER_INSIDERUSER_CREATE; } break; } using (CompaniesSL objCompaniesSL = new CompaniesSL()){ objImplementedCompanyDTO = objCompaniesSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, 0, 1); } if (objUserInfoModel.DateOfJoining != null || objUserInfoModel.DateOfBecomingInsider != null) { DateTime current_date = Common.Common.GetCurrentDate(objLoginUserDetails.CompanyDBConnectionString); if (objUserInfoModel.DateOfJoining > current_date) { sMsgDOJ = Common.Common.getResource("usr_msg_11413"); // "Date of Joining should be less than today's date"; isError = true; } if (objUserInfoModel.DateOfBecomingInsider > current_date) { sMsgDOBI = Common.Common.getResource("usr_msg_11414"); // "Date of Becoming Insider should be less than today's date"; isError = true; } if (objUserInfoModel.DateOfBecomingInsider < objUserInfoModel.DateOfJoining) { sMsgDateCompare = Common.Common.getResource("usr_msg_11415"); // "Date of Becoming Insider should not be less than Date of Joining"; isError = true; } } //check if validation error by checking flag if (!isError) { if (objUserInfoModel.UserInfoId != 0) { using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, objUserInfoModel.UserInfoId); } } InsiderTrading.Common.Common.CopyObjectPropertyByNameAndActivity(objUserInfoModel, objUserInfoDTO); objUserInfoDTO.UserTypeCodeId = ConstEnum.Code.NonEmployeeType; objUserInfoDTO.IsInsider = ConstEnum.UserType.Insider; objUserInfoDTO.StatusCodeId = Common.Common.ConvertToInt32(ConstEnum.UserStatus.Active); objUserInfoDTO.LoggedInUserId = objLoginUserDetails.LoggedInUserID; objUserInfoDTO.AllowUpsiUser = objUserInfoModel.AllowUpsiUser; if (objUserInfoDTO.StateId == 0) { objUserInfoDTO.StateId = null; } if (objUserInfoDTO.CountryId == 0) { objUserInfoDTO.CountryId = null; } objUserInfoDTO.UPSIAccessOfCompanyID = objImplementedCompanyDTO.CompanyId; objUserInfoDTO.Password = ""; using (UserInfoSL objUserInfoSL = new UserInfoSL()){ objUserInfoDTO = objUserInfoSL.InsertUpdateUserDetails(objLoginUserDetails.CompanyDBConnectionString, objUserInfoDTO); } if (objUserInfoDTO.UserInfoId != 0) { nUserInfoID = objUserInfoDTO.UserInfoId; } //check if need to confirm personal details if (IsConfirmDetails && objUserInfoModel.IsRequiredConfirmPersonalDetails == true) { int UserInfoID = 0; int RequiredModuleID = 0; try { objUserPolicyDocumentEventLogDTO = new UserPolicyDocumentEventLogDTO(); //set values to save into event log table objUserPolicyDocumentEventLogDTO.EventCodeId = ConstEnum.Code.Event_ConfirmPersonalDetails; objUserPolicyDocumentEventLogDTO.UserInfoId = objUserInfoDTO.UserInfoId; objUserPolicyDocumentEventLogDTO.MapToId = objUserInfoDTO.UserInfoId; objUserPolicyDocumentEventLogDTO.MapToTypeCodeId = ConstEnum.Code.UserDocument; UserInfoID = objUserInfoDTO.UserInfoId; InsiderInitialDisclosureDTO objInsiderInitialDisclosureDTO = null; using (var objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL()) { objInsiderInitialDisclosureDTO = objInsiderInitialDisclosureSL.Get_mst_company_details(objLoginUserDetails.CompanyDBConnectionString); if (objInsiderInitialDisclosureDTO.RequiredModule == InsiderTrading.Common.ConstEnum.Code.RequiredModuleOtherSecurity) { RequiredModuleID = InsiderTrading.Common.ConstEnum.Code.RequiredModuleOtherSecurity; } else { RequiredModuleID = InsiderTrading.Common.ConstEnum.Code.RequiredModuleOwnSecurity; } } bool isConfirm = false; using (InsiderInitialDisclosureSL objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL()){ isConfirm = objInsiderInitialDisclosureSL.SaveEvent(objLoginUserDetails.CompanyDBConnectionString, objUserPolicyDocumentEventLogDTO, objLoginUserDetails.LoggedInUserID); } if (isConfirm) { strConfirmMessage = Common.Common.getResource("usr_msg_11420"); //Personal Details confirm successfully. //return RedirectToAction("Index", "InsiderInitialDisclosure", new { acid = ConstEnum.UserActions.INSIDER_DISCLOSURE_DETAILS_INITIAL_DISCLOSURE }).Success(HttpUtility.UrlEncode(strConfirmMessage)); return(RedirectToAction("Index", "InsiderInitialDisclosure", new { acid = ConstEnum.UserActions.INSIDER_DISCLOSURE_DETAILS_INITIAL_DISCLOSURE, UserInfoId = UserInfoID, ReqModuleId = RequiredModuleID }).Success(HttpUtility.UrlEncode(strConfirmMessage))); } } catch (Exception ex) { strConfirmMessage = Common.Common.getResource(ex.InnerException.Data[0].ToString()); throw ex; } finally{ objUserPolicyDocumentEventLogDTO = null; } } } } catch (Exception exp) { sMsgException = Common.Common.getResource(exp.InnerException.Data[0].ToString()); isError = true; using (CompaniesSL objCompaniesSL = new CompaniesSL()){ objImplementedCompanyDTO = objCompaniesSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, 0, 1); } } //check if there are validation error and show validation error if (isError) { ModelState.Remove("KEY"); ModelState.Add("KEY", new ModelState()); ModelState.Clear(); //set validation error messages if (sMsgDOJ != "") { ModelState.AddModelError("Error", sMsgDOJ); } if (sMsgDOBI != "") { ModelState.AddModelError("Error", sMsgDOBI); } if (sMsgDateCompare != "") { ModelState.AddModelError("Error", sMsgDateCompare); } if (sMsgException != "") { ModelState.AddModelError("Error", sMsgException); } if (strConfirmMessage != "") { ModelState.AddModelError("Error", strConfirmMessage); } //check if user has selected role and assign those role if (objUserInfoModel.SubmittedRole != null) { lstSelectedRole = new List <PopulateComboDTO>(); for (int cnt = 0; cnt < objUserInfoModel.SubmittedRole.Count; cnt++) { PopulateComboDTO objPopulateComboDTO = new PopulateComboDTO(); objPopulateComboDTO.Key = objUserInfoModel.SubmittedRole[cnt]; lstSelectedRole.Add(objPopulateComboDTO); objPopulateComboDTO = null; } } //check if user already saved and set non editable property with already saved valued in DB if (objUserInfoModel.UserInfoId != 0) { //get saved info from DB UserInfoDTO objExistingDetails_UserInfoDTO = null; using (UserInfoSL objUserInfoSL = new UserInfoSL()){ objExistingDetails_UserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, objUserInfoModel.UserInfoId); } //copy editable property into DTO so we get existing property and change property Common.Common.CopyObjectPropertyByNameAndActivity(objUserInfoModel, objExistingDetails_UserInfoDTO); //copy DTO to new model which can be pass to view with already saved details with newly change details Common.Common.CopyObjectPropertyByName(objExistingDetails_UserInfoDTO, objNewUserInfoModel); //set user info model to employee model which content edited info and already save info //objUserInfoModel = objNewUserInfoModel; } else { //set user info model to employee model which content edited info and already save info objNewUserInfoModel = objUserInfoModel; } objNewUserInfoModel.DefaultRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.NonEmployeeType.ToString(), null, null, null, null, true); //check if user has selected role and assign those role if (lstSelectedRole != null && lstSelectedRole.Count > 0) { objNewUserInfoModel.AssignedRole = lstSelectedRole; } else { objNewUserInfoModel.AssignedRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.NonEmployeeType.ToString(), nUserInfoID.ToString(), null, null, null, false); } lstSelectedRole = null; PopulateCombo(objImplementedCompanyDTO.CompanyId); objEmployeeModel.userInfoModel = objNewUserInfoModel; //check if dmat details model is set or not if (objEmployeeModel.dmatDetailsModel == null) { objEmployeeModel.dmatDetailsModel = new DMATDetailsModel(); if (objUserInfoModel.UserInfoId != 0) { objEmployeeModel.dmatDetailsModel.UserInfoID = objEmployeeModel.userInfoModel.UserInfoId; } } //check if document details are set or not if (objEmployeeModel.documentDetailsModel == null) { objEmployeeModel.documentDetailsModel = new DocumentDetailsModel(); objEmployeeModel.documentDetailsModel.MapToTypeCodeId = ConstEnum.Code.UserDocument; objEmployeeModel.documentDetailsModel.PurposeCodeId = null; if (objUserInfoModel.UserInfoId != 0) { objEmployeeModel.documentDetailsModel.MapToId = objEmployeeModel.userInfoModel.UserInfoId; } } return(View("Create", objEmployeeModel)); } ArrayList lst = new ArrayList(); //before showing success message check if first name and last name is NOT NULL string fname = objUserInfoModel.FirstName == null ? "" : objUserInfoModel.FirstName.Replace("'", "\'").Replace("\"", "\""); string lname = objUserInfoModel.LastName == null ? "" : objUserInfoModel.LastName.Replace("'", "\'").Replace("\"", "\""); lst.Add(fname + " " + lname); string AlertMessage = Common.Common.getResource("usr_msg_11266", lst); objUserInfoModel = null; return(RedirectToAction("Create", new { acid = ConstEnum.UserActions.INSIDER_INSIDERUSER_EDIT, nUserInfoID = nUserInfoID, isPPD_Details_Saved = true }).Success(HttpUtility.UrlEncode(AlertMessage))); }
public ActionResult ChangePassword(int formId, int acid, PasswordManagementModel objPwdMgmtModel) { bool bErrorOccurred = false; string i_ErrorMessage = ""; LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); PasswordManagementDTO objPwdMgmtDTO = new PasswordManagementDTO(); PasswordConfigModel objPassConfigModel = new PasswordConfigModel(); UserInfoSL objUserInfoSL = new UserInfoSL(); UserPolicyDocumentEventLogDTO objChangePasswordEventLogDTO = null; PasswordExpiryReminderDTO objPassExpiryReminderDTO = null; InsiderTradingEncryption.DataSecurity objPwdHash = new InsiderTradingEncryption.DataSecurity(); try { DataSecurity objDataSecurity = new DataSecurity(); string sOldPassword = string.Empty; string sNewPassword = string.Empty; string sConfirmNewPassword = string.Empty; string sPasswordHash = string.Empty; string sPasswordHashWithSalt = string.Empty; string sSaltValue = string.Empty; string javascriptEncryptionKey = Common.ConstEnum.Javascript_Encryption_Key; string userPasswordHashSalt = Common.ConstEnum.User_Password_Encryption_Key; if (objPwdMgmtModel.OldPassword == null || objPwdMgmtModel.OldPassword == "" || objPwdMgmtModel.NewPassword == null || objPwdMgmtModel.NewPassword == "" || objPwdMgmtModel.ConfirmNewPassword == null || objPwdMgmtModel.ConfirmNewPassword == "") { i_ErrorMessage = "All fields are required fields."; bErrorOccurred = true; } else if (objPwdMgmtModel.NewPassword == null || objPwdMgmtModel.NewPassword == "" || objPwdMgmtModel.ConfirmNewPassword == null || objPwdMgmtModel.ConfirmNewPassword == "") { i_ErrorMessage = "Please enter new password and confirm new password."; bErrorOccurred = true; } else if (objPwdMgmtModel.NewPassword != objPwdMgmtModel.ConfirmNewPassword) { i_ErrorMessage = "New password and Confirm password are not matching."; bErrorOccurred = true; } else if (objPwdMgmtModel.OldPassword == objPwdMgmtModel.NewPassword) { i_ErrorMessage = "New password should not be same as old password."; bErrorOccurred = true; } else if (!string.IsNullOrEmpty(objPwdMgmtModel.OldPassword) && !string.IsNullOrEmpty(objPwdMgmtModel.NewPassword) && !string.IsNullOrEmpty(objPwdMgmtModel.ConfirmNewPassword)) { sOldPassword = DecryptStringAES(objPwdMgmtModel.OldPassword, javascriptEncryptionKey, javascriptEncryptionKey); sNewPassword = DecryptStringAES(objPwdMgmtModel.NewPassword, javascriptEncryptionKey, javascriptEncryptionKey); sConfirmNewPassword = DecryptStringAES(objPwdMgmtModel.ConfirmNewPassword, javascriptEncryptionKey, javascriptEncryptionKey); sPasswordHashWithSalt = objPwdHash.CreateSaltandHash(sNewPassword); sPasswordHash = sPasswordHashWithSalt.Split('~')[0].ToString(); sSaltValue = sPasswordHashWithSalt.Split('~')[1].ToString(); } //Check if the new password follows Password policy if (!bErrorOccurred) { Common.Common objCommon = new Common.Common(); bool isPasswordValid = objCommon.ValidatePassword(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.UserName, sNewPassword, sPasswordHash, objLoginUserDetails.LoggedInUserID, out i_ErrorMessage); if (!isPasswordValid) { bErrorOccurred = true; } } if (bErrorOccurred) { ViewBag.LoginError = i_ErrorMessage; return(View("ChangePassword")); } objPwdMgmtModel.UserInfoID = objLoginUserDetails.LoggedInUserID; string saltValue = string.Empty; string calledFrom = "ChangPwd"; using (UserInfoSL ObjUserInfoSL = new UserInfoSL()) { List <AuthenticationDTO> lstUserDetails = ObjUserInfoSL.GetUserLoginDetails(objLoginUserDetails.CompanyDBConnectionString, Convert.ToString(objLoginUserDetails.LoggedInUserID), calledFrom); foreach (var UserDetails in lstUserDetails) { saltValue = UserDetails.SaltValue; } } string usrSaltValue = (saltValue == null || saltValue == string.Empty) ? userPasswordHashSalt : saltValue; if (saltValue != null && saltValue != "") { objPwdMgmtModel.OldPassword = objPwdHash.CreateHashToVerify(sOldPassword, usrSaltValue); } else { objPwdMgmtModel.OldPassword = objPwdHash.CreateHash(sOldPassword, usrSaltValue); } objPwdMgmtModel.NewPassword = sPasswordHash; objPwdMgmtModel.ConfirmNewPassword = sPasswordHash; objPwdMgmtModel.SaltValue = sSaltValue; InsiderTrading.Common.Common.CopyObjectPropertyByName(objPwdMgmtModel, objPwdMgmtDTO); objUserInfoSL.ChangePassword(objLoginUserDetails.CompanyDBConnectionString, ref objPwdMgmtDTO); objLoginUserDetails.PasswordChangeMessage = Common.Common.getResource("usr_msg_11271"); Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); Common.Common.SetSessionValue("IsChangePassword", false); } catch (Exception exp) { string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ViewBag.LoginError = sErrMessage; objPassConfigModel = GetPasswordConfigDetails(); return(View("ChangePassword")); } finally { objLoginUserDetails = null; objPwdMgmtDTO = null; objUserInfoSL = null; objPwdHash = null; } return(RedirectToAction("Index", "Home", new { acid = Convert.ToString(Common.ConstEnum.UserActions.CRUSER_COUSERDASHBOARD_DASHBOARD) })); }
public void LoginUser(ActionExecutingContext filterContext) { DeleteCaptcha(filterContext); LoginUserDetails objLoginUserDetails = null; objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); AuthenticationDTO objAuthenticationDTO = new AuthenticationDTO(); objAuthenticationDTO.LoginID = objLoginUserDetails.UserName; objAuthenticationDTO.Password = objLoginUserDetails.Password; UserInfoDTO objUserAfterValidationObject = null; UserInfoDTO objUserAunthentication = null; PasswordConfigDTO objPasswordConfig = null; List <string> lstAuthorizationActionLinks = null; List <int> lstAuthorisedActionId = null; List <ActivityResourceMappingDTO> lstActivityResourceMappingDTO = null; Dictionary <string, List <ActivityResourceMappingDTO> > dicActivityResourceMappingDTO = null; int loginCount = 0; bool lockFlag = false; bool flag = false; objAuthenticationDTO.Password = null; objLoginUserDetails.Password = null; objLoginUserDetails.IsAccountValidated = true; objLoginUserDetails.ErrorMessage = ""; UserInfoSL objUserInfoSL = new UserInfoSL(); //Load the action permissions in the session object for to be used when checking authorization objUserAunthentication = objUserInfoSL.GetUserAuthencticationDetails(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.UserName); filterContext.HttpContext.Session["GUIDSessionID"] = HttpContext.Current.Request.Cookies.Get("v_au").Value + objUserAunthentication.UserInfoId; objLoginUserDetails.LoggedInUserID = objUserAunthentication.UserInfoId; objLoginUserDetails.EmailID = objUserAunthentication.EmailId; objLoginUserDetails.FirstName = objUserAunthentication.FirstName; objLoginUserDetails.LastName = objUserAunthentication.LastName; objUserInfoSL.GetLoginUserApplicableActions(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID.ToString(), out lstAuthorizationActionLinks, out lstAuthorisedActionId); objLoginUserDetails.AuthorizedActions = lstAuthorizationActionLinks; lstAuthorisedActionId.Add(0); objLoginUserDetails.AuthorisedActionId = lstAuthorisedActionId; objLoginUserDetails.CompanyLogoURL = objUserAunthentication.CompanyLogoURL; objLoginUserDetails.UserTypeCodeId = Convert.ToInt32(objUserAunthentication.UserTypeCodeId); objLoginUserDetails.LastLoginTime = objUserAunthentication.LastLoginTime; objLoginUserDetails.DateOfBecomingInsider = objUserAunthentication.DateOfBecomingInsider; using (var objActivitySL = new ActivitySL()) { lstActivityResourceMappingDTO = objActivitySL.GetActivityResourceMappingDetails(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); } dicActivityResourceMappingDTO = new Dictionary <string, List <ActivityResourceMappingDTO> >(); foreach (var objActivityResourceDTO in lstActivityResourceMappingDTO) { if (!dicActivityResourceMappingDTO.ContainsKey(objActivityResourceDTO.ColumnName)) { dicActivityResourceMappingDTO.Add(objActivityResourceDTO.ColumnName, new List <ActivityResourceMappingDTO>()); } dicActivityResourceMappingDTO[objActivityResourceDTO.ColumnName].Add(objActivityResourceDTO); } objLoginUserDetails.ActivityResourceMapping = dicActivityResourceMappingDTO; objLoginUserDetails.DocumentDetails = new Dictionary <string, DocumentDetailsDTO>(); //set login user details into session Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); Common.Common.WriteLogToFile("Update session with login user details ", System.Reflection.MethodBase.GetCurrentMethod()); //This will update the login time for the user. So this should be done after setting the Lastlogin time in the session object. objUserInfoSL.UpdateUserLastLoginTime(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.UserName); // user is login sucessfully, set validation value set in session and cookies to indicate user is login Common.Common.SetSessionAndCookiesValidationValue(objLoginUserDetails.UserName);//set session validation keys Common.Common.WriteLogToFile("Set login user name into session and cookies values", System.Reflection.MethodBase.GetCurrentMethod()); //get new cookies value after login //string cookies_value = Common.Common.GetSessionValue(ConstEnum.SessionValue.CookiesValidationKey).ToString(); //set cookies //filterContext.HttpContext.Response.Cookies[ConstEnum.CookiesValue.ValidationCookies].Value = cookies_value; //filterContext.HttpContext.Response.Cookies[ConstEnum.CookiesValue.ValidationCookies].Path = HttpContext.Current.Request.ApplicationPath; using (SessionManagement sessionManagement = new SessionManagement()) { sessionManagement.CheckCookiesSessions(objLoginUserDetails, true, (System.Web.HttpRequest)System.Web.HttpContext.Current.Request, (System.Web.HttpResponse)System.Web.HttpContext.Current.Response, string.Empty); sessionManagement.BindCookiesSessions(objLoginUserDetails, true, (System.Web.HttpRequest)System.Web.HttpContext.Current.Request, (System.Web.HttpResponse)System.Web.HttpContext.Current.Response, string.Empty); } Common.Common.WriteLogToFile("Set cookies to response to send back to browser ", System.Reflection.MethodBase.GetCurrentMethod()); }
public ActionResult SetPassword(PasswordManagementModel objPwdMgmtModel) { bool bErrorOccurred = false; string i_ErrorMessage = ""; string NewPassword = null; InsiderTradingDAL.CompanyDTO objSelectedCompany = new CompanyDTO(); UserInfoDTO objUserInfoDTO = new UserInfoDTO(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); try { if (objLoginUserDetails == null) { objLoginUserDetails = new LoginUserDetails(); } if (objPwdMgmtModel.CompanyID == null || objPwdMgmtModel.CompanyID == "") { i_ErrorMessage = "Company is required field."; bErrorOccurred = true; } else if (objPwdMgmtModel.NewPassword == null || objPwdMgmtModel.NewPassword == "" || objPwdMgmtModel.ConfirmNewPassword == null || objPwdMgmtModel.ConfirmNewPassword == "") { i_ErrorMessage = "Please enter new password and confirm password."; bErrorOccurred = true; } else if (objPwdMgmtModel.NewPassword != objPwdMgmtModel.ConfirmNewPassword) { i_ErrorMessage = "New password and Confirm password are not matching."; bErrorOccurred = true; } if (System.Configuration.ConfigurationManager.AppSettings["CompanyType"] == "Textbox") { Dictionary <string, string> objCompaniesDictionary = null; objCompaniesDictionary = new Dictionary <string, string>(); using (CompaniesSL objCompanySL = new CompaniesSL()) { foreach (InsiderTradingDAL.CompanyDTO objCompanyDTO in objCompanySL.getAllCompanies(Common.Common.getSystemConnectionString())) { objCompaniesDictionary.Add(objCompanyDTO.sCompanyDatabaseName, objCompanyDTO.sCompanyName.ToLower()); } } if (objCompaniesDictionary.ContainsValue(objPwdMgmtModel.CompanyID.ToLower())) { objPwdMgmtModel.CompanyID = (from entry in objCompaniesDictionary where entry.Value.ToLower() == objPwdMgmtModel.CompanyID.ToLower() select entry.Key).FirstOrDefault(); } else { objLoginUserDetails.ErrorMessage = "Invalid Company Name"; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); return(RedirectToAction("SetPassword", "Account", new { code = objPwdMgmtModel.HashValue })); } } //hashed password to check password history InsiderTradingEncryption.DataSecurity objPwdHash = new InsiderTradingEncryption.DataSecurity(); string saltValue = string.Empty; if (objPwdMgmtModel.NewPassword != null) { //NewPassword = objPwdHash.CreateSaltandHash(objPwdMgmtModel.NewPassword); string sPasswordHashWithSalt = objPwdHash.CreateSaltandHash(objPwdMgmtModel.NewPassword); NewPassword = sPasswordHashWithSalt.Split('~')[0].ToString(); saltValue = sPasswordHashWithSalt.Split('~')[1].ToString(); } using (CompaniesSL objCompanySL = new CompaniesSL()) { objSelectedCompany = objCompanySL.getSingleCompanies(Common.Common.getSystemConnectionString(), objPwdMgmtModel.CompanyID); } //Check if the new password follows Password policy if (!bErrorOccurred) { Common.Common objCommon = new Common.Common(); PasswordManagementDTO objPasswordManagementUserFromHashCodeDTO = new PasswordManagementDTO(); using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objPasswordManagementUserFromHashCodeDTO = objUserInfoSL.GetUserFromHashCode(objSelectedCompany.CompanyConnectionString, objPwdMgmtModel.HashValue); objUserInfoDTO = objUserInfoSL.GetUserDetails(objSelectedCompany.CompanyConnectionString, objPasswordManagementUserFromHashCodeDTO.UserInfoID); } bool isPasswordValid = objCommon.ValidatePassword(objSelectedCompany.CompanyConnectionString, objUserInfoDTO.LoginID, objPwdMgmtModel.NewPassword, NewPassword, objUserInfoDTO.UserInfoId, out i_ErrorMessage); if (!isPasswordValid) { bErrorOccurred = true; } } if (bErrorOccurred) { //ModelState.AddModelError("Error", i_ErrorMessage); if (objLoginUserDetails == null) { objLoginUserDetails = new LoginUserDetails(); } objLoginUserDetails.ErrorMessage = i_ErrorMessage; objLoginUserDetails.CompanyName = objPwdMgmtModel.CompanyID; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); PasswordConfigSL objPassConfigSL = new PasswordConfigSL(); PasswordConfigDTO objPassConfigDTO = new PasswordConfigDTO(); objPassConfigDTO = objPassConfigSL.GetPasswordConfigDetails(objSelectedCompany.CompanyConnectionString); PasswordConfigModel objPassConfigModel = new PasswordConfigModel(); InsiderTrading.Common.Common.CopyObjectPropertyByName(objPassConfigDTO, objPassConfigModel); TempData["PasswordConfigModel"] = objPassConfigModel; return(RedirectToAction("SetPassword", "Account", new { code = objPwdMgmtModel.HashValue })); //return View("SetPassword", objPwdMgmtModel); } PasswordManagementDTO objPwdMgmtDTO = new PasswordManagementDTO(); if (objLoginUserDetails == null) { objLoginUserDetails = new LoginUserDetails(); } if (objSelectedCompany == null) { objLoginUserDetails.ErrorMessage = "Entered company is incorrect, please enter correct company and try again."; } else { objPwdMgmtModel.NewPassword = NewPassword; objPwdMgmtModel.ConfirmNewPassword = NewPassword; objPwdMgmtModel.SaltValue = saltValue; InsiderTrading.Common.Common.CopyObjectPropertyByName(objPwdMgmtModel, objPwdMgmtDTO); using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objPwdMgmtDTO.UserInfoID = objUserInfoDTO.UserInfoId; objUserInfoSL.ChangePassword(objSelectedCompany.CompanyConnectionString, ref objPwdMgmtDTO); } //InsiderTradingDAL.UserInfoDTO objUserInfo = objUserInfoSL.GetUserDetails(objSelectedCompany.CompanyConnectionString, objPwdMgmtDTO.UserInfoID); objLoginUserDetails.SuccessMessage = Common.Common.getResourceForGivenCompany("usr_msg_11271", objSelectedCompany.sCompanyDatabaseName); } Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); return(RedirectToAction("Login", "Account")); //return RedirectToAction("Index", "Home", new { acid = Convert.ToString(Common.ConstEnum.UserActions.CRUSER_COUSERDASHBOARD_DASHBOARD) }); } catch (Exception exp) { string sErrMessage = Common.Common.getResourceForGivenCompany(exp.InnerException.Data[0].ToString(), objSelectedCompany.sCompanyDatabaseName); if (objLoginUserDetails == null) { objLoginUserDetails = new LoginUserDetails(); } objLoginUserDetails.ErrorMessage = sErrMessage; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); return(RedirectToAction("Login", "Account")); //ModelState.AddModelError("Error", sErrMessage); //return View("SetPassword", objPwdMgmtModel); } finally { objLoginUserDetails = null; } }
public ActionResult Create(int acid, InsiderTrading.Models.COUserInfoModel objUserInfoModel) { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); List <PopulateComboDTO> lstSelectedRole = null; UserInfoSL objUserInfoSL = new UserInfoSL(); InsiderTradingDAL.UserInfoDTO objUserInfoDTO = new UserInfoDTO(); try { InsiderTrading.Common.Common.CopyObjectPropertyByName(objUserInfoModel, objUserInfoDTO); objUserInfoDTO.UserTypeCodeId = ConstEnum.Code.COUserType; objUserInfoDTO.LoggedInUserId = objLoginUserDetails.LoggedInUserID; //Encrypt Password string o_sPassword = string.Empty; if (objUserInfoModel.SubmittedRole != null && objUserInfoModel.SubmittedRole.Count() > 0) { var sSubmittedRoleList = String.Join(",", objUserInfoModel.SubmittedRole); objUserInfoDTO.SubmittedRoleIds = sSubmittedRoleList; } objUserInfoDTO.Password = ""; objUserInfoSL.InsertUpdateUserDetails(objLoginUserDetails.CompanyDBConnectionString, objUserInfoDTO); ArrayList lst = new ArrayList(); //before showing success message check if first name and last name is NOT NULL string fname = objUserInfoDTO.FirstName == null ? "" : objUserInfoDTO.FirstName.Replace("'", "\'").Replace("\"", "\""); string lname = objUserInfoDTO.LastName == null ? "" : objUserInfoDTO.LastName.Replace("'", "\'").Replace("\"", "\""); lst.Add(fname + " " + lname); string AlertMessage = Common.Common.getResource("usr_msg_11266", lst); TempData.Remove("SearchArray"); return(RedirectToAction("Index", "UserDetails", new { acid = Common.ConstEnum.UserActions.CRUSER_COUSER_VIEW }). Success(HttpUtility.UrlEncode(AlertMessage))); } catch (Exception exp) { //check if user has selected role and assign those role if (objUserInfoModel.SubmittedRole != null) { lstSelectedRole = new List <PopulateComboDTO>(); for (int cnt = 0; cnt < objUserInfoModel.SubmittedRole.Count; cnt++) { PopulateComboDTO objPopulateComboDTO = new PopulateComboDTO(); objPopulateComboDTO.Key = objUserInfoModel.SubmittedRole[cnt]; lstSelectedRole.Add(objPopulateComboDTO); } } ModelState.AddModelError("Warning", Common.Common.GetErrorMessage(exp)); ViewBag.StatusDropDown = FillComboValues(ConstEnum.ComboType.ListOfCode, Convert.ToInt32(ConstEnum.CodeGroup.UserStatus).ToString(), null, null, null, null, false); ViewBag.CompanyDropDown = FillComboValues(ConstEnum.ComboType.CompanyList, null, null, null, null, null, true); objUserInfoModel.DefaultRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.COUserType.ToString(), null, null, null, null, true); //check if user has selected role and assign those role if (lstSelectedRole != null && lstSelectedRole.Count > 0) { objUserInfoModel.AssignedRole = lstSelectedRole; objUserInfoModel.SubmittedRole = null; } else { objUserInfoModel.AssignedRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.COUserType.ToString(), objUserInfoModel.UserInfoId.ToString(), null, null, null, false); } ViewBag.UserAction = InsiderTrading.Common.ConstEnum.UserActions.CRUSER_COUSER_EDIT; return(View("Create", objUserInfoModel)); } finally { objLoginUserDetails = null; lstSelectedRole = null; objUserInfoSL = null; objUserInfoDTO = null; } }
public ActionResult Edit(int UserInfoId, string CalledFrom, int acid) { string o_sPassword = string.Empty; bool show_not_login_user_details = true; //flag used to show/hide details on page for login user and other user since for both page is same UserInfoSL objUserInfoSL = new UserInfoSL(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); InsiderTradingDAL.UserInfoDTO objUserInfoDTO = null; try { //Check for not allowing one CO to View personal details of Other CO user, when called from the "View My Details" link if (CalledFrom == "View" && acid == 192 && objLoginUserDetails.LoggedInUserID != UserInfoId) { return(RedirectToAction("Unauthorised", "Home")); } ViewBag.StatusDropDown = FillComboValues(ConstEnum.ComboType.ListOfCode, Convert.ToInt32(ConstEnum.CodeGroup.UserStatus).ToString(), null, null, null, null, false); ViewBag.CompanyDropDown = FillComboValues(ConstEnum.ComboType.CompanyList, null, null, null, null, null, true); objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, UserInfoId); //check if page is show for view mode and if page is shown for logged in user as view details page then do not show role list if (CalledFrom != "Edit") { //check if details being shown for login user then set flag to do not show role list //also check activity id to know if page is shown to user as users view details page if (objUserInfoDTO != null && objUserInfoDTO.UserInfoId == objLoginUserDetails.LoggedInUserID && acid == ConstEnum.UserActions.VIEW_DETAILS_PERMISSION_FOR_CO_USER) { show_not_login_user_details = false; //set flag to do not show role list } } ViewBag.show_not_login_user_details = show_not_login_user_details; if (objUserInfoDTO != null) { COUserInfoModel objUserInfoModel = new COUserInfoModel(); InsiderTrading.Common.Common.CopyObjectPropertyByName(objUserInfoDTO, objUserInfoModel); objUserInfoModel.DefaultRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.COUserType.ToString(), null, null, null, null, true); objUserInfoModel.AssignedRole = FillComboValues(ConstEnum.ComboType.RoleList, ConstEnum.Code.COUserType.ToString(), UserInfoId.ToString(), null, null, null, false); ViewBag.UserAction = acid; if (CalledFrom == "Edit") { return(View("Create", objUserInfoModel)); } else { return(View("View", objUserInfoModel)); } } if (CalledFrom == "Edit") { return(View("Create")); } else { return(View("View")); } } catch (Exception exp) { string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); ViewBag.StatusDropDown = FillComboValues(ConstEnum.ComboType.ListOfCode, Convert.ToInt32(ConstEnum.CodeGroup.UserStatus).ToString(), null, null, null, null, true); ViewBag.CompanyDropDown = FillComboValues(ConstEnum.ComboType.CompanyList, null, null, null, null, null, true); return(View("index")); } finally { objUserInfoSL = null; objLoginUserDetails = null; objUserInfoDTO = null; } }
public ActionResult Create(UserInfoModel objUserInfoModel, string OldPassword) { int nUserInfoID = 0; string Password = null; UserInfoSL objUserInfoSL = new UserInfoSL(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); UserInfoDTO objUserInfoDTO = new UserInfoDTO(); try { InsiderTrading.Common.Common.CopyObjectPropertyByName(objUserInfoModel, objUserInfoDTO); objUserInfoDTO.UserTypeCodeId = ConstEnum.Code.EmployeeType; objUserInfoDTO.IsInsider = ConstEnum.UserType.Insider; objUserInfoDTO.StatusCodeId = Common.Common.ConvertToInt32(ConstEnum.UserStatus.Active); objUserInfoDTO.LoggedInUserId = objLoginUserDetails.LoggedInUserID; Common.Common.encryptData(objUserInfoModel.Password, out Password); if (!Password.Equals(OldPassword)) { objUserInfoDTO.Password = Password; } else { objUserInfoDTO.Password = OldPassword; } if (objUserInfoDTO.StateId == 0) { objUserInfoDTO.StateId = null; } if (objUserInfoDTO.CountryId == 0) { objUserInfoDTO.CountryId = null; } if (objUserInfoDTO.Category == 0) { objUserInfoDTO.Category = null; } if (objUserInfoDTO.SubCategory == 0) { objUserInfoDTO.SubCategory = null; } if (objUserInfoDTO.GradeId == 0) { objUserInfoDTO.GradeId = null; } if (objUserInfoDTO.DesignationId == 0) { objUserInfoDTO.DesignationId = null; } if (objUserInfoDTO.DepartmentId == 0) { objUserInfoDTO.DepartmentId = null; } objUserInfoDTO = objUserInfoSL.InsertUpdateUserDetails(objLoginUserDetails.CompanyDBConnectionString, objUserInfoDTO); if (objUserInfoDTO.UserInfoId != 0) { nUserInfoID = objUserInfoDTO.UserInfoId; } } catch (Exception exp) { PopulateCombo(); ModelState.Remove("KEY"); ModelState.Add("KEY", new ModelState()); ModelState.Clear(); string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); ModelState.AddModelError("Error", sErrMessage); return(View("Create", objUserInfoModel)); } finally { objUserInfoSL = null; objLoginUserDetails = null; objUserInfoDTO = null; } return(RedirectToAction("Create", new { nUserInfoID = nUserInfoID })); }
public ActionResult Index(int acid) { TempData.Remove("SearchArray"); LoginUserDetails objLoginUserDetails = null; InsiderDashboardDTO objInsiderDashboardDTO = null; UserInfoDTO objUserInfoDTO = null; ApprovedPCLDTO objApprovedPCLDTO = null; PasswordExpiryReminderDTO objPassExpiryReminderDTO = null; DateTime CurrentDate; ArrayList lst = new ArrayList(); UserPolicyDocumentEventLogDTO objChangePasswordEventLogDTO = null; CompanyConfigurationDTO objCompanyConfigurationDTO = null; int RequiredModuleID = 0; int noOfDays = 0; object path; ViewBag.dupTransCnt = false; ViewBag.ApprovedPCLCnt = false; Common.Common.WriteLogToFile("Start Method", System.Reflection.MethodBase.GetCurrentMethod()); try { objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); // check IsUserLogin flag in session, and set flag true -- this will indicate user is login and redirect here for first time if (!objLoginUserDetails.IsUserLogin) { objLoginUserDetails.IsUserLogin = true; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); } if (objLoginUserDetails.CompanyName == "DCBBank") { ViewBag.IsVisible = 0; } else { ViewBag.IsVisible = 1; } using (var objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL()) { InsiderInitialDisclosureDTO objInsiderInitialDisclosureDTO = null; objInsiderInitialDisclosureDTO = objInsiderInitialDisclosureSL.Get_mst_company_details(objLoginUserDetails.CompanyDBConnectionString); RequiredModuleID = objInsiderInitialDisclosureDTO.RequiredModule; } objInsiderDashboardModel = new InsiderDashboardModel(); objInsiderDashboardModel.objInsiderDashboardOtherModel = new InsiderDashboardOtherModel(); switch (RequiredModuleID) { case ConstEnum.Code.RequiredModuleOwnSecurity: ViewBag.RequiredModuleOwn = true; ViewBag.RequiredModuleBoth = false; ViewBag.RequiredModuleOther = false; break; case ConstEnum.Code.RequiredModuleOtherSecurity: ViewBag.RequiredModuleOwn = false; ViewBag.RequiredModuleBoth = false; ViewBag.RequiredModuleOther = true; objInsiderDashboardModel.objInsiderDashboardOtherModel = BindDashboardForOtherSecurities(); break; case ConstEnum.Code.RequiredModuleBoth: ViewBag.RequiredModuleOwn = true; int?TradingPolicyID_OS; //check other sericity model is applicable for user or not InsiderInitialDisclosureDTO objInsiderInitialDisclosureDTO = null; using (var objInsiderInitialDisclosureSL = new InsiderInitialDisclosureSL()) { objInsiderInitialDisclosureDTO = objInsiderInitialDisclosureSL.Get_TradingPolicyID_forOS(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); TradingPolicyID_OS = objInsiderInitialDisclosureDTO.TradingPolicyID_OS; } if (TradingPolicyID_OS == null || TradingPolicyID_OS == 0) { ViewBag.RequiredModuleBoth = false; ViewBag.RequiredModuleOther = false; } else { ViewBag.RequiredModuleBoth = true; ViewBag.RequiredModuleOther = true; } objInsiderDashboardModel.objInsiderDashboardOtherModel = BindDashboardForOtherSecurities(); break; } if (objInsiderDashboardModel.objInsiderDashboardOtherModel.IsChangePassword) { Common.Common.SetSessionValue("IsChangePassword", true); return(RedirectToAction("ChangePassword", "UserDetails", new { acid = Convert.ToString(Common.ConstEnum.UserActions.CHANGE_PASSWORD) })); } using (InsiderDashboardSL objInsiderDashboardSL = new InsiderDashboardSL()) { objInsiderDashboardDTO = objInsiderDashboardSL.GetTradingCalenderDetails(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); if (objInsiderDashboardDTO.IsActivated == 1) { ViewBag.hideTrading = 0; } else { ViewBag.hideTrading = 1; } objInsiderDashboardDTO = objInsiderDashboardSL.GetDashboardDetails(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); Common.Common.CopyObjectPropertyByName(objInsiderDashboardDTO, objInsiderDashboardModel); CurrentDate = Convert.ToDateTime(DateTime.Now.Date.ToString("dd/MM/yyyy"), System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat); objPassExpiryReminderDTO = objInsiderDashboardSL.GetPasswordExpiryReminder(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); if (objLoginUserDetails.LoggedInUserID == objPassExpiryReminderDTO.UserID && objPassExpiryReminderDTO.ValidityDate.Date >= CurrentDate && objPassExpiryReminderDTO.ExpiryReminderDate.Date <= CurrentDate) { if ((objPassExpiryReminderDTO.ValidityDate.Date - CurrentDate.Date).Days == 1) { noOfDays = (objPassExpiryReminderDTO.ValidityDate.Date - CurrentDate.Date).Days; } else { noOfDays = (objPassExpiryReminderDTO.ValidityDate.Date - CurrentDate.Date).Days + 1; } lst.Add(noOfDays); lst.Add(objPassExpiryReminderDTO.ValidityDate.Date.ToString("dd/MM/yyyy")); ViewBag.PasswordReminderMsg = Common.Common.getResource("pc_msg_50569", lst); } else if (objPassExpiryReminderDTO.ValidityDate.Date < CurrentDate) { Common.Common.SetSessionValue("IsChangePassword", true); return(RedirectToAction("ChangePassword", "UserDetails", new { acid = Convert.ToString(Common.ConstEnum.UserActions.CHANGE_PASSWORD) })); } } using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); if (objUserInfoDTO.DateOfBecomingInsider != null) { ViewBag.InsiderTypeUser = 1; } else { ViewBag.InsiderTypeUser = 0; } } int SecurityTypeCodeIdCnt = 0; int TransactionTypeCodeIdCnt = 0; int DateOfAcquisitionCnt = 0; using (InsiderDashboardSL objInsiderDashboardSL = new InsiderDashboardSL()) { List <DupTransCntDTO> lstDupTransCnt = objInsiderDashboardSL.Get_DupTransCnt(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); foreach (var dupTransCnt in lstDupTransCnt) { SecurityTypeCodeIdCnt = dupTransCnt.SecurityTypeCodeIdCnt; TransactionTypeCodeIdCnt = dupTransCnt.TransactionTypeCodeIdCnt; DateOfAcquisitionCnt = dupTransCnt.DateOfAcquisitionCnt; } } if (SecurityTypeCodeIdCnt != 0 && TransactionTypeCodeIdCnt != 0 && DateOfAcquisitionCnt != 0) { ViewBag.dupTransCnt = true; TempData["TradingTransactionModel"] = null; TempData["DuplicateTransaction"] = null; } int localApprovedPCLCnt = 0; using (TradingTransactionSL objTradingTransactionSL = new TradingTransactionSL()) { List <ApprovedPCLDTO> lstApprovedPCLCnt = objTradingTransactionSL.GetApprovedPCLCntSL(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID); foreach (var ApprovedPCLCnt in lstApprovedPCLCnt) { localApprovedPCLCnt = ApprovedPCLCnt.ApprovedPCLCnt; } } if (localApprovedPCLCnt != 0) { ViewBag.ApprovedPCLCnt = true; } } catch (Exception exp) { Common.Common.WriteLogToFile("Exception occurred ", System.Reflection.MethodBase.GetCurrentMethod(), exp); } finally { objLoginUserDetails = null; objInsiderDashboardDTO = null; objUserInfoDTO = null; } Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod()); return(View(objInsiderDashboardModel)); }
public ActionResult Summary(int acid, int period, int year, int pdtype, int uid = 0, int tmid = 0) { LoginUserDetails objLoginUserDetails = null; UserInfoDTO objUserInfoDTO = null; ViewBag.showAddTransactionBtn = false; DateTime dtEndDate = DateTime.Now; Dictionary <string, object> dicPeriodStartEnd = null; try { objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); //set activity id for summary page as this page is access from both menu - insider and CO ViewBag.activity_id = acid; using (PeriodEndDisclosureSL objPeriodEndDisclosure = new PeriodEndDisclosureSL()) { dicPeriodStartEnd = objPeriodEndDisclosure.GetPeriodStarEndDate(objLoginUserDetails.CompanyDBConnectionString, year, period, pdtype); DateTime dtStartDate = Convert.ToDateTime(dicPeriodStartEnd["start_date"]); dtEndDate = Convert.ToDateTime(dicPeriodStartEnd["end_date"]); String dtFormat = "dd MMM yyyy"; ViewBag.Period = dtStartDate.ToString(dtFormat) + " - " + dtEndDate.ToString(dtFormat); } //set input vaules for period end summary grid ViewBag.UserId = (uid == 0) ? objLoginUserDetails.LoggedInUserID : uid; ViewBag.YearCode = year; ViewBag.PeriodCode = period; ViewBag.PeriodType = pdtype; ViewBag.TransactionMasterId = (tmid == 0) ? "" : tmid.ToString(); ViewBag.GridType = ConstEnum.GridType.PeriodEndDisclosurePeriodSummary; //if activity id is for CO then fetch employee insider details if (acid == ConstEnum.UserActions.CO_DISCLOSURE_DETAILS_PERIOD_END_DISCLOSURE) { using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, uid); ViewBag.EmployeeId = objUserInfoDTO.EmployeeId; ViewBag.InsiderName = (objUserInfoDTO.UserTypeCodeId == ConstEnum.Code.CorporateUserType) ? objUserInfoDTO.CompanyName : objUserInfoDTO.FirstName + " " + objUserInfoDTO.LastName; } } } catch (Exception ex) { } finally { dicPeriodStartEnd = null; //objLoginUserDetails = null; objUserInfoDTO = null; } int contDisStatusCount = 0; int PEDisStatusCount = 0; int IsIDPending = 0; using (TradingTransactionSL objTradingTransactionSL = new TradingTransactionSL()) { acid = ConstEnum.UserActions.INSIDER_DISCLOSURE_DETAILS_PERIOD_END_DISCLOSURE; year = 0; List <ContinuousDisclosureStatusDTO> lstConDisclosureStatus = objTradingTransactionSL.Get_ContinuousDisclosureStatus(objLoginUserDetails.CompanyDBConnectionString, uid, dtEndDate); foreach (var contDisStatus in lstConDisclosureStatus) { contDisStatusCount = contDisStatus.ContDisPendingStatus; } if (contDisStatusCount > 0) { int ContDisCheck = contDisStatusCount; return(RedirectToAction("PeriodStatus", "PeriodEndDisclosure", new { acid, year, uid, ContDisCheck })); } else { List <ContinuousDisclosureStatusDTO> lstPEDisclosureStatus = objTradingTransactionSL.Get_PEDisclosureStatus(objLoginUserDetails.CompanyDBConnectionString, uid, dtEndDate); foreach (var periodEndStatus in lstPEDisclosureStatus) { PEDisStatusCount = periodEndStatus.PEDisPendingStatus; IsIDPending = periodEndStatus.IsRelativeFound; } if (IsIDPending > 0) { return(RedirectToAction("PeriodStatus", "PeriodEndDisclosure", new { acid, year, uid, PEDisStatusCount, IsIDPending })); } else if (PEDisStatusCount > 0) { int PeriodEndDisCheck = PEDisStatusCount; return(RedirectToAction("PeriodStatus", "PeriodEndDisclosure", new { acid, year, uid, PeriodEndDisCheck })); } else { TradingTransactionMasterDTO objTradingTransactionMasterDTO = null; objTradingTransactionMasterDTO = new TradingTransactionMasterDTO(); objTradingTransactionMasterDTO = objTradingTransactionSL.GetTradingTransactionMasterDetails(objLoginUserDetails.CompanyDBConnectionString, tmid); if (objTradingTransactionMasterDTO.TransactionStatusCodeId == 148002) { ViewBag.showAddTransactionBtn = true; } return(View("Summary")); } } } }
//[AuthorizationPrivilegeFilter] public ActionResult PeriodStatus(int acid, int year = 0, int uid = 0, int ContDisCheck = 0, int PeriodEndDisCheck = 0, int IsIDPending = 0) { LoginUserDetails objLoginUserDetails = null; UserInfoDTO objUserInfoDTO = null; bool backToCOList = false; int activity_id_disclosure = ConstEnum.UserActions.INSIDER_DISCLOSURE_DETAILS_PERIOD_END_DISCLOSURE; int activity_id_disclosure_letter = ConstEnum.UserActions.INSIDER_DISCLOSURE_DETAILS_PERIOD_END_DISCLOSURE_LETTER_SUBMISSION; int activity_id_disclosure_letter_stockexchange = 0; try { objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); ViewBag.UserId = (uid == 0) ? objLoginUserDetails.LoggedInUserID : uid; ViewBag.activity_id = acid; if (IsIDPending > 0) { ModelState.AddModelError("IsIDPending", Common.Common.getResource("dis_msg_53145")); } if (ContDisCheck > 0) { ModelState.AddModelError("ContinuousDisclosureStatus", Common.Common.getResource("dis_lbl_50591")); } if (PeriodEndDisCheck > 0) { ModelState.AddModelError("PEDisclosureStatus", Common.Common.getResource("dis_msg_17391")); } //if login user is CO or admin then show back button on view which redirect back to CO screen for user list if (acid == ConstEnum.UserActions.CO_DISCLOSURE_DETAILS_PERIOD_END_DISCLOSURE || objLoginUserDetails.UserTypeCodeId == 101001 || objLoginUserDetails.UserTypeCodeId == 101002) { backToCOList = true; //set flag to show back button activity_id_disclosure = ConstEnum.UserActions.CO_DISCLOSURE_DETAILS_PERIOD_END_DISCLOSURE; activity_id_disclosure_letter = ConstEnum.UserActions.CO_DISCLOSURE_DETAILS_PERIOD_END_DISCLOSURE_LETTER_SUBMISSION; activity_id_disclosure_letter_stockexchange = ConstEnum.UserActions.CO_DISCLOSURE_DETAILS_PERIOD_END_DISCLOSURE_STOCK_EXCHANGE_SUBMISSION; //if activity id is for CO then fetch employee insider details using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objUserInfoDTO = objUserInfoSL.GetUserDetails(objLoginUserDetails.CompanyDBConnectionString, uid); ViewBag.EmployeeId = objUserInfoDTO.EmployeeId; ViewBag.InsiderName = (objUserInfoDTO.UserTypeCodeId == ConstEnum.Code.CorporateUserType) ? objUserInfoDTO.CompanyName : objUserInfoDTO.FirstName + " " + objUserInfoDTO.LastName; } } //get current year int CurrentYearCode = Common.Common.GetCurrentYearCode(objLoginUserDetails.CompanyDBConnectionString); //show last period end year as default selected int lastPeriodEndYearCode = CurrentYearCode; ViewBag.LastPeriodEndYear = (year == 0) ? lastPeriodEndYearCode : year; //NOTE -- this year list should be from year when user has become insider. //user should be not be able to see ealier year as there won't be any records for earlier year or date from system is implemeted which ever is later List <PopulateComboDTO> lstPopulateComboDTO = new List <PopulateComboDTO>(); List <PopulateComboDTO> lstYear = Common.Common.GetPopulateCombo(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.FinancialYear, null, null, null, null, sLookupPrefix).ToList <PopulateComboDTO>(); //in dropdown list include years less then current year foreach (PopulateComboDTO yr in lstYear) { if (CurrentYearCode >= Convert.ToInt32(yr.Key)) { lstPopulateComboDTO.Add(yr); } } ViewBag.FinancialYearDropDown = lstPopulateComboDTO; ViewBag.GridType = ConstEnum.GridType.PeriodEndDisclosurePeriodStatusList; ViewBag.backToCOList = backToCOList; ViewBag.activity_id_disclosure = activity_id_disclosure; ViewBag.activity_id_disclosure_letter = activity_id_disclosure_letter; ViewBag.activity_id_disclosure_letter_stockexchange = activity_id_disclosure_letter_stockexchange; } catch (Exception ex) { } finally { objLoginUserDetails = null; objUserInfoDTO = null; } return(View("PeriodStatus")); }
public ActionResult Index(string calledFrom = "") { LoginUserDetails objLoginUserDetails = null; //Removing ) ACID for default activities for after loin page. Common.Common.WriteLogToFile("Start Method", System.Reflection.MethodBase.GetCurrentMethod()); Session["IsOTPAuthPage"] = null; bool IsConcurrentSessionActive = false; try { objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); ViewBag.LoginUserName = objLoginUserDetails.UserName; ViewBag.LoginUserCompany = objLoginUserDetails.CompanyName; InsiderTradingDAL.SessionDetailsDTO objSessionDetailsDTO = null; using (UserInfoSL objIsActiveCS = new UserInfoSL()) { IsConcurrentSessionActive = objIsActiveCS.CheckConcurrentSessionConfiguration(objLoginUserDetails.CompanyDBConnectionString); } if (IsConcurrentSessionActive) { if (calledFrom == "Login") { using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objSessionDetailsDTO = objUserInfoSL.SaveSessionStatus(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, "CheckValidLogin"); if (objSessionDetailsDTO == null) { throw new System.Web.HttpException(401, "Unauthorized access"); } } using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objSessionDetailsDTO = objUserInfoSL.SaveSessionStatus(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, "FromLogin"); if (objSessionDetailsDTO != null) { if (objSessionDetailsDTO.UserId == (Convert.ToInt32(objLoginUserDetails.LoggedInUserID))) { objUserInfoSL.DeleteCookiesStatus(objLoginUserDetails.CompanyDBConnectionString, Convert.ToInt32(objLoginUserDetails.LoggedInUserID), " "); //throw new System.Web.HttpException(401, "Unauthorized access"); } } } } } if (objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.Admin || objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.COUserType) { objLoginUserDetails.SelectedParentID = Common.ConstEnum.MenuID.CODASHBOARD; objLoginUserDetails.SelectedChildId = ""; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod()); if (IsConcurrentSessionActive) { if (calledFrom == "Login") { using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objSessionDetailsDTO = objUserInfoSL.SaveSessionStatus(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, (Convert.ToString(HttpContext.Session["GUIDSessionID"])).ToString()); } } } return(RedirectToAction("Index", "CODashboard", new { acid = Common.ConstEnum.UserActions.CRUSER_COUSERDASHBOARD_DASHBOARD })); } else if (objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.EmployeeType || objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.NonEmployeeType || objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.CorporateUserType) { objLoginUserDetails.SelectedParentID = Common.ConstEnum.MenuID.INSIDERDASHBOARD; objLoginUserDetails.SelectedChildId = ""; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod()); //For MCQ InsiderTradingDAL.ImplementedCompanyDTO objImplementedCompanyDTO = new InsiderTradingDAL.ImplementedCompanyDTO(); using (var objCompaniesSL = new InsiderTrading.SL.CompaniesSL()) { objImplementedCompanyDTO = objCompaniesSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, 0, 1); } if (IsConcurrentSessionActive) { if (calledFrom == "Login") { using (UserInfoSL objUserInfoSL = new UserInfoSL()) { objSessionDetailsDTO = objUserInfoSL.SaveSessionStatus(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, (Convert.ToString(HttpContext.Session["GUIDSessionID"])).ToString()); } } } return(RedirectToAction("Index", "InsiderDashboard", new { acid = Common.ConstEnum.UserActions.DASHBOARD_INSIDERUSER })); } else { Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod()); return(RedirectToAction("Home", "About")); } } catch (Exception exp) { Common.Common.WriteLogToFile("Exception occurred ", System.Reflection.MethodBase.GetCurrentMethod(), exp); return(RedirectToAction("Home", "About")); } finally { objLoginUserDetails = null; } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { //filterContext.HttpContext.Session["GUIDSessionID"] = HttpContext.Current.Request.Cookies.Get("v_au").Value; if (filterContext.HttpContext.Session["loginStatus"] != null) { loginStatusFlag = filterContext.HttpContext.Session["loginStatus"].ToString(); } if (filterContext.HttpContext.Session["TwoFactor"] != null) { callForTwoFactor = filterContext.HttpContext.Session["TwoFactor"].ToString(); } if (loginStatusFlag == "1") { if (filterContext.HttpContext.Session["CaptchaValue"] != null) { ActualText = filterContext.HttpContext.Session["CaptchaValue"].ToString(); } else { ActualText = string.Empty; } if (filterContext.HttpContext.Session["SerCaptchaPath"] != null) { CaptchaDirServerPath = filterContext.HttpContext.Session["SerCaptchaPath"].ToString(); } else { CaptchaDirServerPath = string.Empty; } } bool bReturn = false; LoginUserDetails objLoginUserDetails = null; AuthenticationDTO objAuthenticationDTO = null; UserInfoDTO objUserAfterValidationObject = null; UserInfoDTO objUserAunthentication = null; PasswordConfigDTO objPasswordConfig = null; List <string> lstAuthorizationActionLinks = null; List <int> lstAuthorisedActionId = null; List <ActivityResourceMappingDTO> lstActivityResourceMappingDTO = null; Dictionary <string, List <ActivityResourceMappingDTO> > dicActivityResourceMappingDTO = null; int loginCount = 0; bool lockFlag = false; bool flag = false; Common.Common.WriteLogToFile("Start Method", System.Reflection.MethodBase.GetCurrentMethod()); try { objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); if (objLoginUserDetails != null) { //If IsAccountValidated is true in session abject then again it is not checked and only activity aauthorization //is checked. if (!objLoginUserDetails.IsAccountValidated) { objAuthenticationDTO = new AuthenticationDTO(); objAuthenticationDTO.LoginID = objLoginUserDetails.UserName; objAuthenticationDTO.Password = objLoginUserDetails.Password; //string sEncryptedPassword = ""; //Common.Common.encryptData(objAuthenticationDTO.Password, out sEncryptedPassword); //objAuthenticationDTO.Password = sEncryptedPassword; objUserAfterValidationObject = new UserInfoDTO(); using (var objUserInfoSL = new UserInfoSL()) { if (objLoginUserDetails.CompanyDBConnectionString != null) { bReturn = objUserInfoSL.ValidateUser(objLoginUserDetails.CompanyDBConnectionString, objAuthenticationDTO, ref objUserAfterValidationObject); Common.Common.WriteLogToFile("Validated User ", System.Reflection.MethodBase.GetCurrentMethod()); } if (bReturn) { lstAuthorizationActionLinks = new List <string>(); lstAuthorisedActionId = new List <int>(); if (objUserAfterValidationObject.StatusCodeId == ConstEnum.UserStatus.Inactive) { string sErrMessage = Common.Common.getResourceForGivenCompany("usr_msg_11274", objLoginUserDetails.CompanyName); if (sErrMessage == null || sErrMessage == "") { sErrMessage = "Your account has been inactivated. Please contact the Administrator."; } objLoginUserDetails = new LoginUserDetails(); objLoginUserDetails.AuthorisedActionId = lstAuthorisedActionId; objLoginUserDetails.AuthorizedActions = lstAuthorizationActionLinks; objLoginUserDetails.ErrorMessage = sErrMessage; objLoginUserDetails.IsAccountValidated = false; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Account" }, { "action", "Login" } }); } else { if (callForTwoFactor != "1") { string UsrCaptchaText = filterContext.HttpContext.Session["UserCaptchaText"].ToString(); if (ActualText == string.Empty || ActualText == UsrCaptchaText) { LoginUser(filterContext); } else { DeleteCaptcha(filterContext); CaptchaValidation(filterContext); } } } } } } if (objLoginUserDetails.IsAccountValidated && !checkActionAuthorization(filterContext, objLoginUserDetails)) { //If the request is from the Renderaction call and there is unauthorised access then dont redirect the request. if (filterContext.HttpContext.PreviousHandler != null && filterContext.HttpContext.PreviousHandler is MvcHandler) { } else { // filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Home" }, { "action", "Unauthorised" } }); } } } else { Common.Common.WriteLogToFile("User is not login ", System.Reflection.MethodBase.GetCurrentMethod()); objLoginUserDetails = new LoginUserDetails(); objLoginUserDetails.ErrorMessage = ""; objLoginUserDetails.IsAccountValidated = false; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Account" }, { "action", "Login" } }); } } catch (Exception exp) { using (var objPassConfigSL = new PasswordConfigSL()) { if (objLoginUserDetails.CompanyDBConnectionString != null) { objPasswordConfig = objPassConfigSL.GetPasswordConfigDetails(objLoginUserDetails.CompanyDBConnectionString); int count = (Convert.ToInt16(Common.Common.GetSessionValue("LoginCount")) == 0) ? loginCount : Convert.ToInt16(Common.Common.GetSessionValue("LoginCount")); if (count < objPasswordConfig.LoginAttempts) { count++; Common.Common.SetSessionValue("LoginCount", count); filterContext.HttpContext.Session["UserLgnCount"] = count; if (count >= objPasswordConfig.LoginAttempts) { DeleteCaptcha(filterContext); CaptchaValidation(filterContext); } } else { DeleteCaptcha(filterContext); CaptchaValidation(filterContext); } } } Common.Common.WriteLogToFile("Exception occurred ", System.Reflection.MethodBase.GetCurrentMethod(), exp); // string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString()); // objLoginUserDetails.ErrorMessage = sErrMessage; string sErrMessage = ""; if (exp.InnerException != null) { sErrMessage = Common.Common.getResourceForGivenCompany(exp.InnerException.Data[0].ToString(), objLoginUserDetails.CompanyName); } else { sErrMessage = exp.Message; } if (sErrMessage == null || sErrMessage == "") { sErrMessage = "Invalid details entered, please try again with correct details."; } if (Convert.ToBoolean(Common.Common.GetSessionValue("flag")) == true) { sErrMessage = "Your account has been locked. Please contact the Administrator."; } objLoginUserDetails = new LoginUserDetails(); objLoginUserDetails.ErrorMessage = sErrMessage; objLoginUserDetails.IsAccountValidated = false; if (exp.Message != Common.Common.getResource("com_lbl_14027")) { using (SessionManagement sessionManagement = new SessionManagement()) { //sessionManagement.CheckCookiesSessions((LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails), false, (System.Web.HttpRequest)System.Web.HttpContext.Current.Request, (System.Web.HttpResponse)System.Web.HttpContext.Current.Response, "LOGOUT"); sessionManagement.BindCookiesSessions((LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails), false, (System.Web.HttpRequest)System.Web.HttpContext.Current.Request, (System.Web.HttpResponse)System.Web.HttpContext.Current.Response, "LOGOUT"); } Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Account" }, { "action", "Login" } }); } else if (exp.Message.ToString().Equals(Common.Common.getResource("com_lbl_14027")) && HttpContext.Current.Request.Cookies["v_au2"] != null && HttpContext.Current.Request.Cookies["v_au2"].Value != "") { using (SessionManagement sessionManagement = new SessionManagement()) { string decrypteddata = null; Common.Common.dencryptData(HttpContext.Current.Request.Cookies["v_au2"].Value, out decrypteddata); string strCookieName = (false ? string.Empty : decrypteddata + '~' + DateTime.Now.DayOfWeek.ToString().ToUpper()); UserInfoSL objUserInfoSL = new UserInfoSL(); InsiderTradingDAL.SessionDetailsDTO objSessionDetailsDTO = null; LoginUserDetails loginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); objSessionDetailsDTO = objUserInfoSL.GetCookieStatus(loginUserDetails.CompanyDBConnectionString, loginUserDetails.LoggedInUserID, Convert.ToString(strCookieName), false, false); if (objSessionDetailsDTO != null) { //sessionManagement.CheckCookiesSessions((LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails), false, (System.Web.HttpRequest)System.Web.HttpContext.Current.Request, (System.Web.HttpResponse)System.Web.HttpContext.Current.Response, ""); sessionManagement.BindCookiesSessions((LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails), false, (System.Web.HttpRequest)System.Web.HttpContext.Current.Request, (System.Web.HttpResponse)System.Web.HttpContext.Current.Response, ""); objLoginUserDetails.ErrorMessage = string.Empty; objLoginUserDetails.IsAccountValidated = true; } else { Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "controller", "Account" }, { "action", "Login" } }); } } } } finally { filterContext.HttpContext.Session["loginStatus"] = 0; objLoginUserDetails = null; objAuthenticationDTO = null; objUserAfterValidationObject = null; lstAuthorizationActionLinks = null; lstAuthorisedActionId = null; lstActivityResourceMappingDTO = null; dicActivityResourceMappingDTO = null; objUserAunthentication = null; } Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod()); base.OnActionExecuting(filterContext); }