private bool LoginAuth(string UserName, string Password) { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); if (_UserDetailsBusinessLogic.IsExistingUser(UserName, Password)) { var authTicket = new FormsAuthenticationTicket(1, UserName, DateTime.Now, DateTime.Now.AddMinutes(20), false, "test" ); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); Response.Cookies.Add(authCookie); return(true); } else { return(false); } }
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 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 AddOrUpdateUserGroup(SystemUserGroup systemUserGroupObj) { try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); bool isSuccess = false; if (_UserDetailsBusinessLogic.IsUserGroupAvailable(systemUserGroupObj.UserGroupName) == true) { isSuccess = _UserDetailsBusinessLogic.UpdateUserGroup(systemUserGroupObj); } else { isSuccess = _UserDetailsBusinessLogic.SaveUserGroup(systemUserGroupObj); } 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, "UName", 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 int GetMessageCount(string sessionUser) { using (TransactionScope scope1 = new TransactionScope()) { try { int result = 0; MongoClient mongoClient = InitializeMongoClient(); _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); var mongoDatabase = mongoClient.GetDatabase(mongoDBTargetDatabase); var UserVar = mongoDatabase.GetCollection <SystemUser>("SystemUser").AsQueryable().ToList(); int sessionUserID = UserVar.AsQueryable().First(s => s.Username.ToLower() == sessionUser.ToLower()).UserId; var MessageCollection = mongoDatabaseRunTime.GetCollection <ErrorLogDataAccess.DataClasses.UserMessage>("UserMessage"); result = MessageCollection.AsQueryable().Where(s => s.IsDeleted == false && s.ReceivedUserId == sessionUserID && s.IsMessageRead == false).Count(); scope1.Complete(); return(result); } catch (Exception ex) { scope1.Dispose(); throw; } } }
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 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 int SMGSendMessage(List <int> UList, string subject, string message, string sessionUser) { using (TransactionScope scope1 = new TransactionScope()) { try { MongoClient mongoClient = InitializeMongoClient(); _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); var mongoDatabase = mongoClient.GetDatabase(mongoDBTargetDatabase); var UserVar = mongoDatabase.GetCollection <SystemUser>("SystemUser").AsQueryable().ToList(); int sessionUserID = UserVar.AsQueryable().First(s => s.Username.ToLower() == sessionUser.ToLower()).UserId; int parentMessageID = SMGGetNewMessageID(); foreach (int Uid in UList) { var MessageCollection = mongoDatabaseRunTime.GetCollection <ErrorLogDataAccess.DataClasses.UserMessage>("UserMessage"); var messageRow = new ErrorLogDataAccess.DataClasses.UserMessage() { UserMessageId = SMGGetNewMessageID(), ParentUserMessageId = parentMessageID, MessageSubject = subject, MessageBody = message, IsMessageRead = false, SentUserId = sessionUserID, ReceivedUserId = Uid, MessageSentDate = DateTime.Now }; MessageCollection.InsertOne(messageRow); } rnd = new Random(); string requestId = rnd.Next(1, 1000).ToString(); string sessionUserName = _UserDetailsBusinessLogic.GetUserDetails(sessionUserID) .FirstOrDefault().Username; string msgSubject = sessionUserName + " sent you a message"; string msgBody = "Click the following link and navigate to 'Message Portal 'to view the message" + Environment.NewLine + userMessageEmailLink + requestId; MailMessage msg = CommonCommunicationBusinessLogic.ConstructEmail(msgSubject, msgBody, UList); CommonCommunicationBusinessLogic.SendEmail(msg); scope1.Complete(); return(0); } catch (Exception ex) { scope1.Dispose(); throw; } } }
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 { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); // string LoginUserType = System.Web.HttpContext.Current.Session["LoginUserType"].ToString(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { ticket = FormsAuthentication.Decrypt(authCookie.Value); if (_UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim() == "administrator") { ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name) .FirstOrDefault().ProfilePicURL; ViewBag.Username = ticket.Name; ViewBag.UserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim(); ViewBag.RedirectedUserId = "0"; return(View()); } else { this.HttpContext.Session["ErrorMsg"] = "AccessDeniedError"; return(RedirectToAction("Index", "LoginError")); } } else { this.HttpContext.Session["ErrorMsg"] = "LoginErr"; 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, ticket == null ? "N/A" : ticket.Name, ex); this.HttpContext.Session["ErrorMsg"] = "PageLoadError"; return(RedirectToAction("Index", "LoginError")); } }
public List <object> RMSGLoadMessageList(string sessionUser) { using (TransactionScope scope1 = new TransactionScope()) { try { MongoClient mongoClient = InitializeMongoClient(); _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); var mongoDatabase = mongoClient.GetDatabase(mongoDBTargetDatabase); var UserVar = mongoDatabase.GetCollection <SystemUser>("SystemUser").AsQueryable().ToList(); int sessionUserID = UserVar.AsQueryable().First(s => s.Username.ToLower() == sessionUser.ToLower()).UserId; var MessageList = mongoDatabase.GetCollection <UserMessage>("UserMessage").AsQueryable() .ToList(); List <object> returnMessageList = new List <object>(); foreach (var msg in MessageList.Where(s => s.IsDeleted == false && (s.ReceivedUserId == sessionUserID)).OrderByDescending(s => s.IsMessageRead).ThenByDescending(s => s.MessageSentDate).GroupBy(s => s.SentUserId)) { returnMessageList.Add(new { msg.FirstOrDefault().UserMessageId, IsSent = (msg.FirstOrDefault().SentUserId == sessionUserID) ? true : false, UserDetails = new { ProfilePicture = UserVar.First(s => s.UserId == msg.FirstOrDefault().SentUserId).ProfilePicURL, FullName = (UserVar.First(s => s.UserId == msg.FirstOrDefault().SentUserId).FullName) != null ? UserVar.First(s => s.UserId == msg.FirstOrDefault().SentUserId).FullName : UserVar.First(s => s.UserId == msg.FirstOrDefault().SentUserId).Username }, ParentUserMessageId = msg.FirstOrDefault().ParentUserMessageId == null ? 0 : msg.FirstOrDefault().ParentUserMessageId, MessageSubject = msg.FirstOrDefault().MessageSubject, MessageBody = msg.FirstOrDefault().MessageBody, IsMessageRead = msg.FirstOrDefault().IsMessageRead, MessageSentDate = String.Format("{0:g}", msg.FirstOrDefault().MessageSentDate), MessageDeliveryDate = String.Format("{0:g}", msg.FirstOrDefault().MessageDeliveryDate) }); } scope1.Complete(); return(returnMessageList); } catch (Exception ex) { scope1.Dispose(); throw; } } }
private static int redirectedUserId = 0; //Variable to get when user Id is redirected from another page public ActionResult Index(string userId = null) { FormsAuthenticationTicket ticket = null; try { // string LoginUserType = System.Web.HttpContext.Current.Session["LoginUserType"].ToString(); _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); _EncryptionModule = new EncryptionModule(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { ticket = FormsAuthentication.Decrypt(authCookie.Value); ViewBag.Username = ticket.Name; ViewBag.UserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim(); ViewBag.RedirectedUserId = userId != null?_EncryptionModule.Decrypt(userId.ToString()) : "0"; redirectedUserId = userId != null?Convert.ToInt32(_EncryptionModule.Decrypt(userId.ToString())) : 0; //Initialize AWS Configurations => Required for image uploads InitAWSS3Configurations(); return(View()); } else { this.HttpContext.Session["ErrorMsg"] = "LoginErr"; 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, ticket == null ? "N/A" : ticket.Name, ex); this.HttpContext.Session["ErrorMsg"] = "PageLoadError"; return(RedirectToAction("Index", "LoginError")); } }
public JsonResult GetRedirectedUserDetails() { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { ticket = FormsAuthentication.Decrypt(authCookie.Value); if (redirectedUserId == 0) { var userDetails = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name).ToArray(); return(Json(userDetails)); } else { var userDetails = _UserDetailsBusinessLogic.GetUserDetails(redirectedUserId).ToArray(); return(Json(userDetails)); } } else { return(Json(null)); } } 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(null)); } }
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")); } }
public JsonResult LoadUserGroups(int isActive) { //isActive=>Denotes which type of data to get(i.e,active,inactive or all) try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; string userType = "N/A"; if (authCookie != null) { FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); userType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim(); if (userType == "administrator") { var resultArr = _UserDetailsBusinessLogic.GetAllUserGroups(isActive); return(Json(resultArr)); } else { var resultArr = _UserDetailsBusinessLogic.GetAllUserGroupsForOtherUser(isActive); return(Json(resultArr)); } } else { var resultArr = _UserDetailsBusinessLogic.GetAllUserGroupsForOtherUser(isActive); return(Json(resultArr)); } } 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, "UName", ex); return(Json(null)); } }
public JsonResult ChangeStatusForAllGroups(bool isActiveForAll) { try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); bool isSuccess = false; isSuccess = _UserDetailsBusinessLogic.ChangeStatusForAllGroups(isActiveForAll); 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, "UName", ex); return(Json(false)); } }
public JsonResult GetUserGroupNamesForAutoComplete(string userGroupName) { try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); var resultArr = _UserDetailsBusinessLogic.GetUserGroupNamesForAutoComplete(userGroupName); return(Json(resultArr)); } 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, "UName", ex); return(Json(false)); } }
//Check whether username is existing public JsonResult IsUsernameExisting(string chkUserName) { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); bool isExisting = _UserDetailsBusinessLogic.IsUsernameExisting(chkUserName); return(Json(isExisting)); } 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)); } }
/****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)); } }
public ActionResult Index() { try { HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name) .FirstOrDefault().ProfilePicURL; ViewBag.Username = ticket.Name; ViewBag.UserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim(); return(View()); } else { this.HttpContext.Session["ErrorMsg"] = "LoginErr"; return(RedirectToAction("Index", "Login")); } } catch (Exception ex) { currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, "UName", ex); this.HttpContext.Session["ErrorMsg"] = "PageLoadError"; return(RedirectToAction("Index", "LoginError")); } }
//To get all logged in sessions public List <UserSessionLogDTO> GetAllLoggedInSessions(int userId) { using (TransactionScope scope1 = new TransactionScope()) { try { var userCollection = mongoDatabaseRunTime.GetCollection <SystemUser>("SystemUser"); var userGroupCollection = mongoDatabaseRunTime.GetCollection <SystemUserGroup>("SystemUserGroup"); var userSessionLogCollection = mongoDatabaseRunTime.GetCollection <UserSessionLog>("UserSessionLog"); var userGroupList = userGroupCollection.AsQueryable().ToList(); var userSessionLogList = userSessionLogCollection.AsQueryable().ToList(); var userCollectionList = userCollection.AsQueryable().ToList(); _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); //Load session log or all users if userId=0 //Else load the session log for the selected user if (userId == 0) { var userLogData = userSessionLogList .Select(ul => new UserSessionLogDTO { UserSessionLogId = ul.UserSessionLogId, UserId = ul.UserId, ProfilePicURL = userCollectionList.Where(a => a.UserId == ul.UserId).FirstOrDefault().ProfilePicURL, Username = userCollectionList.Where(a => a.UserId == ul.UserId).FirstOrDefault().Username, UserCallingName = userCollectionList.Where(a => a.UserId == ul.UserId).FirstOrDefault().CallingName, UserFullName = userCollectionList.Where(a => a.UserId == ul.UserId).FirstOrDefault().FullName, UserGroupName = userGroupList.Where(a => a.UserGroupId == userCollectionList.Where(b => b.UserId == ul.UserId).FirstOrDefault().UserGroupId).FirstOrDefault().UserGroupName, IPAddress = ul.IPAddress, CountryCode = ul.CountryCode != null?ul.CountryCode.ToLower():null, Country = ul.Country, City = ul.City, Region = ul.Region, LoggedInTimestamp = ul.LoggedInTimestamp, LoggedOffTimestamp = ul.LoggedOffTimestamp }).OrderByDescending(a => a.UserSessionLogId).ToList(); return(userLogData); } else { var userLogData = userSessionLogList .Where(a => a.UserId == userId) .Select(ul => new UserSessionLogDTO { UserSessionLogId = ul.UserSessionLogId, UserId = ul.UserId, ProfilePicURL = userCollectionList.Where(a => a.UserId == ul.UserId).FirstOrDefault().ProfilePicURL, Username = userCollectionList.Where(a => a.UserId == ul.UserId).FirstOrDefault().Username, UserCallingName = userCollectionList.Where(a => a.UserId == ul.UserId).FirstOrDefault().CallingName, UserFullName = userCollectionList.Where(a => a.UserId == ul.UserId).FirstOrDefault().FullName, UserGroupName = userGroupList.Where(a => a.UserGroupId == userCollectionList.Where(b => b.UserId == ul.UserId).FirstOrDefault().UserGroupId).FirstOrDefault().UserGroupName, IPAddress = ul.IPAddress, CountryCode = ul.CountryCode != null ? ul.CountryCode.ToLower() : null, Country = ul.Country, City = ul.City, Region = ul.Region, LoggedInTimestamp = ul.LoggedInTimestamp, LoggedOffTimestamp = ul.LoggedOffTimestamp }).OrderByDescending(a => a.UserSessionLogId).ToList(); return(userLogData); } } catch (Exception ex) { throw; } } }
public ActionResult Index(string requestId = null) { FormsAuthenticationTicket ticket = null; try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; ViewBag.RequestId = requestId; bool isSessionTicketDecryptable = true; if (authCookie != null) { try { ticket = FormsAuthentication.Decrypt(authCookie.Value); } catch (Exception ex) { isSessionTicketDecryptable = false; } if (isSessionTicketDecryptable == true) { ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name) .FirstOrDefault().ProfilePicURL; ViewBag.Username = ticket.Name; ViewBag.UserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim(); return(View()); } else { return(RedirectToAction("Index", "Login", new RouteValueDictionary(new { id = "RedirectedLogin", userMsgRequestIdParam = requestId }))); } } else { if (requestId != null) { return(RedirectToAction("Index", "Login", new RouteValueDictionary(new { id = "RedirectedLogin", userMsgRequestIdParam = requestId }))); } else { this.HttpContext.Session["ErrorMsg"] = "LoginErr"; return(RedirectToAction("Index", "LoginError")); } } } catch (Exception ex) { currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(1); methodName = sf.GetMethod().Name; ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, "UName", ex); this.HttpContext.Session["ErrorMsg"] = "PageLoadError"; return(RedirectToAction("Index", "LoginError")); } }
public ActionResult AuthenticatePasswordReset(ForgotPasswordViewModel model) { try { _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); if ((model.Username != null && model.EMail != null)) { if (_UserDetailsBusinessLogic.IsExistingUserForPasswordRecovery(model.Username, model.EMail)) { bool isEmailServerWorking = TestConnection(smptpServerVal, sendPort); bool isEmailSent = false; if (isEmailServerWorking == true) { //delete all existing temperory passwords for this user _UserDetailsBusinessLogic.DeleteTemperoryPassword(model.Username); string tempPassword = _UserDetailsBusinessLogic.SaveTempPassword(model.Username); if (tempPassword != String.Empty) { _MailMessage = CommonCommunicationBusinessLogic.ConstructEmail(model.Username, model.EMail, tempPassword); isEmailSent = CommonCommunicationBusinessLogic.SendEmail(_MailMessage); } else { TempData["notice"] = "Oops!..The temperory password could not be generated.Please try again."; } } else { TempData["notice"] = "Oops!..Our Email servers seem to be not working at the moment." + Environment.NewLine + "Please send an email to [email protected] to get a temperory password."; } if (isEmailSent == true) { TempData["notice"] = null; TempData["success"] = "Password reset successful." + Environment.NewLine + "Please see your email inbox or spam folder to get the temperory password. "; } else { TempData["notice"] = "Oops!..Could not compelete password recovery process." + Environment.NewLine + "Please send an email stating your username to [email protected] to get a temperory password. "; } return(RedirectToAction("Index", "ForgotPassword")); } else { TempData["notice"] = "Oops!..This Username and EMail combination is not found in our system. "; return(RedirectToAction("Index", "ForgotPassword")); } } else { TempData["notice"] = "Username and EMail are required. "; return(RedirectToAction("Index", "ForgotPassword")); } } 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, "UName", ex); TempData["notice"] = "Oops!..An Error Occured. " + Environment.NewLine + "Please send an email stating your username and full name to " + networkCredentialUserName + " to get a temperory password."; return(RedirectToAction("Index", "ForgotPassword")); } }
private static List <SystemUser> GetToEMailAdresses(List <int> userList) { UserDetailsBusinessLogic _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); return(_UserDetailsBusinessLogic.GetUserDetails(userList)); }
public List <object> RMSGLoadPreviousMessages(string UserName, int messageID) { int MessageID; if (messageID > 0) { MessageID = messageID; } else { return(null); } using (TransactionScope scope1 = new TransactionScope()) { try { MongoClient mongoClient = InitializeMongoClient(); _UserDetailsBusinessLogic = new UserDetailsBusinessLogic(); var mongoDatabase = mongoClient.GetDatabase(mongoDBTargetDatabase); string formattedDate = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture); var UserVar = mongoDatabase.GetCollection <SystemUser>("SystemUser").AsQueryable().ToList(); int sessionUserID = UserVar.AsQueryable().First(s => s.Username.ToLower() == UserName.ToLower()).UserId; var MessageList = mongoDatabase.GetCollection <UserMessage>("UserMessage").AsQueryable() .ToList(); int SUserID = MessageList.FirstOrDefault(s => s.UserMessageId == MessageID).SentUserId.Value; int RUserID = MessageList.FirstOrDefault(s => s.UserMessageId == MessageID).ReceivedUserId.Value; int OtherUserID = (SUserID == sessionUserID ? RUserID : SUserID); List <object> returnMessageList = new List <object>(); foreach (var msg in MessageList.Where(s => s.IsDeleted == false && ((s.ReceivedUserId == SUserID && s.SentUserId == RUserID) || (s.ReceivedUserId == RUserID && s.SentUserId == SUserID))).OrderBy(s => s.MessageSentDate)) { returnMessageList.Add(new { msg.UserMessageId, IsSent = (msg.SentUserId == sessionUserID) ? true : false, UserDetails = new { ProfilePicture = UserVar.First(s => s.UserId == OtherUserID).ProfilePicURL, FullName = (UserVar.First(s => s.UserId == OtherUserID).FullName) != null ? UserVar.First(s => s.UserId == OtherUserID).FullName : UserVar.First(s => s.UserId == OtherUserID).Username }, ParentUserMessageId = msg.ParentUserMessageId == null ? 0 : msg.ParentUserMessageId, MessageSubject = msg.MessageSubject, MessageBody = msg.MessageBody, IsMessageRead = msg.IsMessageRead, MessageSentDate = String.Format("{0:g}", msg.MessageSentDate), MessageDeliveryDate = String.Format("{0:g}", msg.MessageDeliveryDate) }); if (msg.ReceivedUserId == sessionUserID) { var MessageCollection = mongoDatabaseRunTime.GetCollection <ErrorLogDataAccess.DataClasses.UserMessage>("UserMessage"); var filterObj = Builders <ErrorLogDataAccess.DataClasses.UserMessage> .Filter.Eq("UserMessageId", msg.UserMessageId); var updateObj = Builders <ErrorLogDataAccess.DataClasses.UserMessage> .Update .Set("IsMessageRead", true) .Set("MessageDeliveryDate", String.Format("{0:g}", formattedDate)) .Set("LastUpdatedDate", formattedDate) .CurrentDate("lastModified"); MessageCollection.UpdateOne(filterObj, updateObj); } } scope1.Complete(); return(returnMessageList); } catch (Exception ex) { scope1.Dispose(); throw; } } }