Beispiel #1
0
        public ActionResult Index(string calledFrom = "")
        {
            LoginUserDetails objLoginUserDetails = null;

            //Removing ) ACID for default activities for after loin page.
            Common.Common.WriteLogToFile("Start Method", System.Reflection.MethodBase.GetCurrentMethod());

            Session["IsOTPAuthPage"] = null;
            bool IsConcurrentSessionActive = false;

            try
            {
                objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails);

                ViewBag.LoginUserName    = objLoginUserDetails.UserName;
                ViewBag.LoginUserCompany = objLoginUserDetails.CompanyName;

                InsiderTradingDAL.SessionDetailsDTO objSessionDetailsDTO = null;

                using (UserInfoSL objIsActiveCS = new UserInfoSL())
                {
                    IsConcurrentSessionActive = objIsActiveCS.CheckConcurrentSessionConfiguration(objLoginUserDetails.CompanyDBConnectionString);
                }

                if (IsConcurrentSessionActive)
                {
                    if (calledFrom == "Login")
                    {
                        using (UserInfoSL objUserInfoSL = new UserInfoSL())
                        {
                            objSessionDetailsDTO = objUserInfoSL.SaveSessionStatus(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, "CheckValidLogin");

                            if (objSessionDetailsDTO == null)
                            {
                                throw new System.Web.HttpException(401, "Unauthorized access");
                            }
                        }

                        using (UserInfoSL objUserInfoSL = new UserInfoSL())
                        {
                            objSessionDetailsDTO = objUserInfoSL.SaveSessionStatus(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, "FromLogin");

                            if (objSessionDetailsDTO != null)
                            {
                                if (objSessionDetailsDTO.UserId == (Convert.ToInt32(objLoginUserDetails.LoggedInUserID)))
                                {
                                    objUserInfoSL.DeleteCookiesStatus(objLoginUserDetails.CompanyDBConnectionString, Convert.ToInt32(objLoginUserDetails.LoggedInUserID), "  ");
                                    //throw new System.Web.HttpException(401, "Unauthorized access");
                                }
                            }
                        }
                    }
                }

                if (objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.Admin || objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.COUserType)
                {
                    objLoginUserDetails.SelectedParentID = Common.ConstEnum.MenuID.CODASHBOARD;
                    objLoginUserDetails.SelectedChildId  = "";
                    Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails);

                    Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod());
                    if (IsConcurrentSessionActive)
                    {
                        if (calledFrom == "Login")
                        {
                            using (UserInfoSL objUserInfoSL = new UserInfoSL())
                            {
                                objSessionDetailsDTO = objUserInfoSL.SaveSessionStatus(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, (Convert.ToString(HttpContext.Session["GUIDSessionID"])).ToString());
                            }
                        }
                    }
                    return(RedirectToAction("Index", "CODashboard", new { acid = Common.ConstEnum.UserActions.CRUSER_COUSERDASHBOARD_DASHBOARD }));
                }
                else if (objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.EmployeeType || objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.NonEmployeeType ||
                         objLoginUserDetails.UserTypeCodeId == ConstEnum.Code.CorporateUserType)
                {
                    objLoginUserDetails.SelectedParentID = Common.ConstEnum.MenuID.INSIDERDASHBOARD;
                    objLoginUserDetails.SelectedChildId  = "";
                    Common.Common.SetSessionValue(ConstEnum.SessionValue.UserDetails, objLoginUserDetails);

                    Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod());
                    //For MCQ
                    InsiderTradingDAL.ImplementedCompanyDTO objImplementedCompanyDTO = new InsiderTradingDAL.ImplementedCompanyDTO();
                    using (var objCompaniesSL = new InsiderTrading.SL.CompaniesSL())
                    {
                        objImplementedCompanyDTO = objCompaniesSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, 0, 1);
                    }
                    if (IsConcurrentSessionActive)
                    {
                        if (calledFrom == "Login")
                        {
                            using (UserInfoSL objUserInfoSL = new UserInfoSL())
                            {
                                objSessionDetailsDTO = objUserInfoSL.SaveSessionStatus(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, (Convert.ToString(HttpContext.Session["GUIDSessionID"])).ToString());
                            }
                        }
                    }

                    return(RedirectToAction("Index", "InsiderDashboard", new { acid = Common.ConstEnum.UserActions.DASHBOARD_INSIDERUSER }));
                }
                else
                {
                    Common.Common.WriteLogToFile("End Method", System.Reflection.MethodBase.GetCurrentMethod());

                    return(RedirectToAction("Home", "About"));
                }
            }
            catch (Exception exp)
            {
                Common.Common.WriteLogToFile("Exception occurred ", System.Reflection.MethodBase.GetCurrentMethod(), exp);
                return(RedirectToAction("Home", "About"));
            }

            finally
            {
                objLoginUserDetails = null;
            }
        }
Beispiel #2
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"));
        }