Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into improvereportperfor…
Browse files Browse the repository at this point in the history
…mance
  • Loading branch information
sudarshan0212 committed Sep 9, 2024
2 parents 0119df2 + fa60fc1 commit b90923c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 34 deletions.
54 changes: 31 additions & 23 deletions Ginger/Ginger/AutomatePageLib/NewAutomatePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,32 @@ private void ClearAutomatedId(BusinessFlow businessFlowToLoad)

private bool SetOrClearPreviousAutoRunSetDocumentLiteDB(bool isClear = true)
{
LiteDbManager dbManager = new LiteDbManager(mExecutionEngine.ExecutionLoggerManager.Configuration.CalculatedLoggerFolder);
var result = dbManager.GetRunSetLiteData();
var filterData = result.FindOne(a => a.RunStatus == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Automated.ToString());
if (filterData != null)
try
{
if (isClear)
LiteDbManager dbManager = new LiteDbManager(mExecutionEngine.ExecutionLoggerManager.Configuration.CalculatedLoggerFolder);
var result = dbManager.GetRunSetLiteData();
var filterData = result.FindOne(a => a.RunStatus == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Automated.ToString());
if (filterData != null)
{
LiteDbConnector dbConnector = new LiteDbConnector(Path.Combine(mExecutionEngine.ExecutionLoggerManager.Configuration.CalculatedLoggerFolder, "GingerExecutionResults.db"));
dbConnector.DeleteDocumentByLiteDbRunSet(filterData, eExecutedFrom.Automation);
}
else
{
mRunSetLiteDbId = filterData._id;
mRunnerLiteDbId = filterData.RunnersColl[0]._id;
if (isClear)
{
LiteDbConnector dbConnector = new LiteDbConnector(Path.Combine(mExecutionEngine.ExecutionLoggerManager.Configuration.CalculatedLoggerFolder, "GingerExecutionResults.db"));
dbConnector.DeleteDocumentByLiteDbRunSet(filterData, eExecutedFrom.Automation);
}
else
{
mRunSetLiteDbId = filterData._id;
mRunnerLiteDbId = filterData.RunnersColl[0]._id;
}
return true;
}
return true;
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Exception during accessing litedb file", ex);
}
return false;

}
#endregion LiteDB

Expand Down Expand Up @@ -221,7 +229,7 @@ private void Activity_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Activity.TargetApplication))
{
OnTargetApplicationChanged(sender , null);
OnTargetApplicationChanged(sender, null);
UpdateContextWithActivityDependencies();
}
}
Expand Down Expand Up @@ -417,7 +425,7 @@ public async Task LoadBusinessFlowToAutomate(BusinessFlow businessFlowToLoad)
ResetPageUI();

mBusinessFlow = businessFlowToLoad;

CurrentItemToSave = mBusinessFlow;
if (mBusinessFlow != null)
{
Expand Down Expand Up @@ -614,9 +622,9 @@ private void SetActivityEditPage()
ToggleActivityPageUIButtons(!mExecutionIsInProgress);
}
mActivityDetailsPage = new ActivityDetailsPage(mContext.Activity, mContext, mContext.Activity.Type == Amdocs.Ginger.Repository.eSharedItemType.Regular ? Ginger.General.eRIPageViewMode.Automation : Ginger.General.eRIPageViewMode.ViewAndExecute);
/* mActivityDetailsPage.xTargetApplicationComboBox.SelectionChanged -= OnTargetApplicationChanged;
mActivityDetailsPage.xTargetApplicationComboBox.SelectionChanged += OnTargetApplicationChanged;
*/
/* mActivityDetailsPage.xTargetApplicationComboBox.SelectionChanged -= OnTargetApplicationChanged;
mActivityDetailsPage.xTargetApplicationComboBox.SelectionChanged += OnTargetApplicationChanged;
*/
}
else
{
Expand All @@ -630,12 +638,12 @@ private void SetActivityEditPage()
xCurrentActivityFrame.SetContent(mActivityPage);
}
}

private void OnTargetApplicationChanged(object arg1, SelectionChangedEventArgs args)
{
var selectedTargetApplication = (mActivity!=null) ? WorkSpace.Instance.Solution.GetSolutionTargetApplications().FirstOrDefault((targetApp)=>targetApp.Name.Equals(mActivity.TargetApplication)) as TargetApplication : null;
var selectedTargetApplication = (mActivity != null) ? WorkSpace.Instance.Solution.GetSolutionTargetApplications().FirstOrDefault((targetApp) => targetApp.Name.Equals(mActivity.TargetApplication)) as TargetApplication : null;

if (selectedTargetApplication !=null && !mBusinessFlow.TargetApplications.Any(bfTA => ((TargetApplication)bfTA).AppName.Equals(selectedTargetApplication.AppName)))
if (selectedTargetApplication != null && !mBusinessFlow.TargetApplications.Any(bfTA => ((TargetApplication)bfTA).AppName.Equals(selectedTargetApplication.AppName)))
{
// ApplicationAgent applicationAgent = new ApplicationAgent() { AppName = ((TargetApplication)actTargetApp).AppName };
// applicationAgent.ApplicationAgentOperations = new ApplicationAgentOperations(applicationAgent);
Expand Down Expand Up @@ -1249,7 +1257,7 @@ public async Task RunAutomatePageAction(Tuple<Activity, Act, bool> actionToExecu
((AgentOperations)((Agent)mExecutionEngine.CurrentBusinessFlow.CurrentActivity.CurrentAgent).AgentOperations).IsFailedToStart = false;
}

ResumeBusinessFlowAndActivitiesDevelopmentTimeTracking(itemsWithDevTimeTracking);
ResumeBusinessFlowAndActivitiesDevelopmentTimeTracking(itemsWithDevTimeTracking);
}
}

Expand All @@ -1269,7 +1277,7 @@ private IEnumerable<RepositoryItemBase> PauseBusinessFlowAndActivitiesDevelopmen
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.DEBUG, "error while pausing development time tracker for business flow and activities", ex);
}
}

return itemsWithTimerRunning;
}
Expand Down
64 changes: 53 additions & 11 deletions Ginger/GingerCoreNET/LiteDBFolder/LiteDbManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,69 @@ public LiteDbManager(String dbFolderName = "")
dbConnector = new LiteDbConnector(Path.Combine(dbFolderName, "GingerExecutionResults.db")); // Set data to ExecutionResults folder name
InitMappers();
}
/// <summary>
/// Initializes the mappers for LiteDB collections.
/// </summary>
public void InitMappers()
{
var runSetMapper = dbConnector.GetMapper<LiteDbRunSet>();
var runnerMapper = dbConnector.GetMapper<LiteDbRunner>();
var bfMapper = dbConnector.GetMapper<LiteDbBusinessFlow>();
var agMapper = dbConnector.GetMapper<LiteDbActivityGroup>();
var activityMapper = dbConnector.GetMapper<LiteDbActivity>();
var action = dbConnector.GetMapper<LiteDbAction>();
InitRunSetMapper();
InitRunnerMapper();
InitBusinessFlowMapper();
InitActivityGroupMapper();
InitActivityMapper();
}

activityMapper.DbRef(rf => rf.AllActionsColl, NameInDb<LiteDbAction>());
/// <summary>
/// Initializes the mapper for LiteDbRunSet collection.
/// </summary>
private void InitRunSetMapper()
{
var runSetMapper = dbConnector.GetMapper<LiteDbRunSet>();
runSetMapper.DbRef(rf => rf.RunnersColl, NameInDb<LiteDbRunner>());
}

agMapper.DbRef(rf => rf.AllActivitiesColl, NameInDb<LiteDbActivity>());
/// <summary>
/// Initializes the mapper for LiteDbRunner collection.
/// </summary>
private void InitRunnerMapper()
{
var runnerMapper = dbConnector.GetMapper<LiteDbRunner>();
runnerMapper.DbRef(rf => rf.BusinessFlowsColl, NameInDb<LiteDbBusinessFlow>());
runnerMapper.DbRef(rf => rf.AllBusinessFlowsColl, NameInDb<LiteDbBusinessFlow>());
}

/// <summary>
/// Initializes the mapper for LiteDbBusinessFlow collection.
/// </summary>
private void InitBusinessFlowMapper()
{
var bfMapper = dbConnector.GetMapper<LiteDbBusinessFlow>();
bfMapper.DbRef(rf => rf.ActivitiesGroupsColl, NameInDb<LiteDbActivityGroup>());

bfMapper.DbRef(rf => rf.ActivitiesColl, NameInDb<LiteDbActivity>());
bfMapper.DbRef(rf => rf.AllActivitiesColl, NameInDb<LiteDbActivity>());
}

runnerMapper.DbRef(rf => rf.AllBusinessFlowsColl, NameInDb<LiteDbBusinessFlow>());
/// <summary>
/// Initializes the mapper for LiteDbActivityGroup collection.
/// </summary>
private void InitActivityGroupMapper()
{
var agMapper = dbConnector.GetMapper<LiteDbActivityGroup>();
agMapper.DbRef(rf => rf.ActivitiesColl, NameInDb<LiteDbActivity>());
agMapper.DbRef(rf => rf.AllActivitiesColl, NameInDb<LiteDbActivity>());
}

runSetMapper.DbRef(rf => rf.RunnersColl, NameInDb<LiteDbRunner>());
/// <summary>
/// Initializes the mapper for LiteDbActivity collection.
/// </summary>
private void InitActivityMapper()
{
var activityMapper = dbConnector.GetMapper<LiteDbActivity>();
activityMapper.DbRef(rf => rf.ActionsColl, NameInDb<LiteDbAction>());
activityMapper.DbRef(rf => rf.AllActionsColl, NameInDb<LiteDbAction>());
}


public string NameInDb<T>()
{
var name = typeof(T).Name + "s";
Expand Down

0 comments on commit b90923c

Please sign in to comment.