public void LoadControl(MainTaskStatusSearchEnum iMainTaskStatusSearch, MainTaskOrderByEnum iMainTaskOrderBy, Guid?iProjectId, long?iProductLineId, MainTaskTypeEnum?iMainTaskType, Guid?iDevelopperId, long?iPackageId, long?iExternalProjectId) { if (_IsLoading.Value) { return; } using (var locker = new BoolLocker(ref _IsLoading)) { _LoadingType = LoadingType.Criteria; _MainTaskStatusSearchEnum = iMainTaskStatusSearch; _MainTaskOrderBy = iMainTaskOrderBy; _ProjectId = iProjectId; _ProductLineId = iProductLineId; _MainTaskType = iMainTaskType; _DevelopperId = iDevelopperId; _PackageId = iPackageId; _ExternalProjectId = iExternalProjectId; LoadDataGridViewMainTask(true, null); DisplaySelectionMode(); } }
public Tuple <List <MainTask>, int> GetMainTaskList(MainTaskStatusSearchEnum iMainTasksSearchEnum, MainTaskOrderByEnum iOrderBy, Guid?iProjectGUID, long?iProductLineId, MainTaskTypeEnum?iMainTaskType, Guid?iDevelopperGuid, long?iPackageId, int iSkip, int iTake, GranularityEnum iGranularity, long?iExternalProjectId) { if (iTake < 1) { throw new Exception("Le nombre à prendre est invalide"); } //Choix de la table IQueryable <T_E_MainTask> theQuery = DBReleaseDataService.GetQuery <T_E_MainTask>(null); //Statut if (iMainTasksSearchEnum != MainTaskStatusSearchEnum.All) { if (iMainTasksSearchEnum == MainTaskStatusSearchEnum.Canceled) { theQuery = theQuery.Where(x => x.StatusRef == (short)MainTaskStatusEnum.Canceled); } else if (iMainTasksSearchEnum == MainTaskStatusSearchEnum.Completed) { theQuery = theQuery.Where(x => x.StatusRef == (short)MainTaskStatusEnum.Completed); } else if (iMainTasksSearchEnum == MainTaskStatusSearchEnum.InProgress) { theQuery = theQuery.Where(x => x.StatusRef == (short)MainTaskStatusEnum.Dev || x.StatusRef == (short)MainTaskStatusEnum.Staging); } else if (iMainTasksSearchEnum == MainTaskStatusSearchEnum.Request) { theQuery = theQuery.Where(x => x.StatusRef == (short)MainTaskStatusEnum.Requested); } else if (iMainTasksSearchEnum == MainTaskStatusSearchEnum.Waiting) { theQuery = theQuery.Where(x => x.StatusRef == (short)MainTaskStatusEnum.Waiting); } else if (iMainTasksSearchEnum == MainTaskStatusSearchEnum.NotCompleted) { theQuery = theQuery.Where(x => x.StatusRef != (short)MainTaskStatusEnum.Completed && x.StatusRef != (short)MainTaskStatusEnum.Canceled); } else { throw new NotSupportedException(iMainTasksSearchEnum.ToStringWithEnumName()); } } //Gamme, if (iProductLineId != null) { theQuery = theQuery.Where(x => x.T_E_ProductLineTask.Any(y => y.ProductLineId == (long)iProductLineId)); } //Project if (iProjectGUID != null) { theQuery = theQuery.Where(x => x.T_E_SubTask.Any(y => y.ProjectGUID == iProjectGUID)); } //Tasktype if (iMainTaskType != null) { theQuery = theQuery.Where(x => x.TaskTypeRef == (short)iMainTaskType); } //Developper if (iDevelopperGuid != null) { theQuery = theQuery.Where(x => x.T_E_SubTask.Any(y => y.DevelopperGUID == iDevelopperGuid)); } //Package if (iPackageId != null) { theQuery = theQuery.Where(x => x.PackageId == iPackageId); } //External project if (iExternalProjectId != null) { theQuery = theQuery.Where(x => x.ExternalProjectId == iExternalProjectId); } var totalCount = theQuery.Count(); List <T_E_MainTask> entities; if (iOrderBy == MainTaskOrderByEnum.MainTaskId) { entities = theQuery.OrderBy(x => x.MainTaskId).Skip(iSkip).Take(iTake).ToList(); } else if (iOrderBy == MainTaskOrderByEnum.DateObjectif) { entities = theQuery.OrderByDescending(x => x.ObjectifCloseDate.HasValue).ThenBy(x => x.ObjectifCloseDate).Skip(iSkip).Take(iTake).ToList(); } else if (iOrderBy == MainTaskOrderByEnum.TaskPriority) { entities = theQuery.OrderByDescending(x => x.Priority.HasValue).ThenBy(x => x.Priority).Skip(iSkip).Take(iTake).ToList(); } else if (iOrderBy == MainTaskOrderByEnum.PackagePriority) { entities = theQuery.OrderByDescending(x => x.T_E_Package.Priority.HasValue).ThenBy(x => x.T_E_Package.Priority).Skip(iSkip).Take(iTake).ToList(); } else if (iOrderBy == MainTaskOrderByEnum.ProjectNumber) { entities = theQuery.OrderByDescending(x => x.T_E_ExternalProject.ProjectNumber).Skip(iSkip).Take(iTake).ToList(); } else if (iOrderBy == MainTaskOrderByEnum.CreationDate) { entities = theQuery.OrderByDescending(x => x.CreationDate).Skip(iSkip).Take(iTake).ToList(); } else if (iOrderBy == MainTaskOrderByEnum.ProductionDeployementDate) { var environmentProductionShort = (short)EquinoxeExtend.Shared.Enum.EnvironmentEnum.Production; entities = theQuery.OrderByDescending(x => x.T_E_Package.T_E_Deployement.Where(y => y.EnvironmentDestinationRef == environmentProductionShort).OrderByDescending(t => t.DeployementDate).FirstOrDefault().DeployementDate).Skip(iSkip).Take(iTake).ToList(); } else { throw new NotSupportedException(iOrderBy.ToStringWithEnumName()); } if (entities.IsNotNullAndNotEmpty()) { var result = new List <MainTask>(); if (iGranularity == GranularityEnum.Full) { foreach (var mainTaskItem in entities) { result.Add(GetMainTaskById(mainTaskItem.MainTaskId, iGranularity)); } } else if (iGranularity == GranularityEnum.Nude) { result = entities.Select(x => x.Convert()).ToList(); } return(new Tuple <List <MainTask>, int>(result, totalCount)); } return(null); }