예제 #1
0
        /// <summary>
        /// Добавление новых задач
        /// </summary>
        /// <param name="listId"> Id листа в которую нужно добавить задачи</param>
        /// <param name="_tasksId">Список задач через "," которые нужно добавить </param>
        public void addTask(string listId, string _tasksId)
        {
            if (_tasksId == "")
                return;
            Configuration currentConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            /*ITrello trello = new Trello("b9d8a6a9f2aaa03e9b6426c6c135a689");
            trello.Authorize("9180c1adedfd5f7a48153af5c7beed8b45458df229f5262887beb6e4b9e16027");*/
            ITrello trello = new Trello(currentConfig.AppSettings.Settings["AppKey"].Value);

            trello.Authorize(currentConfig.AppSettings.Settings["Token"].Value);
            List list = trello.Lists.WithId(listId);
            string[] tasksId = _tasksId.Split(new char[] { ',' });
            BoardModel borad = findBoardModel(boardModel, list.IdBoard);
            ListModel listMod = findListModel(borad.ListModel, list.Id);
            BindingList<CardModel> cardModel = listMod.CardModel;
            foreach (string taskId in tasksId)
            {
                //trello.Cards.Add()
                NewCard card = new NewCard(taskId, new ListId(list.Id));
                /*card.Name = taskId;
                card.IdBoard = list.IdBoard;
                card.IdList = list.Id;*/
                Card cardAdd = trello.Cards.Add(card);
                cardModel.Add( new CardModel() {Id = cardAdd.Id, IdBoard = cardAdd.IdBoard, IdList = cardAdd.IdList, Name = cardAdd.Name, Desc = cardAdd.Desc != "" ? cardAdd.Desc : "Пусто" });

            }
            //listMod.CardModel = cardModel;
            //borad.ListModel.Add(listMod);
            //boardModel.Add(borad);
        }
예제 #2
0
        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 IEnumerable<NewCard> CreateCards(Grid grid, IListId list)
        {
            if(!grid.Cells.Any())
                return Enumerable.Empty<NewCard>();

            var leftMostColumn = grid.Cells.Min(c => c.Column);

            return grid.Cells
                .GroupBy(c => c.Row)
                .Where(c => c.Any(x => x.Column == leftMostColumn))
                .Select(c =>
                {
                    var newCard = new NewCard(c.First().Value, list);
                    if (c.Count() > 1)
                        newCard.Desc = c.ElementAt(1).Value;
                    return newCard;
                });
        }
        private bool ExportCards(IEnumerable<CardInfo> cards)
        {
            var totalCount = cards.Count();
            var currentCard = 0;
            foreach (var cardInfo in cards)
            {
                if (exportCardsCancellationTokenSource.Token.IsCancellationRequested)
                    return false;

                Task.Factory.StartNew(() => view.ShowStatusMessage(@"Adding card {0}/{1}.", ++currentCard, totalCount),
                    CancellationToken.None, TaskCreationOptions.None, taskScheduler);

                var newCard = new NewCard(cardInfo.Name, cardInfo.ListId) { Desc = cardInfo.Desc };
                var addedCard = trello.Cards.Add(newCard);

                if(cardInfo.Due.HasValue)
                    trello.Cards.ChangeDueDate(addedCard, cardInfo.Due.Value);
            }

            return true;
        }