我使用 Greg Dennis 的 Manatee.Trello 库已经有一段时间了,但我最近才需要在板上移动卡片。不幸的是,我没有成功将一张卡片从同一个列表中的一个列表移动到另一个列表中。得知开发人员决定停止支持 Manatee.Trello,我有点沮丧。
我有两个不同的测试用例,都不起作用。最终目标是根据卡的描述中包含的值搜索卡,然后将该卡移动到同一板中的不同列表中。
当我尝试分配新列表时,以下会引发异常:
Exception:
'' is not a valid value.
Stack trace:
at Manatee.Trello.Internal.Field`1.Validate(T value)
at Manatee.Trello.Internal.Field`1.set_Value(T value)
at Manatee.Trello.Card.set_List(IList value)
at [my project].TrelloTestTwo() in [my code location]:line 333
Private Sub TrelloTestTwo()
TrelloAuthorization.Default.AppKey = AppSettings("TrelloAppKey")
TrelloAuthorization.Default.UserToken = AppSettings("TrelloDefaultUserToken")
Dim Query As String = "TN9999999"
Dim FoundCard As Manatee.Trello.Card
Dim TheNextList As Manatee.Trello.List
Dim Descr As String
Board.DownloadedFields = Board.Fields.Description Or Board.Fields.Labels Or Board.Fields.CustomFields Or Board.Fields.ShortLink Or Board.Fields.ShortUrl Or Board.Fields.Url Or Board.Fields.Lists Or Board.Fields.Cards
Dim bd As Manatee.Trello.Board = New Board("[TheBoardIDFromTrello]")
Dim srch As Search = New Search(Query, 100, SearchModelType.Cards, Nothing, Nothing, True)
bd.Refresh.Wait()
TheNextList = bd.Lists.Item("[TheListIDFromTrello]")
srch.Refresh.Wait()
' this is just a quick and dirty loop right now
' I understand it is not "safe" or "clean"
For Each FoundCard In srch.Cards
Descr = FoundCard.Description
If (Descr = "thevalue") Then Exit For
Next
'THIS THROWS AN EXCEPTION
Try
FoundCard.List = TheNextList
Catch ex As Exception
Stop
End Try
End Sub
以下不会引发异常,但 Card 不会移动到指定的列表。
Private Sub TrelloTestOne()
TrelloAuthorization.Default.AppKey = AppSettings("TrelloAppKey")
TrelloAuthorization.Default.UserToken = AppSettings("TrelloDefaultUserToken")
Dim EditCard As Manatee.Trello.Card
Dim TheNextList As Manatee.Trello.List
Dim Descr As String
Board.DownloadedFields = Board.Fields.Description Or Board.Fields.Labels Or Board.Fields.CustomFields Or Board.Fields.ShortLink Or Board.Fields.ShortUrl Or Board.Fields.Url Or Board.Fields.Lists Or Board.Fields.Cards
Dim bd As Manatee.Trello.Board = New Board("[TheBoardIDFromTrello]")
bd.Refresh.Wait()
TheNextList = bd.Lists.Item("[TheListIDFromTrello]")
EditCard = bd.Cards.Item("[TheCardIDFromTrello]")
'This does not throw an exception, but the card does not move to the specified list
Try
EditCard.List = TheNextList
Catch ex As Exception
Stop
End Try
End Sub
在这两种情况下,Card 和 List 对象都是有效的对象——也就是说,它们不是 NOTHING。