Example #1
0
        public async Task <List <TrelloBoard> > FindAll()
        {
            var ret = new List <TrelloBoard>();

            try
            {
                var auth = new TrelloAuthorization
                {
                    AppKey    = _appKey,
                    UserToken = _userToken
                };

                var factory = new TrelloFactory();

                var me = await factory.Me().ConfigureAwait(true);


                foreach (var board in me.Boards)
                {
                    var t = new TrelloBoard
                    {
                        name = board.Name
                    };
                    ret.Add(t);
                }
            }
            catch (TrelloInteractionException e)
            {
                var msg = e.Message;
            }
            return(ret);
        }
 public TrelloListPage(TrelloBoard board)
 {
     InitializeComponent();
     this.Board      = board;
     Title           = Board.Name;
     BackgroundColor = Color.FromHex(Board.ColorHex);
     loadBordAsync();
 }
        }//LoadBoard end

        //
        private void lvwBoards_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            TrelloBoard board = lvwBoards.SelectedItem as TrelloBoard;

            if (board != null)
            {
                Navigation.PushAsync(new TrelloListPage(board));
                lvwBoards.SelectedItem = null;
            }
            //TrelloListPage p = new TrelloListPage();
        }
Example #4
0
 //очистка бд
 public static void deleteBoard(string myBoardId)
 {
     using (TrelloDbContext db = new TrelloDbContext())
     {
         TrelloBoard board = db.Boards
                             .Where(b => b.Id == myBoardId)
                             .FirstOrDefault();
         db.Boards.Remove(board);
         var           lists   = db.Lists;
         List <string> listIds = new List <string>();
         foreach (TrelloList list in lists)
         {
             if (list.BoardId == myBoardId)
             {
                 listIds.Add(list.Id);
                 db.Lists.Remove(list);
             }
         }
         var           cards   = db.Cards;
         List <string> cardIds = new List <string>();
         foreach (TrelloCard card in cards)
         {
             if (listIds.Contains(card.ListId))
             {
                 cardIds.Add(card.Id);
                 db.Cards.Remove(card);
             }
         }
         var           memberscards = db.MembersCards;
         List <string> memberIds    = new List <string>();
         foreach (MemberCard membercard in memberscards)
         {
             if (cardIds.Contains(membercard.CardId))
             {
                 memberIds.Add(membercard.MemberId);
                 db.MembersCards.Remove(membercard);
             }
         }
         var members = db.Members;
         foreach (TrelloMember member in members)
         {
             if (memberIds.Contains(member.Id))
             {
                 db.Members.Remove(member);
             }
         }
         db.SaveChanges();
         db.Dispose();
     }
     Console.WriteLine("Данные по проекту удалены");
     return;
 }
Example #5
0
    IEnumerator GetBoardTitle(int statusIndex)
    {
        UnityWebRequest BoardTitleRequest = trelloAPI.GetBoardTitleHTTPRequest();

        BoardTitleRequest.chunkedTransfer = false;
        BoardTitleRequest.timeout         = 100000;

        yield return(BoardTitleRequest.SendWebRequest());

        if (BoardTitleRequest.isNetworkError || BoardTitleRequest.isHttpError)
        {
            Debug.Log("An error occured receiving events: " + BoardTitleRequest.responseCode);
        }
        else
        {
            TrelloBoard board = JsonUtility.FromJson <TrelloBoard>(BoardTitleRequest.downloadHandler.text);
            boardTitle = board.name;
        }
    }
Example #6
0
        public async Task <ActionResult <TrelloBoard> > PostTrelloBoard(TrelloBoard trelloBoard)
        {
            var key   = Program.Configuration["Trello:key"];
            var token = Program.Configuration["Trello:token"];
            List <TrelloBoard> list = new List <TrelloBoard>();
            string             apiResponse;

            using (var httpClient = new HttpClient())
            {
                var value = new Dictionary <string, string>
                {
                    { "name", trelloBoard.Name }
                };
                var content = new FormUrlEncodedContent(value);

                using (var response = await httpClient.PostAsync($"https://api.trello.com/1/boards/?key={key}&token={token}", content))
                {
                    apiResponse = await response.Content.ReadAsStringAsync();
                }
            }
            return(Ok(apiResponse));
        }
        private async Task TestModels()
        {
            List <TrelloBoard> list = new List <TrelloBoard>();

            list = await TrelloRepository.GetTrelloBoards();

            foreach (TrelloBoard item in list)
            {
                Debug.WriteLine(item.Name);
                List <TrelloList> l = new List <TrelloList>();
                l = await TrelloRepository.GetTrelloListsAsync(item.BoardId);

                foreach (TrelloList tl in l)
                {
                    TrelloCard card = new TrelloCard()
                    {
                        Name = "Testerdetesterdetest"
                    };
                    await TrelloRepository.AddCardAsync(tl.ListId, card);

                    Debug.WriteLine($"Listname: {tl.Name}");
                    List <TrelloCard> ltc = new List <TrelloCard>();
                    ltc = await TrelloRepository.GetTrelloCardsAsync(tl.ListId);

                    foreach (TrelloCard c in ltc)
                    {
                        Debug.WriteLine($"Cardname: {c.Name}");
                    }
                }
            }
            TrelloBoard b = list.Where(x => x.IsFavorite == true).ToList <TrelloBoard>().First();

            if (b != null)
            {
                Debug.WriteLine(b.Name);
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            string startingBoardId   = "";
            string startingBoardName = "";

            //Console.WriteLine("Введите id доски Trello");
            //startingBoardId = Console.ReadLine();
            //Console.WriteLine("Введите название проекта / команды");
            //startingBoardName = Console.ReadLine();

            //startingBoardId = "QnqeK3SC"; startingBoardName = "Летний интерсив";
            //startingBoardId = "Ni3BxRJ5"; startingBoardName = "KeenSoft";
            //startingBoardId = "K0C0i8wF"; startingBoardName = "Beamdog Newewinter Nights";
            startingBoardId = "nU6GjV5G"; startingBoardName = "Моя тестовая доска";

            //УДАЛЕНИЕ ВСЕХ ДАННЫХ ПО ДОСКЕ
            //deleteBoard(startingBoardId); return;

            string  scriptPath = "C:/Users/Пользователь/source/repos/PythonJsonDeserializer/PythonJsonDeserializer/ApiCallScripts/";
            string  scriptFileName;
            string  scriptCallUrl;            //url api-запроса для скрипта
            string  callResult;
            Program program = new Program();

            //добавляем доску в бд
            using (TrelloDbContext db = new TrelloDbContext())
            {
                TrelloBoard board = new TrelloBoard {
                    Id = startingBoardId, Name = startingBoardName
                };
                db.Boards.Add(board);
                db.SaveChanges();
            }

            //получаем листы доски
            scriptFileName = "call_board_listsv2.py";
            scriptCallUrl  = "\"https://api.trello.com/1/boards/" + startingBoardId + "/lists\"";
            callResult     = program.runApiCall(scriptPath + scriptFileName + " " + scriptCallUrl, "");
            //Console.WriteLine("Результат " +callResult);
            List <AbstractModel>      tlists           = new List <AbstractModel>();
            Deserializer <TrelloList> listDeserializer = new Deserializer <TrelloList>();

            tlists = listDeserializer.jsonDeserialize(callResult);

            //перебор полученных листов
            foreach (TrelloList tlist in tlists)
            {
                //отладочный вывод десериализованного содержимого листов
                Console.WriteLine("Лист. Название: " + decode(tlist.Name) + " / ID: " + tlist.Id + " / Статус: " + tlist.Closed);
                Console.WriteLine();

                //добавляем лист в бд
                using (TrelloDbContext db = new TrelloDbContext())
                {
                    //запиили добавление через обект со всеми полями
                    TrelloList dblist = new TrelloList {
                        Id = tlist.Id, Name = decode(tlist.Name), Closed = tlist.Closed, BoardId = startingBoardId
                    };
                    db.Lists.Add(dblist);
                    db.SaveChanges();
                }

                //получаем карточки листа
                scriptFileName = "call_list_cardsv2.py";
                scriptCallUrl  = "\"https://api.trello.com/1/lists/" + tlist.Id + "/cards\"";
                //scriptCallUrl = "\"https://api.trello.com/1/lists/59e21320df19579bf6b8e1af/cards\"";
                callResult = program.runApiCall(scriptPath + scriptFileName + " " + scriptCallUrl, "");
                //Console.WriteLine("Результат " + callResult);
                List <AbstractModel>      tcards           = new List <AbstractModel>();
                Deserializer <TrelloCard> cardDeserializer = new Deserializer <TrelloCard>();
                tcards = cardDeserializer.jsonDeserialize(callResult);

                //Thread.Sleep(5000);
                //перебор полученных карточек
                foreach (TrelloCard tcard in tcards)
                {
                    //отладочный вывод десериализованного содержимого карточек
                    Console.WriteLine("Карточка. Название: " + decode(tcard.Name) + " / ID: " + tcard.Id + " / Статус: " + tcard.Closed + " / Описание: " + decode(tcard.Desc) + " / Последняя активность: " + tcard.DateLastActivity);
                    Console.WriteLine();

                    //добавляем карточку в бд
                    using (TrelloDbContext db = new TrelloDbContext())
                    {
                        TrelloCard dbcard = new TrelloCard {
                            Id = tcard.Id, Name = decode(tcard.Name), Desc = decode(tcard.Desc), Closed = tcard.Closed, DateLastActivity = tcard.DateLastActivity, Due = tcard.Due, DueComplete = tcard.DueComplete, ListId = tlist.Id
                        };
                        db.Cards.Add(dbcard);
                        db.SaveChanges();
                    }

                    //новый код: получаем разработчиков карточки
                    scriptFileName = "call_card_members.py";
                    scriptCallUrl  = "\"https://api.trello.com/1/cards/" + tcard.Id + "/members\"";
                    callResult     = program.runApiCall(scriptPath + scriptFileName + " " + scriptCallUrl, "");
                    //Отладочный вывод members callResult
                    //Console.WriteLine("\n Результат запроса card members: " + callResult);
                    List <AbstractModel>        tmembers           = new List <AbstractModel>();
                    Deserializer <TrelloMember> memberDeserializer = new Deserializer <TrelloMember>();
                    tmembers = memberDeserializer.jsonDeserialize(callResult);
                    foreach (TrelloMember tmember in tmembers)
                    {
                        try
                        {
                            using (TrelloDbContext db = new TrelloDbContext())
                            {
                                TrelloMember dbmember = new TrelloMember {
                                    Id = tmember.Id, Name = "", FullName = decode(tmember.FullName), Username = tmember.Username
                                };
                                db.Members.Add(dbmember);
                                db.SaveChanges();
                            }
                        }
                        catch
                        { }
                        using (TrelloDbContext db = new TrelloDbContext())
                        {
                            //придумай Id. cardid+memberid слишком длинно? cardid+num?
                            MemberCard dbmembercard = new MemberCard {
                                Id = tmember.Id + tcard.Id, Name = "", CardId = tcard.Id, MemberId = tmember.Id
                            };
                            db.MembersCards.Add(dbmembercard);
                            db.SaveChanges();
                        }
                    }
                }
                Console.WriteLine();
            }
            Console.WriteLine("Конец скрипта. Нажмите любую клавишу");
            Console.Read();
        }
Example #9
0
 public TrelloBoard Create(TrelloBoard item)
 {
     throw new NotImplementedException();
 }