Skip to content

Commit

Permalink
Merge pull request #3574 from Ginger-Automation/Defect/ApplicationPla…
Browse files Browse the repository at this point in the history
…tformUpdate

DefectId - 19221 Added an event to trigger the application platform name change
  • Loading branch information
manas-droid authored Apr 5, 2024
2 parents 27ba624 + 75d52c7 commit 16922e2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 25 deletions.
30 changes: 30 additions & 0 deletions Ginger/Ginger/Activities/ActivityDetailsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,37 @@ private void UserProfile_PropertyChanged(object? sender, PropertyChangedEventArg
TargetAppSelectedComboBox();
}
}
public void UpdateTargetApplication()
{
Dispatcher.Invoke(() =>
{
int pointer = 0;
foreach(TargetApplication targetApplication in xTargetApplicationComboBox.Items)
{
var ApplicationPlatform = WorkSpace.Instance?.Solution?.ApplicationPlatforms?
.FirstOrDefault((appPlat) =>
{
if(appPlat.NameBeforeEdit!=null && appPlat.NameBeforeEdit.Equals(targetApplication.AppName))
{
return true ;
}
return false;
});
if(ApplicationPlatform != null)
{
targetApplication.AppName = ApplicationPlatform.AppName;
if (targetApplication.AppName.Equals(mActivity.TargetApplication) && xTargetApplicationComboBox.SelectedIndex != pointer)
{
xTargetApplicationComboBox.SelectedIndex = pointer;
}
}
pointer++;
}
});
}
private void AutoUpdate_ConsumerList(object? sender, NotifyCollectionChangedEventArgs e)
{
TargetAppSelectedComboBox();
Expand Down
11 changes: 11 additions & 0 deletions Ginger/Ginger/Activities/ActivityPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ limitations under the License.
using Ginger.BusinessFlowWindows;
using Ginger.Repository;
using Ginger.Repository.AddItemToRepositoryWizard;
using Ginger.SolutionWindows;
using Ginger.UserControlsLib;
using Ginger.UserControlsLib.UCListView;
using GingerCore;
Expand Down Expand Up @@ -299,6 +300,7 @@ private void XItemsTabs_SelectionChanged(object sender, SelectionChangedEventArg
{
mConfigurationsPage = new ActivityDetailsPage(mActivity, mContext, mPageViewMode);
xConfigurationsFrame.SetContent(mConfigurationsPage);
TargetApplicationsPage.OnActivityUpdate += UpdateTargetApplication;
}
else
{
Expand All @@ -310,6 +312,15 @@ private void XItemsTabs_SelectionChanged(object sender, SelectionChangedEventArg
}
}

private void UpdateTargetApplication()
{

if (mConfigurationsPage != null)
{
mConfigurationsPage.UpdateTargetApplication();
}
}

private void MActionsPage_ShiftToActionsListEvent(object sender, RoutedEventArgs e)
{
if (mPageViewMode == Ginger.General.eRIPageViewMode.Automation || mPageViewMode == Ginger.General.eRIPageViewMode.ViewAndExecute)
Expand Down
4 changes: 2 additions & 2 deletions Ginger/Ginger/Agents/ApplicationAgentsMapPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
using Amdocs.Ginger.Common.Repository;
using Amdocs.Ginger.UserControls;
using Ginger.Run;
using Ginger.SolutionWindows;
using GingerCore;
using GingerCore.DataSource;
using GingerCore.Platforms;
Expand All @@ -47,7 +48,6 @@ public partial class ApplicationAgentsMapPage : Page
public ObservableList<ApplicationAgent> ApplicationAgents;
GingerExecutionEngine mRunner;
Context mContext;

bool AllowAgentsManipulation;
public delegate void OnBusinessFlowTargetApplicationChange();
public static event OnBusinessFlowTargetApplicationChange BusinessFlowTargetApplicationChanged;
Expand All @@ -65,7 +65,7 @@ public ApplicationAgentsMapPage(GingerExecutionEngine runner, Context context, b
AllowAgentsManipulation = allowAgentsManipulation;
xAppAgentsListBox.Tag = AllowAgentsManipulation;//Placed here for binding with list dataTemplate- need better place
mRunner.GingerRunner.PropertyChanged += MGR_PropertyChanged;

TargetApplicationsPage.OnActivityUpdate += RefreshApplicationAgentsList;
xKeepAgentsOn.Visibility = Visibility.Collapsed;
if (!AllowAgentsManipulation && !WorkSpace.Instance.RunsetExecutor.RunSetConfig.RunModeParallel)
{
Expand Down
13 changes: 8 additions & 5 deletions Ginger/Ginger/AutomatePageLib/NewAutomatePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,16 @@ private void OnTargetApplicationChanged(object arg1, SelectionChangedEventArgs a
{
var selectedTargetApplication = (TargetApplication)mActivityDetailsPage.xTargetApplicationComboBox.SelectedItem;

bool doesApplicationAgentAlreadyExist = mExecutionEngine.GingerRunner.ApplicationAgents.Any((aa) => aa.AppName.Equals(selectedTargetApplication.AppName));

if (!doesApplicationAgentAlreadyExist)
if (selectedTargetApplication != null)
{
ApplicationAgent applicationAgent = new ApplicationAgent() { AppName = selectedTargetApplication.AppName };
bool doesApplicationAgentAlreadyExist = mExecutionEngine.GingerRunner.ApplicationAgents.Any((aa) => aa.AppName.Equals(selectedTargetApplication.AppName));

if (!doesApplicationAgentAlreadyExist)
{
ApplicationAgent applicationAgent = new ApplicationAgent() { AppName = selectedTargetApplication.AppName };

mExecutionEngine.GingerRunner.ApplicationAgents.Add(applicationAgent);
mExecutionEngine.GingerRunner.ApplicationAgents.Add(applicationAgent);
}
}

mApplicationAgentsMapPage.RefreshApplicationAgentsList();
Expand Down
33 changes: 15 additions & 18 deletions Ginger/Ginger/SolutionWindows/TargetApplicationsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ limitations under the License.
using Ginger.UserControls;
using Ginger.UserControlsLib;
using GingerCore;
using GingerCore.Platforms;
using GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -41,6 +39,10 @@ public partial class TargetApplicationsPage : GingerUIPage
Solution mSolution;
string AppName;

public delegate void OnActivityTargetApplicationUpdate();

public static event OnActivityTargetApplicationUpdate OnActivityUpdate;

public TargetApplicationsPage()
{
InitializeComponent();
Expand Down Expand Up @@ -185,26 +187,16 @@ private void UpdateApplicationNameChangeInSolution(ApplicationPlatform app)
foreach (BusinessFlow bf in WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<BusinessFlow>())
{
//update the BF target applications
foreach (var bfApp in bf.TargetApplications)
foreach (var activity in bf.Activities)
{
//donot check for TargetPlugins, only for TargetApplications
if (bfApp.GetType() == typeof(TargetApplication))

if (activity.TargetApplication.Equals(app.NameBeforeEdit))
{
if (((TargetApplication)bfApp).AppName == app.NameBeforeEdit)
{
((TargetApplication)bfApp).AppName = app.AppName;
activity.StartDirtyTracking();
activity.TargetApplication = app.AppName;

//update the bf activities
foreach (Activity activity in bf.Activities)
{
if (activity.TargetApplication == app.NameBeforeEdit)
{
activity.TargetApplication = app.AppName;
}
}
numOfAfectedItems++;
break;
}
numOfAfectedItems++;
}
}
}
Expand All @@ -219,6 +211,11 @@ private void UpdateApplicationNameChangeInSolution(ApplicationPlatform app)
numOfAfectedItems++;
}
}

if(numOfAfectedItems > 0 && OnActivityUpdate!=null)
{
OnActivityUpdate();
}
Reporter.ToUser(eUserMsgKey.StaticInfoMessage, string.Format("{0} items were updated successfully, please remember to Save All change.", numOfAfectedItems));
}

Expand Down

0 comments on commit 16922e2

Please sign in to comment.