private static IList <WorkEntry> TranslateEntries(IEnumerable <TogglEntry> togglEntries) { List <WorkEntry> workEntries = new List <WorkEntry>(); foreach (TogglEntry tEntry in togglEntries) { WorkEntry wEntry = null; try { wEntry = WorkEntry.Create(tEntry); } catch (ArgumentException ae) { Logger.Error("Toggl entry does not contain needed data", ae); } if (wEntry != null) { Logger.DebugFormat("Found work entry in Toggl for {0}", wEntry.IssueId); workEntries.Add(wEntry); } else { Logger.DebugFormat("Toggl entry is not in valid format{0}{1}", Environment.NewLine, tEntry.Description ?? "<null>"); } } return(workEntries); }
public static WorkEntry Create(TogglEntry entry) { if (entry == null) { throw new ArgumentException("Entry cannot be null", nameof(entry)); } if (string.IsNullOrEmpty(entry.At)) { throw new ArgumentException("Entry.At cannot be null", nameof(entry.At)); } if (string.IsNullOrEmpty(entry.Start)) { throw new ArgumentException("Entry.Start cannot be null", nameof(entry.Start)); } WorkEntry wEntry = null; if (JiraInfo.IsMatch(entry.Description ?? string.Empty)) { try { wEntry = new WorkEntry(entry); } catch (FormatException fe) { Logger.Error("Unable to create work entry from Toggl entry", fe); } } return(wEntry); }