Example #1
0
 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;
     }
 }
Example #2
0
 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;
     }
 }
Example #3
0
 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;
         }
     }
 }
Example #4
0
 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;
         }
     }
 }
Example #5
0
 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;
         }
     }
 }
Example #6
0
 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;
         }
     }
 }
Example #7
0
        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;
                }
            }
        }
Example #8
0
        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);
        }
Example #9
0
 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;
     }
 }
Example #10
0
 public void Update()
 {
     using (ES1AutomationEntities context = new ES1AutomationEntities())
     {
         context.Entry(this).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #11
0
 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;
     }
 }
Example #12
0
        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;
            }
        }
Example #13
0
 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);
     }
 }
Example #14
0
 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;
     }
 }
Example #15
0
 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;
         }
     }
 }
Example #16
0
 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);
     }
 }
Example #17
0
 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;
         }
     }
 }
Example #18
0
 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;
     }
 }
Example #19
0
 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));
     }
 }
Example #20
0
 //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();
         }
     }
 }
Example #21
0
File: Build.cs Project: wangn6/rep2
 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;
         }
     }
 }
Example #22
0
 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;
     }
 }
Example #23
0
File: User.cs Project: wangn6/rep2
 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;
     }
 }
Example #24
0
 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);
     }
 }
Example #25
0
 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;
     }
 }