public static Task Log(this Task task, string tag = null, [CallerMemberName] string callerMemberName = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = -1) { if (LogLevel == TaskLogLevel.None) { return(task); } var logEntry = new TaskLogEntry { Task = task, LogTime = DateTime.Now, Tag = tag, CallerMemberName = callerMemberName, CallerFilePath = callerFilePath, CallerLineNumber = callerLineNumber }; s_log[task] = logEntry; task.ContinueWith(t => { TaskLogEntry entry; s_log.TryRemove(t, out entry); }, TaskContinuationOptions.ExecuteSynchronously); return(task); }
public static Task Log(this Task task, string tag = null, [CallerMemberName] string callerMemberName = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = -1) { if (LogLevel == TaskLogLevel.None) { return(task); } var logEntry = new TaskLogEntry() { CallerFilePath = callerFilePath, CallerLineNumber = callerLineNumber, CallerMemberName = callerMemberName, LogTime = DateTime.Now, Task = task, Tag = tag, }; s_log[task] = logEntry; task.ContinueWith(t => { Console.WriteLine("task 已完成"); TaskLogEntry entry; s_log.TryRemove(t, out entry); // }, TaskContinuationOptions.ExecuteSynchronously);// 无演示效果 }, TaskContinuationOptions.OnlyOnRanToCompletion); return(task); }
/// <summary> /// Finds the task log entry with the given taskName and sets the End_Time field to the current datetime and the status flag. /// Also optionally sets a message string /// </summary> /// <param name="taskName">the source name of an existing log entry</param> public void MarkTaskAsComplete(string taskName, bool processWasSuccessfull, string message) { if (!SqlLogEnabled) { return; } if (!_hasOpenLogEntry) { var outputMessage = "Attempted to log a task when no log entry was opened"; LogService.Instance.Error(outputMessage); throw new InvalidOperationException(outputMessage); } else { //find the log entry if it exists TaskLogEntry entry = _runLogEntry.Tasks.Where(x => x.TaskName == taskName).FirstOrDefault(); if (entry == null) { LogService.Instance.Warn("Attempted to close a task entry that did not exist: " + taskName); } else { string status = processWasSuccessfull ? "SUCCESS" : "FAILED"; entry.EndTime = DateTime.Now; entry.Message = message; entry.Status = status; } } }
public async Task <ActionResult <TaskLogEntry> > PostTaskLogEntry(TaskLogEntry taskLogEntry) { // TODO: Do proper validation here. context.TaskLogEntries.Add(taskLogEntry); await context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetTaskLogEntry), new { id = taskLogEntry.Id }, taskLogEntry)); }
public async Task <TaskLogEntry> Log( TaskEnum task, TaskOutcomeEnum taskOutcome, string comment ) { var entry = new TaskLogEntry() { TaskCode = task.Code, TaskOutcomeCode = taskOutcome.Code, Comment = comment }; context.TaskLogEntries.Add(entry); await context.SaveChangesAsync(); return(entry); }
} // end HandleDayOverlaps private static int HandleDayOverlaps(Connection connection, TaskLogEntry taskLogEntry) { DateTime dtStartDateTime; DateTime dtEndDateTime; int iTimeLogID = 0; for (dtEndDateTime = taskLogEntry.TaskDate.AddTicks(863990000000), dtStartDateTime = taskLogEntry.TaskDate.AddDays(1); dtEndDateTime.Date <= DateTime.Today; dtEndDateTime = dtEndDateTime.AddDays(1), dtStartDateTime = dtStartDateTime.AddDays(1)) { if (dtEndDateTime.Date == DateTime.Today) { iTimeLogID = TimeLogEntry.CreateStop(connection, iTimeLogID); if (iTimeLogID > 0) { return (iTimeLogID); } // end if else { return (0); } // end else } // end if else { iTimeLogID = TimeLogEntry.Create(connection, dtEndDateTime, ActionTypes.Stop, taskLogEntry.TaskLogID); if (iTimeLogID > 0) { iTimeLogID = Start.Execute(connection, dtStartDateTime, taskLogEntry.UserID, taskLogEntry.Task.TaskID); if (iTimeLogID <= 0) { return (0); } } // end if else { return (0); } // end else } // end else } // end for return (iTimeLogID); } // end HandleDayOverlaps
private static void PrintBadSchedule(TaskLogEntry entry, string brokenRule) { Console.WriteLine($"Bad schedule: {entry} \"{brokenRule}\""); }
internal static void AddTaskLogEntry(long taskId, TaskLogEntry tle) { TasksQueue[taskId].AddLogEntry(tle); }