Skip to content

Commit

Permalink
Merge branch 'feature/rdmpgit' into dependabot/nuget/main/Microsoft.N…
Browse files Browse the repository at this point in the history
…ET.Test.Sdk-17.7.0
  • Loading branch information
jas88 committed Aug 7, 2023
2 parents f1194f1 + dee81a2 commit 3b8e389
Show file tree
Hide file tree
Showing 48 changed files with 603 additions and 606 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
</package>
"@ | Out-File -Encoding ASCII plugin.nuspec
dotnet publish Plugin/windows/windows.csproj -c Release -o p/windows
dotnet publish Plugin/main/main.csproj -c Release -o p/main
dotnet publish -p:DebugType=embedded -p:GenerateDocumentation=false Plugin/windows/windows.csproj -c Release -o p/windows
dotnet publish -p:DebugType=embedded -p:GenerateDocumentation=false Plugin/main/main.csproj -c Release -o p/main
cmd /c 7z a -tzip HIC.Extensions.nupkg plugin.nuspec p
dotnet run --project RDMP/Tools/rdmp/rdmp.csproj -c Release -- pack -p --file HIC.Extensions.nupkg --dir yaml
dotnet run --project RDMP/Tools/rdmp/rdmp.csproj -c Release -- cmd listsupportedcommands --dir yaml
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "RDMP"]
path = RDMP
url = https://github.com/HicServices/RDMP.git
branch = feature/rc4
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class AutomationUserInterface : PluginUserInterface

public AutomationUserInterface(IBasicActivateItems itemActivator) : base(itemActivator)
{
_overlayProvider = new IconOverlayProvider();
try
{
_scheduleIcon = Image.Load<Rgba32>(AutomationImages.AutomateExtractionSchedule);
Expand All @@ -43,32 +42,36 @@ public override Image<Rgba32> GetImage(object concept, OverlayKind kind = Overla
{
if (concept is AutomateExtractionSchedule || concept as Type == typeof(AutomateExtractionSchedule))
{
return _overlayProvider.GetOverlay(_scheduleIcon,kind);
return IconOverlayProvider.GetOverlay(_scheduleIcon,kind);
}

if (concept is AutomateExtraction || concept as Type == typeof(AutomateExtraction))
{
return _overlayProvider.GetOverlay(_automateExtractionIcon, kind);
return IconOverlayProvider.GetOverlay(_automateExtractionIcon, kind);
}

return base.GetImage(concept, kind);
}

public override object[] GetChildren(object model)
{
if (model is IProject p)
switch (model)
{
var schedule = GetScheduleIfAny(p);
case IProject p:
{
var schedule = GetScheduleIfAny(p);

if(schedule != null)
return new[] { schedule };
}

if(model is IExtractionConfiguration ec)
{
var automate = GetAutomateExtractionIfAny(ec);
if (automate != null)
return new[] { automate };
if(schedule != null)
return new[] { schedule };
break;
}
case IExtractionConfiguration ec:
{
var automate = GetAutomateExtractionIfAny(ec);
if (automate != null)
return new[] { automate };
break;
}
}

return base.GetChildren(model);
Expand All @@ -78,35 +81,24 @@ private AutomateExtractionSchedule GetScheduleIfAny(IProject p)
{
TryGettingAutomationRepository();

if (AutomationRepository == null)
{
return null;
}

return AllSchedules.FirstOrDefault(aes => aes.Project_ID == p.ID);
return AutomationRepository == null ? null : AllSchedules.FirstOrDefault(aes => aes.Project_ID == p.ID);
}

private AutomateExtraction GetAutomateExtractionIfAny(IExtractionConfiguration ec)
{
TryGettingAutomationRepository();

if (AutomationRepository == null)
{
return null;
}

return AllAutomateExtractions.FirstOrDefault(ae => ae.ExtractionConfiguration_ID == ec.ID);
return AutomationRepository == null ? null : AllAutomateExtractions.FirstOrDefault(ae => ae.ExtractionConfigurationId == ec.ID);
}

DateTime lastLook = DateTime.MinValue;
private IconOverlayProvider _overlayProvider;
private Image<Rgba32> _scheduleIcon;
private Image<Rgba32> _automateExtractionIcon;
DateTime _lastLook = DateTime.MinValue;
private readonly Image<Rgba32> _scheduleIcon;
private readonly Image<Rgba32> _automateExtractionIcon;

private void TryGettingAutomationRepository()
{
// we looked recently already dont spam that thing
if (DateTime.Now - lastLook < TimeSpan.FromSeconds(5))
// we looked recently already don't spam that thing
if (DateTime.Now - _lastLook < TimeSpan.FromSeconds(5))
return;

if (AutomationRepository != null)
Expand All @@ -120,39 +112,34 @@ private void TryGettingAutomationRepository()
AllAutomateExtractions = AutomationRepository.GetAllObjects<AutomateExtraction>();
AllSchedules = AutomationRepository.GetAllObjects<AutomateExtractionSchedule>();

lastLook = DateTime.Now;
_lastLook = DateTime.Now;
}
catch (Exception)
{
AutomationRepository = null;
lastLook = DateTime.Now;
_lastLook = DateTime.Now;
}
}

public override IEnumerable<IAtomicCommand> GetAdditionalRightClickMenuItems(object o)
{
if (o is AllExternalServersNode)
{
yield return new ExecuteCommandCreateNewExternalDatabaseServer(BasicActivator, new AutomateExtractionPluginPatcher(), PermissableDefaults.None);
}


if(o is IProject p)
switch (o)
{
yield return new ExecuteCommandCreateNewAutomateExtractionSchedule(BasicActivator, p);
}
if(o is IExtractionConfiguration ec)
{
yield return new ExecuteCommandCreateNewAutomateExtraction(BasicActivator, ec);
}

if(o is AutomateExtraction ae)
{
yield return new ExecuteCommandSet(BasicActivator, ae, typeof(AutomateExtraction).GetProperty(nameof(AutomateExtraction.BaselineDate)))
{
OverrideCommandName = "Set Baseline Date"
};
case AllExternalServersNode:
yield return new ExecuteCommandCreateNewExternalDatabaseServer(BasicActivator, new AutomateExtractionPluginPatcher(), PermissableDefaults.None);
break;
case IProject p:
yield return new ExecuteCommandCreateNewAutomateExtractionSchedule(BasicActivator, p);
break;
case IExtractionConfiguration ec:
yield return new ExecuteCommandCreateNewAutomateExtraction(BasicActivator, ec);
break;
case AutomateExtraction ae:
yield return new ExecuteCommandSet(BasicActivator, ae, typeof(AutomateExtraction).GetProperty(nameof(AutomateExtraction.BaselineDate)))
{
OverrideCommandName = "Set Baseline Date"
};
break;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ public BasicAutomationCommandExecution(IBasicActivateItems activator):base(activ
}
catch (System.Exception e)
{
SetImpossible("No Automation Repository Found:" + e.Message);
SetImpossible($"No Automation Repository Found:{e.Message}");
return;
}

if (AutomationRepository == null)
{
SetImpossible("There is no Automation Repository configured");
return;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,79 +12,73 @@

namespace LoadModules.Extensions.AutomationPlugins.Data;

public class AutomateExtraction : DatabaseEntity, IMapsDirectlyToDatabaseTable
public class AutomateExtraction : DatabaseEntity
{
private readonly AutomateExtractionRepository _repository;

#region Database Properties

private int _extractionConfiguration_ID;
private int _automateExtractionSchedule_ID;
private int _extractionConfigurationId;
private int _automateExtractionScheduleId;
private bool _disabled;
private DateTime? _baselineDate;
private bool _refreshCohort;
private bool _release;

public int ExtractionConfiguration_ID
public int ExtractionConfigurationId
{
get { return _extractionConfiguration_ID; }
set { SetField(ref _extractionConfiguration_ID, value); }
get => _extractionConfigurationId;
set => SetField(ref _extractionConfigurationId, value);
}
public int AutomateExtractionSchedule_ID
public int AutomateExtractionScheduleId
{
get { return _automateExtractionSchedule_ID; }
set { SetField(ref _automateExtractionSchedule_ID, value); }
get => _automateExtractionScheduleId;
set => SetField(ref _automateExtractionScheduleId, value);
}
public bool Disabled
{
get { return _disabled; }
set { SetField(ref _disabled, value); }
get => _disabled;
set => SetField(ref _disabled, value);
}
public DateTime? BaselineDate
{
get { return _baselineDate; }
set { SetField(ref _baselineDate, value); }
get => _baselineDate;
set => SetField(ref _baselineDate, value);
}

public bool RefreshCohort
{
get { return _refreshCohort; }
set {SetField(ref _refreshCohort , value); }
get => _refreshCohort;
set => SetField(ref _refreshCohort , value);
}

public bool Release
{
get { return _release; }
set { SetField(ref _release , value);}
get => _release;
set => SetField(ref _release , value);
}

#endregion

#region Relationships

[NoMappingToDatabase]
public IExtractionConfiguration ExtractionConfiguration { get
{
return _repository.DataExportRepository.GetObjectByID<ExtractionConfiguration>(ExtractionConfiguration_ID);
} }
public IExtractionConfiguration ExtractionConfiguration => _repository.DataExportRepository.GetObjectByID<ExtractionConfiguration>(ExtractionConfigurationId);

[NoMappingToDatabase]
public AutomateExtractionSchedule AutomateExtractionSchedule { get
{
return _repository.GetObjectByID<AutomateExtractionSchedule>(AutomateExtractionSchedule_ID);
}}
public AutomateExtractionSchedule AutomateExtractionSchedule => _repository.GetObjectByID<AutomateExtractionSchedule>(AutomateExtractionScheduleId);

#endregion

public AutomateExtraction(PluginRepository repository, AutomateExtractionSchedule schedule, IExtractionConfiguration config)
{
_repository = (AutomateExtractionRepository) repository;
repository.InsertAndHydrate(this, new Dictionary<string, object>()
repository.InsertAndHydrate(this, new Dictionary<string, object>
{
{"AutomateExtractionSchedule_ID",schedule.ID},
{"ExtractionConfiguration_ID",config.ID},
{"RefreshCohort",false},
{"Release",false},
{"Release",false}

});

Expand All @@ -95,8 +89,8 @@ public AutomateExtraction(PluginRepository repository, DbDataReader r)
: base(repository, r)
{
_repository = (AutomateExtractionRepository) repository;
ExtractionConfiguration_ID = Convert.ToInt32(r["ExtractionConfiguration_ID"]);
AutomateExtractionSchedule_ID = Convert.ToInt32(r["AutomateExtractionSchedule_ID"]);
ExtractionConfigurationId = Convert.ToInt32(r["ExtractionConfiguration_ID"]);
AutomateExtractionScheduleId = Convert.ToInt32(r["AutomateExtractionSchedule_ID"]);
Disabled = Convert.ToBoolean(r["Disabled"]);
BaselineDate = ObjectToNullableDateTime(r["BaselineDate"]);

Expand All @@ -110,46 +104,47 @@ public AutomateExtraction(PluginRepository repository, DbDataReader r)
public override string ToString()
{
_cachedExtractionConfiguration ??=
_repository.DataExportRepository.GetObjectByID<ExtractionConfiguration>(ExtractionConfiguration_ID);
_repository.DataExportRepository.GetObjectByID<ExtractionConfiguration>(ExtractionConfigurationId);

return _cachedExtractionConfiguration.Name;
}

public DataTable GetIdentifiersTable()
{
var dt = new DataTable();
dt.BeginLoadData();

var repo = (TableRepository)Repository;
var server = repo.DiscoveredServer;

using (var con = server.GetConnection())
{
con.Open();
var cmd = server.GetCommand("Select ReleaseID from ReleaseIdentifiersSeen", con);
var da = server.GetDataAdapter(cmd);
da.Fill(dt);
}
using var con = server.GetConnection();
con.Open();
var cmd = server.GetCommand("Select ReleaseID from ReleaseIdentifiersSeen", con);
var da = server.GetDataAdapter(cmd);
da.Fill(dt);
dt.EndLoadData();

return dt;
}

public SuccessfullyExtractedResults GetSuccessIfAnyFor(IExtractableDataSet ds)
{
return _repository.GetAllObjects<SuccessfullyExtractedResults>(@"WHERE ExtractableDataSet_ID = " + ds.ID + " AND AutomateExtraction_ID = " + ID).SingleOrDefault();
return _repository.GetAllObjects<SuccessfullyExtractedResults>(
$@"WHERE ExtractableDataSet_ID = {ds.ID} AND AutomateExtraction_ID = {ID}").SingleOrDefault();
}

public void ClearBaselines()
{
using (var con = _repository.DiscoveredServer.GetConnection())
{
con.Open();
new SqlCommand(@"Delete From
new SqlCommand($@"Delete From
[ReleaseIdentifiersSeen]
where
AutomateExtraction_ID = " + ID, (SqlConnection) con).ExecuteNonQuery();
AutomateExtraction_ID = {ID}", (SqlConnection) con).ExecuteNonQuery();
}

foreach (SuccessfullyExtractedResults r in _repository.GetAllObjectsWithParent<SuccessfullyExtractedResults>(this))
foreach (var r in _repository.GetAllObjectsWithParent<SuccessfullyExtractedResults>(this))
r.DeleteInDatabase();

BaselineDate = null;
Expand Down
Loading

0 comments on commit 3b8e389

Please sign in to comment.