public WebHookReceiverTfs(SyncSystemBusinessService syncSystemBusinessService, MasterBusinessService masterBusinessService, CommonBusinessService commonBusinessService, SyncSystemFieldMappingBusinessService syncSystemFieldMappingBusinessService, Logger logger) { this.logger = logger; this.syncSystemBusinessService = syncSystemBusinessService; this.masterBusinessService = masterBusinessService; this.commonBusinessService = commonBusinessService; this.syncSystemFieldMappingBusinessService = syncSystemFieldMappingBusinessService; }
public BaseController() { //ProjectServerSystemLinkBusinessService = new ProjectServerSystemLinkBusinessService(); Logger = LogManager.GetCurrentClassLogger(); IsDebugMode = Parse(ConfigurationManager.AppSettings["IsDebugMode"]); UnitOfWork = new UnitOfWork(); CommonBusinessService = new CommonBusinessService(UnitOfWork); MasterBusinessService = new MasterBusinessService(UnitOfWork); SyncSystemBusinessService = new SyncSystemBusinessService(UnitOfWork); ProjectServerSystemLinkBusinessService = AutofacDependencyResolver.Current .ApplicationContainer.Resolve <ProjectServerSystemLinkBusinessService>(); SyncSystemFieldMappingBusinessService = new SyncSystemFieldMappingBusinessService(UnitOfWork); MasterWorklogBusinessService = new MasterWorklogBusinessService(UnitOfWork); }
public static DataFromDbViewModel GetDataFromDbViewModel(ProjectOnlineODataService projectOnlineODataService, UnitOfWork unitOfWork, bool isWorklogs) { StagingBusinessService stagingBusinessService = new StagingBusinessService(unitOfWork); SyncSystemBusinessService syncSystemBusinessService = new SyncSystemBusinessService(unitOfWork); ProjectServerSystemLinkBusinessService projectServerSystemLinkBusinessService = new ProjectServerSystemLinkBusinessService(projectOnlineODataService, unitOfWork); MasterWorklogBusinessService masterWorklogBusinessService = new MasterWorklogBusinessService(unitOfWork); MasterBusinessService masterBusinessService = new MasterBusinessService(unitOfWork); DateTime startDateTimesheetPeriods = projectOnlineODataService.GetODataTimesheetPeriods().Select(x => x.StartDate).Min(); DateTime endDateTimesheetPeriods = projectOnlineODataService.GetODataTimesheetPeriods().Select(x => x.EndDate).Max(); DataFromDbViewModel dataFromDbViewModel = new DataFromDbViewModel { SyncSystems = syncSystemBusinessService.GetSyncSystemList(), ProjectServerSystemLinks = projectServerSystemLinkBusinessService.GetList() }; stagingBusinessService.RemoveDoneStagings(); dataFromDbViewModel.StagingsAll = stagingBusinessService.GetAllStagings(isWorklogs); dataFromDbViewModel.MasterWorklogs = masterWorklogBusinessService.GetActualMasterWorklogs(dataFromDbViewModel.StagingsAll, dataFromDbViewModel.SyncSystems, startDateTimesheetPeriods, endDateTimesheetPeriods); List <int> stagingIds = dataFromDbViewModel.StagingsAll.Select(x => x.StagingId).ToList(); //stagingBusinessService.SetStagingsRecordState(stagingIds, // isWorklogs ? ProjectServerConstants.RecordStateActual : ProjectServerConstants.RecordStateGeneral, // RecordStateConst.Pending); dataFromDbViewModel.CustomValuesAll = stagingBusinessService .GetCustomValues(stagingIds); List <VStagingFieldMappingValue> lastUpdateUsersCustomValues = dataFromDbViewModel.CustomValuesAll .Where(x => x.StagingId.HasValue && stagingIds.Contains(x.StagingId.Value) && x.EpmFieldName == ProjectServerConstants.LastUpdateUser) .ToList(); List <AssignmentInfo> assignees = dataFromDbViewModel.StagingsAll .Where(x => !String.IsNullOrEmpty(x.Assignee)) .Select(x => new AssignmentInfo { IssueKey = x.IssueKey, IssueId = x.IssueId, SystemId = x.SystemId, AuthorKey = x.Assignee }).ToList(); List <AssignmentInfo> lastUpdateUsers = (from staging in dataFromDbViewModel.StagingsAll join lu in lastUpdateUsersCustomValues on staging.StagingId equals lu.StagingId select new AssignmentInfo { IssueKey = staging.IssueKey, IssueId = staging.IssueId, SystemId = staging.SystemId, AuthorKey = lu.Value }).ToList(); List <AssignmentInfo> worklogUsers = (from staging in dataFromDbViewModel.StagingsAll join worklog in dataFromDbViewModel.MasterWorklogs on new { staging.SystemId, staging.IssueId } equals new { worklog.SystemId, worklog.IssueId } select new AssignmentInfo { IssueKey = staging.IssueKey, IssueId = staging.IssueId, SystemId = staging.SystemId, AuthorKey = worklog.AuthorKey }).ToList(); dataFromDbViewModel.Assignments = lastUpdateUsers.Union(assignees).Union(worklogUsers).Distinct(new AssignmentInfoComparer()).ToList(); foreach (AssignmentInfo assignmentInfo in dataFromDbViewModel.Assignments) { ODataResource resource = projectOnlineODataService.GetODataResource(assignmentInfo.AuthorKey); if (resource != null) { assignmentInfo.ResourceUid = resource.ResourceId; } } dataFromDbViewModel.Assignments = dataFromDbViewModel.Assignments.Where(x => x.ResourceUid != Guid.Empty).ToList(); //List<string> issueKeysCurrentLevel = dataFromDbViewModel.StagingsAll // .Where(x => x.IsSubTask && !String.IsNullOrEmpty(x.ParentIssueKey)) // .Select(x => x.ParentIssueKey).Distinct().ToList(); dataFromDbViewModel.ParentIssues = new List <Master>(); List <string> issueKeysCurrentLevel = dataFromDbViewModel.StagingsAll .Where(x => !String.IsNullOrEmpty(x.ParentIssueKey)) .Select(x => x.ParentIssueKey).Distinct().ToList(); List <Master> parentIssuesCurrentLevel = masterBusinessService.GetMasters(issueKeysCurrentLevel); dataFromDbViewModel.ParentIssues.AddRange(parentIssuesCurrentLevel); while (parentIssuesCurrentLevel.Count != 0) { issueKeysCurrentLevel = parentIssuesCurrentLevel .Where(x => !String.IsNullOrEmpty(x.ParentIssueKey)) .Select(x => x.ParentIssueKey).Distinct().ToList(); parentIssuesCurrentLevel = masterBusinessService.GetMasters(issueKeysCurrentLevel); dataFromDbViewModel.ParentIssues.AddRange(parentIssuesCurrentLevel); } return(dataFromDbViewModel); }