예제 #1
0
        /// <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);
        }
예제 #2
0
        internal bool IsSSOActivated(string companyName)
        {
            bool IsSSOActivated = false;

            using (CompaniesSL objCompaniesSL = new CompaniesSL())
            {
                IsSSOActivated = objCompaniesSL.getSingleCompanies(InsiderTrading.Common.Common.getSystemConnectionString(), companyName).bIsSSOActivated;
            }

            return(IsSSOActivated);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        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;
            }
        }
예제 #6
0
        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"));
            }
        }
예제 #7
0
        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"));
        }
예제 #8
0
        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" }));
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
        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 }));
        }