public JsonResult SaveMainErrorDetails(ErrorMaster errorObjParam, SolutionMaster solObjParam, ErrorAttachment[] errorImageList, ErrorAttachment[] solutionImageList, bool isSolutionAddForError, bool isErrorWithSolution) { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; ticket = FormsAuthentication.Decrypt(authCookie.Value); int currentUserId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); _ErrorMgtBusinesssLogic = new ErrorMgtBusinesssLogic(); var retVal = string.Empty; retVal = _ErrorMgtBusinesssLogic.SaveMainErrorDetails(errorObjParam, solObjParam, errorImageList, solutionImageList, isSolutionAddForError, isErrorWithSolution, currentUserId); return(Json(retVal)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json("0000")); } }
public JsonResult AddOrUpdateClient(Client ClientObj) { FormsAuthenticationTicket ticket = null; try { _ClientBusinessLogic = new ClientBusinessLogic(); bool isSuccess = false; _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; ticket = FormsAuthentication.Decrypt(authCookie.Value); int currentUserId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); if (_ClientBusinessLogic.IsClientAvailable(ClientObj.ClientCode) == true) { isSuccess = _ClientBusinessLogic.UpdateClient(ClientObj); } else { isSuccess = _ClientBusinessLogic.SaveClient(ClientObj, currentUserId); } return(Json(isSuccess)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json(false)); } }
public JsonResult UpdatePassword(string newPassword) { FormsAuthenticationTicket ticket = null; try { bool isSuccess = false; _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; ticket = FormsAuthentication.Decrypt(authCookie.Value); int currentUserId = redirectedUserId == 0?_UserDetailsBusinessLogic.GetUserID(ticket.Name): redirectedUserId; //Delete temperory password=>If existing only. _UserDetailsBusinessLogic.DeleteTemperoryPassword(currentUserId); isSuccess = _UserDetailsBusinessLogic.UpdatePassword(newPassword, currentUserId); return(Json(isSuccess)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json(false)); } }
public JsonResult SaveImageWithTheUserID(string imageURL) { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; ticket = FormsAuthentication.Decrypt(authCookie.Value); int userId = 0; if (redirectedUserId == 0) { userId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); } else { userId = redirectedUserId; } var isSaved = _UserDetailsBusinessLogic.SaveImageWithTheUserID(imageURL, userId); return(Json(isSaved)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json(false)); } }
public JsonResult SaveSolutionFeedback(SolutionFeedback solFeedbackObj, string solutionCode) { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; ticket = FormsAuthentication.Decrypt(authCookie.Value); int currentUserId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); _SearchSolutionBusinessLogic = new SearchSolutionBusinessLogic(); var retObj = _SearchSolutionBusinessLogic.SaveSolutionFeedback(solFeedbackObj, currentUserId, solutionCode); return(Json(true)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json(false)); } }
public ActionResult Index(string id = null, string userMsgRequestIdParam = null) { FormsAuthenticationTicket ticket = null; try { int userId = 0, latestSessionId = 0; _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); userMsgRequestId = userMsgRequestIdParam; if (id == null || id == "") { System.Web.Security.FormsAuthentication.SignOut(); Session.Abandon(); HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie.Value != "") { //Before destroying the session cookie // 1.Update the session details to UserSessionLog(Update the LoggedOffTimestamp) // 2.Update the 'IsLoggedIn' flsg of SystemUser as false ticket = FormsAuthentication.Decrypt(authCookie.Value); userId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); latestSessionId = _UserDetailsBusinessLogic.GetLatestSessionIdForUser(userId); _UserDetailsBusinessLogic.UpdateUserSessionLog(latestSessionId); _UserDetailsBusinessLogic.UpdateLoggedInStatus(userId, false); authCookie.Expires = DateTime.Now.AddSeconds(-1); Response.Cookies.Add(authCookie); } } else { System.Web.HttpContext.Current.Session["LoginUserType"] = id; } return(View()); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); this.HttpContext.Session["ErrorMsg"] = "PageLoadError"; return(RedirectToAction("Index", "LoginError")); } }
public ActionResult Authenticate(LoginViewModel model) { try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); int userId = 0; if (LoginAuth(model.Username, model.Password)) { if (_UserDetailsBusinessLogic.IsUserActive(model.Username) == true) { //Before redirecting: // 1.Add the session details to UserSessionLog // 2.Update the 'IsLoggedIn' flsg of SystemUser as true userId = _UserDetailsBusinessLogic.GetUserID(model.Username); _UserDetailsBusinessLogic.SaveSessionDetails(userId, IPAddress, countryCode, country, city, region); _UserDetailsBusinessLogic.UpdateLoggedInStatus(userId, true); if (userMsgRequestId != null) { return(RedirectToAction("Index", "UserMessage", new RouteValueDictionary(new { requestId = userMsgRequestId }))); } return(RedirectToAction("Index", "LandingPage")); } else { TempData["notice"] = "Oops..Your account has been inactivated temporarily.Please contact the System Administrator"; return(RedirectToAction("Index", "Login")); } } else { this.HttpContext.Session["ErrorMsg"] = "LoginErr"; TempData["notice"] = "Username Pasword Combination Is Incorrect"; return(RedirectToAction("Index", "Login")); } } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, "N/A", ex); return(RedirectToAction("Index", "Login")); } }
public ActionResult Index() { FormsAuthenticationTicket ticket = null; try { int userId = 0; _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { ticket = FormsAuthentication.Decrypt(authCookie.Value); userId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); loggedUserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim(); } else { loggedUserType = System.Web.HttpContext.Current.Session["LoginUserType"].ToString().ToLower().Trim(); } //This will be used in the cshtml to check whether the user is actively logged in //and is of Administrator User Type ViewBag.UserId = userId; ViewBag.UserType = loggedUserType; ViewBag.RedirectedUserId = "0"; return(View()); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); this.HttpContext.Session["ErrorMsg"] = "PageLoadError"; return(RedirectToAction("Index", "LoginError")); } }
/****Adding New User****/ public JsonResult AddOrUpdateSystemUser(SystemUser systemUser) { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); bool isSuccess; int currentUserId = 0; //Getting current user.. HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { ticket = FormsAuthentication.Decrypt(authCookie.Value); currentUserId = _UserDetailsBusinessLogic.GetUserID(ticket.Name); } if (_UserDetailsBusinessLogic.IsUsernameExisting(systemUser.Username) == true && currentUserId != 0) { isSuccess = _UserDetailsBusinessLogic.UpdateSytemUser(systemUser, currentUserId); } else { isSuccess = _UserDetailsBusinessLogic.AddSystemUser(systemUser, currentUserId); } return(Json(isSuccess)); } catch (Exception ex) { currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex); return(Json(false)); } }