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;
 }
Ejemplo n.º 2
0
 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 async Task <JsonResult> GetSyncSystemListAsync()
        {
            try
            {
                List <SyncSystemDTO> result = await SyncSystemBusinessService.GetSyncSystemListAsync();

                return(Json(new ProxyResponse
                {
                    Data = JsonConvert.SerializeObject(result),
                    Result = "ok",
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                return(HandleException(exception));
            }
        }
        public async Task <JsonResult> ExecuteRequest([FromBody] JiraProxyRequest jiraRequest)
        {
            if (jiraRequest.SystemId == null)
            {
                return(Json(new ProxyResponse
                {
                    Result = "ko",
                    Data = "System Id is null"
                }, JsonRequestBehavior.AllowGet));
            }
            try
            {
                string        response   = null;
                SyncSystemDTO syncSystem = await SyncSystemBusinessService.GetSyncSystemAsync(jiraRequest.SystemId.Value);

                if (syncSystem != null)
                {
                    JiraAccessService jiraAccessService = new JiraAccessService(syncSystem);
                    response = await jiraAccessService.GetJiraResponse(jiraRequest);
                }
                if (String.IsNullOrEmpty(response))
                {
                    return(Json(new ProxyResponse
                    {
                        Result = "ko",
                        Data = "Jira Response is empty"
                    }, JsonRequestBehavior.AllowGet));
                }
                JsonResult jsonResult = Json(new ProxyResponse
                {
                    Result = "ok",
                    Data   = response
                }, JsonRequestBehavior.AllowGet);
                jsonResult.MaxJsonLength = Int32.MaxValue;
                return(jsonResult);
            }
            catch (Exception exception)
            {
                return(HandleException(exception));
            }
        }
 public ExecuteTfs(UnitOfWork unitOfWork)
 {
     syncSystemBusinessService             = new SyncSystemBusinessService(unitOfWork);
     commonBusinessService                 = new CommonBusinessService(unitOfWork);
     syncSystemFieldMappingBusinessService = new SyncSystemFieldMappingBusinessService(unitOfWork);
 }
 public SyncSystemCRUDController(SyncSystemBusinessService referenceBusinessService) : base(
         referenceBusinessService)
 {
 }
        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);
        }