本文整理汇总了C#中Issue.LeanKitCardType方法的典型用法代码示例。如果您正苦于以下问题:C# Issue.LeanKitCardType方法的具体用法?C# Issue.LeanKitCardType怎么用?C# Issue.LeanKitCardType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Issue
的用法示例。
在下文中一共展示了Issue.LeanKitCardType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCardFromItem
private void CreateCardFromItem(BoardMapping project, Issue issue)
{
if (issue == null) return;
var boardId = project.Identity.LeanKit;
var mappedCardType = issue.LeanKitCardType(project);
var validLanes = project.LanesFromState(issue.Fields.Status.Name);
var laneId = validLanes.Any() ? validLanes.First() : project.DefaultCardCreationLaneId;
var card = new Card
{
Active = true,
Title = issue.Fields.Summary,
Description = issue.Fields.Description.SanitizeCardDescription().JiraPlainTextToLeanKitHtml(),
Priority = issue.LeanKitPriority(),
TypeId = mappedCardType.Id,
TypeName = mappedCardType.Name,
LaneId = laneId,
ExternalCardID = issue.Key,
ExternalSystemName = ServiceName,
ExternalSystemUrl = string.Format(_externalUrlTemplate, issue.Key)
};
var assignedUserId = issue.LeanKitAssignedUserId(boardId, LeanKit);
if (assignedUserId != null)
card.AssignedUserIds = new[] {assignedUserId.Value};
if (issue.Fields != null && issue.Fields.DueDate != null && CurrentUser != null)
{
var dateFormat = CurrentUser.DateFormat ?? "MM/dd/yyyy";
card.DueDate = issue.Fields.DueDate.Value.ToString(dateFormat, CultureInfo.InvariantCulture);
}
if (issue.Fields != null && issue.Fields.Labels != null && issue.Fields.Labels.Any())
{
card.Tags = string.Join(",", issue.Fields.Labels);
}
if ((card.Tags == null || !card.Tags.Contains(ServiceName)) && project.TagCardsWithTargetSystemName)
{
if (string.IsNullOrEmpty(card.Tags))
card.Tags = ServiceName;
else
card.Tags += "," + ServiceName;
}
// TODO: Add size from the custom story points field.
Log.Info("Creating a card of type [{0}] for issue [{1}] on Board [{2}] on Lane [{3}]", mappedCardType.Name,
issue.Key, boardId, laneId);
CardAddResult cardAddResult = null;
int tries = 0;
bool success = false;
while (tries < 10 && !success)
{
if (tries > 0)
{
Log.Error(string.Format("Attempting to create card for work item [{0}] attempt number [{1}]",
issue.Key, tries));
// wait 5 seconds before trying again
Thread.Sleep(new TimeSpan(0, 0, 5));
}
try
{
cardAddResult = LeanKit.AddCard(boardId, card, "New Card From Jira Issue");
success = true;
}
catch (Exception ex)
{
Log.Error(string.Format("An error occurred: {0} - {1} - {2}", ex.GetType(), ex.Message,
ex.StackTrace));
}
tries++;
}
card.Id = cardAddResult.CardId;
Log.Info("Created a card [{0}] of type [{1}] for work item [{2}] on Board [{3}] on Lane [{4}]", card.Id,
mappedCardType.Name, issue.Key, boardId, laneId);
}
示例2: CreateCardFromItem
private void CreateCardFromItem(BoardMapping project, Issue issue)
{
if (issue == null) return;
var boardId = project.Identity.LeanKit;
var mappedCardType = issue.LeanKitCardType(project);
var laneId = project.LanesFromState(issue.State).First();
var card = new Card
{
Active = true,
Title = issue.Title,
Description = issue.Body.SanitizeCardDescription(),
Priority = issue.LeanKitPriority(),
TypeId = mappedCardType.Id,
TypeName = mappedCardType.Name,
LaneId = laneId,
ExternalCardID = issue.Id + "|" + issue.Number,
ExternalSystemName = ServiceName,
ExternalSystemUrl = string.Format(_externalUrlTemplate, project.Identity.Target, issue.Number)
};
var assignedUserId = issue.LeanKitAssignedUserId(boardId, LeanKit);
if (assignedUserId != null)
card.AssignedUserIds = new[] { assignedUserId.Value };
if (issue.Milestone != null && issue.Milestone.Due_On != null)
{
if (CurrentUser != null)
{
var dateFormat = CurrentUser.DateFormat ?? "MM/dd/yyyy";
card.DueDate = issue.Milestone.Due_On.Value.ToString(dateFormat);
}
}
if (issue.Labels != null && issue.Labels.Any())
{
card.Tags = string.Join(",", issue.Labels.Select(x => x.Name).ToList());
}
if ((card.Tags == null || !card.Tags.Contains(ServiceName)) && project.TagCardsWithTargetSystemName)
{
if (string.IsNullOrEmpty(card.Tags))
card.Tags = ServiceName;
else
card.Tags += "," + ServiceName;
}
Log.Info("Creating a card of type [{0}] for Issue [{1}] on Board [{2}] on Lane [{3}]", mappedCardType.Name, issue.Number, boardId, laneId);
CardAddResult cardAddResult = null;
int tries = 0;
bool success = false;
while (tries < 10 && !success)
{
if (tries > 0)
{
Log.Error(string.Format("Attempting to create card for issue [{0}] attempt number [{1}]", issue.Id,
tries));
// wait 5 seconds before trying again
Thread.Sleep(new TimeSpan(0, 0, 5));
}
try {
cardAddResult = LeanKit.AddCard(boardId, card, "New Card From GitHub Issue");
success = true;
} catch (Exception ex) {
Log.Error(string.Format("An error occurred: {0} - {1} - {2}", ex.GetType(), ex.Message, ex.StackTrace));
}
tries++;
}
card.Id = cardAddResult.CardId;
Log.Info("Created a card [{0}] of type [{1}] for Issue [{2}] on Board [{3}] on Lane [{4}]", card.Id, mappedCardType.Name, issue.Number, boardId, laneId);
}