public static SupportedEnvironment Update(int supportedEnvironmentID, Object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { SupportedEnvironment environment = context.SupportedEnvironments.Find(supportedEnvironmentID); context.Entry(environment).CurrentValues.SetValues(instance); context.SaveChanges(); return environment; } }
public static ProjectEnvironmentMap Update(int productEnvironmentId, Object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { ProjectEnvironmentMap p = context.ProjectEnvironmentMaps.Find(productEnvironmentId); context.Entry(p).CurrentValues.SetValues(instance); context.SaveChanges(); return p; } }
public static Ranking UpdateRanking(int id, object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { Ranking ranking = context.Rankings.Find(id); if (ranking != null) { context.Entry(ranking).CurrentValues.SetValues(instance); context.SaveChanges(); return ranking; } else { return null; } } }
public static DiagnosticLog UpdateDiagnosticLog(int id, object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { DiagnosticLog log = context.DiagnosticLogs.Find(id); if (null != log) { context.Entry(log).CurrentValues.SetValues(instance); context.SaveChanges(); return log; } else { return null; } } }
public static Ranking AddOrUpdateRanking(Ranking ranking) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { Ranking existingRanking = context.Rankings.Where(r=>r.Name.ToLower() == ranking.Name.ToLower()).FirstOrDefault(); if (existingRanking != null) { existingRanking.Description = ranking.Description; context.Entry(existingRanking).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return existingRanking; } else { context.Rankings.Add(ranking); context.SaveChanges(); return ranking; } } }
public static Release AddOrUpdateRelease(Release release) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { Release existingRelease = context.Releases.Where(r => r.Name.ToLower() == release.Name.ToLower()&& r.Type== release.Type && r.ProductId == release.ProductId).FirstOrDefault(); if (existingRelease != null) { existingRelease.Path = release.Path; existingRelease.Description = release.Description; context.Entry(existingRelease).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return existingRelease; } else { Release r = context.Releases.Add(release); context.SaveChanges(); return r; } } }
public static Branch AddOrUpdateBranch(Branch branch) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { Branch existingBranch = context.Branches.Where(b => b.Name.ToLower() == branch.Name.ToLower() && b.Type==branch.Type && b.ProductId==branch.ProductId).FirstOrDefault(); if (existingBranch != null) { existingBranch.Description = branch.Description; existingBranch.Path = branch.Path; context.Entry(existingBranch).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return existingBranch; } else { Branch b = context.Branches.Add(branch); context.SaveChanges(); return b; } } }
public void AddJobProgressInformation(string information) { try { if (mutex.WaitOne(1000 * 60)) { //this.Description = string.Format(@"<span class='date_time'>{0}</span>: {1}|{2}", System.DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"), information, this.Description); //this.Update(); using (ES1AutomationEntities context = new ES1AutomationEntities()) { AutomationJob job = context.AutomationJobs.Find(this.JobId); job.Description = string.Format(@"<span class='date_time'>{0}</span>: {1}|{2}", System.DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"), information, job.Description); this.Description = job.Description; context.Entry(job).Property(p => p.Description).IsModified = true; context.SaveChanges(); } } } finally { mutex.ReleaseMutex(); } AutomationTask task = JobManagement.GetAutomationTaskOfJob(this); task.AddProgressInformation(information); }
public static AutomationJob UpdateAutomationJob(int jobId, Object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { AutomationJob job = context.AutomationJobs.Find(jobId); if (job != null) { context.Entry(job).CurrentValues.SetValues(instance); context.SaveChanges(); } return job; } }
public void Update() { using (ES1AutomationEntities context = new ES1AutomationEntities()) { context.Entry(this).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public static Project UpdateProject(int projectId, Object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { Project project = context.Projects.Find(projectId); context.Entry(project).CurrentValues.SetValues(instance); context.SaveChanges(); return project; } }
public static TestCaseExecution Update(int executionId, Object instance) { try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { TestCaseExecution execution = context.TestCaseExecutions.Find(executionId); context.Entry(execution).CurrentValues.SetValues(instance); context.SaveChanges(); return execution; } } catch (Exception e) { ATFEnvironment.Log.logger.Error(e); return null; } }
public void SetTaskStatus(TaskStatus status) { //this.TaskStatus = status; //this.ModifyDate = DateTime.UtcNow; //this.Update(); try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { AutomationTask task = context.AutomationTasks.Find(this.TaskId); task.TaskStatus = status; task.ModifyDate = DateTime.UtcNow; this.TaskStatus = status; this.ModifyDate = task.ModifyDate; context.Entry(task).Property(p => p.Status).IsModified = true; context.Entry(task).Property(p => p.ModifyDate).IsModified = true; context.SaveChanges(); } } catch (Exception ex) { ATFEnvironment.Log.logger.Error(ex); } }
public static TestResult Update(int resultId, Object instance) { try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { TestResult result = context.TestResults.Find(resultId); if (result != null) { context.Entry(result).CurrentValues.SetValues(instance); context.SaveChanges(); return result; } else { return null; } } } catch (Exception e) { ATFEnvironment.Log.logger.Error(e); return null; } }
public static Release UpdateRelease(int id, object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { Release release = context.Releases.Find(id); if (release != null) { context.Entry(release).CurrentValues.SetValues(instance); context.SaveChanges(); return release; } else { return null; } } }
public void SetEnvironmentStatus(EnvironmentStatus status) { try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { TestEnvironment environment = context.TestEnvironments.Find(this.EnvironmentId); if (environment.EnvironmentStatus != EnvironmentStatus.Discard || status == EnvironmentStatus.Disposing)//We could not modify the environment status if it's discard, except to change it to disposing { ATFEnvironment.Log.logger.Debug(string.Format("Change Status for Env: {0}, {1} -> {2}", this.Name, this.EnvironmentStatus, status)); environment.Status = (int)status; environment.ModifyDate = DateTime.UtcNow; this.Status = (int)status; this.ModifyDate = environment.ModifyDate; context.Entry(environment).Property(p => p.Status).IsModified = true; context.Entry(environment).Property(p => p.ModifyDate).IsModified = true; context.SaveChanges(); } } } catch (Exception ex) { ATFEnvironment.Log.logger.Error(ex); } }
public static Branch UpdateBranch(int id, object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { Branch branch = context.Branches.Find(id); if (branch != null) { context.Entry(branch).CurrentValues.SetValues(instance); context.SaveChanges(); return branch; } else { return null; } } }
public static AutomationTask UpdateAutomationTask(int taskId, Object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { AutomationTask task = context.AutomationTasks.Find(taskId); if (task != null) { context.Entry(task).CurrentValues.SetValues(instance); context.SaveChanges(); } return task; } }
public void AddProgressInformation(string information) { if (mutex.WaitOne(1000 * 60)) { try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { AutomationTask task = context.AutomationTasks.Find(this.TaskId); task.Information = string.Format(@"<span class='date_time'>{0}</span>: {1}|{2}", System.DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"), information, task.Information); this.Information = task.Information; context.Entry(task).Property(p => p.Information).IsModified = true; context.SaveChanges(); } } catch (Exception ex) { ATFEnvironment.Log.logger.Error(ex); } finally { mutex.ReleaseMutex(); } } else { ATFEnvironment.Log.logger.Error(string.Format("Timeout to wait to write the info [{0}] to task [{1}]", information, this.Name)); } }
//only update the status field of the job public void SetJobsStatus(JobStatus status) { if (this.JobStatus != JobStatus.Cancelled && this.JobStatus != JobStatus.End || status == JobStatus.End) { //this.JobStatus = status; //this.ModifyDate = DateTime.UtcNow; //this.Update(); using (ES1AutomationEntities context = new ES1AutomationEntities()) { AutomationJob job = context.AutomationJobs.Find(this.JobId); job.JobStatus = status; job.ModifyDate = DateTime.UtcNow; context.Entry(job).Property(p => p.Status).IsModified = true; context.Entry(job).Property(p => p.ModifyDate).IsModified = true; context.SaveChanges(); } } }
public static Build Update(int buildId, Object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { Build build = context.Builds.Find(buildId); if (build != null) { context.Entry(build).CurrentValues.SetValues(instance); context.SaveChanges(); return build; } else { return null; } } }
public bool SetTestAgentEnvironment(int environmentId) { try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { AutomationJob job = context.AutomationJobs.Find(this.JobId); job.TestAgentEnvironmentId = environmentId; job.ModifyDate = DateTime.UtcNow; this.TestAgentEnvironmentId = environmentId; this.ModifyDate = job.ModifyDate; context.Entry(job).Property(p => p.TestAgentEnvironmentId).IsModified = true; context.Entry(job).Property(p => p.ModifyDate).IsModified = true; context.SaveChanges(); } return true; } catch (Exception ex) { ATFEnvironment.Log.logger.Error(ex); return false; } }
public static User Update(int userId, Object instance) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { User user = context.Users.Find(userId); context.Entry(user).CurrentValues.SetValues(instance); context.SaveChanges(); return user; } }
public void SetEnvironmentConfig(string config) { try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { TestEnvironment environment = context.TestEnvironments.Find(this.EnvironmentId); environment.Config = config; environment.ModifyDate = DateTime.UtcNow; this.Config = config; this.ModifyDate = environment.ModifyDate; context.Entry(environment).Property(p => p.Config).IsModified = true; context.Entry(environment).Property(p => p.ModifyDate).IsModified = true; context.SaveChanges(); } } catch (Exception ex) { ATFEnvironment.Log.logger.Error(ex); } }
public bool SetTestContent(string suiteId) { try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { AutomationTask task = context.AutomationTasks.Find(this.TaskId); task.TestContent = suiteId; task.ModifyDate = DateTime.UtcNow; this.TestContent = suiteId; this.ModifyDate = task.ModifyDate; context.Entry(task).Property(p => p.TestContent).IsModified = true; context.Entry(task).Property(p => p.ModifyDate).IsModified = true; context.SaveChanges(); } return true; } catch (Exception ex) { ATFEnvironment.Log.logger.Error(ex); return false; } }