public async Task <IActionResult> PutTrelloCard(string id, TrelloCard trelloCard) { var key = Program.Configuration["Trello:key"]; var token = Program.Configuration["Trello:token"]; List <TrelloCard> list = new List <TrelloCard>(); string apiResponse; using (var httpClient = new HttpClient()) { var value = new Dictionary <string, string>(); if (String.Empty != trelloCard.IdList) { value.Add("idList", trelloCard.IdList); } if (String.Empty != trelloCard.Desc) { value.Add("desc", trelloCard.Desc); } var content = new FormUrlEncodedContent(value); Console.WriteLine(trelloCard.Desc); Console.WriteLine(trelloCard.IdList); using (var response = await httpClient.PutAsync($"https://api.trello.com/1/cards/{id}?key={key}&token={token}", content)) { apiResponse = await response.Content.ReadAsStringAsync(); } } return(Ok(apiResponse)); }
public static async Task AddCardAsync(string listId, TrelloCard card) { // ----------- vars_init(); // ----------- string url = $"https://api.trello.com/1/cards?idList={listId}&key={_APIKEY}&token={_USERTOKEN}"; using (HttpClient client = GetHttpClient()) { try { string json = JsonConvert.SerializeObject(card); HttpContent content = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); if (!response.IsSuccessStatusCode) { string errorMsg = $"Unsuccesfull POST to url: {url}, object {json}"; throw new Exception(errorMsg); } } catch (Exception ex) { string errorMsg = $"Something went wrong with url: {url} ({ex.Message})"; throw new Exception(errorMsg); } } }
public static async Task AddCardAsync(string listId, TrelloCard card) { string url = $"{_BASEURI}/cards?idList={listId}&key={_APIKEY}&token={_USERTOKEN}"; using (HttpClient client = GetHttpClient()) { try { string json = JsonConvert.SerializeObject(card); StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); if (!response.IsSuccessStatusCode) { string errorMsg = $"Unsuccesful PUT to url: {url}, object: {json}"; throw new Exception(errorMsg); } //string json = await client.GetStringAsync(url); //TrelloCard item = JsonConvert.DeserializeObject<TrelloCard>(json); //return item; } catch (Exception ex) { throw ex; } } }
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(); }
public async Task <IActionResult> AdicionarCard(TrelloCard card) { var model = await TrelloPostRequest <TrelloCard>( $"card/?name={Uri.EscapeDataString(card.Name)}&idList={card.IdList}&"); return(RedirectToAction("DetalhesBoard", new { id = model.IdBoard })); }
public UnityWebRequest InsertCard(TrelloCard cardToInsert) { UnityWebRequest post = new UnityWebRequest(credentials.trello_card_endpoint + "?token=" + credentials.access_token + "&key=" + credentials.api_key + "&t=" + getUTCTime() + "&idList=" + cardToInsert.idList + "&name=" + cardToInsert.name, "POST"); return(post); }
IEnumerator GetImage(TrelloCard card, string url) { UnityWebRequest textureRequest = UnityWebRequestTexture.GetTexture(url); yield return(textureRequest.SendWebRequest()); card.attachment = DownloadHandlerTexture.GetContent(textureRequest); }
private async void btnCloseCard_Clicked(object sender, EventArgs e) { TrelloCard card = (sender as Button).BindingContext as TrelloCard; card.IsClosed = true; await TrelloRepository.UpdateCardAsync(card); loadListAsync(); }
private async Task NavigateToShoePage() { TrelloCard card = (TrelloCard)lvwTrelloLists.SelectedItem; List <Results2> shoeData = await ShoesRepository.GetShoesByNameAsync(card.name); Results2 shoe = shoeData[0]; var DetailPage = new Views.DetailPage(shoe); Navigation.PushModalAsync(DetailPage); }
private void SaveCategories(SqlConnection conn, TrelloCard card) { foreach (string category in card.Categories) { SqlCommand cmd = new SqlCommand("INSERT INTO card_categories VALUES (@id, @category)", conn); cmd.Parameters.AddWithValue("@id", card.Id); cmd.Parameters.AddWithValue("@category", category); cmd.ExecuteNonQuery(); } }
private async Task addcard(Results2 result) { await DisplayAlert("Alert", "You added this shoe as favorite", "OK"); string listId = "5fd4e03623dc8d8494238fd9"; TrelloCard newCard = new TrelloCard { name = result.Name, CardDesc = result.ImgUrl, IsClosed = false }; await TrelloRepository.AddCardAsync(listId, newCard); }
private async Task DeleteCard(TrelloCard e) { bool answer = await DisplayAlert("Are you sure?", "Would you like to delete this shoe as favorite ?", "Yes", "No"); if (answer == true) { await TrelloRepository.DeleteCardAsync(e.CardId); getlists(lvwTrelloLists); } }
private void lvwCards_ItemSelected(object sender, SelectedItemChangedEventArgs e) { TrelloCard card = lvwCards.SelectedItem as TrelloCard; if (card != null) { card.List = this.List; Navigation.PushAsync(new SingleCardPage(card)); lvwCards.SelectedItem = null; } }
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); }
public SingleCardPage(TrelloCard card) { InitializeComponent(); this.Card = card; BackgroundColor = Color.FromHex(Card.List.Board.ColorHex); lblBoard.Text = Card.List.Board.Name; lblList.Text = Card.List.Name; Title = "Edit"; editName.Text = Card.Name; IsNewCard = false; loadMemberAsync(); }
public IEnumerator SendReportRoutine(TrelloCard card, List <Texture2D> screenshots) { // Shows the "in progress" text inProgressUI.SetActive(true); // We upload the card with an async custom coroutine that will return the card ID // Once it has been uploaded. CustomCoroutine cC = new CustomCoroutine(this, trello.UploadCardRoutine(card)); yield return(cC.coroutine); // The uploaded card ID string cardID = (string)cC.result; int i = 0; foreach (Texture2D screenshot in screenshots) { i++; // We can now attach the screenshot to the card given its ID. yield return(trello.SetUpAttachmentInCardRoutine(cardID, "ScreenShot" + i + ".png", screenshot)); } #if UNITY_STANDALONE // We make sure the log exists before trying to retrieve it. if (System.IO.File.Exists(logPath)) { // We make a copy of the log since the original is being used by Unity. System.IO.File.Copy(logPath, logPathCopy, true); // We attach the Unity log file to the card. yield return(trello.SetUpAttachmentInCardFromFileRoutine(cardID, "output_log.txt", logPathCopy)); } #endif // this one is meant to be replaced with relevant data about your game string relevantData = GetSettings() + GetSystemInfo(); yield return(trello.SetUpAttachmentInCardRoutine(cardID, "SystemInfo.txt", relevantData)); /** * * Attach more convenient data to the card here * **/ // Wait for one extra second to let the player read that his isssue is being processed yield return(new WaitForSeconds(1)); // Since we are done we can deactivate the in progress canvas inProgressUI.SetActive(false); // Now we show the success text to let the user know the action has been completed StartCoroutine(SetActiveForSecondsRoutine(successUI, 2)); }
public Coroutine SendReport(string title, string description, string listName, List <Texture2D> screenshots) { // if both the title and description are empty show warning message to avoid spam if (title == "" && description == "") { StartCoroutine(SetActiveForSecondsRoutine(fillInFormMessageUI, 2)); return(null); } TrelloCard card = trello.NewCard(title, description, listName); return(StartCoroutine(SendReportRoutine(card, screenshots))); }
private TrelloCard CreateCardFromReader(SqlDataReader reader) { TrelloCard card = new TrelloCard() { Id = Convert.ToInt32(reader["card_id"]), Title = Convert.ToString(reader["title"]), ListId = Convert.ToInt32(reader["list_id"]), Description = Convert.ToString(reader["description"]), CreateDate = Convert.ToDateTime(reader["createdate"]) }; return(card); }
public UnityWebRequest InsertCard(TrelloCard cardToInsert, byte[] picture) { var wwwForm = new WWWForm(); wwwForm.AddBinaryData("fileSource", picture, "image.png"); wwwForm.AddField("token", credentials.access_token); wwwForm.AddField("key", credentials.api_key); wwwForm.AddField("t", getUTCTime()); wwwForm.AddField("idList", cardToInsert.idList); wwwForm.AddField("name", cardToInsert.name); var request = UnityWebRequest.Post(credentials.trello_card_endpoint, wwwForm); return(request); }
private string GetCardTFSId(TrelloCard card) { int start, end; if (card.name.Contains("Bug #")) { start = card.name.IndexOf("Bug #") + 5; } else { start = card.name.IndexOf("Product Backlog Item #") + 22; } end = card.name.IndexOf(":"); return(card.name.Substring(start, end - start)); }
public void CreateTask(ITaskDTO taskData) { var client = new RestClient("https://api.trello.com/1"); IRestResponse <TrelloCard> createResponse = CreateCard(taskData, client); if (createResponse.StatusCode == HttpStatusCode.Unauthorized) { Process.Start( string.Format( "https://trello.com/1/authorize?key={0}&name=CreateTask&expiration=1day&response_type=token&scope=read,write", TrelloConfig.Key)); string newToken = null; if ( InputBox.Show("Token not valid", "Allow the new token in your webbrowser and paste it in here.", ref newToken) == DialogResult.OK) { TrelloConfig.WriteToken(newToken); createResponse = CreateCard(taskData, client); } else { MessageBox.Show("Exiting CreateTask", "Exiting", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } TrelloCard card = createResponse.Data; string label = "orange"; //Un-prioratized IRestResponse labelResult = AddLabelToCard(card, label, client); foreach (string tag in taskData.Tags) { string labelColor = TrelloLabelToColorMapper.MapColor(tag); AddLabelToCard(card, labelColor, client); } IRestRequest dueDateReq = new RestRequest(string.Format("{0}/{1}/due", TrelloConfig.Resourses.Cards, card.id)); dueDateReq.Method = Method.PUT; SetKeyAndTokenParametersOnRequest(dueDateReq); dueDateReq.AddParameter(TrelloConfig.ParameterNames.Value, taskData.DueDate.ToString(CultureInfo.InvariantCulture)); IRestResponse dueResp = client.Execute(dueDateReq); //TODO: Verify status else throw exception }
private IRestResponse AddLabelToCard(TrelloCard card, string label, RestClient client) { IRestRequest addLabelsRequest = new RestRequest( string.Format("{0}/{1}{2}", TrelloConfig.Resourses.Cards, card.id, TrelloConfig.Resourses.Labels) ); addLabelsRequest.Method = Method.POST; addLabelsRequest.AddParameter(TrelloConfig.ParameterNames.Value, label); SetKeyAndTokenParametersOnRequest(addLabelsRequest); IRestResponse labelResult = client.Execute(addLabelsRequest); return(labelResult); }
public List <TrelloCard> SearchCards(string searchTerm) { List <TrelloCard> cards = new List <TrelloCard>(); searchTerm = "%" + searchTerm + "%"; try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand( @"SELECT card.id as card_id, card.list_id as list_id, card.title, card.description, card.createdate, card_categories.category FROM card LEFT JOIN card_categories ON card_categories.id = card.id WHERE card.title LIKE @title ORDER BY card_id;", conn); cmd.Parameters.AddWithValue("@title", searchTerm); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { int cardId = Convert.ToInt32(reader["card_id"]); TrelloCard card = cards.LastOrDefault(); if (card == null || cardId != card.Id) { card = CreateCardFromReader(reader); cards.Add(card); } if (reader["category"] != DBNull.Value) { card.Categories.Add(Convert.ToString(reader["category"])); } } } } catch (SqlException ex) { throw; } return(cards); }
public void OnConfirm() { Debug.Log("confirm button pressed: CONFIRM"); TrelloCard createdCard; if (capturer.isPhotoReadyToSend) { createdCard = new TrelloCard(idList, lastMessage, "bottom", capturer.targetTexture); capturer.isPhotoReadyToSend = false; } else { createdCard = new TrelloCard(idList, lastMessage, "bottom"); } WebManager.Instance.Trello.Writer.SendCardToTrello(createdCard); opener.StopInputNote(); }
public ActionResult Card(string token, string cardId, string listId) { if (string.IsNullOrWhiteSpace(token)) { return(RedirectToAction("index", "home")); } var card = new TrelloCard { Id = cardId, ListId = listId, NewComment = string.Empty, Token = token }; return(View(card)); }
private GameObject GetCardNote(TrelloCard card) { Note note = null; if (createdNotes.ContainsKey(card.id)) { note = createdNotes[card.id]; } else { GameObject noteGO = Instantiate(notePrefab, noteParent.transform); Note newNote = noteGO.GetComponentInChildren <Note>(); createdNotes.Add(card.id, newNote); note = newNote; } note.isUsed = true; return(note.gameObject); }
private async void btnSave_Clicked(object sender, EventArgs e) { TrelloCard card = new TrelloCard() { Name = editName.Text }; if (IsNewCard) { await TrelloRepository.AddCardAsync(this.Card.List.ListId, card); } else { Card.Name = card.Name; await TrelloRepository.UpdateCardAsync(Card); } Navigation.PopAsync(); }
private List <TrelloCard> GetListsCards(string key, string token, string listid, ReportLogger reportLogger) { List <TrelloCard> cards = new List <TrelloCard>(); string content = ""; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.trello.com/1/lists/" + listid + "/cards?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) { TrelloCard card = new TrelloCard(); card.Id = subitem["id"].ToString(); card.Desc = subitem["desc"].ToString(); card.Name = subitem["name"].ToString(); card.ShortUrl = subitem["shortUrl"].ToString(); card.Actions = GetCardsActions(key, token, card.Id, reportLogger); card.DateCreated = CreatedDate(subitem["id"].ToString()); cards.Add(card); } reportLogger.EndStep(stepId); } catch (Exception ex) { reportLogger.EndStep(stepId, ex); } return(cards); }
IEnumerator GetCardAttachment(TrelloCard card) { UnityWebRequest CardAttachmentRequest = trelloAPI.GetCardCoverAttachmentHTTPRequest(card); CardAttachmentRequest.chunkedTransfer = false; CardAttachmentRequest.timeout = 100000; yield return(CardAttachmentRequest.SendWebRequest()); if (CardAttachmentRequest.isNetworkError || CardAttachmentRequest.isHttpError) { Debug.Log("An error occured receiving card attachment: " + CardAttachmentRequest.responseCode); } else { string responseToJSON = "{\"trelloAttachment\":" + CardAttachmentRequest.downloadHandler.text + "}"; TrelloAttachmentResponse trelloAttachmentResponse = JsonUtility.FromJson <TrelloAttachmentResponse>(responseToJSON); yield return(Utility.Instance.StartCoroutine(GetImage(card, trelloAttachmentResponse.trelloAttachment.previews[0].url))); } }
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; }