public ActionResult Create() { ViewBag.ShortNameFromList = true; ViewBag.ProjectTypeID = new SelectList(_projectTypeService.Get(x => x.ToList().OrderBy(pt => pt.FullName).ToList()), "ID", "FullName"); return(View(new ProjectScheduleEntryType())); }
public IHttpActionResult GetProjectType(int id) { var projectType = projectTypeService.Get(id); if (projectType != null) { return(Ok(projectType)); } else { return(NotFound()); } }
public ActionResult AllProjectScheduleDueDateStatus(int?projectTypeID, string searchString) { var user = _applicationUserService.GetUser(); int userEmployeeID = _applicationUserService.GetEmployeeID(); ViewBag.CurrentFilter = searchString; ViewBag.SearchProjects = new SelectList(_projectService.GetAll(null, null, null, ProjectStatus.All, null), "ID", "ShortName"); var projectIds = _projectService.GetAll(null, null, searchString, ProjectStatus.All, null).Select(x => x.ID).ToList(); ViewBag.ProjectTypeID = _projectTypeService.Get(x => x.ToList().OrderBy(pt => pt.FullName).ToList()); ViewBag.CurrentProjectTypeID = projectTypeID; ViewBag.TodayPlus3WorkingDays = _productionCalendarService.AddWorkingDaysToDate(DateTime.Today, 3); IList <ProjectScheduleEntry> projectScheduleEntryList; if (projectTypeID != null && projectTypeID.HasValue == true) { ViewBag.CurrentProjectTypeID = projectTypeID.Value; projectScheduleEntryList = _projectScheduleEntryService.GetAllForUser(user) .Where(pse => pse.ProjectScheduleEntryType != null && projectIds.Contains(pse.ProjectID)) .OrderBy(pse => pse.ProjectScheduleEntryType.WBSCode) .Where(pse => pse.Project != null && pse.Project.ProjectTypeID == projectTypeID) .ToList(); IList <ProjectScheduleEntryType> projectScheduleEntryTypeList = _projectScheduleEntryTypeService.Get(psetList => psetList .Where(pset => pset.ProjectTypeID == projectTypeID) .ToList()); if (projectScheduleEntryTypeList != null && projectScheduleEntryTypeList.Count() != 0) { foreach (var projectScheduleEntryType in projectScheduleEntryTypeList) { var projectScheduleEntry = new ProjectScheduleEntry() { ProjectScheduleEntryTypeID = projectScheduleEntryType.ID, ProjectScheduleEntryType = projectScheduleEntryType, Title = projectScheduleEntryType.Title }; projectScheduleEntryList.Add(projectScheduleEntry); } } } else { projectScheduleEntryList = _projectScheduleEntryService.GetAllForUser(user) .Where(pse => pse.ProjectScheduleEntryType != null && projectIds.Contains(pse.ProjectID)) .ToList(); } return(View(projectScheduleEntryList.OrderBy(pse => pse.ProjectScheduleEntryType.WBSCode))); }
public async Task <ApiResult <ProjectTypeViewModel> > Item(string ID) { var res = new ApiResult <ProjectTypeViewModel>(); ProjectTypeInfo m; ProjectTypeViewModel n = new ProjectTypeViewModel(); if (!string.IsNullOrEmpty(ID)) { m = ProjectTypedb.Get("ProjectType", ID); if (m != null) { n.ID = C.String(m._id); n.Names = m.Names; n.Sequence = m.Sequence; n.Remarks = m.Remarks; n.State = m.State; n.AddDate = Utility.GetDateFormat(m.AddDate); res.success = true; } } res.data = n; return(await Task.Run(() => res)); }
public async Task <ApiResult <IEnumerable <ProjectViewModel> > > List(int pageIndex, string Title, string ProjectTypeID, int?State) { var res = new ApiResult <IEnumerable <ProjectViewModel> >() { statusCode = (int)ApiEnum.Status }; if (pageIndex == 0) { pageIndex = 1; } PageParm page = new PageParm(pageIndex); FilterDefinition <ProjectInfo> filter = FilterDefinition <ProjectInfo> .Empty; var list = new List <FilterDefinition <ProjectInfo> >(); if (!string.IsNullOrWhiteSpace(Title)) { list.Add(Builders <ProjectInfo> .Filter.Where(s => s.Names.Contains(Title))); } if (!string.IsNullOrWhiteSpace(ProjectTypeID)) { list.Add(Builders <ProjectInfo> .Filter.Eq("ProjectTypeID", ProjectTypeID)); } if (State != null && State != 0) { list.Add(Builders <ProjectInfo> .Filter.Eq("State", State)); } list.Add(Builders <ProjectInfo> .Filter.Where(m => m._id != null)); filter = Builders <ProjectInfo> .Filter.And(list); long c = 0; var list1 = Projectdb.GetList("Projects", filter, page.PageIndex, page.PageSize, out c); List <ProjectViewModel> list2 = new List <ProjectViewModel>(); if (list1 != null) { foreach (var item in list1) { list2.Add(new ProjectViewModel { ID = C.String(item._id), Names = item.Names, URL = item.URL, Remarks = item.Remarks, State = item.State, ProjectTypeName = ProjectTypedb.Get("ProjectType", item.ProjectTypeID).Names, ProductionDate = Utility.GetDateFormat(item.ProductionDate), CompletionDate = Utility.GetDateFormat(item.CompletionDate), AddDate = Utility.GetDateFormat(item.AddDate), }); } res.success = true; res.data = list2; res.index = pageIndex; res.count = C.Int(c); res.size = page.PageSize; res.pages = C.Int(c) / page.PageSize + 1; } else { res.success = false; res.statusCode = (int)ApiEnum.Status; } return(await Task.Run(() => res)); }
private DataTable GetTSHoursUtilizationReportDataTable(DataTable dataTable, DateTime periodStart, DateTime periodEnd, List <int> departmentsIDs) { List <Employee> currentEmployeeList = _employeeService.GetCurrentEmployees(new DateTimeRange(periodStart, periodEnd)).ToList() .Where(e => e.Department != null) .OrderBy(e => e.Department.ShortName + (e.Department.DepartmentManagerID != e.ID).ToString() + e.FullName).ToList(); var tsHoursRecordForPeriodList = _tsHoursRecordService.Get(x => x.Where(r => r.RecordDate >= periodStart && r.RecordDate <= periodEnd && r.Project != null && r.Project.ProjectType != null).ToList()); int periodRowStartIndex = dataTable.Rows.Count; var projectTypeUtilizationList = _projectTypeService.Get(x => x.Where(pt => pt.Utilization == true).ToList()); var projectTypeNonUtilizationList = _projectTypeService.Get(x => x.Where(pt => pt.Utilization == false).ToList()); dataTable.Rows.Add(periodStart.ToString("MMMM").ToUpper()); dataTable.Rows[dataTable.Rows.Count - 1]["_ISGROUPROW_"] = true; double hoursPeriodTotal = 0; if (departmentsIDs != null) { foreach (int depID in departmentsIDs) { var employeeInDepartmentIDs = GetEmployeesByDepartmentID(depID, currentEmployeeList.ToList()).Select(e => e.ID); double hoursPeriodInDepartment = Math.Round(tsHoursRecordForPeriodList.Where(r => r.EmployeeID != null && employeeInDepartmentIDs.Contains(r.EmployeeID.Value)) .ToList() .Select(c => c.Hours ?? 0) .DefaultIfEmpty() .Sum(h => h), 2); dataTable.Rows[periodRowStartIndex]["Department_" + depID.ToString()] = hoursPeriodInDepartment; hoursPeriodTotal += hoursPeriodInDepartment; } } dataTable.Rows[periodRowStartIndex]["Total"] = hoursPeriodTotal; periodRowStartIndex = dataTable.Rows.Count - 1; foreach (var group in projectTypeUtilizationList.GroupBy(pt => pt.ActivityType)) { dataTable.Rows.Add("-" + group.FirstOrDefault().ActivityType.GetAttributeOfType <DisplayAttribute>().Name); dataTable.Rows[dataTable.Rows.Count - 1]["_ISGROUPROW_"] = false; foreach (var projectType in group.OrderBy(pt => pt.ShortName)) { dataTable.Rows.Add("--" + projectType.Title); dataTable.Rows[dataTable.Rows.Count - 1]["_ISGROUPROW_"] = false; } } dataTable.Rows.Add("ИТОГО Утилизировано"); dataTable.Rows[dataTable.Rows.Count - 1]["_ISGROUPROW_"] = true; int utilizationRowNum = dataTable.Rows.Count - 1; dataTable = FillDataTableHoursForProjectTypes(dataTable, departmentsIDs, currentEmployeeList, tsHoursRecordForPeriodList, projectTypeUtilizationList, periodRowStartIndex); periodRowStartIndex = dataTable.Rows.Count - 1; foreach (var group in projectTypeNonUtilizationList.GroupBy(pt => pt.ActivityType)) { dataTable.Rows.Add("-" + group.FirstOrDefault().ActivityType.GetAttributeOfType <DisplayAttribute>().Name); dataTable.Rows[dataTable.Rows.Count - 1]["_ISGROUPROW_"] = false; foreach (var projectType in group.OrderBy(pt => pt.ShortName)) { dataTable.Rows.Add("--" + projectType.Title); dataTable.Rows[dataTable.Rows.Count - 1]["_ISGROUPROW_"] = false; } } dataTable.Rows.Add("ИТОГО Не улитизировано"); dataTable.Rows[dataTable.Rows.Count - 1]["_ISGROUPROW_"] = true; int nonUtilizationRowNum = dataTable.Rows.Count - 1; dataTable = FillDataTableHoursForProjectTypes(dataTable, departmentsIDs, currentEmployeeList, tsHoursRecordForPeriodList, projectTypeNonUtilizationList, periodRowStartIndex); dataTable.Rows.Add("ИТОГО Утилизация"); dataTable.Rows[dataTable.Rows.Count - 1]["_ISGROUPROW_"] = true; if (departmentsIDs != null) { foreach (int depID in departmentsIDs) { double hoursUtilization = 0; double hoursNonUtilization = 0; if (dataTable.Rows[utilizationRowNum]["Department_" + depID.ToString()] != null || String.IsNullOrEmpty(dataTable.Rows[utilizationRowNum]["Department_" + depID.ToString()].ToString()) == false) { hoursUtilization = (double)dataTable.Rows[utilizationRowNum]["Department_" + depID.ToString()]; } if (dataTable.Rows[nonUtilizationRowNum]["Department_" + depID.ToString()] != null || String.IsNullOrEmpty(dataTable.Rows[nonUtilizationRowNum]["Department_" + depID.ToString()].ToString()) == false) { hoursNonUtilization = (double)dataTable.Rows[nonUtilizationRowNum]["Department_" + depID.ToString()]; } if ((hoursUtilization + hoursNonUtilization) != 0) { dataTable.Rows[dataTable.Rows.Count - 1]["Department_" + depID.ToString()] = Math.Round(hoursUtilization / (hoursUtilization + hoursNonUtilization), 2); } } } double hoursUtilizationTotal = 0; double hoursNonUtilizationTotal = 0; if (dataTable.Rows[utilizationRowNum]["Total"] != null || String.IsNullOrEmpty(dataTable.Rows[utilizationRowNum]["Total"].ToString()) == false) { hoursUtilizationTotal = (double)dataTable.Rows[utilizationRowNum]["Total"]; } if (dataTable.Rows[nonUtilizationRowNum]["Total"] != null || String.IsNullOrEmpty(dataTable.Rows[nonUtilizationRowNum]["Total"].ToString()) == false) { hoursNonUtilizationTotal = (double)dataTable.Rows[nonUtilizationRowNum]["Total"]; } if ((hoursUtilizationTotal + hoursNonUtilizationTotal) != 0) { dataTable.Rows[dataTable.Rows.Count - 1]["Total"] = Math.Round(hoursUtilizationTotal / (hoursUtilizationTotal + hoursNonUtilizationTotal), 2); } dataTable.Rows.Add(""); return(dataTable); }
public ActionResult Index() { return(View(_projectTypeService.Get(x => x.ToList().OrderBy(pt => pt.ShortName).ToList()))); }