public string GetCurrentUserLoggedOn() { EmployeeDAL empdal = new EmployeeDAL(); HRMS_tbl_PM_Employee employeeDetails = empdal.GetEmployeeDetailsFromEmpCode(Convert.ToInt32(Membership.GetUser().UserName)); return(employeeDetails.EmployeeName); }
public ActionResult CertificateSendMail(int EmpID, EmployeeChangesApprovalViewModel model) { var EmployeeID = EmpID; var ChildEmployeeID = model.EmployeeID; try { model.Mail = new EmployeeMailTemplate(); int empid = Convert.ToInt32(EmployeeID); int childemployeeid = Convert.ToInt32(ChildEmployeeID); HRMS_tbl_PM_Employee ChildemployeeDetails = employeeDAL.GetEmployeeDetails(childemployeeid); HRMS_tbl_PM_Employee employeeDetails = employeeDAL.GetEmployeeDetails(empid); if (employeeDetails != null) { model.Mail.From = employeeDetails.EmailID; model.Mail.To = ChildemployeeDetails.EmailID; string mailBody = null; int templateId = 4; List <EmployeeMailTemplate> template = Commondal.GetEmailTemplate(templateId); foreach (var emailTemplate in template) { model.Mail.Subject = emailTemplate.Subject; mailBody = emailTemplate.Message; } mailBody = mailBody.Replace("##HR Admin##", Server.HtmlEncode(employeeDetails.EmployeeName)); model.Mail.Message = mailBody.Replace("<br>", Environment.NewLine); ViewBag.Body = mailBody; string[] roles = { "HR Admin" }; foreach (string r in roles) { string[] users = Roles.GetUsersInRole(r); foreach (string user in users) { HRMS_tbl_PM_Employee employee = employeeDAL.GetEmployeeDetailsFromEmpCode(Convert.ToInt32(user)); if (employee == null) { model.Mail.Cc = model.Mail.Cc + string.Empty; } else { model.Mail.Cc = model.Mail.Cc + employee.EmailID + ";"; } } } } return(PartialView("_MailTemplateApprovalStatus", model.Mail)); } catch (Exception) { return(RedirectToAction("Index", "Error", new { errorCode = "There are some errors." })); } }
public HRMS_tbl_PM_Employee GetEmployeeDetailsByEmployeeCode(string EmployeeCode) { var employeeDetails = dbContext.GetEmployeeDetailsByEmployeeCode_sp(EmployeeCode); HRMS_tbl_PM_Employee empDetails = new HRMS_tbl_PM_Employee(); foreach (var item in employeeDetails) { empDetails.EmployeeName = item.EmployeeName; empDetails.EmployeeID = item.EmployeeID; } return(empDetails); }
public ActionResult GetUploadNameFromUploadById(string empcode) { try { PersonalDetailsDAL personalDAL = new PersonalDetailsDAL(); EmployeeDAL employeeDAL = new EmployeeDAL(); int employeeID = 0; HRMS_tbl_PM_Employee employeeDetails = employeeDAL.GetEmployeeDetailsByEmployeeCode(empcode); if (employeeDetails != null) { employeeID = employeeDetails.EmployeeID; } string EmpName = personalDAL.GetDisplayName(employeeID); return(Json(EmpName, JsonRequestBehavior.AllowGet)); } catch (Exception) { throw; } }
public ActionResult SendEmail(EmployeeMailTemplate model) { bool result = false; try { char[] symbols = new char[] { ';', ' ', ',', '\r', '\n' }; int CcCounter = 0; int ToCounter = 0; if (model.Cc != "" && model.Cc != null) { string CcMailIds = model.Cc.TrimEnd(symbols); model.Cc = CcMailIds; string[] EmailIds = CcMailIds.Split(symbols); string[] CCEmailId = EmailIds.Where(s => !String.IsNullOrEmpty(s)).ToArray(); foreach (string id in CCEmailId) { HRMS_tbl_PM_Employee employeeDetails = employeeDAL.GetEmployeeDetailsFromEmailId(id); if (employeeDetails != null) { CcCounter = 1; } else { CcCounter = 0; break; } } string[] EmailToId = model.To.Split(symbols); string[] EmailToIds = EmailToId.Where(s => !String.IsNullOrEmpty(s)).ToArray(); foreach (string email in EmailToIds) { HRMS_tbl_PM_Employee employeeDetails = employeeDAL.GetEmployeeDetailsFromEmailId(email); if (employeeDetails != null) { ToCounter = 1; } else { ToCounter = 0; break; } } } else { CcCounter = 1; string[] EmailToId = model.To.Split(symbols); string[] EmailToIds = EmailToId.Where(s => !String.IsNullOrEmpty(s)).ToArray(); foreach (string email in EmailToIds) { HRMS_tbl_PM_Employee employeeDetails = employeeDAL.GetEmployeeDetailsFromEmailId(email); if (employeeDetails != null) { ToCounter = 1; } else { ToCounter = 0; break; } } } if (CcCounter == 1 && ToCounter == 1) { result = SendMail(model); if (result == true) { return(Json(new { status = true, validCcId = true, validtoId = true })); } else { return(Json(new { status = false, validCcId = true, validtoId = true })); } } else { if (CcCounter == 1 && ToCounter == 0) { return(Json(new { status = false, validCcId = true, validtoId = false })); } else { if (CcCounter == 0 && ToCounter == 1) { return(Json(new { status = false, validCcId = false, validtoId = true })); } else { return(Json(new { status = false, validCcId = false, validtoId = false })); } } } } catch (Exception) { return(Json(new { status = "Error" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AdminSendMail(EmployeeChangesApprovalViewModel model) { try { if (model.Module == "New Personal Details" || model.Module == "New Residential Details" || model.Module == "OnHold Personal Details" || model.Module == "OnHold Residential Details") { StringBuilder builder = new StringBuilder(); foreach (var item in model.ChangeDetailsList) { if (item.ChildApprovalStatusMasterID == 1 || item.ChildApprovalStatusMasterID == 2 || item.ChildApprovalStatusMasterID == 3) { model.Mail = new EmployeeMailTemplate(); int empid = Convert.ToInt32(model.EmployeeID); int childemployeeid = Convert.ToInt32(item.ChildEmployeeID); HRMS_tbl_PM_Employee ChildemployeeDetails = employeeDAL.GetEmployeeDetails(childemployeeid); HRMS_tbl_PM_Employee employeeDetails = employeeDAL.GetEmployeeDetails(empid); if (employeeDetails != null) { model.Mail.From = employeeDetails.EmailID; model.Mail.To = ChildemployeeDetails.EmailID; string ChildMasterstatus; if (item.ChildApprovalStatusMasterID == 1) { ChildMasterstatus = "On Hold"; } else if (item.ChildApprovalStatusMasterID == 2) { ChildMasterstatus = "Approved"; } else { ChildMasterstatus = "Rejected"; } string approvalStatus = (builder.Append(item.ChildFieldDiscription).Append(" : ").Append(ChildMasterstatus).Append("<br>") + "Comments: " + model.Comments); int templateId = 0; if (model.Module == "New Personal Details" || model.Module == "OnHold Personal Details") { templateId = 1; } if (model.Module == "New Residential Details" || model.Module == "OnHold Residential Details") { templateId = 2; } string mailBody = null; List <EmployeeMailTemplate> template = Commondal.GetEmailTemplate(templateId); foreach (var emailTemplate in template) { model.Mail.Subject = emailTemplate.Subject; mailBody = emailTemplate.Message; } mailBody = mailBody.Replace("##Approval Status##", approvalStatus); mailBody = mailBody.Replace("##HR Admin##", Server.HtmlEncode(employeeDetails.EmployeeName)); model.Mail.Message = mailBody.Replace("<br>", Environment.NewLine); ViewBag.Body = mailBody; string[] roles = { "HR Admin" }; foreach (string r in roles) { string[] users = Roles.GetUsersInRole(r); foreach (string user in users) { HRMS_tbl_PM_Employee employee = employeeDAL.GetEmployeeDetailsFromEmpCode(Convert.ToInt32(user)); if (employee == null) { model.Mail.Cc = model.Mail.Cc + string.Empty; } else { model.Mail.Cc = model.Mail.Cc + employee.EmailID + ";"; } } } } } } } else { } return(PartialView("_MailTemplateApprovalStatus", model.Mail)); } catch (Exception) { return(RedirectToAction("Index", "Error", new { errorCode = "There are some errors." })); } }
public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { model.UserName = model.UserName.Trim(); if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { string[] role = Roles.GetRolesForUser(model.UserName); if (role == null || role.Count() <= 0) { FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Error", new { errorCode = "Error403" })); } EmployeeDAL employeeDAL = new EmployeeDAL(); SemDAL SEMdal = new SemDAL(); int employeeID = employeeDAL.GetEmployeeID(model.UserName); int semEmployeeId = SEMdal.geteEmployeeIDFromSEMDatabase(model.UserName); Guid globalID = Guid.NewGuid(); Session["LoggedInEmployee"] = model.UserName; Session["LoggedInEmployeeSEMID"] = semEmployeeId; Session["SecurityKey"] = globalID.ToString(); string encryptedEmployeeid = Encrypt(Convert.ToString(Session["SecurityKey"].ToString() + employeeID), true); Session["encryptedLoggedinEmployeeID"] = encryptedEmployeeid; string current_DU = employeeDAL.getCurrentDU(model.UserName); Session["Current_DU"] = current_DU; Session["ViewNode"] = employeeDAL.GetViewableNodesForEmployee(Convert.ToInt32(model.UserName)); CommonMethodsDAL Commondal = new CommonMethodsDAL(); string maxRole = Commondal.GetMaxRoleForUser(role); Session["MaxUserRole"] = maxRole; //for Help desk Tab Access //if (User.IsInRole("Super Admin") == false) // Session // return RedirectToAction("Index", "PersonalDetails", new { employeeId = encryptedEmployeeid }); //return RedirectToAction("Index", "Orbit"); if (HttpContext.User.IsInRole("Super Admin")) { Session["SuperAdmin"] = model.UserName; } else { Session["SuperAdmin"] = 0; } Session["EmployeeID"] = model.UserName; HRMS_tbl_PM_Employee employee = employeeDAL.GetEmployeeDetailsByEmployeeCode(model.UserName); Session["LoggedInEmployeeName"] = employee.EmployeeName; if (employee != null) { Session["UserName"] = employee.FirstName; } //added code for access mapping Session["AccessRights"] = employeeDAL.GetPageAccessMapping(model.UserName); XmlDocument doc = new XmlDocument(); string data = employeeDAL.GetPageAccessMapping_xmlData(model.UserName); doc.LoadXml(data); Session["MenuDataList"] = JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.None, true); return(RedirectPermanent("~/Orbitweb/SignInSignOut.aspx")); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult LogIn() { try { LogOnModel model = new LogOnModel(); string userName = Convert.ToString(Request.Form["UserName"]); userName = userName.Trim(); string password = Convert.ToString(Request.Form["pwd"]); string employeeCode = string.Empty; //if (Session["LoggedInEmployee"] != null) // employeeCode = Session["LoggedInEmployee"].ToString(); //if (employeeCode == "") //{ if (Membership.ValidateUser(userName, password)) { FormsAuthentication.SetAuthCookie(userName, true); string[] role = Roles.GetRolesForUser(userName); if (role == null || role.Count() <= 0) { FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Error", new { errorCode = "Error403" })); } EmployeeDAL employeeDAL = new EmployeeDAL(); SemDAL SEMdal = new SemDAL(); int employeeID = employeeDAL.GetEmployeeID(userName); int semEmployeeId = SEMdal.geteEmployeeIDFromSEMDatabase(userName); Session["LoggedInEmployee"] = userName; Session["LoggedInEmployeeSEMID"] = semEmployeeId; Guid globalID = Guid.NewGuid(); Session["SecurityKey"] = globalID.ToString(); string encryptedEmployeeid = Encrypt(Convert.ToString(Session["SecurityKey"].ToString() + employeeID), true); Session["encryptedLoggedinEmployeeID"] = encryptedEmployeeid; string current_DU = employeeDAL.getCurrentDU(userName); if (string.IsNullOrEmpty(current_DU)) { current_DU = "0"; } Session["Current_DU"] = current_DU; //return RedirectToAction("Index", "PersonalDetails", new { employeeId = encryptedEmployeeid }); ////GoLive code for redirecting to orbit if (HttpContext.User.IsInRole("Super Admin")) { Session["SuperAdmin"] = userName; } else { Session["SuperAdmin"] = 0; } Session["EmployeeID"] = userName; HRMS_tbl_PM_Employee employee = employeeDAL.GetEmployeeDetailsByEmployeeCode(userName); if (employee != null) { Session["UserName"] = employee.FirstName; } //added code for access mapping Session["AccessRights"] = employeeDAL.GetPageAccessMapping(userName); XmlDocument doc = new XmlDocument(); string data = employeeDAL.GetPageAccessMapping_xmlData(userName); doc.LoadXml(data); Session["MenuDataList"] = JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.None, true); return(RedirectPermanent("~/Orbitweb/SignInSignOut.aspx")); } else { model.LogOffURL = System.Configuration.ConfigurationManager.AppSettings["Log-OffURL"]; return(View(model)); } //} //else //{ // model.IsValidSession = false; // return View(model); //} } catch { throw; } }
/// <summary> /// Action will fire when user clicks on the Filename,to download the file, /// when viewing the history/Details view of files /// </summary> /// <param name="filename"></param> /// <returns></returns> public ActionResult DownloadHRFile(string filename, int uploadTypeId) { HRMSDBEntities dbContext = new HRMSDBEntities(); UploadsDAL RMGupload = new UploadsDAL(); string Loginemployeecode = string.Empty; string[] loginemployeerole = { }; EmployeeDAL empdal = new EmployeeDAL(); int employeeID = empdal.GetEmployeeID(Membership.GetUser().UserName); HRMS_tbl_PM_Employee loginrolescheck = empdal.GetEmployeeDetails(employeeID); Loginemployeecode = loginrolescheck.EmployeeCode; loginemployeerole = Roles.GetRolesForUser(Loginemployeecode); try { if (loginemployeerole.Contains("RMG")) { var documentformchild = (from document in dbContext.Tbl_RMG_Documents join documentDetails in dbContext.Tbl_RMG_DocumentDetail on document.DocumentId equals documentDetails.DocumentId where document.UploadTypeId == uploadTypeId && documentDetails.FileName == filename select documentDetails).FirstOrDefault(); var documentfromparent = (from document in dbContext.Tbl_RMG_Documents where document.UploadTypeId == uploadTypeId && document.FileName == filename select document).FirstOrDefault(); string rootFolder = (UploadFileLocationRMG); string[] FileExtention = filename.Split('.'); string contentType = "application/" + FileExtention[1]; if (documentformchild != null) { string subfolderpath = Path.Combine(rootFolder, GetUploadTypeTextFromDocIdRMG(documentformchild.DocumentId)); string Filepath = Path.Combine(subfolderpath, filename); if (!System.IO.File.Exists(Filepath)) { throw new Exception(); } return(File(Filepath, contentType, filename)); } else { string subfolderpath = Path.Combine(rootFolder, GetUploadTypeTextFromDocIdRMG(documentfromparent.DocumentId)); string Filepath = Path.Combine(subfolderpath, filename); if (!System.IO.File.Exists(Filepath)) { throw new Exception(); } return(File(Filepath, contentType, filename)); } } else { var documentformchild = (from document in dbContext.Tbl_HR_Documents join documentDetails in dbContext.Tbl_HR_DocumentDetail on document.DocumentId equals documentDetails.DocumentId where document.UploadTypeId == uploadTypeId && documentDetails.FileName == filename select documentDetails).FirstOrDefault(); var documentfromparent = (from document in dbContext.Tbl_HR_Documents where document.UploadTypeId == uploadTypeId && document.FileName == filename select document).FirstOrDefault(); string rootFolder = (UploadFileLocation); string[] FileExtention = filename.Split('.'); string contentType = "application/" + FileExtention[1]; if (documentformchild != null) { string subfolderpath = Path.Combine(rootFolder, GetUploadTypeTextFromDocId(documentformchild.DocumentId)); string Filepath = Path.Combine(subfolderpath, filename); if (!System.IO.File.Exists(Filepath)) { throw new Exception(); } return(File(Filepath, contentType, filename)); } else { string subfolderpath = Path.Combine(rootFolder, GetUploadTypeTextFromDocId(documentfromparent.DocumentId)); string Filepath = Path.Combine(subfolderpath, filename); if (!System.IO.File.Exists(Filepath)) { throw new Exception(); } return(File(Filepath, contentType, filename)); } } } catch (Exception) { ConfigurationViewModel model = new ConfigurationViewModel(); model.SearchedUserDetails = new SearchedUserDetails(); string employeeCode = Membership.GetUser().UserName; string[] role = Roles.GetRolesForUser(employeeCode); if (employeeCode != null) { CommonMethodsDAL Commondal = new CommonMethodsDAL(); model.SearchedUserDetails.UserRole = Commondal.GetMaxRoleForUser(role); } return(PartialView("_FileNotFound", model)); } }
/// <summary> /// / /// </summary> /// <param name="documentId"></param> /// <returns></returns> public ActionResult DeleteHRDocsSelected(List <string> filenames) { UploadsDAL uploads = new UploadsDAL(); HRMSDBEntities dbContext = new HRMSDBEntities(); string Loginemployeecode = string.Empty; string[] loginemployeerole = { }; EmployeeDAL empdal = new EmployeeDAL(); int employeeID = empdal.GetEmployeeID(Membership.GetUser().UserName); HRMS_tbl_PM_Employee loginrolescheck = empdal.GetEmployeeDetails(employeeID); Loginemployeecode = loginrolescheck.EmployeeCode; loginemployeerole = Roles.GetRolesForUser(Loginemployeecode); bool result = false; try { if (loginemployeerole.Contains("RMG")) { if (filenames != null) { foreach (string filename in filenames) { var documentformchild = (from document in dbContext.Tbl_RMG_Documents join documentDetails in dbContext.Tbl_RMG_DocumentDetail on document.DocumentId equals documentDetails.DocumentId where documentDetails.FileName == filename select documentDetails).FirstOrDefault(); string rootFolder = (UploadFileLocationRMG); string subfolderpath = Path.Combine(rootFolder, GetUploadTypeTextFromDocIdRMG(documentformchild.DocumentId)); string Filepath = Path.Combine(subfolderpath, filename); if (System.IO.File.Exists(Filepath)) { System.IO.File.Delete(Filepath); } result = uploads.DeleteRMGDocsSelected(filename); } } return(Json(result, JsonRequestBehavior.AllowGet)); } else { if (filenames != null) { foreach (string filename in filenames) { var documentformchild = (from document in dbContext.Tbl_HR_Documents join documentDetails in dbContext.Tbl_HR_DocumentDetail on document.DocumentId equals documentDetails.DocumentId where documentDetails.FileName == filename select documentDetails).FirstOrDefault(); string rootFolder = (UploadFileLocation); string subfolderpath = Path.Combine(rootFolder, GetUploadTypeTextFromDocId(documentformchild.DocumentId)); string Filepath = Path.Combine(subfolderpath, filename); if (System.IO.File.Exists(Filepath)) { System.IO.File.Delete(Filepath); } result = uploads.DeleteHRDocsSelected(filename); } } return(Json(result, JsonRequestBehavior.AllowGet)); } } catch (Exception) { result = false; return(Json(result, JsonRequestBehavior.AllowGet)); } }