/// <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)); } }
protected void Page_Load(object sender, EventArgs e) { var url = SPContext.Current.Web.Url; vehicleManagementDAL = new VehicleManagementDAL(url); var guidViews = vehicleManagementDAL.GetViewGuildID().Where(x => x.BaseViewID == baseViewID).FirstOrDefault(); TransportationDepartmentControlWP.ViewGuid = guidViews.ID.ToString(); UserHelper userHelper = new UserHelper(); EmployeeInfo currentEmployeeInfo = userHelper.GetCurrentLoginUser(); string selectedDepId = this.Page.Request.Params.Get("AdminDeptId"); XElement filterElement = BuildViewString(currentEmployeeInfo, selectedDepId); XElement xmlViewDef = XElement.Parse(TransportationDepartmentControlWP.XmlDefinition); XElement whereElement = xmlViewDef.Descendants("Where").FirstOrDefault(); if (whereElement != null) { if (whereElement.HasElements) { whereElement.RemoveNodes(); } whereElement.Add(filterElement); TransportationDepartmentControlWP.XmlDefinition = xmlViewDef.ToString(); } }
public EmployeeInfo GetNextApproval(int departmentID, int locationID, StepModuleList StepModule, int stepNumber) { IModuleBuilder moduleBuilder = null; EmployeeInfo nextAssignee = null; switch (StepModule) { case StepModuleList.VehicleManagement: moduleBuilder = new VehicleManagementDAL(SiteUrl); break; case StepModuleList.LeaveManagement: moduleBuilder = new LeaveManagementDAL(SiteUrl); break; default: return(null); } var approvalList = moduleBuilder.CreateApprovalList(departmentID, locationID); if (approvalList.Count > 0 && approvalList.Count() >= stepNumber) { nextAssignee = approvalList.ElementAt(stepNumber - 1); } return(nextAssignee); }
/// <summary> /// InitDALObject /// </summary> /// <param name="listUrl"></param> /// <param name="currentWeb"></param> /// <returns></returns> private static IDelegationManager InitDALObject(string listUrl, SPWeb currentWeb) { IDelegationManager moduleDAL = null; if (string.Compare(listUrl, ShiftManagementList.ListUrl, true) == 0) { moduleDAL = new ShiftManagementDAL(currentWeb.Url); } else if (string.Compare(listUrl, ChangeShiftList.ListUrl, true) == 0) { moduleDAL = new ChangeShiftManagementDAL(currentWeb.Url); } else if (string.Compare(listUrl, OverTimeManagementList.ListUrl, true) == 0) { moduleDAL = new OverTimeManagementDAL(currentWeb.Url); } else if (string.Compare(listUrl, NotOvertimeList.ListUrl, true) == 0) { moduleDAL = new NotOvertimeManagementDAL(currentWeb.Url); } else if (string.Compare(listUrl, VehicleManagementList.ListUrl, true) == 0) { moduleDAL = new VehicleManagementDAL(currentWeb.Url); } else if (string.Compare(listUrl, LeaveManagementList.ListUrl, true) == 0) { moduleDAL = new LeaveManagementDAL(currentWeb.Url); } else if (string.Compare(listUrl, FreightManagementList.ListUrl, true) == 0) { moduleDAL = new FreightManagementDAL(currentWeb.Url); } else if (string.Compare(listUrl, BusinessTripManagementList.Url, true) == 0) { moduleDAL = new BusinessTripManagementDAL(currentWeb.Url); } else if (string.Compare(listUrl, RequestsList.Url, true) == 0) { moduleDAL = new RequestsDAL(currentWeb.Url); } else if (string.Compare(listUrl, EmployeeRequirementSheetsList.Url, true) == 0) { moduleDAL = new EmployeeRequirementSheetDAL(currentWeb.Url); } else if (string.Compare(listUrl, RequestForDiplomaSuppliesList.Url, true) == 0) { moduleDAL = new RequestForDiplomaSupplyDAL(currentWeb.Url); } else if (string.Compare(listUrl, RequisitionOfMeetingRoomList.Url, true) == 0) { moduleDAL = new RequisitionOfMeetingRoomDAL(currentWeb.Url); } return(moduleDAL); }
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)); } }
private void GetVehicleTaskList(VehicleManagementDAL vehicleManagementDAL) { var taskListQuery = _filterTaskManager.BuildTaskListQuery(StepModuleList.VehicleManagement.ToString(), TaskStatusList.InProgress.ToString(), _currentUserADId); List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == VehicleManagementList.ListUrl).Select(d => d.ListItemID).ToList(); var delegationQuery = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserADId, string.Empty, string.Empty, delegatedItemIDs); var query = $@"<Where> <And> <Or> {taskListQuery} {delegationQuery} </Or> <Or> <Eq> <FieldRef Name='{VehicleManagementList.CommonFrom}' /> <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value> </Eq> <Eq> <FieldRef Name='{VehicleManagementList.CommonFrom}' /> <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value> </Eq> </Or> </And> </Where>"; if (this.CountOnly) { TotalCount += vehicleManagementDAL.CountByQuery(query); } else { var vehicleManagementList = vehicleManagementDAL.GetByQuery(query); if (vehicleManagementList != null) { foreach (var vehicleManagement in vehicleManagementList) { var filterTask = new FilterTask(vehicleManagement); filterTask.ApprovalStatusId = ApprovalStatusId; FilterTaskList.Add(filterTask); } } } }
private void InitialViewGUID() { var siteUrl = SPContext.Current.Web.Url; vehicleManagementDAL = new VehicleManagementDAL(siteUrl); var guidViews = vehicleManagementDAL.GetViewGuildID().Where(x => x.BaseViewID == baseViewID).FirstOrDefault(); TransportationApprovalControlWP.ViewGuid = guidViews == null ? "" : guidViews.ID.ToString(); XElement filterElement = BuildViewString(SPContext.Current.Web.CurrentUser.ID, siteUrl); XElement xmlViewDef = XElement.Parse(TransportationApprovalControlWP.XmlDefinition); XElement whereElement = xmlViewDef.Descendants("Where").FirstOrDefault(); if (whereElement != null) { if (whereElement.HasElements) { whereElement.RemoveNodes(); } whereElement.Add(filterElement); TransportationApprovalControlWP.XmlDefinition = xmlViewDef.ToString(); } }
private void GetVehicleTaskList(VehicleManagementDAL vehicleManagementDAL) { var query = _filterTaskManager.BuildApprovalTaskListQuery(StepModuleList.VehicleManagement.ToString(), _currentUserADId, DateTime.Now); if (this.CountOnly) { TotalCount += vehicleManagementDAL.CountByQuery(query); } else { var vehicleManagementList = vehicleManagementDAL.GetByQuery(query); if (vehicleManagementList != null && vehicleManagementList.Count > 0) { foreach (var vehicleManagement in vehicleManagementList) { var filterTask = new FilterTask(vehicleManagement); filterTask.ApprovalStatusId = vehicleManagement.ApprovalStatus == Status.Approved ? ApprovedStatusId : vehicleManagement.ApprovalStatus == Status.Rejected ? RejectedStatusId : InProgressStatusId; FilterTaskList.Add(filterTask); } } } }
public VehicleManagementService() { _vehicleManagementDAL = new VehicleManagementDAL(SPContext.Current.Site.Url); }
public void Visit(VehicleManagementDAL vehicleManagementDAL) { GetVehicleTaskList(vehicleManagementDAL); }
public override void ItemAdded(SPItemEventProperties properties) { try { base.ItemAdded(properties); var siteURL = properties.WebUrl; var vehicleManagementDAL = new VehicleManagementDAL(siteURL); var ItemID = properties.ListItemId; var currentItem = vehicleManagementDAL.GetByID(ItemID); taskManagementDAL = new TaskManagementDAL(siteURL); TaskManagement taskManagement = new TaskManagement(); taskManagement.StartDate = DateTime.Now; taskManagement.DueDate = currentItem.RequestDueDate; taskManagement.PercentComplete = 0; taskManagement.ItemId = currentItem.ID; taskManagement.ItemURL = properties.List.DefaultDisplayFormUrl + "?ID=" + properties.ListItemId; taskManagement.ListURL = properties.List.DefaultViewUrl; taskManagement.TaskName = TASK_NAME; taskManagement.TaskStatus = TaskStatusList.InProgress; taskManagement.StepModule = StepModuleList.VehicleManagement.ToString(); taskManagement.Department = currentItem.CommonDepartment; taskManagement.AssignedTo = currentItem.DepartmentHead; employeeInfoDAL = new EmployeeInfoDAL(siteURL); EmployeeInfo requesterInfo = employeeInfoDAL.GetByID(currentItem.Requester.LookupId); if ((int)Convert.ToDouble(requesterInfo.EmployeeLevel.LookupValue, CultureInfo.InvariantCulture.NumberFormat) == (int)StringConstant.EmployeeLevel.DepartmentHead) { taskManagement.StepStatus = StepStatusList.BODApproval; } else { taskManagement.StepStatus = StepStatusList.DHApproval; } DepartmentDAL _departmentDAL = new DepartmentDAL(siteURL); Department departmentHR = _departmentDAL.GetByCode("HR"); if (departmentHR.ID == currentItem.CommonDepartment.LookupId) { taskManagement.NextAssign = null; } else { EmployeeInfo deptHeadOfHR = employeeInfoDAL.GetByPositionDepartment(StringConstant.EmployeePosition.DepartmentHead, requesterInfo.FactoryLocation.LookupId, departmentHR.ID).FirstOrDefault(); if (deptHeadOfHR != null) { taskManagement.NextAssign = deptHeadOfHR.ADAccount; } } taskManagementDAL.SaveItem(taskManagement); var mailDAL = new EmailTemplateDAL(siteURL); var emailTemplate = mailDAL.GetByKey("VehicleManagement_Request"); EmployeeInfo assigneeInfo = employeeInfoDAL.GetByADAccount(taskManagement.AssignedTo.ID); currentItem.ApprovalStatus = taskManagement.StepStatus; vehicleManagementDAL.SaveOrUpdate(currentItem); vehicleManagementDAL.SendEmail(currentItem, emailTemplate, null, assigneeInfo, VehicleTypeOfEmail.Request, siteURL); try { List <EmployeeInfo> toUsers = DelegationPermissionManager.GetListOfDelegatedEmployees(siteURL, assigneeInfo.ID, StringConstant.VehicleManagementList.ListUrl, currentItem.ID); vehicleManagementDAL.SendDelegationEmail(currentItem, emailTemplate, toUsers, siteURL); } catch { } } 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)); } }
public void Visit(VehicleManagementDAL vehicleManagementDAL) { // Do nothing }