Esempio n. 1
0
        public async Task <IActionResult> PutTrelloList(string id, TrelloList trelloList)
        {
            if (id != trelloList.Id)
            {
                return(BadRequest());
            }

            _context.Entry(trelloList).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TrelloListExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
    public void UpdateCards(TrelloList updatedList)
    {
        list = updatedList;
        Dictionary <string, TrelloCard> cardsById = new Dictionary <string, TrelloCard>();

        foreach (TrelloCard card in updatedList.cards)
        {
            cardsById.Add(card.id, card);
        }

        TrelloCard[] newCards = new TrelloCard[cardsById.Count];
        int          i        = 0;

        foreach (KeyValuePair <string, TrelloCard> cardById in cardsById)
        {
            newCards[i] = cardById.Value;
            i++;
        }
        foreach (KeyValuePair <string, Note> note in createdNotes)
        {
            note.Value.isUsed = false;
        }
        currentCards = newCards;
        PlaceNotes();
    }
Esempio n. 3
0
 private string GetListId(string currentDevBoardId, TrelloListNames listName)
 {
     var listRequest = new RestRequest("1/boards/{currentDevBoardId}/lists?key={keyId}&token={tokenId}", Method.GET);
     listRequest.AddUrlSegment("currentDevBoardId", currentDevBoardId);
     List<TrelloList> trelloLists = Execute<List<TrelloList>>(listRequest);
     TrelloList list = trelloLists.FirstOrDefault(l => l.name.Equals(listName.ToString()));
     if (list != null)
         return list.id;
     return String.Empty;
 }
Esempio n. 4
0
        private TrelloList CreateListFromReader(SqlDataReader reader)
        {
            TrelloList list = new TrelloList()
            {
                Id   = Convert.ToInt32(reader["list_id"]),
                Name = Convert.ToString(reader["name"])
            };

            return(list);
        }
Esempio n. 5
0
        public List <TrelloList> GetLists()
        {
            List <TrelloList> lists = new List <TrelloList>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(
                        @"SELECT list.id as list_id, list.name, card.id as card_id, card.title, card.description, card.createdate, card_categories.category
                        FROM list
                        INNER JOIN card ON list.id = card.list_id
                        LEFT JOIN card_categories ON card_categories.id = card.id
                        ORDER BY list_id, card_id;", conn);

                    SqlDataReader reader = cmd.ExecuteReader();


                    while (reader.Read())
                    {
                        int listId = Convert.ToInt32(reader["list_id"]);
                        int cardId = Convert.ToInt32(reader["card_id"]);

                        TrelloList list = lists.LastOrDefault();
                        if (list == null || listId != list.Id)
                        {
                            list = CreateListFromReader(reader);
                            lists.Add(list);
                        }

                        TrelloCard card = list.Cards.LastOrDefault();
                        if (card == null || cardId != card.Id)
                        {
                            card = CreateCardFromReader(reader);
                            list.Cards.Add(card);
                        }

                        if (reader["category"] != DBNull.Value)
                        {
                            card.Categories.Add(Convert.ToString(reader["category"]));
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }


            return(lists);
        }
        private void lvwTrelloLists_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            TrelloList list = lvwTrelloLists.SelectedItem as TrelloList;

            if (list != null)
            {
                list.Board = this.Board;
                Navigation.PushAsync(new TrelloCardPage(list));
                lvwTrelloLists.SelectedItem = null;
            }
        }
 public SingleCardPage(TrelloList l)
 {
     this.Card = new TrelloCard {
         List = l
     };
     InitializeComponent();
     lblBoard.Text = l.Board.Name;
     lblList.Text  = l.Name;
     Title         = "Add";
     IsNewCard     = true;
 }
        public TrelloCardPage(TrelloList list)
        {
            InitializeComponent();
            this.List        = list;
            BackgroundColor  = Color.FromHex(List.Board.ColorHex);
            Title            = "Cards";
            lblListName.Text = List.Name;
            TapGestureRecognizer gesture = new TapGestureRecognizer();

            gesture.Tapped += AddCard_Tapped;
            lblAddCard.GestureRecognizers.Add(gesture);
        }
        private List <TrelloList> GetLists(string key, string token, ReportLogger reportLogger)
        {
            List <TrelloList> lists = new List <TrelloList>();

            string content = "";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.trello.com/1/board/51f0df83770f50bd3e00783e/lists?key=" + key + "&token=" + token);
            int            stepId  = reportLogger.AddStep();

            try
            {
                WebResponse response = request.GetResponse();
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                    content = reader.ReadToEnd();
                }


                dynamic stuff      = JsonConvert.DeserializeObject(content);
                JArray  jListItems = (JArray)stuff;

                foreach (var subitem in jListItems)
                {
                    TrelloList list = new TrelloList();
                    list.Name    = subitem["name"].ToString();
                    list.BoardId = subitem["idBoard"].ToString();
                    list.Closed  = Convert.ToBoolean(subitem["closed"].Value <bool>());
                    list.Id      = subitem["id"].ToString();
                    list.Pos     = Convert.ToInt32(subitem["pos"].Value <int>());


                    list.Cards = new List <TrelloCard>();
                    list.Cards = GetListsCards(key, token, list.Id, reportLogger);

                    lists.Add(list);
                }
                reportLogger.EndStep(stepId);
            }
            catch (Exception ex)
            {
                reportLogger.EndStep(stepId, ex);
            }

            return(lists);
        }
Esempio n. 10
0
 public void UpdateBoardOfNotes(Dictionary <string, TrelloList> cardsByList)
 {
     if (!isResorting)
     {
         TrelloList[] newListsWithCards = new TrelloList[cardsByList.Count];
         int          i = 0;
         foreach (KeyValuePair <string, TrelloList> cardByList in cardsByList)
         {
             newListsWithCards[i] = cardByList.Value;
             i++;
         }
         foreach (KeyValuePair <string, BoardColumn> list in createdListColumns)
         {
             list.Value.isUsed = false;
         }
         currentListsWithCards = newListsWithCards;
         PlaceBoardColumns();
     }
 }
Esempio n. 11
0
    private GameObject GetBoardColumn(TrelloList list)
    {
        BoardColumn listColumn = null;

        if (createdListColumns.ContainsKey(list.id))
        {
            listColumn = createdListColumns[list.id];
        }
        else
        {
            GameObject  field            = Instantiate(fieldPrefab, transform);
            BoardColumn boardColumnField = field.GetComponentInChildren <BoardColumn>();
            createdListColumns.Add(list.id, boardColumnField);
            listColumn = boardColumnField;
        }
        listColumn.UpdateCards(list);
        listColumn.isUsed = true;
        return(listColumn.gameObject);
    }
Esempio n. 12
0
    private void AssignCardsToList()
    {
        Dictionary <string, TrelloList> orderCardsByList = new Dictionary <string, TrelloList>();

        for (int i = 0; i < lists.Length; i++)
        {
            TrelloList currentList = lists[i];
            currentList.cards = new List <TrelloCard>();
            orderCardsByList.Add(currentList.id, currentList);
        }
        for (int i = 0; i < allCards.Length; i++)
        {
            TrelloCard currentCard       = allCards[i];
            TrelloList listOfCurrentCard = orderCardsByList[currentCard.idList];
            listOfCurrentCard.cards.Add(currentCard);
        }
        cardsByList   = orderCardsByList;
        areListsReady = false;
        areCardsReady = false;
    }
Esempio n. 13
0
        public async Task <ActionResult <TrelloList> > PostTrelloList(TrelloList trelloList)
        {
            _context.TrelloList.Add(trelloList);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TrelloListExists(trelloList.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTrelloList", new { id = trelloList.Id }, trelloList));
        }
Esempio n. 14
0
    private IEnumerator CreateList(List list, Transform board)
    {
        GameObject listObj = Instantiate(trelloList, board);

        TrelloList listVariables = listObj.GetComponent <TrelloList>();

        listVariables.title.text = list.name;

        foreach (Card c in cards)
        {
            if (c.idList == list.id)
            {
                yield return(null);

                GameObject cardObj = Instantiate(trelloCard, listVariables.content);

                yield return(null);

                TrelloCard cardVariables = cardObj.GetComponent <TrelloCard>();

                // Labels
                // if 1 or more labels exist
                if (c.idLabels.Count != 0)
                {
                    int labelCount = 0;
                    // match idLabel with the label id in labels
                    foreach (string idLabel in c.idLabels)
                    {
                        foreach (Label l in labels)
                        {
                            if (l.id == idLabel)
                            {
                                Color labelColour = new Color(0, 1, 1);
                                if (ColorUtility.TryParseHtmlString(l.color, out labelColour))
                                {
                                    cardVariables.colours[labelCount].color = labelColour;
                                }
                                cardVariables.labels[labelCount].SetActive(true);
                                break;
                            }
                        }

                        // only 5 labels are currently supported
                        if (labelCount == 4)
                        {
                            break;
                        }

                        labelCount++;
                    }
                }

                // Title
                cardVariables.title.text = c.name;

                // Members
                if (c.idMembers.Count != 0)
                {
                    int memberCount = 0;

                    foreach (string idMember in c.idMembers)
                    {
                        foreach (Member m in members)
                        {
                            if (m.id == idMember)
                            {
                                string[] initials = m.fullName.Split(' ');
                                foreach (string s in initials)
                                {
                                    cardVariables.names[memberCount].text += s.Substring(0, 1).ToUpper();
                                }
                                cardVariables.members[memberCount].SetActive(true);
                                break;
                            }
                        }

                        if (memberCount == 4)
                        {
                            break;
                        }

                        memberCount++;
                    }
                }

                listVariables.cards.Add(cardObj.transform);
            }
        }

        listVariables.verticalLayoutGroup.enabled = true;

        foreach (Transform t in listVariables.cards)
        {
            yield return(null);

            t.localScale = new Vector3(1, 1, 1);
        }
    }
Esempio n. 15
0
        static void Main(string[] args)
        {
            IConfiguration Configuration = new ConfigurationBuilder()
                                           .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                           .AddEnvironmentVariables()
                                           .AddUserSecrets <Program>()
                                           .AddCommandLine(args)
                                           .Build();


            var connection = new HubConnectionBuilder()
                             .WithUrl("http://localhost:52172/ChatHub")
                             .WithAutomaticReconnect()
                             .Build();


            IServiceCollection services = new ServiceCollection();

            var lists = new List <TrelloList>();
            var test  = Configuration.GetSection("TrelloSettings:TrelloLists")
                        .GetChildren().ToList();

            foreach (var l in test)
            {
                var list = new TrelloList();
                l.Bind(list);
                lists.Add(list);
            }

            TrelloSettings trelloSettings = new TrelloSettings
            {
                ApiKey      = Configuration.GetValue <string>("TrelloSettings:ApiKey"),
                Token       = Configuration.GetValue <string>("TrelloSettings:Token"),
                BoardId     = Configuration.GetValue <string>("TrelloSettings:BoardId"),
                TrelloLists = lists
            };


            services.AddSingleton(trelloSettings);
            services.AddSingleton <TrelloService>();

            TwitchSettings twitchSettings = new TwitchSettings
            {
                BotName          = Configuration.GetValue <string>("TwitchSettings:BotName"),
                AuthToken        = Configuration.GetValue <string>("TwitchSettings:AuthToken"),
                Channel          = Configuration.GetValue <string>("TwitchSettings:Channel"),
                ChannelId        = Configuration.GetValue <string>("TwitchSettings:ChannelId"),
                ChannelAuthToken = Configuration.GetValue <string>("TwitchSettings:ChannelAuthToken"),
                ClientId         = Configuration.GetValue <string>("TwitchSettings:ClientId")
            };

            services.AddSingleton(twitchSettings);
            services.AddSingleton(connection);
            services.AddSingleton <TwitchApiService>();
            services.AddSingleton <TwitchClientService>();

            services.AddSingleton <TwitchPubSubService>();

            var serviceProvider     = services.BuildServiceProvider();
            var twitchClientService = serviceProvider.GetService <TwitchClientService>();
            //api service not currently in use
            //var twitchApiService = serviceProvider.GetService<TwitchApiService>();
            var twitchPubSubService = serviceProvider.GetService <TwitchPubSubService>();


            Console.WriteLine("Hello World!");

            Console.ReadLine();
        }
Esempio n. 16
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();
        }