/// <summary> /// Get all Shift Time /// </summary> /// <returns></returns> /// CALL URL: _vti_bin/Services/ShiftTime/ShiftTimeService.svc/GetShiftTimes public List <ShiftTimeModel> GetShiftTimes() { try { List <ShiftTimeModel> shiftTimes = new List <ShiftTimeModel>(); var shiftTimeList = _shiftTimeDAL.GetShiftTimes(); if (shiftTimeList.Any()) { foreach (var item in shiftTimeList) { shiftTimes.Add( this.ConvertToShiftTimeModel(item) ); } } return(shiftTimes); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Shift Time Service - GetShiftTimes fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
public List <EmployeeModel> GetAllEmployees() { List <EmployeeModel> employees = new List <EmployeeModel>(); try { var employeeList = _employeeInfoDAL.GetAll().Where(x => x.IsActive).OrderBy(y => y.FullName).ToList(); foreach (var item in employeeList) { employees.Add(new EmployeeModel { EmployeeID = item.EmployeeID, ID = item.ID, Department = LookupItemHelper.ConvertToModel(item.Department), Location = LookupItemHelper.ConvertToModel(item.FactoryLocation), DepartmentPermission = item.DepartmentPermission, FullName = item.FullName, EmployeeType = item.EmployeeType }); } return(employees); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - GetAllEmployees - GetManagerByDepartment fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
/// <summary> /// An item is being added. /// </summary> public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); try { SPListItem curItem = properties.ListItem; var departmentRepo = new DepartmentDAL(properties.Site.Url); departmentRepo.CreateDepartmentSite(properties.SiteId, properties.Web.ID, curItem); // Add bod approver to BOD group var userBodString = Convert.ToString(properties.ListItem[StringConstant.DepartmentList.BODField]); if (!string.IsNullOrEmpty(userBodString)) { var employeeInfoRepo = new EmployeeInfoDAL(properties.Site.Url); employeeInfoRepo.AddUserToGroup(properties.Site.ID, properties.Web.ID, curItem, StringConstant.Group.BODGroupName, userBodString); } } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Event Receiver - ItemAdded fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
protected void Page_Load(object sender, EventArgs e) { try { siteUrl = SPContext.Current.Site.Url; _notOvertimeManagementDAL = new NotOvertimeManagementDAL(siteUrl); int currentUserId = SPContext.Current.Web.CurrentUser.ID; string itemIdParam = this.Page.Request.Params.Get("itemId"); XElement filterElement = null; Biz.Models.Delegation delegation = null; if (!string.IsNullOrEmpty(itemIdParam)) { delegation = _notOvertimeManagementDAL.GetDelegatedTaskInfo(itemIdParam); } if (delegation != null) { filterElement = BuildViewFilterStringForDelegation(delegation); } else { filterElement = BuildViewFilterString(currentUserId); } InitialViewGUID(filterElement); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - LeaveOfAbsenceApprovalControl - InitData", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
public List <DepartmentInfo> GetDepartmentsByLcid(string lcid, string locationIds) { try { List <DepartmentInfo> departments = new List <DepartmentInfo>(); DepartmentDAL departmentDAL = new DepartmentDAL(SPContext.Current.Web.Url); List <int> locationCollection = locationIds.SplitStringOfLocations().ConvertAll(e => Convert.ToInt32(e)); var departmentList = departmentDAL.GetByLocations(locationCollection); if (departmentList.Any()) { foreach (var item in departmentList) { string departmentName = lcid.Equals("1066") ? item.VietnameseName : item.Name; departments.Add(new DepartmentInfo() { Id = item.ID, DepartmentName = departmentName }); } } return(departments); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Service - GetDepartmentsByLcid", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
public override void ItemAdding(SPItemEventProperties properties) { base.ItemAdding(properties); try { object fromDateObj = properties.AfterProperties[StringConstant.ChangeShiftList.FromDateField]; if (fromDateObj != null) { DateTime fromDate = Convert.ToDateTime(fromDateObj); DateTime reqDueDate = fromDate.Date; //if (reqDueDate == DateTime.Now.Date) //{ // reqDueDate = reqDueDate.AddHours(23).AddMinutes(59).AddSeconds(59); //} //else //{ // reqDueDate = reqDueDate.AddDays(-1).AddHours(23).AddMinutes(59).AddSeconds(59); //} reqDueDate = reqDueDate.AddHours(23).AddMinutes(59).AddSeconds(59); properties.AfterProperties[StringConstant.CommonSPListField.CommonReqDueDateField] = reqDueDate.ToString(StringConstant.DateFormatTZForCAML); } } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - ChangeShiftEventReceiver - ItemAdding fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// An item was updated. /// </summary> public override void ItemUpdated(SPItemEventProperties properties) { try { base.ItemUpdated(properties); var siteURL = properties.WebUrl; var vehicleManagementDAL = new VehicleManagementDAL(siteURL); var ItemID = properties.ListItemId; var currentItem = vehicleManagementDAL.GetByID(ItemID); if (currentItem.ApprovalStatus == "Cancelled") { taskManagementDAL = new TaskManagementDAL(siteURL); var tasks = taskManagementDAL.GetByItemID(currentItem.ID, StepModuleList.VehicleManagement.ToString()).ToList(); foreach (var task in tasks) { task.TaskStatus = TaskStatusList.Deferred; } taskManagementDAL.SaveItems(tasks); } } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Transportation Event Receiver - ItemAdded fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// Get list of calendar in passed Category /// </summary> /// <param name="categories"></param> /// <returns></returns> /// Call URL: _vti_bin/Services/Calendar/CalendarService.svc/GetByCategories/ public List <CalendarModel> GetByCategories(string categories) { try { List <string> categoryList = new List <string>(); categoryList = categories.Split(',').ToList(); List <CalendarModel> calendars = new List <CalendarModel>(); var calendarList = _calendarDal.GetByCategories(categoryList); foreach (var item in calendarList) { calendars.Add(new CalendarModel { ID = item.ID, Description = item.Description, EndDate = item.EndDate, StartDate = item.StartDate, Location = item.Location, Category = item.Category, Title = item.Title }); } return(calendars); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Calendar Service - GetByCategories fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
/// <summary> /// /// </summary> /// <param name="notOvertimeItemId"></param> /// <param name="result"></param> /// <returns></returns> /// CALL URL: /_vti_bin/Services/Email/EmailService.svc/SendNotOvertimeRequestResultEmail/1/Approve public bool SendNotOvertimeRequestResultEmail(string notOvertimeItemId, string result) { try { int idValue; if (int.TryParse(notOvertimeItemId, out idValue)) { string key = string.Empty; if (result.Equals("Approve")) { key = "LOAbsence_Approve"; } else if (result.Equals("Reject")) { key = "LOAbsence_Reject"; } if (!string.IsNullOrEmpty(key)) { var notOvertimeRequestMailItem = _emailTemplateDAL.GetByKey(key); var notOvertimeManagementItem = _notOvertimeMangementDAL.GetByID(idValue); if (notOvertimeRequestMailItem != null && notOvertimeManagementItem != null) { var employee = _employeeDAL.GetByID(notOvertimeManagementItem.Requester.LookupId); if (employee != null && !string.IsNullOrEmpty(employee.Email)) { string emailBody = HTTPUtility.HtmlDecode(notOvertimeRequestMailItem.MailBody); //lookup email string link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceMember}"; if (employee.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.Administrator) { link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceAdmin}"; } if (employee.EmployeePosition.LookupId == (int)StringConstant.EmployeePosition.DepartmentHead) { link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceManager}"; } emailBody = string.Format(emailBody, employee.FullName, notOvertimeManagementItem.Requester.LookupValue, notOvertimeManagementItem.Date.ToString(StringConstant.DateFormatddMMyyyy2), notOvertimeManagementItem.Reason, notOvertimeManagementItem.Comment); emailBody = emailBody.Replace("#link", link); _sendMailActivity.SendMail(SPContext.Current.Web.Url, notOvertimeRequestMailItem.MailSubject, employee.Email, true, false, emailBody); return(true); } } } } return(false); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Email Service - SendNotOvertimeRequestResultEmail fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(false); } }
/// <summary> /// Send email to Requester after /// </summary> /// <param name="changeshiftItemId"></param> /// <returns></returns> /// CALL URL: /_vti_bin/Services/Email/EmailService.svc/SendChangeShiftRequestMail/1/BOD public bool SendChangeShiftRequestMail(string changeshiftItemId, string toRole) { try { int idValue; if (int.TryParse(changeshiftItemId, out idValue)) { var changeShiftManagementItem = _changeShiftManagementDAL.GetByID(idValue); var changeshiftRequestMailItem = _emailTemplateDAL.GetByKey("ChangeShift_Request"); if (changeshiftRequestMailItem != null && changeShiftManagementItem != null) { string email = string.Empty; string employeeFullname = string.Empty; string link = string.Empty; if (toRole.Equals("DH")) { var accountDHItem = _employeeDAL.GetByADAccount(changeShiftManagementItem.DepartmentHead.ID); email = accountDHItem.Email; employeeFullname = accountDHItem.FullName; link = $"{WebUrl}/{StringConstant.WebPageLinks.ChangeShiftManager}"; } else if (toRole.Equals("BOD")) { var accountBODItem = _employeeDAL.GetByADAccount(changeShiftManagementItem.BOD.ID); email = accountBODItem.Email; employeeFullname = accountBODItem.FullName; link = $"{WebUrl}/{StringConstant.WebPageLinks.ChangeShiftBOD}"; } if (!string.IsNullOrEmpty(email)) { var shiftTimeList = _shiftTimeDAL.GetShiftTimes(); string emailBody = HTTPUtility.HtmlDecode(changeshiftRequestMailItem.MailBody); //lookup email var fromShiftItem = shiftTimeList.Where(x => x.ID == changeShiftManagementItem.FromShift.LookupId).FirstOrDefault(); var toShiftItem = shiftTimeList.Where(x => x.ID == changeShiftManagementItem.ToShift.LookupId).FirstOrDefault(); emailBody = string.Format(emailBody, employeeFullname, changeShiftManagementItem.Requester.LookupValue, changeShiftManagementItem.FromDate.ToString(StringConstant.DateFormatddMMyyyy2), changeShiftManagementItem.ToDate.ToString(StringConstant.DateFormatddMMyyyy2), changeShiftManagementItem.Reason, fromShiftItem.Code, toShiftItem.Code); emailBody = emailBody.Replace("#link", link); _sendMailActivity.SendMail(SPContext.Current.Web.Url, changeshiftRequestMailItem.MailSubject, email, true, false, emailBody); return(true); } } } return(false); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Email Service - SendChangeShiftRequestMail fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(false); } }
/// <summary> /// /// </summary> /// <param name="notOvertimeItemId"></param> /// <param name="toRole"></param> /// <returns></returns> /// CALL URL: : /_vti_bin/Services/Email/EmailService.svc/SendNotovertimeRequestRequestEmail/1/BOD public bool SendNotOverTimeRequestEmail(string notOvertimeItemId, string toRole) { try { int idValue; if (int.TryParse(notOvertimeItemId, out idValue)) { var notOvertimeManagementItem = _notOvertimeMangementDAL.GetByID(idValue); var notOvertimeRequestMailItem = _emailTemplateDAL.GetByKey("LOAbsence_Request"); if (notOvertimeRequestMailItem != null && notOvertimeManagementItem != null) { string link = string.Empty; string email = string.Empty; string empployeeFullname = string.Empty; if (toRole.Equals("DH")) { if (notOvertimeManagementItem.DH != null) { var accountDHItem = _employeeDAL.GetByADAccount(notOvertimeManagementItem.DH.ID); email = accountDHItem.Email; empployeeFullname = accountDHItem.FullName; link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceManager}#tab2"; } } else if (toRole.Equals("BOD")) { if (notOvertimeManagementItem.DH != null) { var accountBODItem = _employeeDAL.GetByADAccount(notOvertimeManagementItem.DH.ID); email = accountBODItem.Email; empployeeFullname = accountBODItem.FullName; link = $"{WebUrl}/{StringConstant.WebPageLinks.LeaveOfAbsenceBOD}#tab2"; } } if (!string.IsNullOrEmpty(email)) { string emailBody = HTTPUtility.HtmlDecode(notOvertimeRequestMailItem.MailBody); //lookup email emailBody = string.Format(emailBody, empployeeFullname, notOvertimeManagementItem.Requester.LookupValue, notOvertimeManagementItem.Date.ToString(StringConstant.DateFormatddMMyyyy2), notOvertimeManagementItem.Reason); emailBody = emailBody.Replace("#link", link); _sendMailActivity.SendMail(SPContext.Current.Web.Url, notOvertimeRequestMailItem.MailSubject, email, true, false, emailBody); return(true); } } } return(false); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Email Service - SendNotOverTimeRequestEmail fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(false); } }
/// <summary> /// Get approvers of empployee by passing Id (employee list item ID) /// </summary> /// <param name="id"></param> /// <returns></returns> /// CALL URL: _vti_bin/Services/Employee/EmployeeService.svc/GetEmployeeApprovers/1 public EmployeeApproverModel GetEmployeeApprovers(string id) { try { EmployeeApproverModel employeeApprover = new EmployeeApproverModel { EmployeeIdentity = Convert.ToInt16(id), }; var currentEmployee = _employeeInfoDAL.GetByID(Convert.ToInt16(id)); if (currentEmployee != null) { var groupLeaders = _employeeInfoDAL.GetByPositionDepartment(StringConstant.EmployeePosition.GroupLeader, currentEmployee.Department.LookupId, currentEmployee.FactoryLocation.LookupId); if (groupLeaders != null) { foreach (var groupLeader in groupLeaders) { employeeApprover.Approver1.Add(new ApproverModel { LoginName = groupLeader.ADAccount.UserName, FullLoginName = groupLeader.FullName }); } } var department = _departmentDAL.GetByID(currentEmployee.Department.LookupId); var accountList = _employeeInfoDAL.GetByPositionDepartment(StringConstant.EmployeePosition.DepartmentHead, department.ID, currentEmployee.FactoryLocation.LookupId); if (accountList.Count > 0) { var DPH = accountList.FirstOrDefault(); employeeApprover.Approver2 = new ApproverModel { LoginName = DPH.ADAccount.UserName, FullLoginName = DPH.FullName }; } if (department != null && department.BOD != null) { employeeApprover.Approver3 = new ApproverModel { LoginName = department.BOD.UserName, FullLoginName = department.BOD.FullName }; } } return(employeeApprover); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Employee Service - GetEmployeeApprovers fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
private void InitialViewGUID() { try { var url = SPContext.Current.Web.Url; taskManagementDAL = new TaskManagementDAL(url); var guidViews = taskManagementDAL.GetViewGuildID().Where(x => x.BaseViewID == baseViewID).FirstOrDefault(); TaskApprovalControlWP.ViewGuid = guidViews.ID.ToString(); XElement xmlViewDef = XElement.Parse(TaskApprovalControlWP.XmlDefinition); XElement whereElement = xmlViewDef.Descendants("Where").FirstOrDefault(); if (whereElement != null) { if (whereElement.HasElements) { whereElement.RemoveNodes(); } // whereElement.Add(BuildQueryString()); //TaskApprovalControlWP.XmlDefinition = xmlViewDef.ToString(); //SPContext.Current.Web.AllowUnsafeUpdates = true; var module = Page.Request["AdminModule"]; if (module != null) { TaskApprovalControlWP.View.Query = string.Format(@"<Where> <And> <In> <FieldRef Name='AssignedTo' LookupId='TRUE' /> <Values> <Value Type='Integer'> <UserID /> </Value> </Values> </In> <And> <Eq> <FieldRef Name='StepModule' /> <Value Type='Choice'>{0}</Value> </Eq> <Eq> <FieldRef Name='Status' /> <Value Type='Choice'>In Progress</Value> </Eq> </And> </And> </Where>", module); } } } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Task Approval Control - InitData", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
public CalendarModel GetHolidayInfo(string dateStr, string location) { CalendarModel calendarModel = null; try { var fromDateValue = dateStr.ToMMDDYYYYDate(false); // mm-dd-yyyy if (fromDateValue != DateTime.MinValue) { List <string> holidays = new List <string>() { StringConstant.CaledarCategory.Holiday, StringConstant.CaledarCategory.Weekend, StringConstant.CaledarCategory.CompensationDayOff }; Biz.Models.Calendar calendar = new Biz.Models.Calendar(); if (location.Equals("1")) { calendar = _calendarDal.GetByDateAndCategories(fromDateValue, holidays); } else if (location.Equals("2")) { calendar = _calendar2Dal.GetByDateAndCategories(fromDateValue, holidays); } if (calendar != null) { calendarModel = (new CalendarModel { ID = calendar.ID, Description = calendar.Description, EndDate = calendar.EndDate, StartDate = calendar.StartDate, Location = calendar.Location, Category = calendar.Category, Title = calendar.Title, Day = calendar.EndDate.Day }); } } return(calendarModel); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Calendar Service - GetHolidayInfo fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
/// <summary> /// Get list holidays in month & location /// </summary> /// <param name="month"></param> /// <param name="year"></param> /// <param name="locationId"></param> /// <returns></returns> /// CALL URL: CALL URL: _vti_bin/Services/Calendar/CalendarService.svc/GetLocationHolidayInMonth/1/2017/1 public List <CalendarModel> GetLocationHolidayInMonth(string month, string year, string location) { List <CalendarModel> calendars = new List <CalendarModel>(); try { int monthValue, yearValue; if (int.TryParse(month, out monthValue) && int.TryParse(year, out yearValue)) { var fromMonth = new DateTime(yearValue, monthValue, 1, 0, 0, 0); var toMonth = new DateTime(yearValue, monthValue, 1, 23, 59, 59).AddMonths(1).AddDays(-1); List <string> holidaysCategory = new List <string>() { StringConstant.CaledarCategory.Holiday, StringConstant.CaledarCategory.Weekend, StringConstant.CaledarCategory.CompensationDayOff }; List <Biz.Models.Calendar> calendarList = new List <Biz.Models.Calendar>(); if (location.Equals("1")) { calendarList = _calendarDal.GetByDateAndCategories(fromMonth, toMonth, holidaysCategory); } else if (location.Equals("2")) { calendarList = _calendar2Dal.GetByDateAndCategories(fromMonth, toMonth, holidaysCategory); } foreach (var item in calendarList) { calendars.Add(new CalendarModel { ID = item.ID, Description = item.Description, EndDate = item.EndDate, StartDate = item.StartDate, Location = item.Location, Category = item.Category, Title = item.Title }); } } return(calendars); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Calendar Service - GetLocationHolidayInMonth fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
public bool IsUserCurrentuserInGroup(string groupName) { try { return(_employeeInfoDAL.IsUserCurrentuserInGroup(groupName)); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Employee Service - IsUserCurrentuserInGroup fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(false); } }
public bool SendDelegationNotOverTimeRequestEmail(string notOvertimeItemId, string toRole) { try { int idValue; if (int.TryParse(notOvertimeItemId, out idValue)) { var notOvertimeManagementItem = _notOvertimeMangementDAL.GetByID(idValue); var notOvertimeRequestMailItem = _emailTemplateDAL.GetByKey("LOAbsence_Request"); if (notOvertimeRequestMailItem != null && notOvertimeManagementItem != null) { var siteUrl = SPContext.Current.Site.Url; string link = string.Format(@"{0}/_layouts/15/RBVH.Stada.Intranet.WebPages/LeaveOfAbsenceManagement/LeaveOfAbsenceApprovalDelegation.aspx?itemId={1}&Source=/_layouts/15/RBVH.Stada.Intranet.WebPages/DelegationManagement/DelegationList.aspx&Source=Tab=DelegationsApprovalTab", siteUrl, notOvertimeManagementItem.ID); var dhUser = _employeeDAL.GetByADAccount(notOvertimeManagementItem.DH.ID); List <EmployeeInfo> toUsers = DelegationPermissionManager.GetListOfDelegatedEmployees(siteUrl, dhUser.ID, StringConstant.NotOvertimeList.ListUrl, notOvertimeManagementItem.ID); if (toUsers != null) { foreach (var toUser in toUsers) { try { if (!string.IsNullOrEmpty(toUser.Email)) { string emailBody = HTTPUtility.HtmlDecode(notOvertimeRequestMailItem.MailBody); emailBody = string.Format(emailBody, toUser.FullName, notOvertimeManagementItem.Requester.LookupValue, notOvertimeManagementItem.Date.ToString(StringConstant.DateFormatddMMyyyy2), notOvertimeManagementItem.Reason); emailBody = emailBody.Replace("#link", link); _sendMailActivity.SendMail(SPContext.Current.Web.Url, notOvertimeRequestMailItem.MailSubject, toUser.Email, true, false, emailBody); } } catch { } } } return(true); } } return(false); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Email Service - SendDelegationNotOverTimeRequestEmail fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(false); } }
/// <summary> /// Get Department List by language code /// </summary> /// <param name="languageCode"></param> /// <returns></returns> /// CALL URL : _vti_bin/Services/Department/DepartmentService.svc/GetDepartmentByIdLanguageCode/1/vi-VN public DepartmentInfo GetDepartmentByIdLanguageCode(string departmentId, string languageCode) { var langCode = string.IsNullOrEmpty(languageCode) ? "en-US" : languageCode; try { var codes = langCode.Split('-'); if (codes.Length > 1) { langCode = codes[0].ToLower() + "-" + codes[1].ToUpper(); } else { switch (langCode) { case "1066": langCode = "vi-VN"; break; case "1033": langCode = "en-US"; break; } } DepartmentInfo departmentInfo = new DepartmentInfo(); int departmentIdValue; if (int.TryParse(departmentId, out departmentIdValue)) { var department = _departmentDal.GetByID(departmentIdValue); if (department != null) { string departmentName = langCode.Equals("vi-VN") ? department.VietnameseName : department.Name; departmentInfo = new DepartmentInfo() { Id = department.ID, DepartmentName = departmentName }; } } return(departmentInfo); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Service - GetDepartmentByIdLanguageCode fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); try { var itemId = properties.ListItem.ID; SendEmailToApprover(properties.Web, itemId); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Shift Management Event Receiver - ItemAdded fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
protected void Page_Load(object sender, EventArgs e) { GetCurrentUser(); try { var url = SPContext.Current.Web.Url; vehicleManagementDAL = new VehicleManagementDAL(url); var guidViews = vehicleManagementDAL.GetViewGuildID().Where(x => x.BaseViewID == baseViewID).FirstOrDefault(); TransportationRequestControlWP.ViewGuid = guidViews.ID.ToString(); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - TransportationRequestControl - InitData", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// An item was added. /// </summary> public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); try { base.ItemAdded(properties); SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(properties.SiteId)) { using (SPWeb web = site.OpenWeb(properties.Web.ID)) { string itemID = Convert.ToString(properties.ListItemId); bool isBOD = false; var approverString = Convert.ToString(properties.ListItem[StringConstant.NotOvertimeList.DHField]); if (!string.IsNullOrEmpty(approverString)) { SPListItem curItem = properties.ListItem; var bodGroup = web.SiteGroups.GetByName("BOD"); var spUserField = properties.ListItem.Fields.GetField(StringConstant.NotOvertimeList.DHField); SPFieldUserValue spNewUserFieldValue = (SPFieldUserValue)spUserField.GetFieldValue(approverString); SPUser spNewBodUser = web.EnsureUser(spNewUserFieldValue.LookupValue); var bodUser = bodGroup.Users.GetByLoginNoThrow(spNewBodUser.LoginName); if (bodUser != null) { isBOD = true; } } var notOverTimeRequestEmail = string.Format("{0}/_vti_bin/Services/Email/EmailService.svc/SendNotOverTimeRequestEmail/{1}/{2}", properties.WebUrl, itemID, isBOD ? "BOD" : "DH"); var delegationNotOverTimeRequestEmail = string.Format("{0}/_vti_bin/Services/Email/EmailService.svc/SendDelegationNotOverTimeRequestEmail/{1}/{2}", properties.WebUrl, itemID, isBOD ? "BOD" : "DH"); SendEmail(notOverTimeRequestEmail); SendEmail(delegationNotOverTimeRequestEmail); } } }); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - NotOvertime Event Receiver - ItemAdded fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// Get manager list with min level /// </summary> /// <param name="departmentId"></param> /// <param name="minLevel"></param> /// <returns></returns> /// URL: _vti_bin/Services/Employee/EmployeeService.svc/GetManagerByDepartment/5/4 public List <EmployeeModel> GetManagerByDepartment(string departmentId, string minLevel) { try { List <EmployeeModel> employees = new List <EmployeeModel>(); var employeePositions = _employeePositionDAL.GetByMinLevel(double.Parse(minLevel, System.Globalization.CultureInfo.InvariantCulture)); if (employeePositions != null && employeePositions.Count() > 0) { var employeePositionIds = employeePositions.Select(x => x.ID).ToList(); var employeeList = _employeeInfoDAL.GetByUserType(true, StringConstant.EmployeeType.ADUser); ////Filter by min level employeeList = employeeList.Where(x => x.Department == null || (x.EmployeeLevel != null && employeePositionIds.Contains(x.EmployeeLevel.LookupId))).ToList(); if (!string.IsNullOrEmpty(departmentId) && Convert.ToInt32(departmentId) > 0) { employeeList = employeeList.Where(x => x.Department == null || (x.Department != null && (x.Department.LookupId == 0 || x.Department.LookupId == Convert.ToInt32(departmentId)))).ToList(); } foreach (var item in employeeList) { employees.Add(new EmployeeModel { EmployeeID = item.EmployeeID, ID = item.ID, Department = LookupItemHelper.ConvertToModel(item.Department), Location = LookupItemHelper.ConvertToModel(item.FactoryLocation), DepartmentPermission = item.DepartmentPermission, FullName = item.FullName, EmployeeType = item.EmployeeType }); } } return(employees); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Employee Service - GetManagerByDepartment fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
public override void ItemUpdated(SPItemEventProperties properties) { base.ItemUpdated(properties); try { int itemID = Convert.ToInt32(properties.ListItemId); NotOvertimeManagementDAL notovertimeDAL = new NotOvertimeManagementDAL(properties.WebUrl); OverTimeManagementDetailDAL overTimeManagementDetailDAL = new OverTimeManagementDetailDAL(properties.WebUrl); var item = notovertimeDAL.GetByID(itemID); string url = string.Empty; if (item != null) { if (item.ApprovalStatus.Equals("1")) { var notOverTimeRequestEmail = string.Format("{0}/_vti_bin/Services/Email/EmailService.svc/SendNotOverTimeRequestEmail/{1}/{2}", properties.WebUrl, itemID, "BOD"); var delegationNotOverTimeRequestEmail = string.Format("{0}/_vti_bin/Services/Email/EmailService.svc/SendDelegationNotOverTimeRequestEmail/{1}/{2}", properties.WebUrl, itemID, "BOD"); SendEmail(notOverTimeRequestEmail); SendEmail(delegationNotOverTimeRequestEmail); } else if (item.ApprovalStatus.Equals("Approved")) { // udpate overtimeDetail var overtimeDetail = overTimeManagementDetailDAL.GetOvertimeEmployeeByDate(item.Requester.LookupId, item.Date).Where(x => x.ApprovalStatus != null && x.ApprovalStatus.LookupValue == "true").SingleOrDefault(); if (overtimeDetail != null) { overtimeDetail.Task = WORKCONTENT; overtimeDetail.SummaryLinks = string.Format(URL, itemID); overTimeManagementDetailDAL.BulkUpdate(new List <OverTimeManagementDetail>() { overtimeDetail }); } } } } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - NotOvertime Event Receiver - ItemUpdated fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// An item is deleting. /// </summary> public override void ItemDeleting(SPItemEventProperties properties) { try { SPListItem curItem = properties.ListItem; var departmentRepo = new DepartmentDAL(properties.Site.Url); var department = departmentRepo.ParseToEntity(curItem); //delete Site departmentRepo.DeleteSite(properties.SiteId, properties.Web.ID, department); DepartmentListSingleton.ResetDepartmentListInstance(); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Event Receiver - ItemDeleting fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } base.ItemDeleted(properties); }
/// <summary> /// Get avatar image /// </summary> /// <param name="id"></param> /// <returns></returns> public string GetAvatar(string id) { try { int itemId = Convert.ToInt32(id); string imageUrl = string.Empty; var employee = _employeeInfoDAL.GetByID(itemId); if (employee != null) { imageUrl = employee.Image; } return(imageUrl); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Employee Service - GetAvatar fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
public bool IsNotOvertimeExist(string employeeId, string date) { try { var fromDateValue = date.ToMMDDYYYYDate(false); // mm-dd-yyyy //get not overtime item with status null or approved var overtimeItem = _notOvertimeManagementDal.GetByDate(Convert.ToInt32(employeeId), fromDateValue); if (overtimeItem != null) { return(true); } return(false); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Overtime Service - IsNotOvertimeExist fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(true); } }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { //Deletes the links when feature is deactivated SPWeb web = null; try { web = properties.Feature.Parent as SPWeb; if (web == null) { return; } web.AllowUnsafeUpdates = true; var nodeColl = web.Navigation.QuickLaunch; for (var nodeIndex = nodeColl.Count - 1; nodeIndex >= 0; nodeIndex--) { if (nodeColl[nodeIndex].Children.Count > 0) { var childrenCollection = nodeColl[nodeIndex].Children; for (var nodeChildIndex = childrenCollection.Count - 1; nodeChildIndex >= 0; nodeChildIndex--) { childrenCollection[nodeChildIndex].Delete(); } } nodeColl[nodeIndex].Delete(); } } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA-Branding - FeatureDeactivating", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } finally { if (web != null) { web.AllowUnsafeUpdates = false; } } }
/// <summary> /// Get overtime in date /// </summary> /// <param name="date"></param> /// <returns></returns> /// CALL URL: _vti_bin/Services/Overtime/OvertimeService.svc/GetOvertimeDetailByDate/4/3-24-2017 public OvertimeEmployeeInDateModel GetOvertimeDetailByDate(string employeeLookupId, string date) { OvertimeEmployeeInDateModel overtimeData = new OvertimeEmployeeInDateModel { IsHasValue = false }; try { int employeeLookupIdValue; var fromDateValue = date.ToMMDDYYYYDate(false); // mm-dd-yyyy var toDateValue = date.ToMMDDYYYYDate(true); if (fromDateValue != DateTime.MinValue && int.TryParse(employeeLookupId, out employeeLookupIdValue)) { var overtimeDetail = _overTimeManagementDetailDAL.GetForEmployeeByDateRange(employeeLookupIdValue, fromDateValue, toDateValue); var firstOvertime = overtimeDetail.FirstOrDefault(x => (x.ApprovalStatus != null && Convert.ToString(x.ApprovalStatus.LookupValue).ToLower().Equals("true"))); if (firstOvertime != null) { overtimeData.FromHour = firstOvertime.OvertimeFrom.Hour; overtimeData.FromMinute = firstOvertime.OvertimeFrom.Minute; overtimeData.ToHour = firstOvertime.OvertimeTo.Hour; overtimeData.ToMinute = firstOvertime.OvertimeTo.Minute; overtimeData.HourPerDay = firstOvertime.WorkingHours; overtimeData.IsHasValue = true; } } return(overtimeData); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Overtime Service - GetOvertimeDetailByDate fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
/// <summary> /// Get active Eeployee by locationId & departmentId /// </summary> /// <param name="locationId"></param> /// <param name="departmentId"></param> /// <param name="maxLevel"></param> /// <returns></returns> /// CALL URL: _vti_bin/Services/Employee/EmployeeService.svc/GetByDepartmentLocation/1/1 public List <EmployeeModel> GetByDepartmentLocation(string locationId, string departmentId, string maxLevel) { try { List <EmployeeModel> employees = new List <EmployeeModel>(); int locationIdValue, departmentIdValue; int level = Convert.ToInt32(maxLevel); if (int.TryParse(locationId, out locationIdValue) && int.TryParse(departmentId, out departmentIdValue)) { string[] viewFields = new string[] { EmployeeInfoList.EmployeeIDField, EmployeeInfoList.FullNameField, EmployeeInfoList.DepartmentField, EmployeeInfoList.FactoryLocationField, EmployeeInfoList.EmployeeTypeField, EmployeeInfoList.DepartmentPermissionField }; var employeeList = _employeeInfoDAL.GetByLocationAndDepartment(locationIdValue, departmentIdValue, true, level, StringConstant.EmployeeInfoList.FullNameField, viewFields); if (employeeList != null) { foreach (var item in employeeList) { employees.Add(new EmployeeModel { EmployeeID = item.EmployeeID, ID = item.ID, Department = LookupItemHelper.ConvertToModel(item.Department), Location = LookupItemHelper.ConvertToModel(item.FactoryLocation), DepartmentPermission = item.DepartmentPermission, FullName = item.FullName, EmployeeType = item.EmployeeType }); } } } return(employees); } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Employee Service - GetByDepartmentLocation fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); return(null); } }
/// CALL URL : _vti_bin/Services/Department/DepartmentService.svc/GetDepartments/vi-VN public List <DepartmentInfo> GetDepartments(string languageCode, string locationIds) { var listResult = new List <DepartmentInfo>(); try { List <Biz.Models.Department> departmentEntities = new List <Biz.Models.Department>(); List <int> locationCollection = locationIds.SplitStringOfLocations().ConvertAll(e => Convert.ToInt32(e)); if (locationCollection != null && !locationCollection.Contains(0)) { var locationFilter = CommonHelper.BuildFilterCommonMultiLocations(locationCollection); if (!string.IsNullOrEmpty(locationFilter)) { departmentEntities = _departmentDal.GetByQuery($"<Where>{locationFilter}</Where>", string.Empty); } } else { departmentEntities = _departmentDal.GetAll(); } foreach (var departmentEntity in departmentEntities) { listResult.Add(new DepartmentInfo { Id = departmentEntity.ID, DepartmentName = languageCode == "vi-VN" ? departmentEntity.VietnameseName : departmentEntity.Name }); } } catch (Exception ex) { ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Service - GetDepartmentByIdLanguageCode fn", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace)); } return(listResult); }