Beispiel #1
0
        /// <summary>
        /// Get team project list
        /// </summary>
        /// <param name="stateFilter"></param>
        /// <param name="top"></param>
        /// <param name="skip"></param>
        /// <returns></returns>
        public async Task <JsonCollection <TeamProject> > GetTeamProjects(ProjectState?stateFilter = null, int?top = null, int?skip = null)
        {
            string response = await GetResponse(string.Empty,
                                                new Dictionary <string, object>() { { "$stateFilter", stateFilter }, { "$top", top }, { "$skip", skip } });

            return(JsonConvert.DeserializeObject <JsonCollection <TeamProject> >(response));
        }
Beispiel #2
0
        /// <summary>
        /// 获取某个分类和状态下总页数
        /// </summary>
        /// <param name="state"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public int GetPageCount(int classifyId, ProjectState?state, int pageSize)
        {
            int projectCount = dal.GetModelCount(classifyId, state);
            int pageCount    = Convert.ToInt32(Math.Ceiling((double)projectCount / pageSize));

            return(pageCount);
        }
Beispiel #3
0
        public Task <List <TeamProjectReference> > ListProjectsAsync(ProjectState?stateFilter = null, int?top = null, int?skip = null, bool?getDefaultTeamImageUrl = null)
        {
            var builder = GetBuilder(project: null, apiPath: "projects");

            builder.AppendEnum("stateFilter", stateFilter);
            builder.AppendInt("$top", top);
            builder.AppendInt("$skip", skip);
            builder.AppendBool("getDefaultTeamImageUrl", getDefaultTeamImageUrl);
            return(ListItemsCore <TeamProjectReference>(builder, limit: top));
        }
        /// <summary>
        /// Gets the team project references for the given <paramref name="projectHttpClient" />.
        /// </summary>
        /// <param name="projectHttpClient">The project HTTP client.</param>
        /// <param name="stateFilter">Filter on team projects in a specific team project state.</param>
        /// <param name="count">The amount of project references to retrieve at most.</param>
        /// <param name="skip">How many project references to skip.</param>
        /// <param name="userState">The user state object to pass along to the underlying method.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">projectCollectionHttpClient</exception>
        public static IAsyncEnumerable <TeamProjectReference> GetTeamProjectReferences(
            this ProjectHttpClient projectHttpClient, ProjectState?stateFilter = null, int?count = null, int?skip = null, object userState = null)
        {
            if (projectHttpClient == null)
            {
                throw new ArgumentNullException(nameof(projectHttpClient));
            }

            return(AsyncEnumerabletHelper.GetAsyncEnumerableForPagedListProducer(
                       iterationInput => projectHttpClient.GetProjects(stateFilter, iterationInput.Count, iterationInput.Skip, userState), count, skip));
        }
        /// <summary>
        /// Gets the team projects for the given <paramref name="projectHttpClient" />.
        /// </summary>
        /// <param name="projectHttpClient">The project HTTP client.</param>
        /// <param name="stateFilter">Filter on team projects in a specific team project state.</param>
        /// <param name="count">The amount of projects to retrieve at most.</param>
        /// <param name="skip">How many projects to skip.</param>
        /// <param name="includeCapabilities">Include capabilities (such as source control) in the team project result.</param>
        /// <param name="includeHistory">Search within renamed projects (that had such name in the past).</param>
        /// <param name="userState">The user state object to pass along to the underlying method.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">projectHttpClient</exception>
        public static IAsyncEnumerable <TeamProject> GetTeamProjects(
            this ProjectHttpClient projectHttpClient, ProjectState?stateFilter = null, int?count = null, int?skip = null, bool?includeCapabilities = null, bool includeHistory = false, object userState = null)
        {
            if (projectHttpClient == null)
            {
                throw new ArgumentNullException(nameof(projectHttpClient));
            }

            return(projectHttpClient.GetTeamProjectReferences(stateFilter, count, skip, userState)
                   .SelectAwait(teamProjectReference =>
                                new ValueTask <TeamProject>(projectHttpClient.GetProject(teamProjectReference.Id.ToString(), includeCapabilities, includeHistory, userState))));
        }
Beispiel #6
0
 /// <summary>
 /// Default constructor for the registry.
 /// </summary>
 internal EditorGameServiceRegistry(IProjectStateRequest projectStateRequest = null,
                                    IProjectStateHelper projectStateHelper   = null,
                                    IServiceFlagRequest serviceFlagRequest   = null,
                                    UserRoleHandler userRoleHandler          = null)
 {
     Services = new Dictionary <string, IEditorGameService>();
     m_ProjectStateRequest = projectStateRequest;
     m_CachedProjectState  = m_ProjectStateRequest?.GetProjectState();
     m_ProjectStateHelper  = projectStateHelper;
     m_ServiceFlagRequest  = serviceFlagRequest;
     m_UserRoleHandler     = userRoleHandler;
 }
Beispiel #7
0
        public async Task <JsonResult> SearchProjects(ProjectState?projectState, string searchName, int pageIndex, int?pageSize)
        {
            pageSize ??= 8;
            var result = await _projectService.SearchProject(projectState, searchName, pageIndex, pageSize.Value);

            return(new JsonResult(new
            {
                total = result.Total,
                projects = result.Records,
                pageCount = result.Total == 0 ? 1
                        : (result.Total % pageSize == 0 ? result.Total / pageSize
                            : result.Total / pageSize + 1)
            }));
        }
Beispiel #8
0
        public async Task <IActionResult> Index(ProjectState?selectedState, string searchName, int?pageIndex, int?pageSize)
        {
            var searchResult = await _projectService.SearchProject(selectedState, searchName, pageIndex ??= 0, pageSize ??= 20);

            var model = ProjectListViewModel.Create(searchResult.Records);

            model.Total         = searchResult.Total;
            model.SearchName    = searchName;
            model.SelectedState = selectedState;
            model.PageIndex     = pageIndex.Value;
            var pmod = model.Total % pageSize.Value;

            model.PageNumber = model.Total == 0 ? 1 : pmod == 0 ? model.Total / pageSize.Value : (model.Total / pageSize.Value + 1);

            return(View(model));
        }
Beispiel #9
0
 void VerifyIfProjectBindChanges()
 {
     if (m_ProjectStateRequest != null && m_ProjectStateHelper != null)
     {
         var currentProjectState = m_ProjectStateRequest.GetProjectState();
         if (m_ProjectStateHelper.IsProjectOnlyPartiallyBound(currentProjectState))
         {
             return;
         }
         if (m_ProjectStateHelper.IsProjectBeingUnbound(m_CachedProjectState, currentProjectState))
         {
             UpdateServicesForProjectUnbinding();
         }
         else if (m_ProjectStateHelper.IsProjectBeingBound(m_CachedProjectState, currentProjectState))
         {
             UpdateServicesForProjectBinding();
         }
         m_CachedProjectState = currentProjectState;
     }
 }
        /// <summary>
        /// 获取状态下所有条数
        /// </summary>
        /// <param name="classifyId">分类id</param>
        /// <param name="state">状态</param>
        /// <returns></returns>
        public int GetModelCount(int classifyId, ProjectState?state)
        {
            StringBuilder       sql    = new StringBuilder($"select count(*) from Projects where PublishState={Convert.ToInt32(PublishState.Approved)} ");
            List <SqlParameter> psList = new List <SqlParameter>();

            if (state != ProjectState.Null && state != null)
            {
                sql.Append(" and State=@state");
                psList.Add(new SqlParameter("@state", state));
            }
            if (classifyId > 0)
            {
                if (sql.ToString().IndexOf("where") < 0)
                {
                    sql.Append(" where");
                }
                sql.Append(" and classifyId=@classifyId");
                psList.Add(new SqlParameter("@classifyId", classifyId));
            }
            return((int)DbHelper.ExecuteScalar(sql.ToString(), psList.ToArray()));
        }
 private Project(string name, Input <string> id, ProjectState?state = null, CustomResourceOptions?options = null)
     : base("mongodbatlas:index/project:Project", name, state, MakeResourceOptions(options, id))
 {
 }
Beispiel #12
0
 private Project(string name, Input <string> id, ProjectState?state = null, CustomResourceOptions?options = null)
     : base("openstack:identity/project:Project", name, state, MakeResourceOptions(options, id))
 {
 }
 public bool TryGetProjectState(ProjectId projectId, [NotNullWhen(true)] out ProjectState?state)
 => _projectStates.TryGetValue(projectId, out state);
Beispiel #14
0
 private Project(string name, Input <string> id, ProjectState?state = null, CustomResourceOptions?options = null)
     : base("gcp:organizations/project:Project", name, state, MakeResourceOptions(options, id))
 {
 }
Beispiel #15
0
 public bool IsProjectBeingBound(ProjectState?cachedProjectState, ProjectState currentProjectState)
 {
     return((!cachedProjectState.HasValue ||
             !cachedProjectState.Value.ProjectBound) &&
            currentProjectState.ProjectBound);
 }
Beispiel #16
0
        /// <summary>
        /// Gets all projects.
        /// </summary>
        /// <param name="client">The <see cref="ProjectHttpClient"/> to use.</param>
        /// <param name="stateFilter">Filter on team projects in a specific team project state.</param>
        /// <param name="pageSize">Page size to use while retrieving the projects.</param>
        /// <param name="includeCapabilities">Include capabilities (such as source control) in the team project result.</param>
        /// <param name="userState">The user state object.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        public static async Task <IList <TeamProject> > GetAllProjects(this ProjectHttpClient client, ProjectState?stateFilter = null, int pageSize = 25, bool?includeCapabilities = null, object userState = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (pageSize <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pageSize));
            }

            var result = new List <TeamProject>();

            int currentPage = 0;
            var currentProjectReferences = (await client.GetProjects(stateFilter, pageSize, currentPage, userState).ConfigureAwait(false)).ToList();

            while (currentProjectReferences.Count > 0)
            {
                foreach (var projectReference in currentProjectReferences)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    result.Add(await client.GetProject(projectReference.Id, includeCapabilities, userState).ConfigureAwait(false));
                }

                // check whether the recently returned item(s) were less than the max page size
                if (currentProjectReferences.Count < pageSize)
                {
                    break; // if so, break the loop as we've read all instances
                }
                // otherwise continue
                cancellationToken.ThrowIfCancellationRequested();
                currentProjectReferences = (await client.GetProjects(stateFilter, pageSize, currentPage, userState).ConfigureAwait(false)).ToList();
            }

            cancellationToken.ThrowIfCancellationRequested();
            return(result);
        }
Beispiel #17
0
 private Project(string name, Input <string> id, ProjectState?state = null, CustomResourceOptions?options = null)
     : base("azuredevops:Core/project:Project", name, state, MakeResourceOptions(options, id))
 {
 }
Beispiel #18
0
 /// <summary>
 /// Get an existing Project resource's state with the given name, ID, and optional extra
 /// properties used to qualify the lookup.
 /// </summary>
 ///
 /// <param name="name">The unique name of the resulting resource.</param>
 /// <param name="id">The unique provider ID of the resource to lookup.</param>
 /// <param name="state">Any extra arguments used during the lookup.</param>
 /// <param name="options">A bag of options that control this resource's behavior</param>
 public static Project Get(string name, Input <string> id, ProjectState?state = null, CustomResourceOptions?options = null)
 {
     return(new Project(name, id, state, options));
 }
Beispiel #19
0
 private Project(string name, Input <string> id, ProjectState?state = null, CustomResourceOptions?options = null)
     : base("aws:devicefarm/project:Project", name, state, MakeResourceOptions(options, id))
 {
 }
Beispiel #20
0
 private Project(string name, Input <string> id, ProjectState?state = null, CustomResourceOptions?options = null)
     : base("alicloud:maxcompute/project:Project", name, state, MakeResourceOptions(options, id))
 {
 }