示例#1
0
        public ARequestView createRequest(ARequestView request)
        {
            if (request.GetType() == typeof(RequestView)) {
                LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
                UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
                int defaultID = Int32.Parse((string)MainFactory.getConfiguration().get("BIManagerID"));
                int supportID = lookupMgr.getSupportAreas().Where(x => x.ID == ((RequestView)request).SupportArea.ID).FirstOrDefault().DeveloperID ?? defaultID;
                if (((RequestView)request).CType.ID == 3 || ((RequestView)request).CType.ID == 7)
                    supportID = lookupMgr.getSupportAreas().Where(x => x.ID == ((RequestView)request).SupportArea.ID).FirstOrDefault().SupportID ?? defaultID;

                // auto select program based off support area.
                ((RequestView)request).Program = lookupMgr.getPrograms().Where(x => x.ID == this.svc.getProgramFromSupportArea(((RequestView)request).SupportArea.ID)).Cast<Program>().FirstOrDefault();

                ((RequestView)request).AssignedTo = (User)userMgr.getUser(supportID);
                request.setLastUpdated();
                RequestView requestView = (RequestView)request;
                if (((RequestView)request).AssignedTo.EmployeeID != defaultID)
                    requestView = (RequestView)this.setStatusID((AProjectView)request, 2);
                else
                    requestView = (RequestView)this.setStatusID((AProjectView)request, 1);

                Configuration config = MainFactory.getConfiguration();
                if (((RequestView)request).ValueDriver.ID != 1)
                    ((RequestView)request).Value = ((RequestView)request).Value * Decimal.Parse((string)config.get("HoursCostMultiplierExternal"));

                requestView = convertRequest(this.svc.saveRequest(requestView));

                this.requestList.Data.Add(requestView);
                HttpContext.Current.Application.Lock();
                HttpContext.Current.Application["Request"] = this.requestList;
                HttpContext.Current.Application.UnLock();
                return requestView;
            }
            throw new NotSupportedException("Cannot createa a request that is not a project or a request type at this time.");
        }
示例#2
0
        public void setValueDriver(int id, int value)
        {
            RequestMgr requestMgr = new RequestMgr(ConsoleFactory.getRequestSvc());
            LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
            RequestView request = requestMgr.getRequest(id);

            // throw exception if bad request id
            if (request == null) {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.BadRequest) {
                    Content = new StringContent(string.Format(" No Request with ID = {0}", id)),
                    ReasonPhrase = "Request ID Not Found"
                };
                throw new HttpResponseException(response);
            }

            ValueDriver valueDriver = (ValueDriver)lookupMgr.getValueDrivers().Where(x => x.ID == value);
            // throw exception if bad requestType ID
            if (valueDriver == null) {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.BadRequest) {
                    Content = new StringContent(string.Format(" No Value Driver with ID = {0}", id)),
                    ReasonPhrase = "Request Type Not Found"
                };
                throw new HttpResponseException(response);
            }

            request.ValueDriver = valueDriver;
            requestMgr.updateRequest(request);
        }
示例#3
0
        public void setSupportArea(int id, int value)
        {
            RequestMgr requestMgr = new RequestMgr(ConsoleFactory.getRequestSvc());
            LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
            RequestView request = requestMgr.getRequest(id);

            // throw exception if bad request id
            if (request == null) {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.BadRequest) {
                    Content = new StringContent(string.Format(" No Request with ID = {0}", id)),
                    ReasonPhrase = "Request ID Not Found"
                };
                throw new HttpResponseException(response);
            }

            SupportArea supportArea = lookupMgr.getSupportAreas().Where(x => x.ID == value).FirstOrDefault();
            // throw exception if bad requestType ID
            if (supportArea == null) {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.BadRequest) {
                    Content = new StringContent(string.Format(" No Support Area with ID = {0}", id)),
                    ReasonPhrase = "Request Type Not Found"
                };
                throw new HttpResponseException(response);
            }

            request.SupportArea = supportArea;
            requestMgr.updateRequest(request);
        }
示例#4
0
        private RequestView convertRequest(REQUEST request)
        {
            UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
            LookupMgr lookupMgr = new LookupMgr(this.svc);
            Configuration config = MainFactory.getConfiguration();
            RequestView r = new RequestView(request,
                                    (User)userMgr.getUser(request.SUBMITTED_BY_ID),
                                    (User)userMgr.getUser(request.REQUESTED_BY_ID),
                                    (User)userMgr.getUser((int)request.ASSIGNED_TO_ID),
                                    null,
                                    lookupMgr.getRequestCategories(false).Where(x => x.ID == request.REQUEST_CATEGORY_ID).FirstOrDefault(),
                                    lookupMgr.getSupportAreas().Where(x => x.ID == request.SUPPORT_AREA_ID).FirstOrDefault(),
                                    null,
                                    lookupMgr.getPrograms().Where(x => x.ID == request.PROGRAM_ID).Cast<Program>().FirstOrDefault(),
                                    lookupMgr.getValueDrivers().Where(x => x.ID == request.VALUE_DRIVER_ID).Cast<ValueDriver>().FirstOrDefault(),
                                    this.requestStatusList.Data.Where(x => x.ID == request.REQUEST_STATUS_ID).FirstOrDefault(),
                                    lookupMgr.getRequestTypes(EOpenType.Request, false).Where(x => x.ID == request.REQUEST_TYPE_ID).FirstOrDefault(),
                                    Decimal.Parse((string)config.get("HoursCostMultiplierInternal")),
                                    Decimal.Parse((string)config.get("HoursCostMultiplierExternal")));

            return r;
        }
示例#5
0
 private ProjectView convertProject(PROJECT project)
 {
     UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
     LookupMgr lookupMgr = new LookupMgr(this.svc);
     Configuration config = MainFactory.getConfiguration();
     return new ProjectView(project,
                 (User)userMgr.getUser(project.SUBMITTED_BY_ID),
                 (User)userMgr.getUser(project.REQUESTED_BY_ID),
                 null,
                 lookupMgr.getSupportAreas().Where(x => x.ID == project.SUPPORT_AREA_ID).FirstOrDefault(),
                 lookupMgr.getPrograms().Where(x => x.ID == project.PROGRAM_ID).Cast<Program>().FirstOrDefault(),
                 lookupMgr.getValueDrivers().Where(x => x.ID == project.VALUE_DRIVER_ID).Cast<ValueDriver>().FirstOrDefault(),
                 this.projectStatusList.Data.Where(x => x.ID == project.PROJECT_STATUS_ID).FirstOrDefault(),
                 lookupMgr.getRequestTypes(EOpenType.Project, false).Where(x => x.ID == project.PROJECT_TYPE_ID).FirstOrDefault(),
                 Decimal.Parse((string)config.get("HoursCostMultiplierInternal")),
                 Decimal.Parse((string)config.get("HoursCostMultiplierExternal")),
                 (User)userMgr.getUser(project.PROJECT_LEAD_ID ?? 0));
 }
示例#6
0
        public RequestView updateRequest(RequestView request)
        {
            LookupMgr lookupMgr = new LookupMgr(this.svc);
            RequestView oldRequest = getRequest(request.ID);

            string from = (string)MainFactory.getConfiguration().get(CONFIG_EMAIL);

            if (request.EstimatedDueDate == null)
                throw new ArgumentException("Estimated Due Date cannot be empty.");

            string status = this.requestStatusList.Data.Where(x => x.ID == request.Status.ID).FirstOrDefault().Text.ToLower();
            request.Status.Text = status;
            // update elements
            if (status.Equals("complete") && request.Status.ID != oldRequest.Status.ID) {
                if (request.Resolution == null || request.Resolution.Length < 1)
                    throw new ArgumentException("You are closing this request. Please provide a resolution.");
                foreach (ElementView element in oldRequest.ElementList.ToList()) {
                    if (element.ClosedDate == null) {
                        if (!element.AssignedTo.Equals(request.AssignedTo))
                            throw new InvalidOperationException("There are elements that are not assigned to you. You cannot close this request until these elements are closed manually.");

                        element.PercentComplete = 100;
                        element.Resolution = "AutoStamp: " + request.Resolution;
                        element.Status = this.elementStatusList.Data.Where(x => x.Text.Equals("Complete")).FirstOrDefault();
                        updateElement(element, true);
                    }
                }
                request.setClosed();
                EmailSvc.Email(from,
                                request.RequestedBy.EmailAddress,
                                "",
                                "Request " + request.ID + " - " + request.Summary + " has been completed",
                                ConsoleFactory.requestEmailSubmitterStatusChange(request));
            } else if ((status.Equals("rejected") || status.Equals("cancelled")) && request.Status.ID != oldRequest.Status.ID) {
                if (request.Resolution == null || request.Resolution.Length < 1)
                    throw new ArgumentException("You are closing this request. Please provide a resolution.");
                request.setClosed();
                EmailSvc.Email(from,
                                request.RequestedBy.EmailAddress,
                                "",
                                "Request " + request.ID + " - " + request.Summary + " has been " + request.Resolution + ".",
                                ConsoleFactory.requestEmailSubmitterStatusChange(request));
            } else if (status.Equals("on hold") && request.Status.ID != oldRequest.Status.ID)
                request.setHoldDate();
            else if (oldRequest.Status.Text.ToLower().Equals("on hold") && request.Status.ID != oldRequest.Status.ID)
                request.setResumeDate();
            else if (status.Equals("moved to project") && request.Status.ID != oldRequest.Status.ID) {
                UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());

                if (request.EstimatedHours == null || request.EstimatedHours <= 0)
                    throw new ArgumentException("Request must have estimated hours before being requested for promotion.");

                EmailSvc.Email(from,
                                userMgr.getUser(Int32.Parse((string)MainFactory.getConfiguration().get("BIManagerID"))).EmailAddress,
                                "",
                                "Request " + request.ID + " - " + request.Summary + " has been updated",
                                ConsoleFactory.requestEmailPromoteBody(request));
                request.ManagerQueueDate = DateTime.Today;
            }

            // hours are different. update cost
            if (request.EstimatedHours != oldRequest.EstimatedHours)
                request.EstimatedCost = request.EstimatedHours * request.InternalHoursMultiplier;

            request.ActualCost = oldRequest.ElementList.Sum(x => x.Hours) * request.InternalHoursMultiplier;
            request.isNew = false;
            request.setLastUpdated();

            RequestView r = convertRequest(this.svc.updateRequest(request));

            //change oldRequest's child Element's parent pointer to this
            foreach (ElementView e in oldRequest.ElementList)
                e.Parent = r;

            r.ElementList = oldRequest.ElementList;

            // change Parent's pointer to this
            if (r.Parent != null) {
                r.Parent.RequestList.Remove(r);
                r.Parent.RequestList.Add(r);
            }

            // if a u parent was added in this update.
            if (r.Parent == null && request.Parent != null && request.Parent.ID != 0) {
                foreach (RequestView rv in this.requestList.Data)
                    if (rv.Parent != null && rv.Parent.ID == request.Parent.ID) {
                        r.Parent = rv.Parent;
                        r.Parent.RequestList.Add(r);
                        break;
                    }
            }

            // change the pointer in the requestList to point to this object
            foreach (RequestView rv in this.requestList.Data.ToList())
                if (rv.ID == request.ID)
                    this.requestList.Data.Remove(rv);
            this.requestList.Data.Add(r);

            HttpContext.Current.Application.Lock();
            HttpContext.Current.Application["Request"] = this.requestList;
            HttpContext.Current.Application.UnLock();
            return r;
        }
示例#7
0
        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;
        }
示例#8
0
        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;
        }
示例#9
0
 public ContentResult RequestTypes(bool? activeOnly)
 {
     bool active = activeOnly == null ? false : (bool)activeOnly;
     LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
     return Jsonify<IList<LookupActive>>.Serialize(lookupMgr.getRequestTypes(EOpenType.Request, active));
 }
示例#10
0
 public ContentResult ValueDrivers()
 {
     LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
     return Jsonify<IList<ALookup>>.Serialize(lookupMgr.getValueDrivers());
 }
示例#11
0
 public ContentResult RequestAreas()
 {
     LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
     return Jsonify<IList<ILookup>>.Serialize(lookupMgr.getSupportAreas().Cast<ILookup>().ToList());
 }
示例#12
0
 public ContentResult Employees(string input, bool? activeOnly)
 {
     bool active = activeOnly == null ? false : (bool)activeOnly;
     LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
     return Jsonify<IList<IUser>>.Serialize(lookupMgr.getEmployees(input, active));
 }
示例#13
0
        private RequestView submitRequest(NewRequestModel request)
        {
            UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
            LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
            RequestView submittal = new RequestView();
            submittal.RequestedBy = (User)userMgr.getUser(request.RequestBy);
            submittal.SubmittedBy = (User)userMgr.getUser(request.SubmittedBy);
            submittal.SupportArea = lookupMgr.getSupportAreas().Where(x => x.ID == request.SupportAreaID).FirstOrDefault();
            submittal.CType = lookupMgr.getRequestTypes(EOpenType.Request, true).Where(x => x.ID == request.TypeID).FirstOrDefault();
            submittal.RequestCategory = lookupMgr.getRequestCategories(true).Where(x => x.ID == request.RequestCategory).FirstOrDefault();
            submittal.RequestedDueDate = request.RequestedDueDate;
            submittal.Summary = request.RequestSummary;
            submittal.Description = request.RequestDescription;
            submittal.ValueDriver = lookupMgr.getValueDrivers().Where(x => x.ID == request.ValueDriverID).Cast<ValueDriver>().FirstOrDefault();
            submittal.Value = request.Value;
            submittal.ValueReason = request.ValueReason;

            RequestMgr requestMgr = new RequestMgr(ConsoleFactory.getRequestSvc());
            RequestView r = (RequestView)requestMgr.createRequest(submittal);
            addToNewRequests(r);
            return r;
        }
示例#14
0
        public new ActionResult Request(int? type = null)
        {
            int? id = type;
            if (id == null)
                throw new HttpException(404, "Not Found");

            RequestMgr requestMgr = new RequestMgr(ConsoleFactory.getRequestSvc());
            LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
            EmployeeMgr employeeMgr = new EmployeeMgr(ConsoleFactory.getEmployeeSvc());
            RequestView request = requestMgr.getRequest((int)id);
            if (request == null)
                throw new HttpException(404, "Not Found");

            ViewData["statusList"] = requestMgr.getStatusList(EOpenType.Request);
            ViewData["programList"] = lookupMgr.getPrograms();
            ViewData["typeList"] = lookupMgr.getRequestTypes(EOpenType.Request, false);
            ViewData["supportArea"] = lookupMgr.getSupportAreas();
            ViewData["valueDriver"] = lookupMgr.getValueDrivers();
            IList<IEmployee> admin = employeeMgr.getAdminList();
            ViewData["assignedTo"] = employeeMgr.getAdminList();
            ViewData["requestCategory"] = lookupMgr.getRequestCategories(false);
            ViewData["project"] = requestMgr.getProjects();

            ViewBag.Message = "Request #" + request.ID;
            ViewData["type"] = EOpenType.Request;
            ViewData["error"] = TempData["error"] ?? "";
            ViewData["isValidated"] = TempData["valid"] ?? true;
            ViewData["user"] = (IUser)Session["User"];
            return View("FullView", request);
        }
示例#15
0
        public ActionResult Project(int? type = null)
        {
            int? id = type;
            if (id == null)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            RequestMgr requestMgr = new RequestMgr(ConsoleFactory.getRequestSvc());
            LookupMgr lookupMgr = new LookupMgr(ConsoleFactory.getRequestSvc());
            ProjectView project = requestMgr.getProject((int)id);

            ViewData["statusList"] = requestMgr.getStatusList(EOpenType.Project);
            ViewData["programList"] = lookupMgr.getPrograms();
            ViewData["typeList"] = lookupMgr.getRequestTypes(EOpenType.Project, false);
            ViewData["supportArea"] = lookupMgr.getSupportAreas();
            ViewData["valueDriver"] = lookupMgr.getValueDrivers();

            ViewData["type"] = EOpenType.Project;
            ViewData["user"] = (IUser)Session["User"];
            ViewData["isValidated"] = TempData["valid"] ?? true;
            ViewData["error"] = TempData["error"] ?? "";
            ViewBag.Message = "Project #" + project.ID;
            if (project == null)
                return Dashboard(null, null);
            return View("FullView", project);
        }