Skip to content

Commit

Permalink
GSAGH-550:missing file added
Browse files Browse the repository at this point in the history
  • Loading branch information
SandeepArup committed Dec 23, 2024
1 parent 6857862 commit 46a194d
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions GsaGH/Helpers/TaskHelper.cs
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);
}
}
}

0 comments on commit 46a194d

Please sign in to comment.