-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6857862
commit 46a194d
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
|
||
using GsaAPI; | ||
|
||
using GsaGH.Parameters; | ||
|
||
namespace GsaGH.Helpers { | ||
internal static partial class TaskHelper { | ||
public static int CreateDefaultStaticAnalysisTask(ref GsaModel model) { | ||
int taskId = model.ApiModel.AddAnalysisTask(); | ||
model.ApiModel.CreateDefaultAnalysisCasesForTheTask(taskId); | ||
return taskId; | ||
} | ||
|
||
public static int AddAnalysisTask(ref GsaAnalysisTask task, ref GsaModel model) { | ||
int taskId = model.ApiModel.AddAnalysisTask(task.ApiTask); | ||
model.ApiModel.CreateDefaultAnalysisCasesForTheTask(taskId); | ||
return taskId; | ||
} | ||
|
||
public static void ImportAnalysisTask(GsaAnalysisTask task, ref GsaModel model) { | ||
ReadOnlyDictionary<int, AnalysisTask> existingTasks = model.ApiModel.AnalysisTasks(); | ||
if (task != null && !existingTasks.Keys.Contains(task.Id)) { | ||
int highestTask = existingTasks.Count(); | ||
var analysisCases = new Dictionary<int, AnalysisCase>(); | ||
foreach (GsaAnalysisCase analysisCase in task.Cases) { | ||
analysisCases.Add(analysisCase.Id, new AnalysisCase(analysisCase.Name, analysisCase.Definition)); | ||
} | ||
if (task.ApiTask != null) { | ||
if (analysisCases.Count == 0) { | ||
AddAnalysisTask(ref task, ref model); | ||
} else { | ||
model.ApiModel.ImportAnalysisTask(task.ApiTask, new ReadOnlyDictionary<int, AnalysisCase>(analysisCases)); | ||
task.Id = highestTask + 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static void ImportAnalysisTask(GsaAnalysisTask task, Model model) { | ||
var gsaModel = new GsaModel(model); | ||
ImportAnalysisTask(task, ref gsaModel); | ||
} | ||
} | ||
} |