async Task ExecuteHttp(TaskOptions taskOptions) { DateTime dateTime = DateTime.Now; HttpResponseMessage httpMessage; HttpClient client = _clientFactory.CreateClient("api"); if (!string.IsNullOrEmpty(taskOptions.AuthKey) && !string.IsNullOrEmpty(taskOptions.AuthValue)) { client.DefaultRequestHeaders.Add(taskOptions.AuthKey.Trim(), taskOptions.AuthValue.Trim()); } if (taskOptions.RequestType == RequestTypeEnum.Get) { httpMessage = await client.GetAsync(taskOptions.ApiUrl); } else { httpMessage = await client.PostAsync(taskOptions.ApiUrl, null); } TaskLog taskLog = new TaskLog() { ExecutionDuration = DateTime.Now.Subtract(dateTime).Milliseconds, ExecutionTime = dateTime, Msg = await httpMessage.Content.ReadAsStringAsync(), TaskId = taskOptions.Id, TaskLogStatus = httpMessage.IsSuccessStatusCode ? TaskLogStatusEnum.Success : TaskLogStatusEnum.Fail }; _ = _taskLogService.WriteLog(taskLog); _ = _taskService.UpdateLastRunTime(taskOptions.Id); }
public Task <ListResult <TaskLog> > GetTasksLogAsync(string searchString, int page, int page_size, string order_by = "", bool descending = false) { //var request = new RestRequest(Method.GET); //request.Resource = "Users/self"; //return this.Sdk.ExecuteAsync<ListResult<Project>>(request); var val = Task.Run(() => { ListResult <TaskLog> taskLogs = new ListResult <TaskLog>(); for (int i = 0; i < 5; i++) { TaskLog tl = new TaskLog(); tl.tasklog_id = i; tl.minutes = i * 10; tl.date = DateTime.Now; tl.comment = $"Comments {i}"; taskLogs.items.Add(tl); } return(taskLogs); }); return(val); }
public IActionResult Post([FromBody] TaskLogAPI item) { if (item == null) { return(BadRequest()); } TaskLog TaskLog = TaskLogAPI.To(item); try { TaskLog = new TaskLogBF(DB).Create(TaskLog); return(CreatedAtRoute( "TaskLogRoute", new { controller = "TaskLog", id = TaskLog.ID }, TaskLogAPI.From(TaskLog))); } catch (Exception ex) { return(BadRequest(ex)); } }
protected void Button1_Click(object sender, EventArgs e) { byte[] gbyte = Encoding.GetEncoding("GB2312").GetBytes("这是GB2312编码!"); string base64Str = Convert.ToBase64String(gbyte); string[] Demos = { "1", "A", "w", "6" }; //var strDic = from obDic in Demos orderby StringComparer.Ordinal descending select obDic; Array.Sort(Demos, string.CompareOrdinal); string[] result3 = Demos; //string[] result2 = strDic.ToArray(); string aa = "1321313"; return; int mathNum = 1996; int result = (int)AssemblyHelper.DLLFuncWithParam(out string expInfo, @"I:\API开发(Romens雨人)\LearnWay\HongFireSimple\Demo\bin\Debug\Demo.dll", "Demo", "Math", "Add", new Type[] { Type.GetType("System.Int32") }, mathNum); int result1 = (int)AssemblyHelper.DLLFunc(out string error, @"I:\API开发(Romens雨人)\LearnWay\HongFireSimple\Demo\bin\Debug\Demo.dll", "Demo", "Math", "Reduce"); AssemblyHelper.DLLAction(out string e2, @"I:\API开发(Romens雨人)\LearnWay\HongFireSimple\Demo\bin\Debug\Demo.dll", "Demo", "Math", "Errormethod"); int[] ints; TaskLog taskLog = new TaskLog(); Task t = new Task(() => { taskLog.DebugLog(); }); //重复任务 RecurringJob.AddOrUpdate("20190323LoopTask", () => taskLog.DebugLog(), Cron.MinuteInterval(5)); }
public IActionResult Put(int id, [FromBody] TaskLog taskLog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != taskLog.Id) { return(BadRequest()); } _context.Entry(taskLog).State = EntityState.Modified; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TaskLogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(StatusCodes.Status204NoContent)); }
private void btnSave_Click(object sender, EventArgs e) { _task.Description = txtDescription.Text; _task.ProjectID = _projectId; TaskLog taskLog = new TaskLog(); taskLog.TaskDate = DateTime.Now; taskLog.TaskStatusID = (int)cmbTaskStatus.SelectedValue; if (taskLog.TaskStatusID != 1) { taskLog.EmployeeID = (int)cmbTaskEmployee.SelectedValue; } if (_taskID < 0) { _task.CreatedDate = DateTime.Now; } _task.TaskLogs.Add(taskLog); bool result = false; try { result = (_taskID < 0) ? _taskBuss.Add(_task) : _taskBuss.Update(_task); } catch (Exception ex) { MessageBox.Show(ex.Message); } MessageBox.Show(result ? "İşlem başarılı" : "İşlem başarısız"); this.Close(); }
public static void LogCompleted(DateTime date, int taskId, bool completed, bool saveToDB = true) { var existing = DB.TasksLog.FirstOrDefault(x => x.Date == date && x.TaskID == taskId); if (existing != null) { existing.Completed = completed; } else { TaskLog log = new TaskLog() { Date = date, TaskID = taskId, Completed = completed }; DB.TasksLog.Add(log); } if (saveToDB) { DB.SaveChanges(); } }
public async Task <IActionResult> Toggle(int id) { if (!User.Identity.IsAuthenticated) { return(Unauthorized()); } var task = await _context.Task.FindAsync(id); if (id != task.Id) { return(NotFound()); } if (!string.Equals(task.AuthorId, User.FindFirst(ClaimTypes.NameIdentifier).Value) && !string.Equals(task.AssigneeId, User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } task.Closed = !task.Closed; var log = new TaskLog() { Title = task.Closed ? "Closed" : "Opened", Description = $"{(task.Closed ? "Closed" : "Opened")} a task", Created = DateTime.Now, TaskId = task.Id, UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value }; _context.Update(task); _context.Add(log); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), new { id = task.Id })); }
private void button4_Click(object sender, EventArgs e) { //Run TaskLog tl = new TaskLog(); tl.Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "TaskRunner", "Task Logs", DateTime.Now.Day + "_" + DateTime.Now.Month + "_" + DateTime.Now.Year + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + ".log"); tl.PreprendDateTime = true; for (int i = 0; i < listBox1.Items.Count; i++) { ITask task = (ITask)listBox1.Items[i]; if (task != null) { applicationLog.Add("Running task " + task.ToString()); if (task.Run()) { //Log the task result. //Also allow the running task access to either the same log file or a seperate log file } } } tl.Flush(); MessageBox.Show("All tasks have completed. Check the task log files for any errors", "TaskRunner", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TaskEntries,LogDate,ApplicationUserId")] TaskLog taskLog) { if (id != taskLog.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(taskLog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskManagerExists(taskLog.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(taskLog)); }
public async Task <IActionResult> Create([Bind("Id,TaskEntries,LogDate,ApplicationUserId")] TaskLog taskLog) { if (ModelState.IsValid) { if (User.IsInRole("Employee")) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var applicationUser = _context.Employee.Where(c => c.ApplicationUserId == userId).FirstOrDefault(); taskLog.ApplicationUserId = userId; _context.Add(taskLog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } if (User.IsInRole("Manager")) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var applicationUser = _context.Manager.Where(c => c.ApplicationUserId == userId).FirstOrDefault(); taskLog.ApplicationUserId = userId; _context.Add(taskLog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUser, "Id", "Id"); return(View(taskLog)); }
public TaskLog Create(TaskLog item) { if (item.IsValid()) { try { db.TaskLogs.Add(item); db.SaveChanges(); if (item.TaskID.HasValue) { item.Task = db.Tasks.Where(t => t.ID == item.TaskID.Value).Single(); } MarkNotIsNew(item); return(item); } catch (Exception ex) { db.TaskLogs.Remove(item); throw ex; } } else { throw new Exception("TaskLog is invalid"); } }
protected override string Insert(TaskLog log) { FileInfo fileInfo = this.EnsureFilePath(log); File.WriteAllText(fileInfo.FullName, string.Join(Environment.NewLine, new string[] { log.MachineName, log.IdentityName, log.CommandLine, string.Empty, "---- BEGIN LOG", this.Line(log, null, new object[0]) })); return(fileInfo.Name); }
private async Task EndPage() { if (pageWriter != null) { pageWriter.Flush(); pageData.Flush(); pageWriter.Dispose(); pageWriter = null; pageData = null; var log = new TaskLog(string.Format(@"logs\{0:D}", taskProperties.TaskInstanceId)); var taskLog = await taskClient.CreateLogAsync(log).ConfigureAwait(false); // Upload the contents using (var fs = File.Open(dataFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { await taskClient.AppendLogContentAsync(taskLog.Id, fs).ConfigureAwait(false); } // Create a new record and only set the Log field var attachmentUpdataRecord = new TimelineRecord { Id = taskProperties.TaskInstanceId, Log = taskLog }; await taskClient.UpdateTimelineRecordsAsync(attachmentUpdataRecord, default(CancellationToken)).ConfigureAwait(false); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,TaskId,UserId,Created")] TaskLog taskLog) { if (!User.Identity.IsAuthenticated) { return(Unauthorized()); } if (id != taskLog.Id) { return(NotFound()); } taskLog.Updated = DateTime.Now; if (ModelState.IsValid) { try { _context.Update(taskLog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskLogExists(taskLog.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Details", "Tasks", new { id = taskLog.TaskId })); } return(View(taskLog)); }
private string GetLockDescription(ITask task, TaskLog log, Arguments arguments, PreventConcurrentTaskExecutionAttribute preventConcurrent) { string description = $"Acquired by '{task.Name()}'. TaskLogId: {log.Id ?? "<n/a>"}."; Type customLockDescriptionType = preventConcurrent?.CustomLockDescription; if (customLockDescriptionType != null) { if (!(_kernel.Resolve(customLockDescriptionType) is IPreventConcurrentTaskExecutionCustomLockDescription customLockDescription)) { throw new InvalidOperationException( $@"Unable to resolve custom lock description type '{customLockDescriptionType.FullName}' which has been specified on task '{task.GetType().FullName}'. Either the type does not implement '{nameof(IPreventConcurrentTaskExecutionCustomLockDescription)}'-interface or you forgot to register the type as a custom lock description. You can register custom lock descriptions when setting up Integration Service in the ApplicationContext.Create(...)-method: using (IApplicationContext context = ApplicationContext.Create(application => application .Tasks(tasks => tasks .ConcurrentTaskExecution(concurrentTaskExecution => concurrentTaskExecution .AddFromAssemblyOfThis<Program>() .AddCustomLockDescription<MyCustomLockDescription>()))"); } description = customLockDescription.GetLockDescription(task, arguments, description); } return(description); }
/// <summary> /// 写日志 /// </summary> /// <param name="log"></param> public async Task WriteLog(TaskLog log) { string sql = @"INSERT INTO TaskLog (TaskId,ExecutionTime,ExecutionDuration,Msg,TaskLogStatus) VALUES (@TaskId,@ExecutionTime,@ExecutionDuration,@Msg,@TaskLogStatus)"; using var con = new DapperDbContexts().Connection; await con.ExecuteAsync(sql, log); }
internal FileInfo GetFilePath(TaskLog log, string baseDirectory) { if (log == null) { throw new ArgumentNullException("log"); } return(this.Combine(baseDirectory, log.TimeStamp, "{0}", new object[] { log.Name })); }
/// <exception cref="System.Exception"/> private string ReadStdOut(JobConf conf) { TaskAttemptID taskId = ((TaskAttemptID)TaskAttemptID.ForName(conf.Get(MRJobConfig .TaskAttemptId))); FilePath stdOut = TaskLog.GetTaskLogFile(taskId, false, TaskLog.LogName.Stdout); return(ReadFile(stdOut)); }
public IActionResult Post([System.Web.Http.FromBody] TaskLog taskLog) { _context.TaskLog.Add(taskLog); new TaskLog { }; _context.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = taskLog.Id }, taskLog)); }
public static bool AddTaskLog(TaskLog taskLog) { using (var conn = new MySqlConnection(Global.MySQLConnection)) { var sql = "insert into task_log(id,task_id,response,execute_time,apm) values(@id,@task_id,@response,@execute_time,@apm)"; var result = conn.Execute(sql, taskLog); return(result > 0); } }
private async void SaveCloseButton_Click(object sender, RoutedEventArgs e) { taskLog = await TaskLog.Save(taskLog); if (this.Frame.CanGoBack) { this.Frame.GoBack(); } }
internal FileInfo GetFilePath(TaskLog log, string baseDirectory) { if (log == null) { throw new ArgumentNullException(nameof(log)); } return(Combine(baseDirectory, log.TimeStamp, "{0}", log.Name)); }
public static string GetTaskLog(RestCommand command, int taskLogID) { TaskLog taskLog = TaskLogs.GetTaskLog(command.LoginUser, taskLogID); if (taskLog.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } return(taskLog.GetXml("TaskLog", true)); }
public ActionResult <string> Get(int id) { TaskLog taskLog = _context.TaskLog.Find(id); if (taskLog == null) { return(NotFound()); } return(Ok(taskLog)); }
public Exception OnException(ITask currentTask, TaskLog log, Vertica.Integration.Model.Arguments arguments, Exception exception) { string alias = arguments["Alias"]; log.LogMessage($"Unable to start {alias} (TaskLogId: {log.Id}): {exception.Message}"); // Return <null> to stop the task from being executed but without any exceptions thrown return(null); }
internal static void MarkNotIsNew(TaskLog item) { if (item.CheckIns != null) { foreach (var checkIn in item.CheckIns) { CheckInBF.MarkNotIsNew(checkIn); } } }
private void LogManager_LogAdded(TaskLog taskLog) { Dispatcher.Invoke(() => { lvLog.Items.Add(new LogItem() { TaskLog = taskLog }); }); }
public void InsertTaskLog(TaskLog item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } _taskLogRepository.Insert(item); //event notification _eventPublisher.EntityInserted(item); }
public void Drop(IDropInfo dropInfo) { if (dropInfo.Data is Task) { Task sourceItem = dropInfo.Data as Task; dynamic targetItem; Guid targetId; if (dropInfo.TargetItem is ColumnItemViewModel) { targetItem = dropInfo.TargetItem as ColumnItemViewModel; targetId = targetItem.Column.Id; if (taskService.FindById(sourceItem.Id) != null && columnService.FindById(targetItem.Column.Id) != null) { var colLast = columnService.FindById(sourceItem.Column.Id); var colNew = columnService.FindById(targetId); taskService.UpdateColumnId(targetId, sourceItem); var log = new TaskLog { ChangedBy = CurrentUser.Instance.User.FullName, TaskId = sourceItem.Id }; log.Message = TaskLogMessages.ColumnChangedMessage(colLast.Title, colNew.Title); taskLogService.CreateAsync(log); columnService.LoadColumns(CurrentProject.Instance.Project.Id); columnService.LoadColumns(CurrentProject.Instance.Project.Id); columnService.LoadColumns(CurrentProject.Instance.Project.Id); } } } else { ColumnItemViewModel sourceItem = dropInfo.Data as ColumnItemViewModel; ColumnItemViewModel targetItem = dropInfo.TargetItem as ColumnItemViewModel; if (sourceItem != null && targetItem != null) { if (columnService.FindById(sourceItem.Column.Id) != null && columnService.FindById(targetItem.Column.Id) != null) { var sourceIndex = ColumnsOfProject.Instance.Columns.First(x => x.Column.Id == sourceItem.Column.Id).Column.Position; var targetIndex = ColumnsOfProject.Instance.Columns.First(x => x.Column.Id == targetItem.Column.Id).Column.Position; if (sourceIndex != targetIndex) { columnService.UpdateAsync(sourceIndex, targetItem.Column); columnService.UpdateAsync(targetIndex, sourceItem.Column); columnService.LoadColumns(CurrentProject.Instance.Project.Id); columnService.LoadColumns(CurrentProject.Instance.Project.Id); columnService.LoadColumns(CurrentProject.Instance.Project.Id); } } } } }
public Task<TaskLog> CreateLogAsync(Guid scopeIdentifier, string hubName, Guid planId, TaskLog log, CancellationToken cancellationToken) { CheckConnection(); return _taskClient.CreateLogAsync(scopeIdentifier, hubName, planId, log, cancellationToken); }