Exemple #1
0
 public AutomationTaskDTO Create(AutomationTaskDTO instance)
 {
     instance.CreateDate = DateTime.UtcNow;
     instance.ModifyDate = DateTime.UtcNow;
     AutomationTask task = AutomationTask.CreateTask(instance.ToEntity());
     task.AddProgressInformation(string.Format("{0} submitted an automation task.", User.GetUserById(task.CreateBy).Username));
     return task.ToDTO();
 }
Exemple #2
0
        /// <summary>
        /// Invoked when <see cref="ToDTO"/> operation is about to return.
        /// </summary>
        /// <param name="dto"><see cref="AutomationTaskDTO"/> converted from <see cref="AutomationTask"/>.</param>
partial         static void OnDTO(this AutomationTask entity, AutomationTaskDTO dto);
Exemple #3
0
        public AutomationTaskDTO Update(string taskId, AutomationTaskDTO instance)
        {
            instance.ModifyDate = DateTime.UtcNow;
            instance.TaskId = Int32.Parse(taskId);
            string message = string.Empty;
            string user =  User.GetUserById(instance.ModifyBy).Username;
            if (instance.Status == (int)TaskStatus.Cancelling)
            {
                message = string.Format("Task is cancelled by {0}.", user);
            }
            else
            {
                message = string.Format("Task is updated by {0}.", user);
            }

            instance.Information = AutomationTask.GetAutomationTask(int.Parse(taskId)).Information;

            AutomationTask task = AutomationTask.UpdateAutomationTask(Int32.Parse(taskId), instance);
            task.AddProgressInformation(message);
            return task.ToDTO();
        }
Exemple #4
0
        /// <summary>
        /// Converts this instance of <see cref="AutomationTask"/> to an instance of <see cref="AutomationTaskDTO"/>.
        /// </summary>
        /// <param name="entity"><see cref="AutomationTask"/> to convert.</param>
        public static AutomationTaskDTO ToDTO(this AutomationTask entity)
        {
            if (entity == null) return null;

            var dto = new AutomationTaskDTO();

            dto.TaskId = entity.TaskId;
            dto.Name = entity.Name;
            dto.Status = entity.Status;
            dto.Type = entity.Type;
            dto.Priority = entity.Priority;
            dto.CreateDate = entity.CreateDate;
            dto.CreateBy = entity.CreateBy;
            dto.ModifyDate = entity.ModifyDate;
            dto.ModifyBy = entity.ModifyBy;
            dto.BuildId = entity.BuildId;
            dto.EnvironmentId = entity.EnvironmentId;
            dto.TestContent = entity.TestContent;
            dto.Information = entity.Information;
            dto.Description = entity.Description;
            dto.RecurrencePattern = entity.RecurrencePattern.Value;
            dto.StartDate = entity.StartDate.Value;
            dto.StartTime = entity.StartTime.Value;
            dto.WeekDays = entity.WeekDays.Value;
            dto.WeekInterval = entity.WeekInterval.Value;
            if (entity.ParentTaskId != null)
            {
                dto.ParentTaskId = entity.ParentTaskId.Value;
            }
            if (entity.BranchId != null)
            {
                dto.BranchId = entity.BranchId.Value;
            }
            if (entity.ReleaseId != null)
            {
                dto.ReleaseId = entity.ReleaseId.Value;
            }
            if (entity.ProductId != null)
            {
                dto.ProductId = entity.ProductId.Value;
            }
            if (entity.ProjectId != null)
            {
                dto.ProjectId = entity.ProjectId.Value;
            }

            dto.NotifyStakeholders = entity.NotifyStakeholders.HasValue ? entity.NotifyStakeholders.Value : false;
            dto.WriteTestResultBack = entity.WriteTestResultBack.HasValue ? entity.WriteTestResultBack.Value : false;
            dto.SetupScript = entity.SetupScript;
            dto.TeardownScript = entity.TeardownScript;
            dto.EnableCodeCoverage = entity.EnableCodeCoverage.HasValue ? entity.EnableCodeCoverage.Value : false;
            entity.OnDTO(dto);

            return dto;
        }