static void Main(string[] args)
        {
            _mytracker = new PivotalTracker(_apiKey);

            //GetIcebox();

            //Authorisation();

            //var story = new PivotalStory();
            //story.Name = "Hello";
            //story.Description = "World";
            //story.StoryType = StoryType.Chore.ToString();
            //story.Labels = new List<PivotalLabel>()
            //{
            //    new PivotalLabel { Name = "My Label" }
            //};

            //var saved = Task.Run(() => _mytracker.CreateNewStoryAsync(_projectId, story)).Result;

            //Task.Run(() => _mytracker.CreateNewStoryTaskAsync(_projectId, saved.Id.Value, "I am first first raised.", position: 1));
            //Task.Run(() => _mytracker.CreateNewStoryTaskAsync(_projectId, saved.Id.Value, "I am second first raised.", position: 2));
            //Task.Run(() => _mytracker.CreateNewStoryTaskAsync(_projectId, saved.Id.Value, "I am second third raised."));
            //Console.WriteLine("Done!");
            //GetUserInfo();
            //GetProjects();
            //CreateNewStory();
            //PersistProjectIdToTrackerInstance();
            //TestSearch();
            TestGetMyWork();


            Console.ReadKey();
        }
 public PivotalTracker GetTracker()
 {
     // Don't use object initialiser here! We want to initialise the PivotalTracker instance and then overwrite the HttpService with our Mock
     _tracker = new PivotalTracker {
         HttpService = FakeHttpService.Object
     };
     return(_tracker);
 }
        static void Main(string[] args)
        {
            _mytracker = new PivotalTracker(_apiKey);

            //GetUserInfo();
            GetProjects();
            //CreateNewStory();
            Console.ReadKey();
        }
 public PivotalTracker GetTracker(string apiToken = "test", int?projectId = null)
 {
     // Don't use object initialiser here! We want to initialise the PivotalTracker instance and then overwrite the HttpService with our Mock
     _tracker = new PivotalTracker(apiToken, projectId)
     {
         HttpService = FakeHttpService.Object
     };
     return(_tracker);
 }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;

            var tracker        = new PivotalTracker();
            var authorisedUser = await tracker.AuthorizeAsync("your_username", "your_password");

            var projects = await tracker.GetProjectsAsync();

            var story = await tracker.CreateNewStoryAsync(projects.First().Id,
                                                          new PivotalStory { Name = "I'm from uwp" });

            await tracker.CreateNewStoryTaskAsync(2008069, story.Id.Value, "From uwp");

            await tracker.CreateNewStoryTaskAsync(2008069, story.Id.Value, "From uwp2");

            await tracker.CreateNewStoryTaskAsync(2008069, story.Id.Value, "From uwp3");

            await tracker.CreateNewStoryTaskAsync(2008069, story.Id.Value, "From uwp4", true, 1);

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
        private static void Authorisation()
        {
            // We create a new instance of the PivotalTracker class using the default constructor
            var tracker = new PivotalTracker();
            // Authorise the tracker instance with username/password. Returns a PivotalUser if successful. Throws an exception if not.
            var authUser = tracker.AuthorizeAsync("your_username", "your_password").Result;

            Console.WriteLine($"API Token on user: {authUser.ApiToken}");
            Console.WriteLine($"API Token on tracker: {tracker.ApiToken}");
        }
        public async Task <IActionResult> HandlePivotalWebhook(WebhookData webhookData)
        {
            var data    = webhookData;
            var pivotal = new PivotalTracker("d1a787245f2e520a7ffe765329aa7e0c", 2438879);
            var storyId = data.Changes.Where(x => x.Kind == "story").Select(x => x.Id).Single();

            var reviews = await pivotal.Tracker.GetStoryReviewsByIdAsync(2438879, storyId.Value);

            var projectReviews      = reviews.Where(x => x.ReviewTypeId == 5692600).ToList();
            var isAnyProjectReviews = projectReviews.Any();

            _logger.Log(LogLevel.Debug, JsonConvert.SerializeObject(new { projectReviews, isAnyProjectReviews }));

            return(Ok());
        }
        private static void PersistProjectIdToTrackerInstance()
        {
            // Just grab us the first Project our API Key has access to
            int projectIdToPersist =
                _mytracker.GetProjectsAsync().Result
                .First()
                .Id;
            // Create a new PivotalTracker instance so that it doesn't interfere with `_mytracker`.
            // Passing it an Id will cause it to persist that Id
            PivotalTracker newTracker = new PivotalTracker(_apiKey, projectIdToPersist);

            // We can call the GetProjectStories without passing a projectId as we have one persisted
            List <PivotalStory> projectStories = newTracker.GetProjectStoriesAsync().Result;

            Console.WriteLine($"Found {projectStories.Count} stories using the persisted Project Id '{projectIdToPersist}'");
        }
        BurndownData GetBurndownData(int project, string label, string historicalDataPath)
        {
            var tracker = new PivotalTracker(Environment.GetEnvironmentVariable("TrackerToken", EnvironmentVariableTarget.Machine));
            var stories =
                tracker.Stories(project).Result
                .Where(item => item.Labels.Contains(label, StringComparer.InvariantCultureIgnoreCase))
                .ToArray();

            var pointsRemaining = stories.Where(item => item.CurrentState != PivotalStoryState.Accepted).Sum(item => Math.Max(0, item.Estimate ?? 0));
            var totalPointsBurned = stories.Where(item => item.CurrentState == PivotalStoryState.Accepted).Sum(item => Math.Max(0, item.Estimate ?? 0));

            var burndownData = new BurndownData();
            burndownData.Load(Server.MapPath(historicalDataPath));
            burndownData.Add(DateTime.Today, pointsRemaining, totalPointsBurned);
            return burndownData;
        }
		public Tracker GetTrackerInstance (TrackerType trackerType)
		{
			if (trackers.ContainsKey(trackerType)) return trackers[trackerType];

			switch (trackerType) {
			case TrackerType.DoneDone:
				trackers[trackerType] = new DoneDoneTracker (trackerType);
				break;
			case TrackerType.PivotalTracker:
				trackers[trackerType] = new PivotalTracker (trackerType);
				break;
			case TrackerType.JIRA:
				trackers[trackerType] = new JiraTracker (trackerType);
				break;
			default:
				return null;
			}

			return trackers[trackerType];
		}
Exemple #11
0
 public PivotalTrackerTestClass()
 {
     pt = new DotNetPivotalTrackerApi.Services.PivotalTracker(_apiToken);
 }