protected void Application_Start() { System.Security.Cryptography.CryptoConfig.AddAlgorithm(typeof(System.Deployment.Internal.CodeSigning.RSAPKCS1SHA256SignatureDescription), "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"); MvcHandler.DisableMvcResponseHeader = true; AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); ModelMetadataProviders.Current = new Mvc2Templates.Providers.CustomModelMetadataProvider(); System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("en-IN"); // ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder()); // ModelBinders.Binders.Add(typeof(decimal?), new DecimalModelBinder()); /* * Update the resources for all the companies available in the master when starting the application so that * resources will be available to be used. */ CompaniesSL objCompaniesSL = new CompaniesSL(); List <InsiderTradingDAL.CompanyDTO> lstCompaniesDTO = objCompaniesSL.getAllCompanies(Common.Common.getSystemConnectionString()); foreach (InsiderTradingDAL.CompanyDTO objCompanyDTO in lstCompaniesDTO) { Common.Common.UpdateCompanyResources(objCompanyDTO.CompanyConnectionString, objCompanyDTO.sCompanyDatabaseName); } // ModelBinders.Binders.DefaultBinder = new DecimalModelBinder(); ModelBinders.Binders.Add(typeof(int), new DecimalModelBinder()); ModelBinders.Binders.Add(typeof(long), new DecimalModelBinder()); ModelBinders.Binders.Add(typeof(int?), new DecimalModelBinder()); ModelBinders.Binders.Add(typeof(long?), new DecimalModelBinder()); ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinderNew()); ModelBinders.Binders.Add(typeof(decimal?), new DecimalModelBinderNew()); }
/// <summary> /// This method is used to get single company connection string /// </summary> /// <param name="s_CompanyName">string: Name of the company</param> /// <returns>CompanyDTO</returns> public static CompanyDTO GetCompanyDetials(string s_CompanyName) { CompaniesSL objCompanySL = new CompaniesSL(); InsiderTradingDAL.CompanyDTO objSelectedCompany = objCompanySL.getSingleCompanies(CommonModel.getSystemConnectionString(), s_CompanyName); return(objSelectedCompany); }
public ActionResult SetPassword(string Code) { //For company specific url.. auto fill company name string ClientName = ""; string currentURL = HttpContext.Request.Url.AbsoluteUri; int index = currentURL.IndexOf("//"); string RemoveProtocol = ""; RemoveProtocol = currentURL.Substring(index + 2); ClientName = RemoveProtocol.Split('.')[0].ToLower(); if (ClientName == "axisbank") { ClientName = "axis bank"; } LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); PasswordPolicyDTO objPasswordPolicy = new PasswordPolicyDTO(); //When the Hash code contains + in it then it gets encoded to space because of which the HshCode gets changed and further when changing password for user it gives invalid Link error. //So as space is not generated in the generated hash code so we can assume that when there is sapce in the hash code it should be + there and so are replacing it before using it. Code = Code.Replace(" ", "+"); if (objLoginUserDetails != null) { ViewBag.ErrorMessage = objLoginUserDetails.ErrorMessage; objLoginUserDetails.ErrorMessage = ""; Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); } 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); } if (objCompaiesDictionary.ContainsValue(ClientName.ToLower())) { ViewBag.URLCompanyName = ClientName; } else { ViewBag.URLCompanyName = "IgnoreCompanyName"; } ViewBag.CompaniesDropDown = objCompaiesDictionary; PasswordManagementModel objPwdMgmtModel = new PasswordManagementModel(); objPwdMgmtModel.HashValue = Code; ViewBag.Hashcode = Code; ViewBag.CalledFrom = "ForgetPassword"; return(View("SetPassword", objPwdMgmtModel)); }
internal bool IsSSOActivated(string companyName) { bool IsSSOActivated = false; using (CompaniesSL objCompaniesSL = new CompaniesSL()) { IsSSOActivated = objCompaniesSL.getSingleCompanies(InsiderTrading.Common.Common.getSystemConnectionString(), companyName).bIsSSOActivated; } return(IsSSOActivated); }
/// <summary> /// This method is to check whether the SSO is activated. /// </summary> /// <param name="companyIDList">Current CompanyName</param> /// <returns>True for Yes and False for No</returns> internal bool IsSSOActivated(CompanyIDList companyIDList) { bool IsSSOActivated = false; using (CompaniesSL objCompaniesSL = new CompaniesSL()) { IsSSOActivated = objCompaniesSL.getSingleCompanies(InsiderTrading.Common.Common.getSystemConnectionString(), "Vigilante_" + companyIDList.ToString()).bIsSSOActivated; } return(IsSSOActivated); }
/// <summary> /// This method is used to setup all the pre-requisite for Login to applicaton /// </summary> /// <param name="HT_Params">Collection of EmailID and CompanyName</param> /// <returns>returns True for Sucessfull and false for Failure</returns> internal bool SetupLoginDetails(Hashtable HT_Params) { bool IsLoginSetupSucceed = false; using (CompaniesSL objCompaniesSL = new CompaniesSL()) { LoginUserDetails objLoginUserDetails = new LoginUserDetails(); CompanyDTO objSelectedCompany = new CompanyDTO(); objSelectedCompany = objCompaniesSL.getSingleCompanies(InsiderTrading.Common.Common.getSystemConnectionString(), HT_Params[CommonConstant.s_AttributeComapnyName].ToString()); objLoginUserDetails.CompanyDBConnectionString = objSelectedCompany.CompanyConnectionString; using (DataSecurity objDataSecurity = new DataSecurity()) { UserInfoDTO userInfoDTO = new UserInfoDTO(); UserInfoDAL objUserInfoDAL = new UserInfoDAL(); userInfoDTO = objUserInfoDAL.LoginSSOUserInfo(objLoginUserDetails.CompanyDBConnectionString, HT_Params); if (userInfoDTO.LoginID == null) { foreach (string perKey in HT_Params.Keys) { if (!perKey.Equals("CompanyName")) { throw new Exception(string.Format(CommonConstant.s_InvalidAttribute, perKey)); } } } objLoginUserDetails.UserName = userInfoDTO.LoginID; objLoginUserDetails.Password = userInfoDTO.Password; objLoginUserDetails.CompanyDBConnectionString = objSelectedCompany.CompanyConnectionString; objLoginUserDetails.CompanyName = objSelectedCompany.sCompanyDatabaseName; objLoginUserDetails.IsUserLogin = false; //this flag indicate that user is not yet login sucessfully Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails); IsLoginSetupSucceed = true; } } return(IsLoginSetupSucceed); }
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 ForgetPassword() { //For company specific url.. auto fill company name string ClientName = ""; string currentURL = HttpContext.Request.Url.AbsoluteUri; int index = currentURL.IndexOf("//"); string RemoveProtocol = ""; RemoveProtocol = currentURL.Substring(index + 2); ClientName = RemoveProtocol.Split('.')[0].ToLower(); if (ClientName == "axisbank") { ClientName = "axis bank"; } if (ConfigurationManager.AppSettings["ActivateWaterMark"].ToString() == "true") { string DomainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; if (DomainName == ConfigurationManager.AppSettings["DomainName"]) { ViewData["WaterMarkCompanyName"] = ConfigurationManager.AppSettings["WaterMarkTextForCompanyName"]; ViewData["WaterMarkLoginId"] = ConfigurationManager.AppSettings["WaterMarkTextForLoginId"]; ViewData["WaterMarkEmailId"] = ConfigurationManager.AppSettings["WaterMarkTextForEmailId"]; } } LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); if (objLoginUserDetails != null) { if (!(objLoginUserDetails.LoggedInUserID == 0 && objLoginUserDetails.ErrorMessage == null)) { ModelState.AddModelError("", objLoginUserDetails.ErrorMessage); objLoginUserDetails.ErrorMessage = string.Empty; } } 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); } if (objCompaiesDictionary.ContainsValue(ClientName.ToLower())) { ViewBag.URLCompanyName = ClientName; } else { ViewBag.URLCompanyName = "IgnoreCompanyName"; } ViewBag.CompaniesDropDown = objCompaiesDictionary; PasswordManagementModel objPwdMgmtModel = new PasswordManagementModel(); DeleteCaptcha(); CaptchaValidation(); return(View("ForgetPassword")); }
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 ActionResult Login() { LoginUserDetails objLoginUserDetails = null; CompaniesSL objCompaniesSL = null; List <InsiderTradingDAL.CompanyDTO> lstCompanies = null; Dictionary <string, string> objCompaniesDictionary = null; PasswordConfigDTO objPasswordConfig = null; int loginCount = 0; Session["TwoFactor"] = 0; Session["IsOTPAuthPage"] = null; try { //Clear browser cache //Response.Cache.SetNoStore(); //Response.Cache.SetCacheability(HttpCacheability.NoCache); //Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1)); //For company specific url.. auto fill company name string ClientName = ""; string currentURL = HttpContext.Request.Url.AbsoluteUri; int index = currentURL.IndexOf("//"); string RemoveProtocol = ""; RemoveProtocol = currentURL.Substring(index + 2); ClientName = RemoveProtocol.Split('.')[0].ToLower(); if (ClientName == "axisbank") { ClientName = "axis bank"; } Random random = new Random(); int num = random.Next(); Session["randomNumber"] = num; if (ConfigurationManager.AppSettings["ActivateWaterMark"].ToString() == "true") { string DomainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; if (DomainName == ConfigurationManager.AppSettings["DomainName"]) { ViewData["WaterMarkCompanyName"] = ConfigurationManager.AppSettings["WaterMarkTextForCompanyName"]; ViewData["WaterMarkLoginId"] = ConfigurationManager.AppSettings["WaterMarkTextForLoginId"]; ViewData["WaterMarkPassword"] = "******"; } } //set session validation value Common.Common.SetSessionAndCookiesValidationValue(ConstEnum.SessionAndCookiesKeyBeforeLogin); //create new cookies for login page string cookies_value = Common.Common.GetSessionValue(ConstEnum.SessionValue.CookiesValidationKey).ToString(); //Response.Cookies.Add(new HttpCookie(ConstEnum.CookiesValue.ValidationCookies, cookies_value) { Path = Request.ApplicationPath /*, Expires = DateTime.Now.AddDays(1)*/ }); objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); //set session key to null Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, null); using (objCompaniesSL = new CompaniesSL()) { lstCompanies = objCompaniesSL.getAllCompanies(Common.Common.getSystemConnectionString()); objCompaniesDictionary = new Dictionary <string, string>(); //List<SelectListItem> lstCompaniesListBox = new List<SelectListItem>(); //commented unused variable objCompaniesDictionary.Add("", "Select Company"); foreach (InsiderTradingDAL.CompanyDTO objCompanyDTO in lstCompanies) { objCompaniesDictionary.Add(objCompanyDTO.sCompanyDatabaseName, objCompanyDTO.sCompanyName); } if (objCompaniesDictionary.ContainsValue(ClientName.ToLower())) { ViewBag.URLCompanyName = ClientName; } else { ViewBag.URLCompanyName = "IgnoreCompanyName"; } } ViewBag.JavascriptEncryptionKey = Common.ConstEnum.Javascript_Encryption_Key; ViewBag.CompaniesDropDown = objCompaniesDictionary; if (objLoginUserDetails != null) { ViewBag.LoginError = objLoginUserDetails.ErrorMessage; ViewBag.SuccessMessage = objLoginUserDetails.SuccessMessage; } else { ViewBag.LoginError = ""; } } catch (Exception exp) { Common.Common.WriteLogToFile("Exception occurred ", System.Reflection.MethodBase.GetCurrentMethod(), exp); } finally { objLoginUserDetails = null; lstCompanies = null; } return(View()); }
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 override void OnActionExecuting(ActionExecutingContext filterContext) { CompilationSection compilationSection = (CompilationSection)System.Configuration.ConfigurationManager.GetSection(@"system.web/compilation"); //UserInfoSL objUserInfoSL = new UserInfoSL(); CompaniesSL objCompaniesSL = new CompaniesSL(); ResourcesSL objResourcesSL = new ResourcesSL(); InsiderTradingDAL.CompanyDTO objSelectedCompany = new CompanyDTO(); LoginUserDetails objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails); string sConnectionString = ""; if (objLoginUserDetails == null || objLoginUserDetails.CompanyName == null) { sConnectionString = Common.Common.getSystemConnectionString(); Dictionary <string, string> lstCompanyResources = new Dictionary <string, string>(); objResourcesSL.GetAllResources(sConnectionString, out lstCompanyResources); HttpContext.Current.Application.Set("InsiderTrading", lstCompanyResources); if (compilationSection.Debug) { using (FileStream filestream = new FileStream((System.Web.HttpContext.Current.Server.MapPath("~/DebugLogs/DebugLogs.txt")), FileMode.Append, FileAccess.Write, FileShare.ReadWrite)) { StreamWriter sWriter = new StreamWriter(filestream); sWriter.WriteLine("UpdateResourcesFilter--> OnActionExecuting method called and got Exception for - Login details || Company name is null :- " + DateTime.Now); sWriter.WriteLine("--------------------------------------------------------------------"); sWriter.Close(); sWriter.Dispose(); filestream.Close(); filestream.Dispose(); } } } else { objSelectedCompany = objCompaniesSL.getSingleCompanies(Common.Common.getSystemConnectionString(), objLoginUserDetails.CompanyName); sConnectionString = objLoginUserDetails.CompanyDBConnectionString; Dictionary <string, string> objResourceFromContext = ((Dictionary <string, string>)HttpContext.Current.Application.Get(objLoginUserDetails.CompanyName)); if (objSelectedCompany.nUpdateResources == 1 || (objResourceFromContext == null || objResourceFromContext.Count == 0)) { Common.Common.UpdateCompanyResources(sConnectionString, objLoginUserDetails.CompanyName); } if (compilationSection.Debug) { using (FileStream filestream = new FileStream((System.Web.HttpContext.Current.Server.MapPath("~/DebugLogs/DebugLogs.txt")), FileMode.Append, FileAccess.Write, FileShare.ReadWrite)) { StreamWriter sWriter = new StreamWriter(filestream); sWriter.WriteLine("UpdateResourcesFilter--> OnActionExecuting method called :- " + DateTime.Now); sWriter.WriteLine("--------------------------------------------------------------------"); sWriter.Close(); sWriter.Dispose(); filestream.Close(); filestream.Dispose(); } } } //Note: Fetch the activity access for user and load in session here base.OnActionExecuting(filterContext); }
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(int acid, int TemplateMasterId, string calledFrom = "") { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); //CompaniesSL objCompaniesSL = new CompaniesSL(); ImplementedCompanyDTO objImplementedCompanyDTO = new ImplementedCompanyDTO(); TemplateMasterModel objTemplateMasterModel = new TemplateMasterModel(); List <PopulateComboDTO> lstList = new List <PopulateComboDTO>(); //TemplateMasterSL objTemplateMasterSL = new TemplateMasterSL(); TemplateMasterDTO objTemplateMasterDTO = new TemplateMasterDTO(); StringWriter objSignatureWriter = new StringWriter(); StringWriter objSubjectWriter = new StringWriter(); StringWriter objTemplateWriter = new StringWriter(); StringWriter objAddress1Writer = new StringWriter(); StringWriter objAddress2Writer = new StringWriter(); //get list of communication mode lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.CommunicationModes, null, null, null, null, true); if (TemplateMasterId == 0) { List <PopulateComboDTO> lstListForRules = new List <PopulateComboDTO>(); foreach (PopulateComboDTO objItem in lstList) { if (objItem.Key != ConstEnum.Code.CommunicationModeForFormE.ToString()) { lstListForRules.Add(objItem); } } ViewBag.CommunicationMode = lstListForRules; } else { ViewBag.CommunicationMode = lstList; } //get list of disclousre type lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.DisclosureType, null, null, null, null, true); ViewBag.DisclosureType = lstList; //get list of user type for letter type communicaiton mode lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.DisclosureLetterForUserType, ConstEnum.Code.CommunicationModeForLetter.ToString(), null, null, null, true); ViewBag.LetterFor = lstList; //get list of user type for FAQ type communicaiton mode lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.DisclosureLetterForUserType, ConstEnum.Code.CommunicationModeForFAQ.ToString(), null, null, null, true); ViewBag.FAQFor = lstList; lstList = null; ViewBag.TemplateMasterId = TemplateMasterId; ViewBag.placeholderarr = "[]"; if (TemplateMasterId > 0) { using (var objTemplateMasterSL = new TemplateMasterSL()) { objTemplateMasterDTO = objTemplateMasterSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, TemplateMasterId); } InsiderTrading.Common.Common.CopyObjectPropertyByName(objTemplateMasterDTO, objTemplateMasterModel); if (objTemplateMasterModel.CommunicationModeCodeId == ConstEnum.Code.CommunicationModeForEmail) { objTemplateMasterModel.CommunicationFromEmail = objTemplateMasterModel.CommunicationFrom; } objTemplateMasterModel.Contents = objTemplateMasterModel.Contents.Replace("\\r\\n", Environment.NewLine); HttpUtility.HtmlDecode(objTemplateMasterModel.Contents, objContentsWriter); objTemplateMasterModel.Contents = objContentsWriter.ToString(); HttpUtility.HtmlDecode(objTemplateMasterModel.Subject, objSubjectWriter); objTemplateMasterModel.Subject = objSubjectWriter.ToString(); HttpUtility.HtmlDecode(objTemplateMasterModel.TemplateName, objTemplateWriter); objTemplateMasterModel.TemplateName = objTemplateWriter.ToString(); if (objTemplateMasterModel.CommunicationModeCodeId == Common.ConstEnum.Code.CommunicationModeForEmail) { List <string> lst = new List <string>(); MatchCollection mcol = Regex.Matches(objTemplateMasterModel.Contents, @"\|~\|(.*?)\|~\|"); foreach (Match m in mcol) { if (m != null && m.ToString() != "") { //objTemplateMasterModel.Contents = objTemplateMasterModel.Contents.Replace(m.ToString(), "[[[[" + m.ToString() + "]]]]"); objTemplateMasterModel.Contents = objTemplateMasterModel.Contents; } } } if (objTemplateMasterModel.CommunicationModeCodeId == Common.ConstEnum.Code.CommunicationModeForFormE) { List <string> lst = new List <string>(); MatchCollection matPlaceholderPattern1 = Regex.Matches(objTemplateMasterModel.Contents, @" \[(.*?)\]"); foreach (Match m in matPlaceholderPattern1) { if (m != null && m.ToString() != "") { objTemplateMasterModel.Contents = objTemplateMasterModel.Contents.Replace(m.ToString(), " [" + m.ToString().Trim() + "]"); } } MatchCollection matPlaceholderPattern2 = Regex.Matches(objTemplateMasterModel.Contents, @">(\[{1})(.*?)\]"); foreach (Match m in matPlaceholderPattern2) { //lst.Add(m.ToString()); if (m != null && m.ToString() != "") { string sPlaceHolderToReplace = m.ToString().Substring(1); objTemplateMasterModel.Contents = objTemplateMasterModel.Contents.Replace(m.ToString(), ">[" + sPlaceHolderToReplace.Trim() + "]"); } } } if (objTemplateMasterModel.Signature != null) { objTemplateMasterModel.Signature = objTemplateMasterModel.Signature.Replace("\\r\\n", Environment.NewLine); HttpUtility.HtmlDecode(objTemplateMasterModel.Signature, objSignatureWriter); objTemplateMasterModel.Signature = objSignatureWriter.ToString(); } if (objTemplateMasterModel.ToAddress1 != null) { objTemplateMasterModel.ToAddress1 = objTemplateMasterModel.ToAddress1.Replace("\\r\\n", Environment.NewLine); HttpUtility.HtmlDecode(objTemplateMasterModel.ToAddress1, objAddress1Writer); objTemplateMasterModel.ToAddress1 = objAddress1Writer.ToString(); } //for communcition type letter -- check if checkbox address 2 optional is checked or not // if checkbox is NOT checked then set null else replace new line character for text entered if (objTemplateMasterModel.CommunicationModeCodeId == ConstEnum.Code.CommunicationModeForLetter && !objTemplateMasterModel.IsCommunicationTemplate) { objTemplateMasterModel.ToAddress2 = null; } else { if (objTemplateMasterModel.ToAddress2 != null) { objTemplateMasterModel.ToAddress2 = objTemplateMasterModel.ToAddress2.Replace("\\r\\n", Environment.NewLine); HttpUtility.HtmlDecode(objTemplateMasterModel.ToAddress2, objAddress2Writer); objTemplateMasterModel.ToAddress2 = objAddress2Writer.ToString(); } } if (objTemplateMasterModel.CommunicationModeCodeId == ConstEnum.Code.CommunicationModeForFormE) { //Fetch the list of placeholders as per the communication mode lstList = FillComboValues(ConstEnum.ComboType.TemplateMasterPlaceholderList, objTemplateMasterModel.CommunicationModeCodeId.ToString(), null, null, null, null, false); List <string[]> arrPlaceholdersList = new List <string[]>(); foreach (var placeholder in lstList) { string[] arrPlaceholder = new string[1]; arrPlaceholder[0] = placeholder.Value; arrPlaceholdersList.Add(arrPlaceholder); } ViewBag.placeholderarr = JsonConvert.SerializeObject(arrPlaceholdersList).ToString(); } } else { using (var objCompaniesSL = new CompaniesSL()) { objImplementedCompanyDTO = objCompaniesSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, 0, 1); } //objTemplateMasterModel.CommunicationFrom = objImplementedCompanyDTO.EmailId; ViewBag.ImplementedCompanyEmailId = objImplementedCompanyDTO.EmailId; } ViewBag.CommunicationMode_id = objTemplateMasterModel.CommunicationModeCodeId; ViewBag.IsDisplayBackButton = true; ViewBag.calledFrom = calledFrom; ViewBag.acid = acid; if (calledFrom == "Communication") { ViewBag.IsDisplayBackButton = false; return(PartialView("Create", objTemplateMasterModel)); } else if (calledFrom == "CommunicationRule") { ViewBag.IsDisplayBackButton = false; return(PartialView("Create", objTemplateMasterModel)); } else { return(View("Create", objTemplateMasterModel)); } }
public JsonResult UpdateResourceValue(ResourceModel objResourceModel, int acid) { bool bReturn = false; LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); ResourcesSL objResourcesSL = new ResourcesSL(); ResourcesDTO objResourcesDTO = new ResourcesDTO(); CompaniesSL objCompaniesSL = new CompaniesSL(); bool statusFlag = false; var ErrorDictionary = new Dictionary <string, string>(); Common.Common objCommon = new Common.Common(); string message = string.Empty; try { if (!objCommon.ValidateCSRFForAJAX()) { return(Json(new { status = statusFlag, Message = ErrorDictionary }, JsonRequestBehavior.AllowGet)); } Common.Common.CopyObjectPropertyByName(objResourceModel, objResourcesDTO); objResourcesDTO.LoggedInUserId = objLoginUserDetails.LoggedInUserID; bReturn = objResourcesSL.SaveDetails(objLoginUserDetails.CompanyDBConnectionString, objResourcesDTO); if (bReturn) { objCompaniesSL.UpdateMasterCompanyDetails(Common.Common.getSystemConnectionString(), objLoginUserDetails.CompanyName, 1); Common.Common.UpdateCompanyResources(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.CompanyName); //return Json(new //{ // status = true, // Message = InsiderTrading.Common.Common.getResource("mst_msg_10049") //"Resource Update Successfully." //}, JsonRequestBehavior.AllowGet); statusFlag = true; message = InsiderTrading.Common.Common.getResource("mst_msg_10049"); } else { statusFlag = false; message = "Resource not saved."; } //return Json(new //{ // status = false, // Message = "Resource not saved." //}, JsonRequestBehavior.AllowGet); } 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; objResourcesSL = null; objResourcesDTO = null; objCompaniesSL = null; } return(Json(new { status = statusFlag, Message = message }, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveImportedRecordsProc(int acid, MassUploadModel objMassUploadModel, Dictionary <int, List <DocumentDetailsModel> > dicPolicyDocumentsUploadFileList, int massuploadid) { LoginUserDetails objLoginUserDetails = null; string sCurrentCompanyDBName = ""; string sConnectionString = ""; CompanyDTO objCompanyToMassUpload; Dictionary <string, DocumentDetailsDTO> objDocumentDetailsdDTO = new Dictionary <string, DocumentDetailsDTO>(); string sFilePath = ""; string sFileName = ""; string sErrorMessage = ""; //objDocumentDetailsdDTO. string directory = ConfigurationManager.AppSettings["Document"]; Dictionary <string, List <MassUploadResponseDTO> > objSheetWiseError = new Dictionary <string, List <MassUploadResponseDTO> >(); Dictionary <string, string> objInvalidSheetColumnError = new Dictionary <string, string>(); MassUploadDTO objSelectedMassUploadDTO = new MassUploadDTO(); string sErrorFileGuid = ""; bool bErrorExistInExcelSheets = false; bool bCheckifExcelIsvalid = false; int nSavedMassUploadLogId = 0; try { objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)InsiderTrading.Common.ConstEnum.SessionValue.UserDetails); objDocumentDetailsdDTO = objLoginUserDetails.DocumentDetails; sCurrentCompanyDBName = objLoginUserDetails.CompanyName; sConnectionString = objLoginUserDetails.CompanyDBConnectionString; using (var objCompaniesSL = new CompaniesSL()) { objCompanyToMassUpload = objCompaniesSL.getSingleCompanies(Common.Common.getSystemConnectionString(), objLoginUserDetails.CompanyName); } sConnectionString = objCompanyToMassUpload.CompanyConnectionStringWithTimeout(5000); ViewBag.acid = acid; if (dicPolicyDocumentsUploadFileList.ContainsKey(InsiderTrading.Common.ConstEnum.Code.MassUpload) && dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload].Count > 0) { if (dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload].Count > 0) { using (var objMassUploadSL = new MassUploadSL()) { objSelectedMassUploadDTO = objMassUploadSL.GetSingleMassUploadDetails(sConnectionString, massuploadid); } string sUploadedFileOriginalName = dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload][0].DocumentName; sUploadedFileOriginalName = sUploadedFileOriginalName.Substring(0, sUploadedFileOriginalName.IndexOf(".")); if (objSelectedMassUploadDTO.TemplateFileName != sUploadedFileOriginalName) { sErrorMessage = "The selected file name does not match with the Template to be used for \"" + objSelectedMassUploadDTO.MassUploadName + "\". Please select correct file and try again."; TempData["ErrorMessage"] = sErrorMessage; TempData["IsError"] = "1"; return(RedirectToAction("OpenFileUploadDialog", "MassUpload", new { acid = ViewBag.acid, massuploadid = massuploadid })); } sFileName = dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload][0].GUID; } sFilePath = directory + "temp/" + sFileName; } if (sFileName == null || sFileName == "" || sFilePath == "") { sErrorMessage = "File not selected."; TempData["ErrorMessage"] = sErrorMessage; TempData["IsError"] = "1"; return(RedirectToAction("OpenFileUploadDialog", "MassUpload", new { acid = ViewBag.acid, massuploadid = massuploadid })); } using (var objParameterisedMassUploadSL = new MassUploadSL(massuploadid, sConnectionString, sCurrentCompanyDBName)) { //objMassUploadSL = new InsiderTradingMassUpload.MassUploadSL(massuploadid, sConnectionString, sCurrentCompanyDBName); //Add entry in the Log table and generate the MapToId (i.e. the log table id) for the document to be saved. objParameterisedMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, 0, massuploadid, InsiderTrading.Common.ConstEnum.Code.MassUploadStarted, null, "", "", objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId); //Save the document and add entry in the Document table List <DocumentDetailsModel> objSavedDocumentDetialsModelList = new List <DocumentDetailsModel>(); using (var objDocumentDetailsSL = new DocumentDetailsSL()) { objSavedDocumentDetialsModelList = objDocumentDetailsSL.SaveDocumentDetails(objLoginUserDetails.CompanyDBConnectionString, dicPolicyDocumentsUploadFileList[InsiderTrading.Common.ConstEnum.Code.MassUpload], Convert.ToInt32(InsiderTrading.Common.ConstEnum.Code.MassUpload), nSavedMassUploadLogId, objLoginUserDetails.LoggedInUserID); } objParameterisedMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, InsiderTrading.Common.ConstEnum.Code.MassUploadStarted, objSavedDocumentDetialsModelList[0].DocumentId, "", "", objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId); objParameterisedMassUploadSL.SetUploadedfileGUID(objSavedDocumentDetialsModelList[0].GUID); sFilePath = objSavedDocumentDetialsModelList[0].DocumentPath; objParameterisedMassUploadSL.SetExcelFilePath(sFilePath); objParameterisedMassUploadSL.SetEncryptionSaltValue(Common.ConstEnum.User_Password_Encryption_Key); objParameterisedMassUploadSL.ExecuteMassUploadCall(); bCheckifExcelIsvalid = objParameterisedMassUploadSL.IsExcelValid(); if (!bCheckifExcelIsvalid) { //Check if there are errors in the excel sheet before processing it for mass upload insert. //If all the data from the excel is valid then only let user impoert the excel file. bErrorExistInExcelSheets = objParameterisedMassUploadSL.CheckIfErrorExistInExcelSheets(); Dictionary <string, List <MassUploadExcelSheetErrors> > objAllSheetColumnWiseErrorList = objParameterisedMassUploadSL.GetExcelSheetWiseErrors(); if (bErrorExistInExcelSheets) { TempData["AllSheetErrors"] = objAllSheetColumnWiseErrorList; TempData["AllSheetErrorsPresent"] = bErrorExistInExcelSheets; sErrorFileGuid = objParameterisedMassUploadSL.WriteErrorsToExcel(ConfigurationManager.AppSettings["ExportDocument"], ConfigurationManager.AppSettings["Document"]); //Update the error log file name in log table objParameterisedMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, Common.ConstEnum.Code.MassUploadFailed, null, sErrorFileGuid + ".xlsx", "", objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId); TempData["ErrorFileGuid"] = sErrorFileGuid; TempData["SuccessMessage"] = "Successfully Imported the Excel"; } } else { sErrorMessage = "Uploaded excel is not valid. Please use the provided template for corresponding mass upload and try again."; objParameterisedMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, Common.ConstEnum.Code.MassUploadFailed, null, "", sErrorMessage, objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId); } } } catch (Exception exp) { sErrorMessage = exp.Message; if (exp.Source == "Microsoft JET Database Engine") { sErrorMessage = "Uploaded excel is not valid. Please use the provided template for corresponding mass upload and try again."; } using (var objMassUploadSL = new MassUploadSL()) { objMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, Common.ConstEnum.Code.MassUploadFailed, null, "", sErrorMessage, objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId); } } finally { //objLoginUserDetails = null; objCompanyToMassUpload = null;; objDocumentDetailsdDTO = null; objSheetWiseError = null; objInvalidSheetColumnError = null; objSelectedMassUploadDTO = null; } //TempData is equivalent to ViewBag, but TempData is used when sending the data during redirection if ((sErrorMessage != null && sErrorMessage != "") || bErrorExistInExcelSheets) { TempData["ErrorMessage"] = sErrorMessage; TempData["IsError"] = "1"; } else { TempData["SuccessMessage"] = "Successfully Imported the Excel"; TempData["IsError"] = "0"; using (var objMassUploadSL = new MassUploadSL()) { objMassUploadSL.AddUpdateLogEntry(objLoginUserDetails.CompanyDBConnectionString, nSavedMassUploadLogId, massuploadid, Common.ConstEnum.Code.MassUploadCompleted, null, "", "", objLoginUserDetails.LoggedInUserID, out nSavedMassUploadLogId); } } objMassUploadModel.MassUploadFile = Common.Common.GenerateDocumentList(Common.ConstEnum.Code.MassUpload, 0, 0, null, 0); return(RedirectToAction("OpenFileUploadDialog", "MassUpload", new { acid = ViewBag.acid, massuploadid = massuploadid })); }
public ActionResult Index() { LoginUserDetails objLoginUserDetails = null; SSOSL objSSOSL = null; UserInfoDTO ObjuserDTO = null; CompanyDTO objSelectedCompany = null; DataSecurity objDataSecurity = null; UserPrincipal userPrincipal = null; string s_debugInfo = string.Empty; string PrompSSOCredentials = "1"; try { if (PrompSSOCredentials == (ConfigurationManager.AppSettings["PromptSSOCredentials"].ToString())) { Dictionary <string, string> objCompaniesDictionary = null; List <InsiderTradingDAL.CompanyDTO> lstCompanies = null; using (CompaniesSL objCompaniesSL = new CompaniesSL()) { lstCompanies = objCompaniesSL.getAllCompanies(Common.Common.getSystemConnectionString()); objCompaniesDictionary = new Dictionary <string, string>(); objCompaniesDictionary.Add("", "Select Company"); foreach (InsiderTradingDAL.CompanyDTO objCompanyDTO in lstCompanies) { objCompaniesDictionary.Add(objCompanyDTO.sCompanyDatabaseName, objCompanyDTO.sCompanyName); } } ViewBag.JavascriptEncryptionKey = Common.ConstEnum.Javascript_Encryption_Key; ViewBag.CompaniesDropDown = objCompaniesDictionary; return(View("SSOLogin")); //return View("AuthenticationFailed"); } else { //Login with Directory Credentials using (DirectoryEntry dirEntry = new DirectoryEntry("WinNT://" + Environment.UserDomainName)) { string s_CurrentLoggedInUser = Request.ServerVariables["LOGON_USER"].ToUpper(); s_debugInfo = "# Domain Name - " + Environment.UserDomainName + "# Request Server Variables (LOGON_USER) - " + s_CurrentLoggedInUser; if (string.IsNullOrEmpty(s_CurrentLoggedInUser)) { s_CurrentLoggedInUser = System.Web.HttpContext.Current.User.Identity.Name; s_debugInfo += "# System.Web.HttpContext.Current.User.Identity.Name - " + s_CurrentLoggedInUser; } if (string.IsNullOrEmpty(s_CurrentLoggedInUser)) { s_CurrentLoggedInUser = User.Identity.Name; s_debugInfo += "# User.Identity.Name - " + User.Identity.Name; } foreach (DirectoryEntry item in dirEntry.Children) { using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain)) { userPrincipal = UserPrincipal.FindByIdentity(ctx, Request.ServerVariables["LOGON_USER"].Replace(Environment.UserDomainName + @"\", string.Empty)); if (userPrincipal != null) { if (s_CurrentLoggedInUser.Equals((Environment.UserDomainName + @"\" + userPrincipal.SamAccountName).ToUpper())) { s_debugInfo += "# User Principal Given Name - " + userPrincipal.GivenName + "# User Principal EmployeeId - " + userPrincipal.EmployeeId + "# User Principal EmailAddress - " + userPrincipal.EmailAddress; using (objSSOSL = new SSOSL()) { objLoginUserDetails = new LoginUserDetails(); objSelectedCompany = new CompanyDTO(); objSelectedCompany = objSSOSL.getSingleCompanies(InsiderTradingSSO.Common.Common.getSystemConnectionString(), ConfigurationManager.AppSettings["DBName"].ToString()); objLoginUserDetails.CompanyDBConnectionString = objSelectedCompany.CompanyConnectionString; Hashtable ht_Param = new Hashtable(); if (userPrincipal.EmployeeId != null && !userPrincipal.EmployeeId.Length.Equals(0)) { ht_Param.Add("EmployeeId", userPrincipal.EmployeeId); } else { ht_Param.Add("EmailId", userPrincipal.EmailAddress); } ObjuserDTO = objSSOSL.LoginSSOUserInfo(objLoginUserDetails.CompanyDBConnectionString, ht_Param); objDataSecurity = new DataSecurity(); Dictionary <string, object> dictUserDetails = new Dictionary <string, object>(); dictUserDetails.Add("sUserName", ObjuserDTO.LoginID); dictUserDetails.Add("sPassword", ObjuserDTO.Password); dictUserDetails.Add("sCompanyName", objSelectedCompany.sCompanyDatabaseName); dictUserDetails.Add("sCalledFrom", objDataSecurity.CreateHash(string.Format(Common.ConstEnum.s_SSO, Convert.ToString(DateTime.Now.Year)), Common.ConstEnum.User_Password_Encryption_Key)); return(this.RedirectAndPost(ConfigurationManager.AppSettings["VigilanteURL"].ToString(), dictUserDetails)); } } } } } } } } catch { s_debugInfo += "# Login Failed. "; return(View("AuthenticationFailed")); } finally { if (compilationSection.Debug) { if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("~/DebugLogs"))) { Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("~/DebugLogs")); } using (FileStream filestream = new FileStream(System.Web.HttpContext.Current.Server.MapPath("~/DebugLogs/SSODebugLogs.txt"), FileMode.Append, FileAccess.Write, FileShare.ReadWrite)) { StreamWriter sWriter = new StreamWriter(filestream); sWriter.WriteLine(" SSO Login - " + DateTime.Now); string[] arr_debugInfo = s_debugInfo.Split('#'); foreach (string debugInfo in arr_debugInfo) { sWriter.WriteLine(debugInfo); } sWriter.WriteLine("--------------------------------------------------------------------"); sWriter.Close(); sWriter.Dispose(); filestream.Close(); filestream.Dispose(); } } } return(View()); }
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(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))); }