public RequestView(REQUEST request, User submittedBy, User requestedBy, User assignedTo, IList<ElementView> elements, LookupActive requestCategory, SupportArea supportArea, ProjectView project, Program program, ValueDriver valueDriver, LookupSorted requestStatus, LookupActive requestType, decimal? internalHoursMultiplier, decimal? externalHoursMultiplier) : base(request, submittedBy, requestedBy, supportArea, program, valueDriver, requestStatus, requestType, internalHoursMultiplier, externalHoursMultiplier, assignedTo) { this.RequestCategory = requestCategory; this.Parent = project; this.ElementList = elements == null ? new List<ElementView>() : elements; this.Resolution = request.RESOLUTION; this.ITFeatures = request.IT_FEATURE; this.TopOffnetAttributeNumber = request.TOP_OFFNET_ATTRIBUTE_NUMBER; }
public bool Equals(ProjectView pv) { if ((object)pv == null) return false; return this.ID == pv.ID; }
public ProjectView saveProject(RequestView request, DateTime startDate) { if (request.Parent != null && request.Parent.ID != 0) throw new ArgumentException("Request is already part of a project. It cannot be promoted to project."); LookupMgr lookupMgr = new LookupMgr(this.svc); UserMgr userMgr = new UserMgr(MainFactory.getUserSvc()); request.SubmittedBy = (User)userMgr.getUser(request.SubmittedBy.EmployeeID); request.RequestedBy = (User)userMgr.getUser(request.RequestedBy.EmployeeID); request.AssignedTo = (User)userMgr.getUser(request.AssignedTo.EmployeeID); request.Program = lookupMgr.getPrograms().Where(x => x.ID == request.Program.ID).Cast<Program>().FirstOrDefault(); request.RequestCategory = lookupMgr.getRequestCategories(true).Where(x => x.ID == request.RequestCategory.ID).FirstOrDefault(); request.Status = this.requestStatusList.Data.Where(x => x.Text.ToLower().Equals("moved to project")).FirstOrDefault(); request.CType = lookupMgr.getRequestTypes(EOpenType.Request, true).Where(x => x.ID == request.CType.ID).FirstOrDefault(); request.SupportArea = lookupMgr.getSupportAreas().Where(x => x.ID == request.SupportArea.ID).FirstOrDefault(); request.ValueDriver = lookupMgr.getValueDrivers().Where(x => x.ID == request.ValueDriver.ID).Cast<ValueDriver>().FirstOrDefault(); ProjectView project = new ProjectView(request); project.Status = this.projectStatusList.Data.Where(x => x.Text.Equals("Pending")).FirstOrDefault(); project.StartDate = startDate; project.ManagerApprovedDate = DateTime.Today; project = convertProject(this.svc.saveProject(project)); request.Parent = project; request.isNew = false; request.setLastUpdated(); project.RequestList.Add(getRequest(request.ID)); updateRequest(request); // update pointer and status foreach (RequestView rv in this.requestList.Data.ToList()) { if (rv.ID == request.ID) { request.ElementList = rv.ElementList; this.requestList.Data.Remove(rv); } } this.requestList.Data.Add(request); HttpContext.Current.Application.Lock(); HttpContext.Current.Application["Request"] = this.requestList; HttpContext.Current.Application.UnLock(); return project; }
public ProjectView updateProject(ProjectView project) { LookupMgr lookupMgr = new LookupMgr(this.svc); ProjectView oldProject = getProject(project.ID); string status = this.projectStatusList.Data.Where(x => x.ID == project.Status.ID).FirstOrDefault().Text.ToLower(); // check if everything is closed if (status.Equals("complete") && project.Status.ID != oldProject.Status.ID) { foreach (RequestView request in oldProject.RequestList) { if (request.ClosedDate == null) throw new InvalidOperationException("There are still requests open under this project. Please close these manually for accuracy."); } project.setClosed(); } else if ((status.Equals("rejected") || status.Equals("cancelled")) && project.Status.ID != oldProject.Status.ID) project.setClosed(); else if (status.Equals("on hold") && project.Status.ID != oldProject.Status.ID) project.setHoldDate(); else if (oldProject.Status.Text.ToLower().Equals("on hold") && project.Status.ID != oldProject.Status.ID) project.setResumeDate(); // hours are different. update cost if (project.EstimatedHours != project.EstimatedHours) project.EstimatedCost = project.EstimatedHours * project.InternalHoursMultiplier; project.ActualCost = oldProject.RequestList.Sum(x => x.Hours) * project.InternalHoursMultiplier; project.isNew = false; project.setLastUpdated(); ProjectView p = convertProject(this.svc.updateProject(project)); //change project's child request's parent pointer to this foreach (RequestView r in oldProject.RequestList) r.Parent = p; p.RequestList = oldProject.RequestList; HttpContext.Current.Application.Lock(); HttpContext.Current.Application["Request"] = this.requestList; HttpContext.Current.Application.UnLock(); return p; }
private PROJECT convertProject(ProjectView project) { return new PROJECT { SUBMITTED_BY_ID = project.SubmittedBy.EmployeeID, REQUESTED_BY_ID = project.RequestedBy.EmployeeID, PROJECT_TYPE_ID = (short)project.CType.ID, SUPPORT_AREA_ID = (short)project.SupportArea.ID, PROGRAM_ID = project.Program == null ? null : (short?)project.Program.ID, VALUE_DRIVER_ID = (short)project.ValueDriver.ID, PROJECT_STATUS_ID = (byte)project.Status.ID, SUBMITTED_DATE = project.OpenDate, REQUESTED_DUE_DATE = (DateTime)project.RequestedDueDate, ESTIMATED_DUE_DATE = project.EstimatedDueDate, MANAGER_QUEUE_DATE = project.ManagerQueueDate, MANAGER_APPROVED_DATE = project.ManagerApprovedDate, HOLD_DATE = project.HoldDate, RESUME_DATE = project.ResumeDate, CLOSED_DATE = project.ClosedDate, LAST_UPDATED_DATE = project.LastUpdated, ESTIMATED_HOURS = project.EstimatedHours, VALUE = project.Value, ESTIMATED_COST = project.EstimatedCost, ACTUAL_COST = project.ActualCost, PROJECT_SUMMARY = project.Summary, PROJECT_DESCRIPTION = project.Description, VALUE_REASON = project.ValueReason, MANAGER_NOTE = project.ManagerNote, PROJECT_LEAD_ID = project.AssignedTo.EmployeeID, START_DATE = project.StartDate }; }
public PROJECT updateProject(ProjectView project) { try { using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) { PROJECT details = db.PROJECTs.Where(x => x.PROJECT_ID == project.ID).FirstOrDefault(); details.PROJECT_STATUS_ID = (byte)project.Status.ID; details.PROGRAM_ID = project.Program == null ? null : (project.Program.ID > 0 ? (short)project.Program.ID : details.PROGRAM_ID); details.PROJECT_TYPE_ID = (short)project.CType.ID; details.SUPPORT_AREA_ID = (short?)project.SupportArea.ID; details.VALUE_DRIVER_ID = (short)project.ValueDriver.ID; details.ESTIMATED_DUE_DATE = project.EstimatedDueDate; details.ESTIMATED_COST = project.EstimatedCost; details.ESTIMATED_HOURS = project.EstimatedHours; details.ACTUAL_COST = project.ActualCost; details.CLOSED_DATE = project.ClosedDate; db.SubmitChanges(); return details; } } catch (Exception se) { throw new Exception("Unable to update project #" + project.ID + " Due to " + se.Message); } }
public PROJECT saveProject(ProjectView project) { try { PROJECT submittal = convertProject(project); using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) { db.PROJECTs.InsertOnSubmit(submittal); db.SubmitChanges(); return submittal; } } catch (Exception e) { MainFactory.getLogSvc().logError(this.GetType().Name, MainFactory.getCurrentMethod(), "rs-sr-01", e.Message + "\n" + e.StackTrace); throw new Exception("Something terrible has happened."); } throw new Exception("Something terrible has happened. Please notify us if you continue to see these errors."); }
public ReturnGrid(int id, string requestor, string assigned, string category, string type, string area, string summary, DateTime? submitted, DateTime? dueDate, string status, DateTime? closed, decimal hours, ProjectView parent) { this.ID = id; this.Requestor = requestor; this.Assigned = assigned; this.Category = category; this.Type = type; this.Area = area; this.Summary = summary; this.Submitted = submitted; this.DueDate = DueDate; this.Status = status; this.Closed = closed; this.Hours = hours; this.Parent = parent == null ? null : (int?)parent.ID; }
public ActionResult updateProject(ProjectView projectView) { ProjectView project = null; if (projectView != null) { try { RequestMgr requestMgr = new RequestMgr(ConsoleFactory.getRequestSvc()); project = requestMgr.updateProject(projectView); TempData["error"] = "Update Successful"; TempData["valid"] = true; return RedirectToAction("Project", "Console", new { id = project.ID }); } catch (Exception e) { project = projectView; project.isNew = false; TempData["error"] = e.Message; TempData["valid"] = false; return RedirectToAction("Project", "Console", new { id = projectView.ID }); } } return Dashboard(null, null); }