public static void UpdateWorkerStatusInDb(object sender, WorkerStatusUpdateEventArgs data) { if (data.WorkerId == Guid.Empty) { return; } using (var dc = new AryaServicesDbDataContext()) { var task = dc.AryaTasks.FirstOrDefault(nt => nt.ID == data.WorkerId); if (task == null) { return; } task.Status = data.CurrentState.ToString(); task.StatusMessage = data.StatusMessage; task.LastUpdateOn = DateTime.Now; dc.SubmitChanges(); } }
public static AryaTask CreateAryaTask(Guid id, Guid projectID, string description, string argumentDirectoryPath, Guid submittedBy, Type jobType) { using (var db = new AryaServicesDbDataContext()) { var nt = new AryaTask { ID = id, ProjectID = projectID, Description = description, ArgumentDirectoryPath = argumentDirectoryPath, Status = "New", SubmittedBy = submittedBy, SubmittedOn = DateTime.Now, LastUpdateOn = DateTime.Now, JobType = jobType.FullName.Split('.').Last() }; db.AryaTasks.InsertOnSubmit(nt); db.SubmitChanges(); return(nt); } }