/// <summary> /// Gets the user control meant to configure the task type /// </summary> /// <param name="cmTaskType"></param> /// <returns></returns> public UserControl GetTaskConfigUI(CMTaskTypeDto cmTaskType) { var taskFactory = GetTaskFactory(cmTaskType.Name); var configUC = taskFactory.GetTaskConfigUI(cmTaskType); return(configUC); }
/// <summary> /// Gets the user control meant to edit or view a particular task /// </summary> /// <param name="cmTaskType"></param> /// <param name="cmSystem"></param> /// <param name="cmFeature"></param> /// <param name="cmTask"></param> /// <returns></returns> public UserControl GetTaskUI(CMTaskTypeDto cmTaskType, CMSystemDto cmSystem, CMFeatureDto cmFeature, CMTaskDto cmTask) { var taskFactory = GetTaskFactory(cmTaskType.Name); var taskUC = taskFactory.GetTaskUI(cmTaskType, cmSystem, cmFeature, cmTask); return(taskUC); }
private void Window_Loaded(object sender, RoutedEventArgs e) { this.Title = cmTaskDto.Title; ref_TaskTypeDto = CMDataProvider.DataStore.Value.CMTaskTypes.Value.Get(cmTaskDto.CMTaskTypeId); ref_FeatureDto = CMDataProvider.DataStore.Value.CMFeatures.Value.Get(cmTaskDto.CMFeatureId); ref_SystemDto = CMDataProvider.DataStore.Value.CMSystems.Value.Get(ref_FeatureDto.CMSystemId); LoadTaskStatesCombo(); LoadTaskUI(); }
public override bool HasTaskData(CMTaskTypeDto cmTaskType, CMTaskDto cmTask) { switch (cmTaskType.Name) { case nameof(BuildInTaskTypes.FeatureDependency): return(FeatureDependencyExtensions.FeatureDependencyDataProvider.Get_ForTaskId(cmTask.Id) != null); case nameof(BuildInTaskTypes.Note): return(NoteExtensions.NoteDataProvider.Get_ForTaskId(cmTask.Id) != null); } return(false); }
public override void CreateTaskDataInstance(CMTaskTypeDto cmTaskType, CMTaskDto cmTaskTemplate, CMTaskDto cmTaskInstance) { switch (cmTaskType.Name) { case nameof(BuildInTaskTypes.FeatureDependency): FeatureDependencyExtensions.FeatureDependency_CreateTaskDataInstance(cmTaskTemplate, cmTaskInstance); break; case nameof(BuildInTaskTypes.Note): NoteExtensions.Note_CreateTaskDataInstance(cmTaskTemplate, cmTaskInstance); break; } }
public override UserControl GetTaskUI(CMTaskTypeDto cmTaskType, CMSystemDto cmSystem, CMFeatureDto cmFeature, CMTaskDto cmTask) { switch (cmTaskType.Name) { case nameof(BuildInTaskTypes.FeatureDependency): var featureDependencyTaskUI = new FeatureDependencyUC(cmSystem, cmFeature, cmTask); return(featureDependencyTaskUI); case nameof(BuildInTaskTypes.Note): var noteTaskUI = new NoteUC(cmSystem, cmFeature, cmTask); return(noteTaskUI); } return(null); }
public override UserControl GetTaskConfigUI(CMTaskTypeDto cmTaskType) { switch (cmTaskType.Name) { case nameof(BuildInTaskTypes.FeatureDependency): var configUI = new FeatureDependencyConfigUC(); return(configUI); case nameof(BuildInTaskTypes.Note): // No config UI for the note task return(null); } return(null); }
public override List <string> GetRequiredTaskStates(CMTaskTypeDto cmTaskType) { var requiredStates = new List <string>(); switch (cmTaskType.Name) { case nameof(BuildInTaskTypes.FeatureDependency): requiredStates.Add(nameof(FeatureDependencyTaskStateNames.WaitingOnChoice)); requiredStates.Add(nameof(FeatureDependencyTaskStateNames.WaitingOnDependency)); break; case nameof(BuildInTaskTypes.Note): // No required states in the note task break; } return(requiredStates); }
private TreeViewItem GetTVI_TaskType(CMTaskTypeDto cmTaskTypeDto) { var taskTypeTVI = new TreeViewItem() { Header = cmTaskTypeDto.Name, Tag = new TreeViewTag(cmTaskTypeDto), }; // Add the context menu // There is no context menu actions currently for task types var contextMenu = new ContextMenu(); contextMenu.Visibility = Visibility.Hidden; taskTypeTVI.ContextMenu = contextMenu; taskTypeTVI.Selected += TreeConfiguration_NodeSelected; return(taskTypeTVI); }
/// <summary> /// Gets a configuration UI that can be used to configure each task type that are supplied by this task factory. /// It is optional for the task factory to implement this. A blank panel will be used by default. /// </summary> /// <returns></returns> public virtual UserControl GetTaskConfigUI(CMTaskTypeDto cmTaskType) { return(new UserControl()); }
/// <summary> /// The UI that is shown when editing a task /// </summary> /// <param name="cmTaskType"></param> /// <param name="cmSystem"></param> /// <param name="cmFeature"></param> /// <param name="cmTask"></param> /// <returns></returns> public abstract UserControl GetTaskUI(CMTaskTypeDto cmTaskType, CMSystemDto cmSystem, CMFeatureDto cmFeature, CMTaskDto cmTask);
/// <summary> /// Gets a list of task states that the specified task type will set at any point. /// This list should not include the following reserved states, which are automatically added for all states. /// * Closed - Represents a task that is closed. /// * Template - A task that is a template will have this state /// * Instance - When a task is copied from a template to an instance the instance will be at this state initially /// </summary> /// <param name="taskType"></param> /// <returns></returns> public abstract List <string> GetRequiredTaskStates(CMTaskTypeDto cmTaskType);
/// <summary> /// Taskes care of scanning for task factories and registering them in the database if needed. /// </summary> /// <returns></returns> private static string RegisterTaskFactories_InDatabase() { var taskFactories = TaskFactoriesCatalog.Instance.TaskFactories.ToList(); var currentFactoriesFromDisk = new List <string>(); var currentTaskTypesFromDisk = new List <string>(); // Check to make sure each task factory is available by its name foreach (var taskFactory in taskFactories) { var cmTaskFactory = CMDataProvider.DataStore.Value.CMTaskFactories.Value.Get_ForName(taskFactory.Name); if (cmTaskFactory == null) { var newTaskFactoryDto = new CMTaskFactoryDto() { Name = taskFactory.Name, Version = taskFactory.Version }; var opResult = CMDataProvider.DataStore.Value.CMTaskFactories.Value.Insert(newTaskFactoryDto); if (opResult.Errors.Any()) { return(opResult.ErrorsCombined); } cmTaskFactory = CMDataProvider.DataStore.Value.CMTaskFactories.Value.Get_ForName(taskFactory.Name); } if (currentFactoriesFromDisk.Contains(cmTaskFactory.Name)) { return($"There is more than 1 task factory registering with the same name {cmTaskFactory.Name}. Please resolve this before running the program."); } currentFactoriesFromDisk.Add(cmTaskFactory.Name); // Make sure all of the task types that this task factory provides are registered in the database foreach (var taskTypeName in taskFactory.GetTaskTypes()) { var cmTaskType = CMDataProvider.DataStore.Value.CMTaskTypes.Value.Get_ForName(taskTypeName); if (cmTaskType == null) { var newTaskTypeDto = new CMTaskTypeDto() { Name = taskTypeName }; var opResult = CMDataProvider.DataStore.Value.CMTaskTypes.Value.Insert(newTaskTypeDto); if (opResult.Errors.Any()) { return(opResult.ErrorsCombined); } cmTaskType = CMDataProvider.DataStore.Value.CMTaskTypes.Value.Get_ForName(taskTypeName); } if (currentTaskTypesFromDisk.Contains(cmTaskType.Name)) { return($"There is more than 1 task type registering with the same name {cmTaskType.Name}. Please resolve this before running the program."); } currentTaskTypesFromDisk.Add(cmTaskType.Name); // Make sure the task states for this task type are registered // First make sure the built in states are present var reservedInternalTaskStates = ReservedTaskStates.States; var reservedTaskPluginStates = taskFactory.GetRequiredTaskStates(cmTaskType); var invalidPluginStates = reservedTaskPluginStates.Intersect(reservedInternalTaskStates); if (invalidPluginStates.Any()) { var allInvalidStates = string.Join(",", invalidPluginStates); return($"The task factory {taskFactory.Name} is attempting to use reserved state(s) {allInvalidStates}. Please remove this task factory and try again."); } var allReservedTaskStates = reservedInternalTaskStates.Union(reservedTaskPluginStates); int priority = 0; foreach (var taskState in allReservedTaskStates) { var dbTaskState = CMDataProvider.DataStore.Value.CMTaskStates.Value.Get_ForInternalName(taskState, cmTaskType.Id); if (dbTaskState == null) { var newTaskStateDto = new CMTaskStateDto() { DisplayName = taskState, InternalName = taskState, Reserved = true, TaskTypeId = cmTaskType.Id, Priority = ++priority }; var opResult = CMDataProvider.DataStore.Value.CMTaskStates.Value.Insert(newTaskStateDto); if (opResult.Errors.Any()) { return(opResult.ErrorsCombined); } } else { dbTaskState.InternalName = taskState; dbTaskState.DisplayName = taskState; dbTaskState.Reserved = true; var opResult = CMDataProvider.DataStore.Value.CMTaskStates.Value.Update(dbTaskState); if (opResult.Errors.Any()) { return(opResult.ErrorsCombined); } } } // Un-reserve states that are not required to be reserved now, just in case we are upgrading the db var dbTaskStates = CMDataProvider.DataStore.Value.CMTaskStates.Value.GetAll_ForTaskType(cmTaskType.Id); foreach (var dbTaskState in dbTaskStates) { if (dbTaskState.Reserved && !allReservedTaskStates.Contains(dbTaskState.InternalName)) { dbTaskState.Reserved = false; var opResult = CMDataProvider.DataStore.Value.CMTaskStates.Value.Update(dbTaskState); if (opResult.Errors.Any()) { return(opResult.ErrorsCombined); } } } } } // Go through everything that is currently registered in the db and check for things that are now missing on disk // mcbtodo: for now I'm just showing an error here, but there should be a way to either automatically resolve this // mcbtodo: issue or give instructions to the user on how to clean up any references to the removed taskfactory/tasktype. // mcbtodo: nothing referenced the factories yet, add this back in or delete as some point //var dbTaskFactories = CMDataProvider.DataStore.Value.CMTaskFactories.Value.GetAll(); //foreach (var dbTaskFactory in dbTaskFactories) //{ // if (!currentFactoriesFromDisk.Contains(dbTaskFactory.Name)) // { // return $"Task factory with name {dbTaskFactory.Name} that was previously registered has been removed. Please put this task factory back in place so the program can run properly."; // } //} var dbTaskTypes = CMDataProvider.DataStore.Value.CMTaskTypes.Value.GetAll(); foreach (var dbTaskType in dbTaskTypes) { // The only restriction is that task types are named uniquely across the collection. It is acceptable if a task type moves from one factory to another. if (!currentTaskTypesFromDisk.Contains(dbTaskType.Name)) { return($"Task type {dbTaskType.Name} that was previously registered has been removed. Please restore the previous configuration so the program can run properly."); } } return(null); }
public bool HasTaskData(CMTaskTypeDto cmTaskType, CMTaskDto cmTask) { var taskFactory = GetTaskFactory(cmTaskType.Name); return(taskFactory.HasTaskData(cmTaskType, cmTask)); }
/// <summary> /// Called when the program needs to determine if task data exists already for a task or not /// </summary> /// <param name="cmTask"></param> /// <returns></returns> public abstract bool HasTaskData(CMTaskTypeDto cmTaskType, CMTaskDto cmTask);
/// <summary> /// Called when instancing a task. A <see cref="CMTaskDto"/> will have already been created and is passed in. /// The task factory should create any task data for this new task and take care of updating the database. /// </summary> /// <param name="cmTaskType"></param> /// <param name="cmTaskInstance">The id of the newly created CMTaskDto instance that was created from the template</param> public void CreateTaskDataInstance(CMTaskTypeDto cmTaskType, CMTaskDto cmTaskTemplate, CMTaskDto cmTaskInstance) { var taskFactory = GetTaskFactory(cmTaskType.Name); taskFactory.CreateTaskDataInstance(cmTaskType, cmTaskTemplate, cmTaskInstance); }
/// <summary> /// Called when instancing a task. A <see cref="CMTaskDto"/> will have already been created and is passed in. /// The task factory should create any task data for this new task and take care of updating the database. /// </summary> /// <param name="cmTaskType"></param> /// <param name="cmTaskTemplate">The task template that the task was created from</param> /// <param name="cmTaskInstance">The new task that was created</param> public abstract void CreateTaskDataInstance(CMTaskTypeDto cmTaskType, CMTaskDto cmTaskTemplate, CMTaskDto cmTaskInstance);
public TaskTypeConfigUC(Config configWindow, CMTaskTypeDto cmTaskType) { InitializeComponent(); this.cmTaskType = cmTaskType; this.ConfigWindow = configWindow; }