コード例 #1
0
		public PagedSortedList<DeployCredentialsMasked> GetMaskedCredentialList(ListOptions listOptions)
		{
			var list = _credentialsRepository.GetCredentialsList(listOptions);
			var mappedList = list.Items.Select(i=>AutoMapper.Mapper.Map(i, new DeployCredentialsMasked())).ToList();
			var pagedList = new StaticPagedList<DeployCredentialsMasked>(mappedList, list.PageNumber, list.PageSize, list.TotalItemCount);
			return new PagedSortedList<DeployCredentialsMasked>(pagedList, list.SortField, list.SortAscending);
		}
コード例 #2
0
		public PagedSortedList<DeployBatchStatus> GetDeployBatchStatusList(ListOptions listOptions)
		{
            var requestList = _deployRepository.GetBatchRequestList(listOptions);
            var returnListItems = requestList.Items.Select(i => BuildDeployBatchStatus(i)).ToList();
            var pagedList = new StaticPagedList<DeployBatchStatus>(returnListItems, requestList.PageNumber, requestList.PageSize, requestList.TotalItemCount);
            return new PagedSortedList<DeployBatchStatus>(pagedList, listOptions.SortField, listOptions.SortAscending.Value);
		}
コード例 #3
0
 public PagedSortedList<DeployCredentials> GetCredentialsList(ListOptions listOptions)
 {
     var sql = GetBaseQuery();
     listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "UserName", true);
     using(var db = _sqlConnectionInfo.GetDB())
     {
         return db.PageAndSort<DeployCredentials>(listOptions, sql);
     }
 }
コード例 #4
0
		public object Get(DeployQueueRequest request)
		{
			var listOptions = new ListOptions();
			if(request != null)
			{
				listOptions = request.BuildListOptions();
			}
			return _deployQueueManager.GetQueue(listOptions);
		}
コード例 #5
0
 public PagedSortedList<SystemRole> GetSystemRoleList(ListOptions listOptions)
 {
     listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "RoleName", true);
     var query = _documentSession.QueryNoCache<SystemRole>();
     switch(listOptions.SortField)
     {
         case "RoleName":
             return query.PageAndSort(listOptions, i=>i.RoleName);
         default:
             throw new UnrecognizedSortFieldException<SystemRole>(listOptions);
     }
 }
コード例 #6
0
 public static ListOptions SetDefaults(ListOptions listOptions, int pageSize, int pageNumber, string sortField, bool sortAscending)
 {
     if(listOptions == null)
     {
         listOptions = new ListOptions();
     }
     listOptions.PageSize = listOptions.PageSize.GetValueOrDefault(pageSize);
     listOptions.PageNumber = listOptions.PageNumber.GetValueOrDefault(pageNumber);
     listOptions.SortField = StringHelper.IsNullOrEmpty(listOptions.SortField, sortField);
     listOptions.SortAscending = listOptions.SortAscending.GetValueOrDefault(sortAscending);
     return listOptions;
 }
コード例 #7
0
 public PagedSortedList<SystemLog> GetList(ListOptions listOptions, List<EnumSystemLogType> systemLogTypeList = null)
 {
     listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "MessageDateTimeUtc", false);
     var sql = PetaPoco.Sql.Builder
                 .Append("FROM SystemLog WHERE 0=0");
     if(systemLogTypeList != null && systemLogTypeList.Any())
     {
         sql = sql.Append("AND EnumSystemLogTypeID IN (@systemLogTypeList)", new { systemLogTypeList });
     }
     using(var db = _sqlConnectionInfo.GetDB())
     {
         return db.PageAndSort<SystemLog>(listOptions, sql);
     }
 }
コード例 #8
0
 public PagedSortedList<SystemLog> GetList(ListOptions listOptions, List<EnumSystemLogType> systemLogTypeList = null)
 {
     listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "MessageDateTimeUtc", false);
     var query = _documentSession.QueryNoCache<SystemLog>();
     if(systemLogTypeList != null && systemLogTypeList.Any())
     {
         query = query.Where(i=>i.EnumSystemLogTypeID.In(systemLogTypeList));
     }
     switch (listOptions.SortField)
     {
         case "MessageDateTimeUtc":
             return query.PageAndSort(listOptions, i => i.MessageDateTimeUtc);
         default:
             throw new ArgumentException("Unrecognized Sort Field " + listOptions.SortField);
     }
 }
コード例 #9
0
		public void Execute(Quartz.IJobExecutionContext context)
		{
			_logger.Info("Starting PurgeBuildJob.Execute");
			try 
			{
				bool doneList = false;
				int pageNumber = 1;
				while(!doneList)
				{
					var listOptions = new ListOptions
					{
						PageNumber = pageNumber,
						PageSize = 100,
						SortAscending = true,
						SortField = "UpdatedDateTimeUtc"
					};
					var list = _buildManager.GetBuildList(listOptions);
					if (list.Items != null)
					{
						foreach(var build in list.Items)
						{
							try 
							{
								_buildPurger.PurgeBuildIfNecessary(build);
							}
							catch(Exception err)
							{
								_logger.ErrorException(string.Format("Error purging build \"{0}\": {1}", build.DisplayValue, err.ToString()), err);
							}
						}
					}
					if(list.IsLastPage)
					{
						doneList = true;
					}
					else 
					{
						pageNumber++;
					}
				}
			}
			catch(Exception err)
			{
				this._logger.ErrorException("PurgeBuildJob.Execute Failed: " + err.ToString(), err);
			}
			_logger.Info("Done PurgeBuildJob.Execute");
		}
コード例 #10
0
 public PagedSortedList<DeployBuild> GetBuildList(ListOptions listOptions, string projectId = null, string branchId = null, string componentId = null)
 {
     listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "UpdatedDateTimeUtc", false);
     using(var db = _sqlConnectionInfo.GetDB())
     {
         var sql = GetBaseQuery();
         sql = sql.Append("WHERE 1=1");
         if(!string.IsNullOrEmpty(projectId))
         {
             sql = sql.Append("AND ProjectID=@0", projectId);
         }
         if(!string.IsNullOrEmpty(branchId))
         {
             sql = sql.Append("AND ProjectBranchID=@0", branchId);
         }
         if(!string.IsNullOrEmpty(componentId))
         {
             sql = sql.Append("AND ProjectComponentID=@0", componentId);
         }
         return db.PageAndSort<DeployBuild>(listOptions, sql);
     }
 }
コード例 #11
0
		private List<string> GetNotificationEmailAddresses(string projectId, Func<ProjectNotificationFlags, bool> flagsFilter)
		{
			List<string> emailAddresseList = new List<string>();
			bool done = false;
			int pageCounter = 1;
			while (!done)
			{
				var listOptions = new ListOptions
				{
					PageNumber = pageCounter,
					PageSize = 10,
					SortAscending = true,
					SortField = "UserName"
				};

                throw new NotSupportedException();
                //var userList = _membershipRepository.GetUserList_old(listOptions,
                //                    //i => i.ProjectNotificationItemList.Any(j => j.ProjectId == projectId && flagsFilter(j.Flags)));
                //                    i=>i.ProjectNotificationItemList.Any(j=>j.ProjectId == projectId && j.Flags.DeployRequested));
                //foreach (var user in userList.Items)
                //{
                //    if (!string.IsNullOrEmpty(user.EmailAddress))
                //    {
                //        emailAddresseList.Add(user.EmailAddress);
                //    }
                //}
                //if (userList.IsLastPage)
                //{
                //    done = true;
                //}
                //else
                //{
                //    pageCounter++;
                //}
			}
			return emailAddresseList;
		}
コード例 #12
0
 public PagedSortedList<DeployBatchRequest> GetBatchRequestList(ListOptions listOptions)
 {
     throw new NotSupportedException();
 }
コード例 #13
0
		public PagedSortedList<DeployBuild> GetBuildList(ListOptions listOptions, string projectId = null, string branchId = null, string componentId = null)
		{
			return this._buildRepository.GetBuildList(listOptions, projectId, branchId, componentId);
		}
コード例 #14
0
		public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
		{
			var repository = this.GetRepository();
			var listOptions = new ListOptions
			{
				PageNumber = pageIndex+1,
				PageSize = pageSize,
				SortField="UserName", 
				SortAscending = true
			};
			var pagedList = repository.GetUserList(listOptions);
			totalRecords = pagedList.TotalItemCount;
			return CreateMembershipCollection(pagedList);
		}
コード例 #15
0
		public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
		{
			var repository = this.GetRepository();
			var listOptions = new ListOptions
			{
				PageNumber = pageIndex,
				PageSize = pageSize,
				SortField="EmailAddress", 
				SortAscending = true
			};
            var pagedList = repository.GetUserList(listOptions, emailAddressList:emailToMatch.ListMe());
			totalRecords = pagedList.TotalItemCount;
			return CreateMembershipCollection(pagedList);
		}
コード例 #16
0
        public PagedSortedList<ComponentDeployHistory> GetComponentDeployHistory(ListOptions listOptions = null, List<string> projectIdList = null, List<string> branchIdList = null,
                                                                            List<string> componentIdList = null, List<string> buildIdList = null, List<string> environmentIdList = null,
                                                                            List<string> environmentNameList = null, List<string> machineIdList = null, List<string> machineNameList = null,
                                                                            List<string> statusList = null)
        {
            var baseQuery = _documentSession.Query<DeployState>().Customize(i => i.WaitForNonStaleResultsAsOfNow());
            RavenQueryStatistics stats;
            baseQuery = baseQuery.Statistics(out stats);
            if (projectIdList != null)
            {
                baseQuery = baseQuery.Where(i => i.ProjectId.In(projectIdList));
            }
            if (branchIdList != null)
            {
                baseQuery = baseQuery.Where(i => i.Build.ProjectBranchId.In(branchIdList));
            }
            if (componentIdList != null)
            {
                baseQuery = baseQuery.Where(i => i.Component.Id.In(componentIdList));
            }
            if (buildIdList != null)
            {
                //baseQuery = baseQuery.Where(i => i.Build.Id == buildIdList[0]);
                baseQuery = baseQuery.Where(i=>i.Build.Id.In(buildIdList));
            }
            if (environmentIdList != null)
            {
                baseQuery = baseQuery.Where(i => i.Environment.Id.In(environmentIdList));
            }
            if (environmentNameList != null)
            {
                baseQuery = baseQuery.Where(i => i.Environment.EnvironmentName.In(environmentNameList));
            }
            if (machineIdList != null)
            {
                baseQuery = baseQuery.Where(i => i.MachineList.Any(j => j.Id.In(machineIdList)));
            }
            if (machineNameList != null)
            {
                baseQuery = baseQuery.Where(i => i.MachineList.Any(j => j.MachineName.In(machineNameList)));
            }
            if (statusList != null)
            {
                List<EnumDeployStatus> statusEnumList = (from i in statusList
                                                         select EnumHelper.Parse<EnumDeployStatus>(i)).ToList();
                baseQuery = baseQuery.Where(i => i.Status.In(statusEnumList));
            }

            var query = GetComponentDeployHistoryBaseQuery(baseQuery);
            listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "DeploymentStartedDateTimeUtc", false);
            switch (listOptions.SortField.ToLower())
            {
                case "deploymentstarteddatetimeutc":
                    return query.PageAndSort(listOptions, i => i.DeploymentStartedDateTimeUtc);
                case "version":
                    return query.PageAndSort(listOptions, i => i.SortableVersion);
                default:
                    throw new UnrecognizedSortFieldException<ComponentDeployHistory>(listOptions);
            }
        }
コード例 #17
0
 public PagedSortedList<SystemRole> GetSystemRoleList(ListOptions listOptions)
 {
     listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "RoleName", true);
     switch(listOptions.SortField)
     {
         case "RoleName":
             //Have a nice day
             break;
         default:
             throw new UnrecognizedSortFieldException<SystemRole>(listOptions);
     }
     using(var db = _sqlConnectionInfo.GetDB())
     {
         var dbList = db.PageAndSort<SqlSystemRole>(listOptions, new PetaPoco.Sql(""));
         return dbList.Cast<SystemRole>(i=>i.ToDto());
     }
 }
コード例 #18
0
 public PagedSortedList<DeployBuild> GetBuildList(ListOptions listOptions, string projectId = null, string branchId = null, string componentId = null)
 {
     throw new NotSupportedException();
 }
コード例 #19
0
 public PagedSortedList<SrirachaUser> GetUserList(ListOptions listOptions, List<string> userNameList=null, List<string> emailAddressList=null)
 {
     var query = _documentSession.QueryNoCache<SrirachaUser>();
     if(userNameList != null && userNameList.Any())
     {
         query = query.Where(i=>i.UserName.In(userNameList));
     }
     if(emailAddressList != null && emailAddressList.Any())
     {
         query = query.Where(i=>i.EmailAddress.In(emailAddressList));
     }
     listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "UserName", true);
     switch (listOptions.SortField)
     {
         case "UserName":
             return query.PageAndSort(listOptions, i => i.UserName);
         case "EmailAddress":
             return query.PageAndSort(listOptions, i => i.EmailAddress);
         default:
             throw new UnrecognizedSortFieldException<SrirachaUser>(listOptions);
     }
 }
コード例 #20
0
        public PagedSortedList<ComponentDeployHistory> GetComponentDeployHistory(ListOptions listOptions, List<string> projectIdList, List<string> branchIdList, List<string> componentIdList, List<string> buildIdList, List<string> environmentIdList, List<string> environmentNameList, List<string> machineIdList, List<string> machineNameList, List<string> statusList)
        {
            listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "DeploymentStartedDateTimeUtc", false);
            using(var db = _sqlConnectionInfo.GetDB())
            {
                var deployStateSql = GetBaseDeployStateQuery().Append("WHERE 1=1");
                if(projectIdList != null && projectIdList.Count > 0)
                {
                    deployStateSql = deployStateSql.Append("AND ProjectID IN (@idList)", new { idList = projectIdList });
                }
                if(branchIdList != null && branchIdList.Count > 0)
                {
                    deployStateSql = deployStateSql.Append("AND BranchID IN (@idList)", new { idList = branchIdList });
                }
                if(componentIdList != null && componentIdList.Count > 0)
                {
                    deployStateSql = deployStateSql.Append("AND ComponentID IN (@idList)", new { idList = componentIdList });
                }
                if(buildIdList != null && buildIdList.Count > 0)
                {
                    deployStateSql = deployStateSql.Append("AND BuildID IN (@idList)", new { idList = buildIdList });
                }
                if(environmentIdList != null && environmentIdList.Count > 0)
                {
                    deployStateSql = deployStateSql.Append("AND EnvironmentID IN (@idList)", new { idList = environmentIdList });
                }
                if (environmentNameList != null && environmentNameList.Count > 0)
                {
                    deployStateSql = deployStateSql.Append("AND EnvironmentName IN (@nameList)", new { nameList = environmentNameList });
                }
                if (machineIdList != null && machineIdList.Count > 0)
                {
                    deployStateSql = deployStateSql.Append("AND DeployState.ID IN (SELECT x.DeployStateID FROM DeployStateMachine x WHERE x.MachineID IN (@idList))", new { idList = machineIdList });
                }
                if (machineNameList != null && machineNameList.Count > 0)
                {
                    deployStateSql = deployStateSql.Append("AND DeployState.ID IN (SELECT x.DeployStateID FROM DeployStateMachine x WHERE x.MachineName IN (@nameList))", new { nameList = machineNameList });
                }
                if (statusList != null && statusList.Count > 0)
                {
                    List<int> statusIdList = (from i in statusList
                                                             select (int)EnumHelper.Parse<EnumDeployStatus>(i)).ToList();
                    deployStateSql = deployStateSql.Append("AND EnumDeployStatusID IN (@statusIdList)", new { statusIdList = statusIdList });
                }
                if (!string.IsNullOrEmpty(listOptions.SortField))
                {
                    switch(listOptions.SortField.ToLower())
                    {
                        case "deploymentstarteddatetimeutc":
                            //OK
                            break;
                        case "version":
                            listOptions.SortField = "SortableVersion";
                            break;
                        default:
                            throw new ArgumentException("Unrecognized sort field: " + listOptions.SortField);
                    }
                }
                var dbStateList = db.PageAndSort<SqlDeployState>(listOptions, deployStateSql);

                var idList = dbStateList.Items.Select(i=>i.ID);
                var dbMachineList = new List<SqlDeployStateMachine>();
                if(idList.Count() > 0)
                {
                    var machineSql = GetBaseMachineQuery().Append("WHERE DeployStateID IN (@deployStateIdList)", new { deployStateIdList=idList });
                    dbMachineList = db.Fetch<SqlDeployStateMachine>(machineSql).ToList();
                }
                var returnList = dbStateList.Cast(i=>PopulateComponentDeployHistory(i, dbMachineList));
                returnList.Items.ForEach(i=>i.BuildDisplayValue = DeployBuild.GetDisplayValue(i.ProjectName, i.ProjectBranchName, i.ProjectComponentName, i.Version));
                return returnList;
            }
        }
コード例 #21
0
 public PagedSortedList<SrirachaUser> GetUserList(ListOptions listOptions, List<string> userNameList = null, List<string> emailAddressList = null)
 {
     listOptions = ListOptions.SetDefaults(listOptions, 20, 1, "UserName", true);
     var sql = PetaPoco.Sql.Builder.Append("WHERE 0=0");
     if(userNameList != null && userNameList.Any())
     {
         sql = sql.Append("AND UserName IN (@userNameList)", new {userNameList});
     }
     if(emailAddressList != null && emailAddressList.Any())
     {
         sql = sql.Append("AND EmailAddress IN (@emailAddressList)", new {emailAddressList});
     }
     switch(listOptions.SortField)
     {
         case "UserName":
         case "EmailAddress":   
             //Have a nice day!
             break;
         default:
             throw new UnrecognizedSortFieldException<SrirachaUser>(listOptions);
     }
     using(var db = _sqlConnectionInfo.GetDB())
     {
         var list = db.PageAndSort<SqlSrirachaUser>(listOptions, sql);
         return list.Cast(i=>i.ToDto());
     }
 }
コード例 #22
0
		public PagedSortedList<DeployBatchRequest> GetDeployBatchRequestList(ListOptions listOptions)
		{
			return _deployRepository.GetBatchRequestList(listOptions);
		}
コード例 #23
0
		public PagedSortedList<DeployBatchRequest> GetQueue(ListOptions listOptions, List<EnumDeployStatus> statusList=null, List<string> environmentIds=null, bool includeResumeRequested=true)
		{
			return _deployRepository.GetDeployQueue(listOptions, statusList, environmentIds, includeResumeRequested);
		}
コード例 #24
0
 public PagedSortedList<SystemRole> GetSystemRoleList(ListOptions listOptions)
 {
     this.EnsureEveryoneRoleExists();
     this.EnsureAdministratorRoleExists();
     return _systemRoleRepository.GetSystemRoleList(listOptions);
 }
コード例 #25
0
 public PagedSortedList<SrirachaUser> GetUserList(ListOptions listOptions, List<string> userNameList = null)
 {
     return _membershipRepository.GetUserList(listOptions, userNameList);
 }
コード例 #26
0
 public PagedSortedList<ComponentDeployHistory> GetComponentDeployHistory(ListOptions listOptions, List<string> projectIdList, List<string> branchIdList, List<string> componentIdList, List<string> buildIdList, List<string> environmentIdList, List<string> environmentNameList, List<string> machineIdList, List<string> machineNameList, List<string> statusList)
 {
     listOptions = ListOptions.SetDefaults(listOptions, 10, 1, "DeploymentStartedDateTimeUtc", false);
     return _deployStateRepository.GetComponentDeployHistory(listOptions, projectIdList, branchIdList, componentIdList, buildIdList, environmentIdList, environmentNameList, machineIdList, machineNameList, statusList);
 }
コード例 #27
0
        //private string FormatId(string domain, string userName)
        //{
        //    string returnValue = "DeployCredentials_" + userName.Replace("\\", "_");
        //    if(!string.IsNullOrEmpty(domain))
        //    {
        //        returnValue += "_" + domain.Replace("\\","_");
        //    }
        //    return returnValue;
        //}

		public PagedSortedList<DeployCredentials> GetCredentialsList(ListOptions listOptions)
		{
			listOptions = listOptions ?? new ListOptions();
			var pagedList = _documentSession.QueryPageAndSort<DeployCredentials>(listOptions, "UserName", true, null);
			return new PagedSortedList<DeployCredentials>(pagedList, listOptions.SortField, listOptions.SortAscending.GetValueOrDefault());
		}
コード例 #28
0
 public PagedSortedList<DeployBatchRequest> GetBatchRequestList(ListOptions listOptions)
 {
     listOptions = ListOptions.SetDefaults(listOptions, 10, 1, "SubmittedDateTimeUtc", false);
     var pagedList = _documentSession.QueryPageAndSort<DeployBatchRequest>(listOptions, "SubmittedDateTimeUtc", false);
     return new PagedSortedList<DeployBatchRequest>(pagedList, listOptions.SortField, listOptions.SortAscending.Value);
 }
コード例 #29
0
 public PagedSortedList<DeployBatchRequest> GetDeployQueue(ListOptions listOptions, List<EnumDeployStatus> statusList = null, List<string> environmentIds = null, bool includeResumeRequested = true)
 {
     throw new NotSupportedException();
 }
コード例 #30
0
 public PagedSortedList<SystemLog> GetList(ListOptions listOptions, List<EnumSystemLogType> systemLogTypeList = null)
 {
     throw new NotSupportedException();
 }