Beispiel #1
0
        internal List <LcsProject> GetAllProjects()
        {
            const int numberOfProjectsRequested = 50;
            int       numberOfProjectReturned;
            var       allProjects = new List <LcsProject>();
            var       pageNumber  = 0;

            SetRequestVerificationToken($"{LcsUrl}/V2");
            do
            {
                pageNumber++;
                var pagingParams = new PagingParameters()
                {
                    DynamicPaging = new DynamicPaging()
                    {
                        StartPosition  = pageNumber * numberOfProjectsRequested - numberOfProjectsRequested,
                        ItemsRequested = numberOfProjectsRequested
                    }
                };
                var pagingParamsJson = JsonConvert.SerializeObject(pagingParams, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });

                using (_stringContent = new StringContent(pagingParamsJson, Encoding.UTF8, "application/json"))
                {
                    var result = _httpClient.PostAsync($"{LcsUrl}/RainierProject/AllProjectsList", _stringContent).Result;
                    result.EnsureSuccessStatusCode();

                    var responseBody = result.Content.ReadAsStringAsync().Result;
                    var response     = JsonConvert.DeserializeObject <Response>(responseBody);
                    if (response.Success && response.Data != null)
                    {
                        var projects = JsonConvert.DeserializeObject <ProjectsData>(response.Data.ToString()).Results;
                        numberOfProjectReturned = projects.Count;
                        allProjects.AddRange(projects);
                    }
                    else
                    {
                        numberOfProjectReturned = 0;
                    }
                }
            }while (numberOfProjectReturned == numberOfProjectsRequested);

            SetLastActivity();

            return(allProjects);
        }
Beispiel #2
0
        internal List <DeployablePackage> GetPagedDeployablePackageList(CloudHostedInstance instance)
        {
            const int numberOfPackagesRequested = 50;
            int       numberOfPackagesReturned;
            var       packageList = new List <DeployablePackage>();
            var       pageNumber  = 0;

            SetRequestVerificationToken($"{LcsUrl}/V2");
            do
            {
                pageNumber++;
                var pagingParams = new PagingParameters()
                {
                    DynamicPaging = new DynamicPaging()
                    {
                        StartPosition  = pageNumber * numberOfPackagesRequested - numberOfPackagesRequested,
                        ItemsRequested = numberOfPackagesRequested
                    }
                };
                var pagingParamsJson = JsonConvert.SerializeObject(pagingParams, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                });

                using (_stringContent = new StringContent(pagingParamsJson, Encoding.UTF8, "application/json"))
                {
                    var result = _httpClient.PostAsync(GetPagedDeployablePackageListUrl(instance), _stringContent).Result;
                    result.EnsureSuccessStatusCode();

                    var responseBody = result.Content.ReadAsStringAsync().Result;
                    var response     = JsonConvert.DeserializeObject <Response>(responseBody);
                    if (response.Success && response.Data != null)
                    {
                        var packages = JsonConvert.DeserializeObject <PackagesData>(response.Data.ToString()).Results;
                        numberOfPackagesReturned = packages.Count;
                        packageList.AddRange(packages);
                    }
                    else
                    {
                        numberOfPackagesReturned = 0;
                    }
                }
            }while (numberOfPackagesReturned == numberOfPackagesRequested);

            return(packageList);
        }
Beispiel #3
0
        internal List <ActionDetails> GetEnvironmentHistoryDetails(CloudHostedInstance instance)
        {
            const int historyItemsCount = 40;

            var pagingParams = new PagingParameters()
            {
                DynamicPaging = new DynamicPaging()
                {
                    StartPosition  = 0,
                    ItemsRequested = historyItemsCount
                }
            };
            var pagingParamsJson = JsonConvert.SerializeObject(pagingParams, new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Auto
            });

            using (_stringContent = new StringContent(pagingParamsJson, Encoding.UTF8, "application/json"))
            {
                SetRequestVerificationToken($"{LcsUrl}/V2");
                var result = _httpClient.PostAsync($"{LcsUrl}/Environment/GetEnvironmentHistoryDetails/{LcsProjectId}?environmentId={instance.EnvironmentId}&_={DateTimeOffset.Now.ToUnixTimeSeconds()}", _stringContent).Result;
                result.EnsureSuccessStatusCode();
                var settings = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };

                var responseBody = result.Content.ReadAsStringAsync().Result;
                var response     = JsonConvert.DeserializeObject <Response>(responseBody);
                if (response.Success)
                {
                    var data = JsonConvert.DeserializeObject <EnvironmentHistoryDetailsData>(response.Data.ToString(), settings);
                    if (data != null)
                    {
                        return(data.Results);
                    }
                }
                return(null);
            }
        }