Esempio n. 1
0
        protected override AuthenticationResult VerifyAuthenticationCore(AuthorizedTokenResponse response)
        {
            try
            {
                if (response != null && !String.IsNullOrWhiteSpace(response.AccessToken))
                {
                    ChelloClient client = new ChelloClient(_consumerKey, response.AccessToken);
                    Member member = client.Members.Single("me");

                    response.ExtraData.Add("url", member.Url);
                    response.ExtraData.Add("gravatar", member.Gravatar);
                    response.ExtraData.Add("username", member.Username);
                    response.ExtraData.Add("bio", member.Bio);
                    response.ExtraData.Add("fullName", member.FullName);

                    return new AuthenticationResult(true, _providerName, response.AccessToken, member.Username, response.ExtraData);
                }

                return new AuthenticationResult(false);
            }
            catch (Exception ex)
            {
                return new AuthenticationResult(ex, _providerName);
            }
        }
Esempio n. 2
0
        public ActionResult Board(string id, string s = "", string e = "")
        {
            ChelloClient client = TrelloClientFactory.Get();
            Board        board  = client.Boards.Single(id);

            ViewBag.BoardName = board.Name;
            ViewBag.BoardId   = id;

            DateTime startDate = DateTime.MinValue;
            DateTime endDate   = DateTime.MaxValue;

            DateTime.TryParseExact(s, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out startDate);

            if (!DateTime.TryParseExact(e, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out endDate))
            {
                endDate = DateTime.MaxValue;
            }

            ActivityRepository  repository = new ActivityRepository(id);
            CumulativeFlowModel cards      = new CumulativeFlowModel(repository, startDate, endDate);
            CumulativeFlowModel points     = null;

            if (repository.Lists.SelectMany(l => l.Cards).Any(c => c.Points.HasValue))
            {
                points = new CumulativeFlowModel(repository, startDate, endDate, (cs) => { return(cs.Where(c => c.Points.HasValue).Sum(c => c.Points.Value)); }, "Points");
            }

            return(View(new DiagramsModel(cards, points)));
        }
Esempio n. 3
0
        protected override AuthenticationResult VerifyAuthenticationCore(AuthorizedTokenResponse response)
        {
            try
            {
                if (response != null && !String.IsNullOrWhiteSpace(response.AccessToken))
                {
                    ChelloClient client = new ChelloClient(_consumerKey, response.AccessToken);
                    Member       member = client.Members.Single("me");

                    response.ExtraData.Add("url", member.Url);
                    response.ExtraData.Add("gravatar", member.Gravatar);
                    response.ExtraData.Add("username", member.Username);
                    response.ExtraData.Add("bio", member.Bio);
                    response.ExtraData.Add("fullName", member.FullName);

                    return(new AuthenticationResult(true, _providerName, response.AccessToken, member.Username, response.ExtraData));
                }

                return(new AuthenticationResult(false));
            }
            catch (Exception ex)
            {
                return(new AuthenticationResult(ex, _providerName));
            }
        }
Esempio n. 4
0
        //
        // GET: /Diagrams/

        public ActionResult Index()
        {
            ChelloClient client = TrelloClientFactory.Get();

            var boards = client.Boards.ForUser("me");

            ViewBag.Boards       = boards.Where(b => !b.Closed);
            ViewBag.ClosedBoards = boards.Where(b => b.Closed);

            return(View());
        }
Esempio n. 5
0
        private void Initialize()
        {
            ChelloClient client = TrelloClientFactory.Get();

            _lists = client.Lists.ForBoard(_boardId).ToDictionary(l => l.Id, l => new ActivityList(l.Id, l.Name));

            IEnumerable <CardUpdateAction> updates = client.CardUpdates.ForBoard(_boardId, new { limit = 1000, filter = "createCard,updateCard,moveCardFromBoard,moveCardToBoard,updateBoard,createBoard" });

            // HACK: Board closing doesn't come back properly - assume if last activity was a board update it is board closing
            // may give strange results for some cases
            if (updates.FirstOrDefault().Type.Equals("updateBoard", StringComparison.OrdinalIgnoreCase))
            {
                BoardClosed = DateTime.Parse(updates.FirstOrDefault().Date).ToUniversalTime();
            }

            ProcessUpdates(client, updates);
        }
Esempio n. 6
0
        private void ProcessUpdates(ChelloClient client, IEnumerable <CardUpdateAction> updates)
        {
            if (updates == null)
            {
                return;
            }

            foreach (var update in updates.Reverse())
            {
                switch (update.Type.ToUpperInvariant())
                {
                case "CREATECARD":
                case "MOVECARDTOBOARD":
                    if (update.Data.List != null)
                    {
                        _lists.AddCard(update.Data.List.Id, new ActivityCard(update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime()));
                    }
                    break;

                case "UPDATECARD":
                    if (update.Data.ListAfter != null && update.Data.ListBefore != null)
                    {
                        _lists.FinishCard(update.Data.ListBefore.Id, update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime());
                        _lists.AddCard(update.Data.ListAfter.Id, new ActivityCard(update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime()));
                    }
                    else if (update.Data.Card.Closed)
                    {
                        foreach (string listId in _lists.Keys)
                        {
                            _lists.FinishCard(listId, update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime());
                        }
                    }
                    break;

                case "MOVECARDFROMBOARD":
                    // When a card is moved form a board, it's history isn't included in the boards activity any more, get it seperately
                    var cardHistory = client.CardUpdates.ForCard(update.Data.Card.Id, new { limit = 1000, filter = "createCard,updateCard" });
                    ProcessUpdates(client, cardHistory);

                    foreach (string listId in _lists.Keys)
                    {
                        _lists.FinishCard(listId, update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime());
                    }

                    break;

                case "CREATEBOARD":
                    BoardOpened  = DateTime.Parse(update.Date).ToUniversalTime();
                    LimitedByApi = false;
                    break;
                }

                if (LimitedByApi && updates.Any())
                {
                    BoardOpened = DateTime.Parse(updates.LastOrDefault().Date);
                }

                if (update.Data.Card != null)
                {
                    foreach (string listId in _lists.Keys)
                    {
                        _lists.UpdatePoints(listId, update.Data.Card);
                    }
                }
            }
        }
Esempio n. 7
0
        private void ProcessUpdates(ChelloClient client, IEnumerable<CardUpdateAction> updates)
        {
            if (updates == null)
            {
                return;
            }

            foreach (var update in updates.Reverse())
            {
                switch (update.Type.ToUpperInvariant())
                {
                    case "CREATECARD":
                    case "MOVECARDTOBOARD":
                        if (update.Data.List != null)
                        {
                            _lists.AddCard(update.Data.List.Id, new ActivityCard(update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime()));
                        }
                        break;
                    case "UPDATECARD":
                        if (update.Data.ListAfter != null && update.Data.ListBefore != null)
                        {
                            _lists.FinishCard(update.Data.ListBefore.Id, update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime());
                            _lists.AddCard(update.Data.ListAfter.Id, new ActivityCard(update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime()));
                        }
                        else if (update.Data.Card.Closed)
                        {
                            foreach (string listId in _lists.Keys)
                            {
                                _lists.FinishCard(listId, update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime());
                            }
                        }
                        break;
                    case "MOVECARDFROMBOARD":
                        // When a card is moved form a board, it's history isn't included in the boards activity any more, get it seperately
                        var cardHistory = client.CardUpdates.ForCard(update.Data.Card.Id, new { limit = 1000, filter = "createCard,updateCard" });
                        ProcessUpdates(client, cardHistory);

                        foreach (string listId in _lists.Keys)
                        {
                            _lists.FinishCard(listId, update.Data.Card, DateTime.Parse(update.Date).ToUniversalTime());
                        }

                        break;
                    case "CREATEBOARD":
                        BoardOpened = DateTime.Parse(update.Date).ToUniversalTime();
                        LimitedByApi = false;
                        break;
                }

                if (LimitedByApi && updates.Any())
                {
                    BoardOpened = DateTime.Parse(updates.LastOrDefault().Date);
                }

                if (update.Data.Card != null)
                {
                    foreach (string listId in _lists.Keys)
                    {
                        _lists.UpdatePoints(listId, update.Data.Card);
                    }
                }
            }
        }