private void CalculateTicketKey(TogglWorklog sourceWorklog, TempoWorklog worklog) { // TODO: What occurs if we add more than one tag to worklog? var key_tag = sourceWorklog.Tags.FirstOrDefault(x => x.StartsWith("key_")); if (!string.IsNullOrEmpty(key_tag)) { var index = key_tag.LastIndexOf('_') + 1; if (index > 0 && index < key_tag.Length) { var parsedKey = key_tag.Substring(index); if (JiraKeyIsValid(parsedKey)) { worklog.TicketKey = parsedKey; } } } else if (!string.IsNullOrEmpty(sourceWorklog.Description)) { var dot_index = sourceWorklog.Description.IndexOf("."); if (dot_index >= 0) { var parsedKey = sourceWorklog.Description.Substring(0, dot_index); if (JiraKeyIsValid(parsedKey)) { worklog.TicketKey = parsedKey; worklog.Description = sourceWorklog.Description.Substring(dot_index + 1).Trim(); } } } }
private void CalculateActivity(TogglWorklog sourceWorklog, TempoWorklog worklog) { var activity = "Other"; if (!string.IsNullOrEmpty(sourceWorklog.Project) && ActivitiesMap.Keys.Contains(sourceWorklog.Project)) { activity = ActivitiesMap[sourceWorklog.Project]; } worklog.Activity = activity; }
private TempoWorklog Convert(TogglWorklog sourceWorklog) { var wl = new TempoWorklog { StartTime = sourceWorklog.StartTime, EndTime = sourceWorklog.EndTime, Description = sourceWorklog.Description, }; CalculateTicketKey(sourceWorklog, wl); CalculateActivity(sourceWorklog, wl); return(wl); }