내가 원하는 기능을 복제하는 테스트를 만들었습니다
public void MoveCardsBetweenLists(
string originListName,
string destinationListName,
string originBoardName,
string destinationBoardName = null)
{
var fromBoard = GetBoard(originBoardName); // returns a Manatee.Trello.Board
var toBoard = destinationBoardName == null
|| destinationBoardName.Equals(originBoardName, StringComparison.OrdinalIgnoreCase)
? fromBoard
: GetBoard(destinationBoardName);
var fromList = GetListFromBoard(originListName, fromBoard); // returns a Manatee.Trello.List from the specified Board
var toList = GetListFromBoard(destinationListName, toBoard);
for (int i = 0; i < fromList.Cards.Count(); i++)
{
fromList.Cards[i].Move(1, toList);
}
}
여기 Manatee.Trello.Card 내 확장 방법 :
여기 내 전화 코드입니다. 기본적으로, 나는 내 보드에 7 장의 카드를 만들고 다른 목록으로 이동 한 다음 삭제합니다 (초기 상태 유지).
private static void Run(System.Action action)
{
var serializer = new ManateeSerializer();
TrelloConfiguration.Serializer = serializer;
TrelloConfiguration.Deserializer = serializer;
TrelloConfiguration.JsonFactory = new ManateeFactory();
TrelloConfiguration.RestClientProvider = new WebApiClientProvider();
TrelloAuthorization.Default.AppKey = TrelloIds.AppKey;
TrelloAuthorization.Default.UserToken = TrelloIds.UserToken;
action();
TrelloProcessor.Flush();
}
#region http://stackoverflow.com/q/39926431/878701
private static void Move(Card card, int position, List list = null)
{
if (list != null && list != card.List)
{
card.List = list;
}
card.Position = position;
}
[TestMethod]
public void MovingCards()
{
Run(() =>
{
var list = new List(TrelloIds.ListId);
var cards = new List<Card>();
for (int i = 0; i < 10; i++)
{
cards.Add(list.Cards.Add("test card " + i));
}
var otherList = list.Board.Lists.Last();
for(var i = 0; i < cards.Count; i++)
{
Move(card, i, otherList);
}
foreach (var card in cards)
{
card.Delete();
}
});
}
#endregion
빠른 질문 : 당신의 실행이 종료하기 전에 TrelloProcessor.Flush()
를 호출하고 있습니까? 그렇지 않으면 응용 프로그램이 끝날 때 일부 변경 사항이 요청 프로세서 대기열에 남아있어 절대로 전송되지 않습니다. 자세한 내용은 내 wiki page on processing requests을 참조하십시오.
또한 각 이동의 위치로 1
을 사용하고있는 것으로 나타났습니다. 이렇게하면 신뢰할 수없는 주문을 받게됩니다. Trello가 사용하는 위치 데이터는 부동 소수점입니다. 다른 두 카드 사이에 카드를 배치하려면 다른 카드의 평균값을 사용하면됩니다. 귀하의 경우 (대상 목록이 비어있는 경우) 주문에 대한 인덱서 변수를 보내주십시오. 대상 목록이 비어 있지 않으면 목록의 다른 카드를 기반으로 새로운 위치를 계산해야합니다 (Trello 평균법에 따라).
마지막으로, 내가 가진 확장 코드가 마음에 들어요. 라이브러리에 추가하는 것이 유용하다고 생각되는 아이디어가 있다면 GitHub 레포를 포크하고 끌어 오기 요청을 만드십시오.
잘 작동해야하는 것처럼 보입니다. 내가 그걸 가지고 놀게하면 나는 돌아올거야. 예제 솔루션 (내 사용자 이름 @ yahoo)을 보내 주시면 도움이 될 것입니다. – gregsdennis