/// <summary>
        /// User is Trello authenticated
        /// </summary>
        /// <returns>Bool and auth url</returns>
        public ActionResult IsAuthenticated()
        {
            var userKey = GetUserKey();

            // validate
            if (string.IsNullOrEmpty(userKey))
            {
                // generate auth url
                var link = new Trello(TrelloApiKey).GetAuthorizationUrl(TrelloAppName, Scope.ReadOnly, Expiration.Never).ToString();
                return CreateResponse(new { isLogged = false, authUrl = link });
            }

            return CreateResponse(new { isLogged = true, authUrl = string.Empty });
        }
Esempio n. 2
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            Trello = new Trello("1ed8d91b5af35305a60e169a321ac248");
            MessageBus = new MessageBus();

            var exportCardsControl = new ExportCardsControl();
            var importCardsControl = new ImportCardsControl();
            var authorizeForm = new AuthorizationDialog();

            ExportCardsTaskPane = CustomTaskPanes.Add(exportCardsControl, "Export cards to Trello");
            ExportCardsTaskPane.Width = 300;
            ExportCardsTaskPane.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;

            ImportCardsTaskPane = CustomTaskPanes.Add(importCardsControl, "Import cards from Trello");
            ImportCardsTaskPane.Width = 300;
            ImportCardsTaskPane.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;

            TaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            ExportCardsPresenter = new ExportCardsPresenter(exportCardsControl, Trello, new GridToNewCardTransformer(), TaskScheduler, MessageBus);
            ImportCardsPresenter = new ImportCardsPresenter(importCardsControl, MessageBus, Trello, TaskScheduler);
            AuthorizePresenter = new AuthorizePresenter(authorizeForm, Trello, MessageBus);

            Globals.Ribbons.TrelloRibbon.SetMessageBus(MessageBus);

            TryToAuthorizeTrello();
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TrelloLog" /> class.
        /// </summary>
        public TrelloLog()
        {
            Tasks = new TaskFactory();
            LogBoardName = ConfigurationManager.AppSettings["Trello-LogBoardName"];

            if (TrelloClient != null)
                return;

            var appKey = ConfigurationManager.AppSettings["Trello-ApplicationKey"];
            var token = ConfigurationManager.AppSettings["Trello-AuthToken"];
            var org = ConfigurationManager.AppSettings["Trello-Organization"];

            var trello = new Trello(appKey);
            TrelloClient = trello;

            if (string.IsNullOrEmpty(token))
                return;

            trello.Authorize(token);

            if (!string.IsNullOrEmpty(org))
                Organization =
                    TrelloClient.Organizations.ForMe().FirstOrDefault(
                        o => o.Name.Equals(org, StringComparison.OrdinalIgnoreCase));
        }
        public TrelloBoardService CreateTrelloBoardService(string key, string token, string boardId)
        {
            var trelloService = new Trello(key);
            trelloService.Authorize(token);

            return new TrelloBoardService(trelloService, boardId);
        }
        public static bool HasConfiguration()
        {
            if (File.Exists(CoreSprintApp.TrelloConfigPath))
            {
                var configLines = File.ReadAllLines(CoreSprintApp.TrelloConfigPath);
                var hasTwoLines = configLines.Length > 1;

                if (hasTwoLines)
                {
                    try
                    {
                        var trello = new TrelloNet.Trello(configLines[0]);
                        trello.Authorize(configLines[1]);
                        trello.Members.Me();
                        return true;
                    }
                    catch (TrelloUnauthorizedException)
                    {
                        return false;
                    }
                }
            }

            return false;
        }
Esempio n. 7
0
        public SiteModule()
        {
            trello = new TrelloNet.Trello(ConfigurationManager.AppSettings["AuthKey"]);
            trello.Authorize(ConfigurationManager.AppSettings["AuthToken"]);

            Get["/"] = o =>
                {
                    var boards = GetBoards();

                    return View["views/default", boards];
                };

            Get["/api/boards"] = o => GetBoards();

            Get["/api/boards/{id}/lists"] = o =>
                {
                    var board = trello.Boards.WithId(o.id);

                    return trello.Lists.ForBoard(board);
                };

            Get["/api/boards/{boardId}/lists/{listId}/cards"] = o =>
                {
                    var list = trello.Lists.WithId(o.listId);

                    var cards = trello.Cards.ForList(list);

                    return cards;
                };
        }
Esempio n. 8
0
        public void On(Event <LogEventData> evt)
        {
            try
            {
                ITrello trello = new TrelloNet.Trello(TrelloApiKey);

                trello.Authorize(TrelloApiSecret);

                var board = trello.Boards.Search(BoardName).FirstOrDefault();
                if (board == null)
                {
                    throw new ArgumentException(string.Format("Could not find Trello board named '{0}'", BoardName));
                }

                var list = trello.Lists.ForBoard(board).FirstOrDefault(x => x.Name.Equals(ListName, StringComparison.OrdinalIgnoreCase));

                if (list == null)
                {
                    throw new ArgumentException(string.Format("Could not find Trello list named '{0}'", BoardName));
                }

                // TODO parse the details out better
                trello.Cards.Add(new NewCard(evt.Data.RenderedMessage, list));
            }
            catch (Exception ex)
            {
                Log.Warning("Failed to create new Trello card.", ex);
            }
        }
Esempio n. 9
0
        public TrelloRunner(TrelloConfiguration configuration)
        {
            _trello = new Trello(configuration.AppKey);
            _configuration = configuration;

            _configuration.UserName = (_configuration.UserName ?? "").Trim('@');

            _trello.Authorize(configuration.UserToken);
        }
        public static void Configure()
        {
            Console.WriteLine("Configurando integração com Trello...");
            string appKey, userToken;
            using (var browser = new BrowserDataRetriever(DataGetter))
            {
                appKey = GetAppKey(browser);

                var trello = new TrelloNet.Trello(appKey);
                var urlUserToken = trello.GetAuthorizationUrl(CoreSprintApp.TrelloAppName, Scope.ReadOnly, Expiration.Never);

                userToken = GetUserToken(browser, urlUserToken);
            }

            File.WriteAllLines(CoreSprintApp.TrelloConfigPath, new List<string> { appKey, userToken });
            Console.WriteLine("\r\nConfiguração do Trello finalizada!");
        }
Esempio n. 11
0
        public TrelloViewModel()
        {
            //return;
            Configuration currentConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            currentConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ITrello trello = new Trello(currentConfig.AppSettings.Settings["AppKey"].Value);

            trello.Authorize(currentConfig.AppSettings.Settings["Token"].Value);
            boardModel = new BindingList<BoardModel>();
            
            /*var test = trello.Members.Me();
            System.Collections.Generic.IEnumerable<Organization> organization = trello.Organizations.ForMe();
            Organization org = organization.ElementAt(0);*/

            var board = trello.Boards.ForMe();
            for (int i = 0; i != board.Count(); i++)
            {
                Board boards = board.ElementAt(i);
                if (boardModelCheckBox == null)
                    boardModelCheckBox = new BindingList<BoardModel>();
                boardModelCheckBox.Add(new BoardModel() { Id = boards.Id, Name = boards.Name, Desc = boards.Desc });
            }

            browser = new Browser();
            string document = browser.GET("http://servicedesk.gradient.ru/", Encoding.UTF8);
            if (document == null)
                document = browser.GET("http://servicedesk.gradient.ru/", Encoding.UTF8);
            if (document == null)
                document = browser.GET("http://servicedesk.gradient.ru/", Encoding.UTF8);
            //document = browser.GET("http://servicedesk.gradient.ru/api/task", Encoding.UTF8);
            string test = "";

        }
Esempio n. 12
0
        public void getBoardListAndCard(string _boardId)
        {

            Configuration currentConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ITrello trello = new Trello(currentConfig.AppSettings.Settings["AppKey"].Value);
            if (currentConfig.AppSettings.Settings["Token"] == null)
                throw new Exception("Не указан token для доступа");
            trello.Authorize(currentConfig.AppSettings.Settings["Token"].Value);
            Board boards = trello.Boards.WithId(_boardId);
            if (boardModel == null)
                boardModel = new BindingList<BoardModel>();
            else
                boardModel.Clear();

            boardModel.Add(new BoardModel() { Id = boards.Id, Name = boards.Name, Desc = boards.Desc });
            var Lists = trello.Lists.ForBoard(new BoardId(boards.Id));
            for (int y = 0; y != Lists.Count(); y++)
            {
                List list = Lists.ElementAt(y);
                listModel = boardModel[0].ListModel;
                if (listModel == null)
                    listModel = new BindingList<ListModel>();
                listModel.Add(new ListModel() { Id = list.Id, IdBoard = list.IdBoard, Name = list.Name });
                var cards = trello.Cards.ForList(new ListId(list.Id));
                for (int z = 0; z != cards.Count(); z++)
                {
                    Card card = cards.ElementAt(z);
                    cardModel = listModel[y].CardModel;
                    if (cardModel == null)
                        cardModel = new BindingList<CardModel>();
                    memberModel = new BindingList<MemberModel>();
                    if(card.Desc == "")
                    {
                        /*string document = browser.GET(string.Format("http://servicedesk.gradient.ru/task/view/{0}", card.Name), Encoding.UTF8);
                        if(document != null)
                        {
                            string descr = "";
                            Regex regex = new Regex("<p class=\"task-name\">(.*?)</p>");
                            MatchCollection mc = regex.Matches(document);
                            if(mc.Count != 0)
                                descr = string.Format("Название:\n{0}\n", HttpUtility.HtmlDecode(mc[0].Groups[1].Value.Replace("<br/>","\n")));
                            else
                            {
                                regex = new Regex("<input class=\".*?\" id=\"name\" maxlength=\"500\" name=\"name\" type=\"text\" value=\"(.*?)\" />");
                                //<input class="width98 big required" id="name" maxlength="500" name="name" type="text" value="ЕСС. Обработка по получению данных из ЗУП через Веб-сервис" />
                                mc = regex.Matches(document);
                                if(mc.Count != 0)
                                    descr = string.Format("Название:\n{0}\n", HttpUtility.HtmlDecode(mc[0].Groups[1].Value.Replace("<br/>", "\n")));
                            }
                            regex = new Regex("<p class=\"task-description\">(.*?)</p>");
                            mc = regex.Matches(document);
                            if(mc.Count != 0)
                                descr += string.Format("Описание:\n{0}",HttpUtility.HtmlDecode( mc[0].Groups[1].Value.Replace("<br/>", "\n")));
                            else
                            {
                                regex = new Regex("<textarea class=\".*?\" cols=\".*?\" id=\"description\" name=\"description\" rows=\".*?\">[\\s|\\S](.*?)[\\s|\\S]</textarea>");
                                mc = regex.Matches(document);
                                if (mc.Count != 0)
                                    descr += string.Format("Описание:\n{0}", HttpUtility.HtmlDecode(mc[0].Groups[1].Value.Replace("<br/>", "\n")));
                            }
                            card.Desc = descr;
                            //trello.Cards.Update(card);
                        }*/
                    }
                    foreach(string memberId in card.IdMembers)
                    {
                        Member member = trello.Members.WithId(memberId);
                        memberModel.Add(new MemberModel() { Id = member.Id, AvatarHash = string.Format("https://trello-avatars.s3.amazonaws.com/{0}/30.png",member.AvatarHash), Bio = member.FullName, Username = member.Username });
                   
                    }
                    cardModel.Add(new CardModel() { Id = card.Id,
                                                    IdBoard = card.IdBoard,
                                                    IdList = card.IdList,
                                                    Name = card.Name,
                                                    Desc = card.Desc != "" ? card.Desc : "Пусто",
                                                    Due = Convert.ToDateTime(card.Due),
                                                    User = memberModel
                                                  }
                                 );
                    listModel[y].CardModel = cardModel;
                    
                }
                if (cards.Count() == 0)
                {
                    cardModel = listModel[y].CardModel;
                    if (cardModel == null)
                        cardModel = new BindingList<CardModel>();
                    cardModel.Add(new CardModel() { IdBoard = boards.Id, IdList = list.Id, Name = "Пусто", Desc = "Пусто" });
                    listModel[y].CardModel = cardModel;
                }
                boardModel[0].ListModel = listModel;
            }
            if (Lists.Count() == 0)
            {
                listModel = boardModel[0].ListModel;
                if (listModel == null)
                    listModel = new BindingList<ListModel>();
                listModel.Add(new ListModel());
                cardModel = listModel[0].CardModel;
                if (cardModel == null)
                    cardModel = new BindingList<CardModel>();
                cardModel.Add(new CardModel());
                listModel[0].CardModel = cardModel;
                boardModel[0].ListModel = listModel;

            }

        }
Esempio n. 13
0
 public TrelloService()
 {
     trello = new Trello("b2260b9a6ad59a9e7f2cabd2716578a6");
 }
 private TrelloItemProvider()
 {
     trello = new Trello("[key]");
     trello.Authorize("[token]");
 }
Esempio n. 15
0
 public Worker()
 {
     _trello = new TrelloNet.Trello(Constants.ApplicationId);
     _cardProvider = new TrelloCardProvider();
     _taskBuilder = new TaskBuilder();
 }