public Model.Stats.CardStats GetCardStats(string listName, List<Action> actions) { var listData = ListDataFactory.GetListData(listName); var cardData = new CardData() { Actions = actions, Card = new Card() }; var cardStats = new TrelloStats.Model.Stats.CardStats() { CardData = cardData, ListData = listData, ListNames = ListNameConfigStub, TimeZone = TrelloStatsConfigStub.TimeZone }; return cardStats; }
private static void AddCards(List<DevCard> list, List backlog, ITrello trello, int count) { _cards = new List<Card>(); _dic = new Dictionary<Card, DevCard>(); foreach (var devCard in list) { Console.WriteLine(devCard.ToString()); var cardname = GetCardName(devCard); var cc = new NewCard(cardname, backlog); var msg = devCard.ToString(); msg += Environment.NewLine + Environment.NewLine + string.Format("Feature:{0} Priority:{1} {2}", devCard.Feature + Environment.NewLine, devCard.Priority + Environment.NewLine, devCard.Notes + Environment.NewLine); cc.Desc = msg; var card = trello.Cards.ForList(backlog).FirstOrDefault(a => a.Name.ToLowerInvariant() == cardname.ToLowerInvariant()); if (card == null) { card = trello.Cards.Add(cc); } _cards.Add(card); _dic.Add(card, devCard); } }
public SearchResults() { Boards = new List<Board>(); Cards = new List<Card>(); Organizations = new List<Organization>(); Members = new List<Member>(); Actions = new List<Action>(); }
public static IDocumentTagContextBuilder AddCards(this IDocumentTagContextBuilder builder, List<Card> cards) { foreach (var card in cards) { builder.Paragraph(z => z.Text(card.Name)); } return builder; }
public static IDocument AddCards(this IDocument builder, List<Card> cards) { foreach (var card in cards) { builder.AddEle(Link.With(string.Format("\t- {0}", card.Name.Replace("&", "&")), card.Url).Create()); } return builder; }
public byte[] GenerateCardReports(List<Card> cards, List<List> lists, List<string> users) { var weekNumber = DateTimeHelper.GetWeekNumber(DateTime.Now); const string interval = "201#.##.## - 201#.##.##"; IDocument myDoc = new Document2004(); myDoc = myDoc.AddHeader(weekNumber, interval).AddHeadline(weekNumber).AddReports(cards, lists); return myDoc.CreateResponse(); }
public TrelloClient(ITrelloConfig trelloConfig) { _trelloConfig = trelloConfig; _trello = Ioc.Container.Resolve<ITrello>(new ParameterOverride("key", _trelloConfig.TrelloKey)); _trello.Authorize(_trelloConfig.TrelloToken); _lists = GetLists(); _members = GetMembers(); _cards = new List<TfsCard>(); BoardId = new BoardId(trelloConfig.BoardId); }
private ListData CreateListData(List list) { var cardList = _trelloClient.GetCardsForList(list); var listData = new ListData(list); foreach (var card in cardList) { listData.AddCardData(CreateCardData(card)); } return listData; }
/// <summary> /// Get user boards /// </summary> /// <returns>User boars</returns> public ActionResult GetBoards() { var boards = TrelloInstance.Boards.ForMe().OrderBy(b => b.Name); var retBoards = new List<object>(); foreach (var board in boards) { retBoards.Add(new { board.Id, board.Name, board.Closed, board.IdOrganization, board.Desc }); } return CreateResponse(retBoards); }
public byte[] GenerateCardReports(List<Card> cards, List<List> lists, List<string> users) { // Opening the Excel template... using (var fs = new MemoryStream()) { var templateWorkbook = new HSSFWorkbook(); var sheet = templateWorkbook.CreateSheet("Sheet1"); sheet.CreateHeader().AddReports(cards, lists, users); sheet.ForceFormulaRecalculation = true; return templateWorkbook.CreateRepsonse(); } }
private static void AddAcceptanceCriteria(List backlog, Board board) { foreach (var card in _trello.Cards.ForList(backlog).Where(a=>a.Checklists.Count==0)) { var gg = _devCards.FirstOrDefault(a => GetCardName(a) == card.Name); var cl = SetChecklist(gg); _trello.Cards.AddChecklist(card, cl); _trello.Cards.Update(card); _trello.Checklists.Update(cl); } }
public static IDocument AddLists(this IDocument builder, List<Card> cards, List<List> lists) { var groupped = cards.GroupBy(c => c.IdList); foreach (var group in groupped) { var name = lists.FirstOrDefault(l => l.Id == @group.Key).Name; builder.AddEle(Heading3.With(string.Format("{0}:", name)).WithStyle().SetBold(false).Create()); builder.AddCards(group.ToList()); } return builder; }
public static IDocumentTagContextBuilder AddLists(this IDocumentTagContextBuilder builder, List<Card> cards, List<List> lists) { var groupped = cards.GroupBy(c => c.IdList); foreach (var group in groupped) { var name = lists.FirstOrDefault(l => l.Id == @group.Key).Name; builder.Paragraph(z => z.Bold.Text(string.Format("{0}:", name))) .AddCards(group.ToList()) .EmptyLine(); } return builder; }
public byte[] GenerateCardReports(List<Card> cards, List<List> lists) { using (var docxDocument = new DocxDocument(SimpleTemplate.EmptyWordFile)) { var builder = new DocxDocumentBuilder(docxDocument); builder.Tag(SimpleTemplate.HeaderTagName, x => x.Paragraph(z => z.Bold.Text("X. etap - 2012.03.18 - 29 - várható fejlesztések"))); builder.Tag(SimpleTemplate.ContentTagName, x => FoxbyWordServiceHelper.AddHeadline(x, 12).AddReports(cards, lists)); return docxDocument.ToArray(); } }
private static string[] CreateStringArrayFromCard(Card card, IEnumerable<List> lists, IEnumerable<string> fieldsToInclude) { var list = new List<string>(); if(fieldsToInclude.Contains("Name")) list.Add(card.Name); if (fieldsToInclude.Contains("Description")) list.Add(card.Desc); if (fieldsToInclude.Contains("Due Date")) list.Add(card.Due.ToString()); if (fieldsToInclude.Contains("List")) list.Add(lists.FirstOrDefault() != null ? lists.FirstOrDefault().Name : null); return list.ToArray(); }
public void GivenATrelloServiceWhenGetColumnCardCounts() { var listOne = new List {Id = ListOneId, Name = ListOneId}; var listTwo = new List {Id = ListTwoId, Name = ListTwoId}; var listThree = new List {Id = ListThreeId, Name = ListThreeId}; _lists = new List<List> {listOne, listTwo, listThree}; var listOneCards = new List<Card> {new Card()}; var listTwoCards = new List<Card> {new Card(), new Card()}; var listThreeCards = new List<Card> {new Card(), new Card(), new Card()}; var mockBoards = new Mock<IBoards>(); mockBoards .Setup(b => b.WithId(It.IsAny<string>())) .Returns(new Board()); var mockLists = new Mock<ILists>(); mockLists .Setup(l => l.ForBoard(It.IsAny<Board>(), It.IsAny<ListFilter>())) .Returns(_lists); var mockCards = new Mock<ICards>(); mockCards .Setup(c => c.ForList(listOne, It.IsAny<CardFilter>())) .Returns(listOneCards); mockCards .Setup(c => c.ForList(listTwo, It.IsAny<CardFilter>())) .Returns(listTwoCards); mockCards .Setup(c => c.ForList(listThree, It.IsAny<CardFilter>())) .Returns(listThreeCards); _mockTrelloService = new Mock<ITrello>(); _mockTrelloService .SetupGet(s => s.Boards) .Returns(mockBoards.Object); _mockTrelloService .SetupGet(s => s.Lists) .Returns(mockLists.Object); _mockTrelloService .SetupGet(s => s.Cards) .Returns(mockCards.Object); var trelloBoardService = new TrelloBoardService(_mockTrelloService.Object, "boardId"); _result = trelloBoardService.GetColumnCardCounts(); }
public List<Board> Load() { List<Board> boards = new List<Board>(); if (File.Exists(path)) { try { string str = File.ReadAllText(path, Encoding.UTF8); boards = JsonConvert.DeserializeObject<List<Board>>(str); } catch (Exception ex) { Debug.WriteLine(ex); } } return boards; }
public static ISheet AddReports(this ISheet builder, List<Card> cards, List<List> lists, List<string> users) { var comparer = new CardComparer(); var groupped = cards.GroupBy(c => c.Labels, comparer); //var rowNumber = 1; foreach (var group in groupped) { // write project name var name = "Egyéb"; var key = group.Key.FirstOrDefault(); if (key != null) { name = key.Name; } var tempCards = group.ToList(); foreach (var grouppedCard in tempCards) { var actual = grouppedCard.RemoveUnusedMembers(users); if (actual.Members.Count > 1) { foreach (var member in actual.Members) { builder.AddCard(name, actual, member); builder.AddSubtasks(actual); //rowNumber = rowNumber + 1; } } else { builder.AddCard(name, actual, actual.Members.FirstOrDefault()); builder.AddSubtasks(actual); //rowNumber = rowNumber + 1; } } } return builder; }
public static IDocument AddReports(this IDocument builder, List<Card> cards, List<List> lists) { var comparer = new CardComparer(); var groupped = cards.GroupBy(c => c.Labels, comparer); foreach (var group in groupped) { // write project name var name = "Egyéb"; var key = group.Key.FirstOrDefault(); if (key != null) { name = key.Name; } builder.AddEle(new BreakLine(1)); builder.AddEle(Heading2.With(string.Format("{0}:", name)).WithStyle().Bold().Create()); builder.AddLists(group.ToList(), lists); } return builder; }
public static IDocumentTagContextBuilder AddReports(this IDocumentTagContextBuilder builder, List<Card> cards, List<List> lists) { var comparer = new CardComparer(); var groupped = cards.GroupBy(c => c.Labels, comparer); foreach (var group in groupped) { // write project name var name = "Egyéb"; var key = group.Key.FirstOrDefault(); if (key != null) { name = key.Name; } builder.Paragraph(z => z.Bold.Text(String.Format("{0}:", name))) .AddLists(group.ToList(), lists) .EmptyLine(); } return builder; }
private string[,] GetCardsForSelectedLists(IEnumerable<Card> allCards, IEnumerable<string> fieldsToInclude, List<Card.Label> labelFilter) { var cards = allCards.Where(c => view.CheckedLists.Select(cl => cl.Id).Contains(c.IdList)).ToList(); IEnumerable<string[]> cardsToImportWithListName; if (labelFilter.Count < Enum.GetNames(typeof(TrelloNet.Color)).Length) { cardsToImportWithListName = from c in cards join l in view.CheckedLists on c.IdList equals l.Id into gj where IntersectLabelLists(c.Labels,labelFilter) select CreateStringArrayFromCard(c, gj, fieldsToInclude); } else { cardsToImportWithListName = from c in cards join l in view.CheckedLists on c.IdList equals l.Id into gj select CreateStringArrayFromCard(c, gj, fieldsToInclude); } return new[] { fieldsToInclude.ToArray() }.Union(cardsToImportWithListName).ToArray().ToMultidimensionalArray(); }
private void CardImportWork(object sender, EventArgs eventArgs, bool update) { view.ShowStatusMessage((update ? "Updating" : "Importing") + " cards..."); view.EnableImport = false; view.EnableUpdate = false; view.EnableSelectionOfBoards = false; view.EnableSelectionOfLists = false; view.EnableSelectionOfLabels = false; trello.Async.Cards.ForBoard(view.SelectedBoard, BoardCardFilter.Open) .ContinueWith(t => { if (t.Exception != null) { HandleException(t.Exception); return; } List<Card.Label> checkedLabels = new List<Card.Label>(); foreach (KeyValuePair<Color, string> kvp in view.CheckedLabels) { Card.Label label = new Card.Label(); label.Color = kvp.Key; label.Name = kvp.Value; checkedLabels.Add(label); } // We should only import cards in lists the user selected var cardsToImport = GetCardsForSelectedLists(t.Result, view.FieldsToInclude, checkedLabels); // Create a range based on the current selection. Rows = number of cards, Columns = 4 (to fit name, desc, list and due date) var numberOfRows = cardsToImport.GetUpperBound(0) + 1; var numberOfColumns = view.FieldsToInclude.Count(); var rangeThatFitsAllCards = ResizeToFitAllCards(Globals.ThisAddIn.Application.ActiveWindow.RangeSelection, numberOfRows, numberOfColumns); // Store the address of this range for later user var addressToFirstCell = rangeThatFitsAllCards.AddressLocal; if (!update) { // Kind of copy/paste this range InsertRange(rangeThatFitsAllCards); // The rangeThatFitsAllCards was change after the InsertRange call, so create a new range based on addressToFirstCell rangeThatFitsAllCards = ResizeToFitAllCards(Globals.ThisAddIn.Application.ActiveSheet.Range(addressToFirstCell), numberOfRows, numberOfColumns); } // Set the values of the cells to the cards name, desc and due date UpdateRangeWithCardsToImport(rangeThatFitsAllCards, cardsToImport); view.ShowStatusMessage(string.Format("{0} card(s) imported!", numberOfRows - 1)); view.EnableImport = true; view.EnableUpdate = true; view.EnableSelectionOfBoards = true; view.EnableSelectionOfLists = true; view.EnableSelectionOfLabels = true; }, taskScheduler); }
private static void AddLabels(List backlog, Board board) { foreach (var card in _trello.Cards.ForList(backlog)) { if (!_dic.Any(a => a.Key.Name == card.Name)) continue; var xxx = _dic.FirstOrDefault(a => a.Key.Name == card.Name); if (xxx.Key != null) { SetPriority(xxx.Value, card, _count); _count++; SetTrelloLabel(xxx.Value, card); // _trello.Cards.Update(card); Thread.Sleep(500); } } }
private static void Main(string[] args) { if (!System.IO.File.Exists(File)) throw new FileNotFoundException(File); _pck = new ExcelPackage(new FileInfo(File)); GetColumnIndexes(); const string milestone = "Screens"; _devCards = ExtractDevCards().Where(a => a.Milestone == milestone && a.EstimatedHours > 0).ToList(); _trello = new Trello("7b17eb1ed849a91c051da9c924f93cfb"); var url = _trello.GetAuthorizationUrl("userstorydataloader", Scope.ReadWrite); //Process.Start(url.AbsoluteUri); _trello.Authorize("db2c728bfd1b4cca3e07c0176e6ac3208fd4f363f383f9e0a2ac74081da4cd95"); _board = _trello.Boards.WithId("55a8cdfd9536d1d4a332691f"); _backlog = _trello.Lists .ForBoard(_board) .FirstOrDefault(a => a.Name == "Backlog"); _lbls = _trello.Labels.ForBoard(_board); AddCards(_devCards, _backlog, _trello, _count); Thread.Sleep(5000); AddAcceptanceCriteria(_backlog, _board); Thread.Sleep(5000); AddLabels(_backlog, _board); }
private static List<DevCard> ExtractDevCards() { var worksheet = _pck.Workbook.Worksheets.First(x => x.Name == "Backlog"); Console.WriteLine(worksheet.Name); var list = new List<DevCard>(); var start = worksheet.Dimension.Start; var end = worksheet.Dimension.End; for (var row = start.Row; row <= end.Row; row++) { if (row <= 1) continue; if (row > 50) break; Rows.Add(row); var dc = new DevCard(); for (var col = start.Column; col <= end.Column; col++) { // ... Cell by cell... object cellValue = worksheet.Cells[row, col].Text; // This got me the actual value I needed. Debug.WriteLine(cellValue); if (col > 50) break; switch (col) { case 1: dc.Milestone = Convert.ToString(cellValue); break; case 3: dc.Feature = Convert.ToString(cellValue); break; case 4: dc.AsA = Convert.ToString(cellValue); break; case 5: dc.IWantTo = Convert.ToString(cellValue); break; case 6: dc.SoThat = Convert.ToString(cellValue); break; case 7: dc.Priority = Convert.ToString(cellValue); break; case 8: var ss = Convert.ToString(cellValue); var no = string.IsNullOrEmpty(ss) ? "5" : ss; dc.EstimatedHours = Convert.ToInt16(no); break; case 9: dc.Notes = Convert.ToString(cellValue); break; default: int icol; if (_columnIndexes.TryGetValue("UAC", out icol)) if (icol == col) { dc.AcceptanceCriteria = Convert.ToString(cellValue); } break; } } list.Add(dc); } return list; }
private bool IntersectLabelLists(List<Card.Label> a, List<Card.Label> b) { var intersection = from la in a join lb in b on la.Color equals lb.Color select true; if (intersection.Count<bool>() == 0) return false; foreach (bool found in intersection) if (!found) return false; return true; }
/// <summary> /// Separate <paramref name="cards"/> by card labels /// </summary> /// <param name="cards">Unsepareted cards</param> /// <returns>Separeted cards</returns> public static IEnumerable<Card> SepareteCardByLabels(IEnumerable<Card> cards) { var separeted = new List<Card>(); foreach (var card in cards) { // if more than one label, you should be separately if (card.Labels.Count > 1) { foreach (var label in card.Labels) { var newCard = new Card(); newCard.InjectFrom(card); newCard.Labels = new List<Card.Label> { label }; separeted.Add(newCard); } } else { separeted.Add(card); } } return separeted; }
/// <summary> /// Get card Ids from all action /// </summary> /// <param name="trello">trello interface</param> /// <param name="boardId">board Id</param> /// <param name="startDate">filter start date</param> /// <param name="endDate">filter end date</param> /// <returns>List of card ids</returns> public static List<string> GetCardIdsFromActions(ITrello trello, string boardId, DateTime startDate, DateTime endDate) { var actions = trello.Actions.ForBoard( new BoardId(boardId), since: Since.Date(startDate), paging: new Paging(1000, 0), filter: CardActionTypes); var changedCardActions = actions.Where(a => a.Date > startDate && a.Date < endDate).ToList(); var changedCardIds = new List<string>(); foreach (var changedCardAction in changedCardActions) { // get only cards var cardId = GetCardIdFromAction(changedCardAction); // modified card if (!string.IsNullOrEmpty(cardId)) { // card id isnt exist if (!changedCardIds.Contains(cardId)) { changedCardIds.Add(cardId); } } } return changedCardIds; }
private static string[] CreateStringArrayFromCard(Card card, IEnumerable<List> lists, IEnumerable<string> fieldsToInclude) { var list = new List<string>(); Match match = Regex.Match(card.Name, @"(.*)?\[(([0-9]+)/)?([0-9]+)\](.*)?"); if (fieldsToInclude.Contains("Name")) { if (match.Success) { list.Add(match.Groups[1].Value.Trim() + match.Groups[5].Value); } else { list.Add(card.Name); } } if (fieldsToInclude.Contains("Description")) list.Add(card.Desc); if (fieldsToInclude.Contains("Due Date")) list.Add(card.Due.ToString()); if (fieldsToInclude.Contains("List")) list.Add(lists.FirstOrDefault() != null ? lists.FirstOrDefault().Name : null); int est = -1, log = -1, taskEst = -1, taskLog = -1; if (match.Success) { est = int.Parse(match.Groups[4].Value); } if (match.Success) { if (match.Groups[3].Value.Trim() != "") log = int.Parse(match.Groups[3].Value); } string relTasks = "", allTasks = ""; int i = 0; foreach (TrelloNet.Card.Checklist cl in card.Checklists) { Match clMatch = Regex.Match(cl.Name, @"\{(.*?)\}"); bool relevant = false; if (!clMatch.Success || clMatch.Groups[1].Value == (lists.FirstOrDefault() != null ? lists.FirstOrDefault().Name : null)) relevant = true; foreach (TrelloNet.Card.CheckItem ci in cl.CheckItems) { Match ciMatch = Regex.Match(ci.Name, @"(.*)?\[(([0-9]+)/)?([0-9]+)\](.*)?"); if (ciMatch.Success) { if (taskEst < 0) taskEst = 0; if (taskLog < 0) taskLog = 0; taskEst += int.Parse(ciMatch.Groups[4].Value); if (ci.Checked) taskLog += int.Parse(ciMatch.Groups[4].Value); else if (ciMatch.Groups[3].Value.Trim() != "") taskLog += int.Parse(ciMatch.Groups[3].Value); } string ciName = ciMatch.Groups[0].Value.Trim() + ciMatch.Groups[5].Value; if (relevant) relTasks += (i++ > 0 ? ",\r\n" : "") + ciName; allTasks += (i++ > 0 ? ",\r\n" : "") + ciName; } } if (fieldsToInclude.Contains("Estimates")) { if (taskEst >= 0) list.Add(taskEst.ToString()); else if (est >= 0) list.Add(est.ToString()); else list.Add(""); } if (fieldsToInclude.Contains("Time Log")) { if (taskLog >= 0) list.Add(taskLog.ToString()); else if (log >= 0) list.Add(log.ToString()); else list.Add(""); } if (fieldsToInclude.Contains("Labels")) { var labelStrings = from l in card.Labels select l.Name + "(" + l.Color.ToString() + ")"; string labelString = ""; foreach (string l in labelStrings) { labelString += (labelString.Length > 0?",\r\n":"") + l; } list.Add(labelString); } if (fieldsToInclude.Contains("Tasks (Relevant)")) { list.Add(relTasks); } if (fieldsToInclude.Contains("Tasks (All)")) { list.Add(allTasks); } return list.ToArray(); }
public void LoadCards(BackgroundWorker worker, List list) { client.RefreshList(worker, new List[]{ list }); }