コード例 #1
0
ファイル: Program.cs プロジェクト: TatevikBarseghyan/courses
        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);
        }
コード例 #2
0
ファイル: TaskLogger.cs プロジェクト: monsterNY/vlxm
        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);
        }
コード例 #3
0
        /// <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;
                }
            }
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: Stop.cs プロジェクト: chrisgray13/SandsOfTime
      } // 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
コード例 #7
0
 private static void PrintBadSchedule(TaskLogEntry entry, string brokenRule)
 {
     Console.WriteLine($"Bad schedule: {entry}  \"{brokenRule}\"");
 }
コード例 #8
0
ファイル: TaskScheduler.cs プロジェクト: radtek/BackO
 internal static void AddTaskLogEntry(long taskId, TaskLogEntry tle)
 {
     TasksQueue[taskId].AddLogEntry(tle);
 }