Esempio n. 1
0
        public ActionResult ProjSummary(int id)
        {
            var projSummary = new ProjectSummary();

            if (id != 0)
            {
                var lead = db.leads.Where(l => l.lead_number == id).First();

                if (lead != null)
                {
                    // only recalculate if lead is not close
                    if (!lead.project_status.project_status_name.Equals(Constants.proj_Status_Closed, StringComparison.OrdinalIgnoreCase))
                    {
                        new GeneralHelper().SaveProjectTotal(lead.lead_number);
                    }

                    lead = db.leads.Where(l => l.lead_number == id).First();
                    ProjSummaryHelper projSummaryHelper = new ProjSummaryHelper();
                    if (db.total_cost.Where(c => c.lead_number == id).Any())
                    {
                        projSummary.TotalCost = db.total_cost.Where(c => c.lead_number == id).First();
                    }
                    projSummary      = projSummaryHelper.CalculateInstallCategoryCostMap(lead, projSummary);
                    projSummary      = projSummaryHelper.CalculateInstallationsData(lead, projSummary);
                    projSummary      = projSummaryHelper.GetProductCategoryList(lead, projSummary);
                    projSummary      = projSummaryHelper.GetProductTotalMap(lead, projSummary);
                    projSummary      = projSummaryHelper.SetCustomerData(lead, projSummary);
                    projSummary      = projSummaryHelper.SetAddresses(lead, projSummary);
                    projSummary.Lead = lead;
                }
            }

            return(View(projSummary));
        }
Esempio n. 2
0
        public ProjectSummary GetProductCategoryList(lead lead, ProjectSummary projectSummary)
        {
            projectSummary.ProductMapList1 = this.GetProductMapList(Constants.catDefList1, lead);
            projectSummary.ProductMapList2 = this.GetProductMapList(Constants.catDefList2, lead);

            return(projectSummary);
        }
Esempio n. 3
0
        public async void CreateAProject_NullLocationCheck_ReturnBadRequestException()
        {
            var errMessage            = "Bad Request";
            LocationResource location = null;
            var summary = new ProjectSummary {
                Title            = "",
                Location         = location,
                ProjectStartDate = new System.DateTime(),
                ProjectEndDate   = new System.DateTime(),
                ProjectNumber    = "test"
            };
            var manager = new ProjectManager {
                UserID    = "1",
                FirstName = "",
                LastName  = ""
            };
            var profile = new ProjectProfile {
                ProjectSummary = summary,
                ProjectManager = manager,
                UsersSummary   = Enumerable.Empty <UserSummary>(),
                Openings       = Enumerable.Empty <OpeningPositionsSummary>()
            };

            var result = (await _controller.CreateAProject(profile)) as ObjectResult;

            Assert.Equal(StatusCodes.Status400BadRequest, result.StatusCode);
            Assert.IsType <BadRequestException>(result.Value);
            var response = result.Value as BadRequestException;

            Assert.Equal(errMessage, response.status);
        }
Esempio n. 4
0
        private async Task <int> CreateAProject(
            SqlConnection connection, int locationId,
            ProjectSummary projectSummary, ProjectManager projectManager
            )
        {
            var sql = @"
                INSERT INTO Projects 
                    ([Number], [Title], [LocationId], [ManagerId], [ProjectStartDate], [ProjectEndDate])
                VALUES 
                    (@Number, @Title, @LocationId, @ManagerId, @ProjectStartDate, @ProjectEndDate);
                SELECT CAST(scope_identity() as int);
            ;";

            connection.Open();
            var createdProjectId = await connection.QuerySingleAsync <int>(sql, new
            {
                Number           = projectSummary.ProjectNumber,
                Title            = projectSummary.Title,
                LocationId       = locationId,
                ManagerId        = projectManager.UserID,
                ProjectStartDate = projectSummary.ProjectStartDate,
                ProjectEndDate   = projectSummary.ProjectEndDate
            });

            connection.Close();

            return(createdProjectId);
        }
Esempio n. 5
0
        public async Task <ProjectSummary> GetSummary(string organization,
                                                      string project,
                                                      string repositoryFilter = null,
                                                      DateTime?startDate      = null)
        {
            var repositories = await _azureDevopsService.GetRepositories(organization, project);

            var filteredRepositories = FilterRepositories(repositories, repositoryFilter);

            var componentTasks = filteredRepositories
                                 .Select(r => ProcessComponent(r, organization, project, startDate))
                                 .ToList();
            var components = await Task.WhenAll(componentTasks);

            var result = new ProjectSummary
            {
                Organization     = organization,
                Project          = project,
                RepositoryFilter = repositoryFilter,
                StartDate        = startDate,
                Components       = components
            };

            return(result);
        }
 private void SumEntity(ProjectSummary item, IList projectTasks)
 {
     item.SumQuoteWorkHours  = projectTasks.AsQueryable().Select("QuoteWorkHours").Cast <double?>().Sum() ?? 0;
     item.SumActualWorkHours = projectTasks.AsQueryable().Select("ActualWorkHours").Cast <double?>().Sum() ?? 0;
     item.SumActualInput     = projectTasks.AsQueryable().Select("ActualInput").Cast <double?>().Sum() ?? 0;
     item.SumEffort          = projectTasks.AsQueryable().Select("Effort").Cast <double?>().Sum() ?? 0;
     item.SumOvertime        = projectTasks.AsQueryable().Select("Overtime").Cast <double?>().Sum() ?? 0;
     item.SumRemainderTime   = item.SumActualWorkHours - item.SumEffort;
     if (item.SumActualInput > 0)
     {
         item.SumInputEffortRate = item.SumEffort / item.SumActualInput;
         item.SumInputEffortRate = double.Parse(item.SumInputEffortRate.ToString("0.00"));
     }
     else
     {
         item.SumActualInput = 0d;
     }
     if (item.SumActualWorkHours > 0)
     {
         item.SumEvaluateExactlyRate = item.SumQuoteWorkHours / item.SumActualWorkHours;
         item.SumEvaluateExactlyRate = double.Parse(item.SumEvaluateExactlyRate.ToString("0.00"));
     }
     else
     {
         item.SumActualWorkHours = 0d;
     }
 }
        private void BindIterationGrid(IList projectTasks, IList projectIterations, BindResult bindResult)
        {
            IList taskIterationList = projectTasks.AsQueryable().Where("ProjectIterationId != null").Select("ProjectIterationId").Cast <Guid>().Distinct().ToArrayList();
            List <ProjectSummary> IterationSummaryList = new List <ProjectSummary>();
            var displayNameFormat = "{0} ({1:yy/MM/dd} - {2:yy/MM/dd})";

            foreach (var iterationId in taskIterationList)
            {
                IList iterationList     = projectIterations.AsQueryable().Where("ProjectIterationId=@0", iterationId).ToArrayList();
                IList iterationNameList = iterationList.AsQueryable().Select("Name").Cast <string>().ToArrayList();
                if (iterationNameList.Count <= 0)
                {
                    continue;
                }
                ProjectSummary iterationItem = new ProjectSummary();
                iterationItem.Name = iterationNameList[0].ToString();
                IList taskList = projectTasks.AsQueryable().Where("ProjectIterationId=@0", iterationId).ToArrayList();
                SumEntity(iterationItem, taskList);
                iterationItem.Id = (Guid)iterationId;
                var iteration = ConvertData.Convert <Katrin.Domain.Impl.ProjectIteration>(iterationList[0]);
                iterationItem.NameAndDate = string.Format(displayNameFormat, iterationItem.Name, iteration.StartDate, iteration.Deadline);
                iterationItem.StartDate   = iteration.StartDate ?? DateTime.Today;
                IterationSummaryList.Add(iterationItem);
            }
            IterationSummaryList            = IterationSummaryList.AsQueryable().OrderBy("StartDate desc ").ToList();
            bindResult.IterationSummaryList = IterationSummaryList;
        }
Esempio n. 8
0
        public ActionResult Index(int?id, int?reportID)
        {
            if (Session["UserID"] != null)
            {
                var viewModel = new ProjectSummary();
                viewModel.Projects = db.Projects
                                     .Include(i => i.Reports)
                                     .OrderBy(i => i.ProjectName);

                if (id != null)
                {
                    ViewBag.ProjectID = id.Value;
                    viewModel.Reports = viewModel.Projects.Where(i => i.ProjectID == id.Value).Single().Reports;
                }

                if (reportID != null)
                {
                    ViewBag.ReportID = reportID.Value;
                    var selectedReport = viewModel.Reports.Where(x => x.ReportID == reportID).Single();
                    db.Entry(selectedReport).Collection(x => x.Opinions).Load();
                    foreach (Opinion opinion in selectedReport.Opinions)
                    {
                        db.Entry(opinion).Reference(x => x.User).Load();
                    }
                    viewModel.Opinions = selectedReport.Opinions;
                }
                //return View(db.Projects.ToList());
                return(View(viewModel));
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
Esempio n. 9
0
        public IList <ProjectSummary> GetProjectSprintDetails(int projectId, int WeekId)
        {
            //Fetch the weekid  for week master table
            int weekId = _genericService.GetWeekIdFromMasterTable(WeekId, DateTime.Now.Year);

            var currentWeek   = _genericService.GetWeek(DateTime.Now.GetPreviousWeek());
            int currentWeekId = _genericService.GetWeekIdFromMasterTable(currentWeek, DateTime.Now.Year);

            var projectSummary = this.context.Query <ProjectSummary>().Where(p => p.ProjectId == projectId && p.IsActive == true).ToList();

            if (weekId != 0)
            {
                projectSummary = projectSummary.Where(p => p.WeekId == weekId).ToList();
            }

            if (projectSummary.Count() == 0)
            {
                if (weekId >= currentWeekId)
                {
                    ProjectSummary prevWeekData = this.context.Query <ProjectSummary>().Where(p => p.ProjectId == projectId && p.IsActive == true).OrderByDescending(p => p.WeekId).FirstOrDefault();
                    if (prevWeekData != null)
                    {
                        projectSummary = this.context.Query <ProjectSummary>().Where(p => p.ProjectId == projectId && p.IsActive == true && p.WeekId == prevWeekData.WeekId).OrderByDescending(p => p.WeekId).ToList();
                        foreach (var item in projectSummary)
                        {
                            item.ProjectSummaryId = 0;
                        }
                    }
                }
            }

            return(projectSummary);
        }
Esempio n. 10
0
        public ActionResult DeleteConfirmed(long id)
        {
            ProjectSummary projectSummary = db.ProjectSummary.Find(id);

            db.ProjectSummary.Remove(projectSummary);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 11
0
 public ActionResult Edit([Bind(Include = "GrantId,Organisation,ProjectTitle,Country,RequestedAmount,ProjectDuration,Theme,ApplicationDate,IsAnonymousGrant,AnnonymousReason")] ProjectSummary projectSummary)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projectSummary).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(projectSummary));
 }
Esempio n. 12
0
        private void StepInto()
        {
            ProjectSummary ps = this.ProjectSummaryListBox.SelectedItem as ProjectSummary;

            if (ps == null)
            {
                return;
            }

            this.StepIntoRequested?.Invoke(this, new StepIntoRequestedEventArgs(ps.ProjectBuild));
        }
Esempio n. 13
0
        public ActionResult LoadSummary(Guid id)
        {
            var            project = ProjectManager.GetById(id);
            var            issues  = ProjectManager.GetIssues(id).ToList();
            ProjectSummary summary = new ProjectSummary(project, issues);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("Projects/_Summary", summary));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 14
0
        public bool Exists(ProjectSummary summary)
        {
            foreach (var item in Summaries)
            {
                if (item.PlantOrder?.Id == summary.PlantOrder?.Id)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 15
0
        //Used by Ajax to delete the ProjectSummary. Returns a Partial View to update the User Interface.
        public PartialViewResult Delete(int id)
        {
            User           loggedUser     = UserHelper.GetUser();
            ProjectSummary projectSummary = db.ProjectSummary.Find(id);

            if (projectSummary != null)
            {
                db.ProjectSummary.Remove(projectSummary);
                db.SaveChanges();
            }
            var projectSummaries = db.ProjectSummary.Where(p => p.ProjectID == projectSummary.ProjectID).Where(u => u.UserID == loggedUser.UserID).Include(p => p.User);

            return(PartialView("~/Views/ProjectSummary/_PartialProjectSummaryList.cshtml", projectSummaries));
        }
        private void BindSummaryData()
        {
            var prjectId = Guid.Empty;

            if (_chartView == null)
            {
                return;
            }
            if (_chartView.Context.CurrentObject != null)
            {
                prjectId = ConvertData.Convert <Katrin.Domain.Impl.Project>(_chartView.Context.CurrentObject).ProjectId;
            }

            var worker = new BackgroundWorker();

            worker.WorkerSupportsCancellation = true;
            worker.DoWork += (s, ex) =>
            {
                var entity = (Katrin.Domain.Impl.Project)_objectSpace.GetOrNew("Project", prjectId, "Manager,SaleService,ProjectTasks,ProjectIterations");

                ProjectSummary projectSummaryEntity = new ProjectSummary();
                var            projectTasks         = entity.ProjectTasks.ToList();
                projectTasks = projectTasks.Where(c => c.IsDeleted == false).ToList();
                SumEntity(projectSummaryEntity, projectTasks);

                //
                Type entityType      = entity.GetType();
                Type listGenericType = typeof(List <>);
                Type listType        = listGenericType.MakeGenericType(entityType);
                var  list            = (IList)Activator.CreateInstance(listType);
                list.Add(entity);
                BindResult bindResult = new BindResult();
                bindResult.ProjectEntity        = list;
                bindResult.projectSummaryEntity = new List <ProjectSummary>()
                {
                    projectSummaryEntity
                };


                BindMemberGrid(projectTasks, bindResult);

                IList projectIterations = entity.ProjectIterations.ToList();
                BindIterationGrid(projectTasks, projectIterations, bindResult);

                BindIterationScheduler(projectTasks, projectIterations, bindResult);
                ex.Result = bindResult;
            };
            worker.RunWorkerCompleted += WorkerRunWorkerCompleted;
            worker.RunWorkerAsync();
        }
Esempio n. 17
0
        // GET: ProjectSummaries/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProjectSummary projectSummary = db.ProjectSummary.Find(id);

            if (projectSummary == null)
            {
                return(HttpNotFound());
            }
            return(View(projectSummary));
        }
Esempio n. 18
0
        /// <summary>
        /// Converts a <see cref="ProjectStatus"/> to a model.
        /// </summary>
        /// <param name="projectStatus">The project status.</param>
        /// <returns>
        /// The new <see cref="ProjectSummary"/>.
        /// </returns>
        public static ProjectSummary ToModel(this ProjectStatus projectStatus)
        {
            // These properties are always needed
            var model = new ProjectSummary
            {
                Name        = projectStatus.Name,
                BuildStage  = projectStatus.BuildStage.Length == 0 ? null : projectStatus.BuildStage,
                Status      = Convert(projectStatus.Status),
                BuildStatus = Convert(projectStatus.BuildStatus),
                Times       = new ProjectSummaryTimes
                {
                    LastRun = projectStatus.LastBuildDate
                },
                Messages = projectStatus.Messages.Length == 0 ? null : projectStatus.Messages.Select(m => m.ToModel()).ToArray()
            };

            // Activity is only valid if the project is running
            model.Activity = projectStatus.Status == ProjectIntegratorState.Running
                ? Convert(projectStatus.Activity)
                : ProjectSummaryActivity.NotRunning;

            // Only add the next run time if we are waiting
            if ((projectStatus.Status == ProjectIntegratorState.Running) && projectStatus.Activity.IsSleeping())
            {
                model.Times.NextRun = projectStatus.NextBuildTime;
            }

            // Work out which labels are needed
            var hasLastBuild           = !string.IsNullOrWhiteSpace(projectStatus.LastBuildLabel);
            var hasLastSuccessfulBuild = !string.IsNullOrWhiteSpace(projectStatus.LastSuccessfulBuildLabel) &&
                                         (projectStatus.BuildStatus != IntegrationStatus.Success);

            if (hasLastBuild || hasLastSuccessfulBuild)
            {
                model.Labels = new ProjectSummaryLabels();
                if (hasLastBuild)
                {
                    model.Labels.Last = projectStatus.LastBuildLabel;
                }

                // Only set the last successful if it is different from the last build (and we are not in a success state)
                if (hasLastSuccessfulBuild && (projectStatus.LastBuildLabel != projectStatus.LastSuccessfulBuildLabel))
                {
                    model.Labels.LastSuccessful = projectStatus.LastSuccessfulBuildLabel;
                }
            }

            return(model);
        }
Esempio n. 19
0
        public AllProjectsPage()
        {
            InitializeComponent();

            var project = new ProjectSummary
            {
                Name        = "Test",
                Description = "FooBar this is a description"
            };

            _ViewModel = new ProjectSummaryViewModel();
            _ViewModel.DataStore.AddItemAsync(project).Wait();
            _ViewModel.DisplayErrorHandler = DisplayError;
            BindingContext = _ViewModel;
        }
Esempio n. 20
0
        public ProjectSummary CalculateProposalAmtDue(int id, ProjectSummary projSummary)
        {
            var totalCost = db.total_cost.Where(c => c.lead_number == id).FirstOrDefault();

            if (totalCost != null)
            {
                projSummary.TotalCost            = totalCost;
                projSummary.TotalAmt             = ((double)totalCost.total_cost1).ToString("C", CultureInfo.CurrentCulture);
                projSummary.AmtDueAtSignProposal = ((double)totalCost.total_cost1 * 0.5).ToString("C", CultureInfo.CurrentCulture);
                projSummary.AmtDueUponStartWork  = ((double)totalCost.total_cost1 * 0.4).ToString("C", CultureInfo.CurrentCulture);
                projSummary.AmtDueUponCompletion = ((double)totalCost.total_cost1 * 0.1).ToString("C", CultureInfo.CurrentCulture);
            }

            return(projSummary);
        }
Esempio n. 21
0
        public PartialViewResult Create([Bind(Include = "NoOfTasks,NoOfTasksInProgress,NoOfTasksNotStarted,NoOfCompletedTasks,ProjectID,UserID")] ProjectSummary projectSummary)
        {
            User loggedUser = UserHelper.GetUser();

            if (ModelState.IsValid)
            {
                projectSummary.UserID     = loggedUser.UserID;
                projectSummary.ReportDate = DateTime.Now;
                db.ProjectSummary.Add(projectSummary);
                db.SaveChanges();
            }

            var projectSummaries = db.ProjectSummary.Where(p => p.ProjectID == projectSummary.ProjectID).Where(u => u.UserID == loggedUser.UserID).Include(p => p.User);

            return(PartialView("~/Views/ProjectSummary/_PartialProjectSummaryList.cshtml", projectSummaries));
        }
Esempio n. 22
0
        //Used to load the Project Summary Report from the database to view Historic Summaries.
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProjectSummary projectSummary = db.ProjectSummary.Find(id);

            if (projectSummary == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ReportDate = projectSummary.ReportDate;
            ViewBag.ProjectId  = projectSummary.ProjectID;
            int NoOfTasks          = projectSummary.NoOfTasks;
            int NoOfCompletedTasks = projectSummary.NoOfCompletedTasks;

            ViewBag.percNoOfCompletedTasks = CalculationPercentage(NoOfCompletedTasks, NoOfTasks);

            int NoOfTasksInProgress = projectSummary.NoOfTasksInProgress;

            ViewBag.percNoOfTasksInProgress = CalculationPercentage(NoOfTasksInProgress, NoOfTasks);

            int NoOfTasksNotStarted = projectSummary.NoOfTasksNotStarted;

            ViewBag.percNoOfTasksNotStarted = CalculationPercentage(NoOfTasksNotStarted, NoOfTasks);

            Project project = db.Projects.Find(projectSummary.ProjectID);

            ViewBag.projectName = project.ProjectName;

            User loggedUser       = UserHelper.GetUser();
            var  projectSummaries = db.ProjectSummary.Where(p => p.ProjectID == projectSummary.ProjectID).Where(u => u.UserID == loggedUser.UserID).Include(p => p.User);

            ViewBag.projectSummaries = projectSummaries;

            ProjectSummary ps = new ProjectSummary
            {
                NoOfTasks           = NoOfTasks,
                NoOfTasksInProgress = NoOfTasksInProgress,
                NoOfTasksNotStarted = NoOfTasksNotStarted,
                NoOfCompletedTasks  = NoOfCompletedTasks,
                ProjectID           = projectSummary.ProjectID
            };

            return(View("ProjectSummary", ps));
        }
Esempio n. 23
0
        private async void PdfViewerPreviewPage_ButtonOpenProjectClicked(ProjectPreviewPage projectPreviewPage, ProjectPreviewType projectPreviewType, FolderModel project)
        {
            var tabItem = FindTab(projectPreviewPage.Index);

            if (tabItem != null)
            {
                var name = GetProjectIdentifier(projectPreviewPage.SelectedPlantOrder, projectPreviewPage.SelectedFileEntry);
                if (name != null)
                {
                    UpdateTabViewItemHeader(tabItem, project, name);

                    var plantOrder = projectPreviewPage.SelectedPlantOrder;
                    var fileEntry  = projectPreviewPage.SelectedFileEntry;

                    if (fileEntry == null && plantOrder != null)
                    {
                        fileEntry = projectPreviewPage.FindFilename(plantOrder);
                    }

                    if (tabItem.Content is Frame frame && fileEntry != null)
                    {
                        ProjectViewSession session;
                        session = await ProjectViewSession.LoadAsync();

                        var summary = new ProjectSummary()
                        {
                            FileEntry          = fileEntry,
                            Folder             = project,
                            PlantOrder         = plantOrder,
                            ProjectPreviewType = projectPreviewType
                        };
                        if (session == null)
                        {
                            session = new ProjectViewSession();
                        }
                        await session.Add(summary);

                        frame.Navigate(typeof(ProjectContentPage), new object[] { projectPreviewType, project, fileEntry, plantOrder, false });
                    }
                    else
                    {
                        var dialog = new InfoDialog("Es wurde leider keine Datei gefunden", "Information", InfoDialogType.Error);
                        await dialog.ShowAsync();
                    }
                }
            }
Esempio n. 24
0
        private async Task <int> UpdateAProject(
            SqlConnection connection, int locationId,
            ProjectSummary projectSummary, ProjectManager projectManager
            )
        {
            string currentManagerId = await GetCurrentManagerIdOfProject(connection, projectSummary.ProjectNumber);

            if (!String.Equals(currentManagerId, projectManager.UserID))
            {
                var updatedUserCount = await UpdateOneUser(connection, projectManager.UserID);

                if (updatedUserCount != 1)
                {
                    var error = new InternalServerException("New Manager is not updated! Please check server!");
                    throw new CustomException <InternalServerException>(error);
                }
            }

            var sql = @"
                UPDATE Projects 
                SET 
                    Title = @Title,
                    LocationId = @LocationId,
                    ManagerId = @ManagerId,
                    ProjectStartDate = @ProjectStartDate,
                    ProjectEndDate = @ProjectEndDate
                WHERE
                    Number = @Number
            ;";

            connection.Open();
            int updatedCount = await connection.ExecuteAsync(sql, new
            {
                Number           = projectSummary.ProjectNumber,
                Title            = projectSummary.Title,
                LocationId       = locationId,
                ManagerId        = projectManager.UserID,
                ProjectStartDate = projectSummary.ProjectStartDate,
                ProjectEndDate   = projectSummary.ProjectEndDate
            });

            connection.Close();

            return(updatedCount);
        }
Esempio n. 25
0
        public Task <bool> Remove(ProjectSummary summary)
        {
            if (Summaries == null)
            {
                return(Task.FromResult(false));
            }

            if (Exists(summary))
            {
                var removed = Summaries.Remove(summary);
                if (removed)
                {
                    return(SaveAsync(this));
                }
            }

            return(Task.FromResult(false));
        }
Esempio n. 26
0
        public ProjectSummary CalculateInstallationsData(lead lead, ProjectSummary projectSummary)
        {
            double operationExp = 0.0;
            InstallationCalculationHelper calHelper = new InstallationCalculationHelper();

            foreach (var item in lead.installations)
            {
                projectSummary.TwoWayMilesToJob           = Math.Round(calHelper.CalculateBothWayMilesToJob(item.oneway_mileages_to_destination), 2);
                projectSummary.TotalInstallationDays      = Math.Round(calHelper.CalculateTotalInstallationDays(item.installation_days, item.tile_installation_days), 2);
                projectSummary.PaidTravelTimeOneWay       = Math.Round(calHelper.CalculatePaidTravelTimeOneWay(item.travel_time_one_way), 2);
                projectSummary.TotalApplicableTravelHours = Math.Round(calHelper.CalculateTotalApplicableTravelHours(item.installation_days, item.travel_time_one_way, item.recommendation), 2);
                operationExp = item.total_operational_expenses != null ? (double)item.total_operational_expenses : 0;
            }

            projectSummary.OperationalExp = operationExp == 0 ? new FeeCalculationHelper().CalculateTotalOperationalExpense(lead) : operationExp;

            return(projectSummary);
        }
Esempio n. 27
0
        public ProjectSummary SetCustomerData(lead lead, ProjectSummary projectSummary)
        {
            customer c = lead.customer;

            if (lead.project_status.project_status_name.Equals(Constants.proj_Status_Closed, StringComparison.OrdinalIgnoreCase))
            {
                var archived_lead = db.archive_leads.Where(a => a.lead_number == lead.lead_number).FirstOrDefault();
                if (archived_lead != null)
                {
                    c.customer_firstname = archived_lead.customer_firstname;
                    c.customer_lastname  = archived_lead.customer_lastname;
                    c.email = archived_lead.customer_email;
                }
            }
            projectSummary.Customer = c;

            return(projectSummary);
        }
Esempio n. 28
0
        //Calculate all the Project Summary details needed for the report page
        public ActionResult ProjectSummary(int projectId)
        {
            var tasks     = db.Tasks.Where(t => t.ProjectID == projectId).Include(t => t.Project);
            int NoOfTasks = tasks.Count();

            ViewBag.ProjectId = projectId;

            var tasksCompleted     = tasks.Where(t => t.TaskStatus == TaskStatus.Completed);
            int NoOfCompletedTasks = tasksCompleted.Count();

            ViewBag.percNoOfCompletedTasks = CalculationPercentage(NoOfCompletedTasks, NoOfTasks);

            var tasksInProgress     = tasks.Where(t => t.TaskStatus == TaskStatus.InProgress);
            int NoOfTasksInProgress = tasksInProgress.Count();

            ViewBag.percNoOfTasksInProgress = CalculationPercentage(NoOfTasksInProgress, NoOfTasks);

            var tasksNotStarted     = tasks.Where(t => t.TaskStatus == TaskStatus.NotStarted);
            int NoOfTasksNotStarted = tasksNotStarted.Count();

            ViewBag.percNoOfTasksNotStarted = CalculationPercentage(NoOfTasksNotStarted, NoOfTasks);

            Project project = db.Projects.Find(projectId);

            ViewBag.projectName = project.ProjectName;

            User loggedUser = UserHelper.GetUser();

            var projectSummaries = db.ProjectSummary.Where(p => p.ProjectID == projectId).Where(u => u.UserID == loggedUser.UserID).Include(p => p.User);

            ViewBag.projectSummaries = projectSummaries;

            ProjectSummary ps = new ProjectSummary
            {
                NoOfTasks           = NoOfTasks,
                NoOfTasksInProgress = NoOfTasksInProgress,
                NoOfTasksNotStarted = NoOfTasksNotStarted,
                NoOfCompletedTasks  = NoOfCompletedTasks,
                ProjectID           = projectId
            };

            return(View("ProjectSummary", ps));
        }
Esempio n. 29
0
        public void GetSummariesByUser()
        {
            ProjectService service = new ProjectService();

            Project project = (Project)CreateRecord();

            Insert(project);

            service.Assign(project.ID, _manager.ID);
            Collection <ProjectSummary> summaries = service.GetSummariesByUser(_manager.ID);

            Assert.IsTrue(summaries.Count == 1);

            ProjectSummary summary = summaries[0];

            Assert.AreEqual(project.ID, summary.ProjectID);

            service.Unassign(project.ID, _manager.ID);
        }
        private void BindMemberGrid(IList projectTasks, BindResult bindResult)
        {
            IList taskOwnerList = projectTasks.AsQueryable().Where("OwnerId !=null").Select("OwnerId").Cast <Guid>().Distinct().ToArrayList();
            List <ProjectSummary> memberSummaryList = new List <ProjectSummary>();

            foreach (var ownerId in taskOwnerList)
            {
                ProjectSummary memberItem = new ProjectSummary();
                var            userName   = _users.AsQueryable().Where("userid=@0", ownerId).Select("FullName")._First();
                if (userName == null)
                {
                    continue;
                }
                memberItem.Name = userName.ToString();
                IList taskList = projectTasks.AsQueryable().Where("OwnerId=@0", ownerId).ToArrayList();
                SumEntity(memberItem, taskList);
                memberSummaryList.Add(memberItem);
            }
            bindResult.memberSummaryList = memberSummaryList;
        }
Esempio n. 31
0
 public ProjectReport()
 {
     Months = new List<MonthEntry>();
     Summary = new ProjectSummary();
     Costs = new ProjectCosts();
 }