Пример #1
0
        public void UpdateBacklogArticle(RallyArtifactsByState artifactsByState)
        {
            string apiKey    = Environment.GetEnvironmentVariable("KNOWLEDGE_OWL_API_KEY").Trim();
            string articleId = Environment.GetEnvironmentVariable("KNOWLEDGE_OWL_ARTICLE_ID").Trim();
            var    knowledgeOwlRestClient = new RestClient("https://app.knowledgeowl.com/api/head/");

            knowledgeOwlRestClient.Authenticator = new HttpBasicAuthenticator(apiKey, "AnyFooBarPassword");
            if (knowledgeOwlRestClient == null)
            {
                throw new ArgumentNullException(nameof(knowledgeOwlRestClient));
            }

            var backlogTable  = CreateTable(artifactsByState.Backlog);
            var currentTable  = CreateTable(artifactsByState.CurrentIteration);
            var previousTable = CreateTable(artifactsByState.PreviousIterations);

            var urlPut     = string.Format("article/{0}.json", articleId);
            var requestPut = new RestRequest(urlPut, Method.PUT);

            requestPut.Parameters.Clear();
            requestPut.RequestFormat = DataFormat.Json;
            requestPut.AddHeader("accept", "application/json, text/plain, */*");
            requestPut.AddHeader("content-type", "application/json");

            var article = new Article();

            article.current_version.en.text = CreateBody(previousTable, currentTable, backlogTable);
            requestPut.AddJsonBody(article); //serializes the object automatically
            var responsePut = knowledgeOwlRestClient.Execute(requestPut);

            _logger.Debug(responsePut.Content);
        }
Пример #2
0
        private RallyArtifactsByState GroupByStates(IList <RallyArtifact> artifacts, IList <RallyIteration> iterations)
        {
            var artifactsByState = new RallyArtifactsByState();

            var previous = iterations.Where(x => x.EndDate < DateTime.Today).Select(x => x.Name);

            artifactsByState.PreviousIterations = artifacts.Where(x => previous.Contains(x.IterationName)).ToList();

            var current =
                iterations.Where(x => x.EndDate >= DateTime.Today &&
                                 x.StartDate <= DateTime.Today).Select(x => x.Name);

            artifactsByState.CurrentIteration =
                artifacts.Where(x => current.Contains(x.IterationName)).ToList();

            artifactsByState.Backlog =
                artifacts.Where(x => previous.Contains(x.IterationName) == false &&
                                current.Contains(x.IterationName) == false)
                .ToList();

            return(artifactsByState);
        }