// [Timeout(60000)] public void SendActionToRemoteGrid() { // Arrange ActPlugIn actPlugin = new ActPlugIn() { ServiceId = "DummyService", ActionId = "A1" }; //Act GingerNodeProxy.RemoteGridIP = RemoteGridIP; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GingerNodeProxy.RemoteGridPort = RemoteGridPort; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GingerNodeInfo gingerNodeInfo = new GingerNodeInfo() { }; GingerNodeProxy gingerNodeProxy = new GingerNodeProxy(gingerNodeInfo, true); NewPayLoad actionPayLoad = ExecuteOnPlugin.CreateActionPayload(actPlugin); NewPayLoad actionResult = gingerNodeProxy.RunAction(actionPayLoad); ExecuteOnPlugin.ParseActionResult(actionResult, actPlugin); //Assert Assert.AreEqual(RemoteGingerGrid.NodeList.Count, 2); Assert.AreEqual("A1 Result", actPlugin.ExInfo); }
internal static void FindNodeAndRunAction(ActPlugIn act) { // If we have remote grid(s) then we go for remote run ObservableList <RemoteServiceGrid> remoteServiceGrids = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <RemoteServiceGrid>(); if (remoteServiceGrids.Count > 0) { ExecuteActionOnRemotePlugin(act); } else { GingerNodeInfo GNI = null; try { GNI = GetGingerNodeInfoForPluginAction((ActPlugIn)act); if (GNI != null) { ExecuteActionOnPlugin((ActPlugIn)act, GNI); } } catch (Exception ex) { Console.WriteLine(ex.Message); string errorMessage = ""; if (GNI == null) { errorMessage += "Cannot find GingerNodeInfo in service grid for: " + ((ActPlugIn)act).PluginId + ", Service " + ((ActPlugIn)act).ServiceId + Environment.NewLine; } errorMessage += "Error while executing Plugin Service action " + Environment.NewLine; errorMessage += ex.Message; act.Error = errorMessage; } } }
public override void ActionEnd(uint eventTime, Act action, bool offlineMode = false) { if (action is ActPlugIn) { ActPlugIn actPlugIn = ((ActPlugIn)action); WorkSpace.Instance.Telemetry.Add("actionend", new { ActionType = action.ActionType, Guid = action.Guid, Name = action.GetType().Name, Elasped = action.Elapsed, Status = action.Status.ToString(), Plugin = actPlugIn.PluginId, ServiceId = actPlugIn.ServiceId, ActionID = actPlugIn.ActionId }); } else { WorkSpace.Instance.Telemetry.Add("actionend", new { ActionType = action.ActionType, Guid = action.Guid, Name = action.GetType().Name, Elasped = action.Elapsed, Status = action.Status.ToString() }); } }
public void RunFlow() { //Arrange WorkSpace.LockWS(); Agent agent = prep(); BusinessFlow BF = new BusinessFlow("BF1"); BF.TargetApplications.Add(new TargetApplication() { AppName = cWebApp }); BF.Activities[0].TargetApplication = cWebApp; ActPlugIn a1 = new ActPlugIn() { PluginId = mPluginId, ServiceId = mServiceId, ActionId = "A1", Active = true }; BF.Activities[0].Acts.Add(a1); //Act mGingerRunner.RunBusinessFlow(BF); Console.WriteLine("a1.Error = " + a1.Error); agent.Close(); //Assert Assert.IsTrue(string.IsNullOrEmpty(a1.Error), "Action.Error=null"); Assert.AreEqual(eRunStatus.Passed, a1.Status, "a1.Status"); Assert.AreEqual(eRunStatus.Passed, BF.Activities[0].Status, "Activity Status = Pass"); WorkSpace.RelWS(); }
public void SpeedTest() { //Arrange ResetBusinessFlow(); WorkSpace.Instance.LocalGingerGrid.NodeList.Clear(); Activity activitiy1 = new Activity() { Active = true, TargetApplication = mAppName }; mBusinessFlow.Activities.Add(activitiy1); for (int i = 0; i < 1000; i++) { ActPlugIn act1 = new ActPlugIn() { PluginId = "Memo", ServiceId = "MemoService", ActionId = "Say", Active = true }; act1.AddOrUpdateInputParamValue("text", "hello " + i); activitiy1.Acts.Add(act1); } //Act mGingerRunner.RunRunner(); //Assert Assert.AreEqual(mBusinessFlow.RunStatus, eRunStatus.Passed, "mBF.RunStatus"); Assert.AreEqual(eRunStatus.Passed, activitiy1.Status); Assert.IsTrue(activitiy1.Elapsed < 20000, "a0.Elapsed Time less than 20000ms/10sec"); }
public void PluginSay() { //Arrange ResetBusinessFlow(); WorkSpace.Instance.LocalGingerGrid.NodeList.Clear(); Activity a1 = new Activity() { Active = true, TargetApplication = mAppName }; mBusinessFlow.Activities.Add(a1); ActPlugIn act1 = new ActPlugIn() { PluginId = "Memo", ServiceId = "MemoService", ActionId = "Say", Active = true }; act1.AddOrUpdateInputParamValue("text", "hello"); a1.Acts.Add(act1); //Act mGingerRunner.RunRunner(); string outVal = act1.GetReturnValue("I said").Actual; //Assert Assert.AreEqual("hello", outVal, "outVal=hello"); Assert.AreEqual(eRunStatus.Passed, mBusinessFlow.RunStatus); Assert.AreEqual(eRunStatus.Passed, a1.Status); }
private void RunAction(ActPlugIn a1, GingerNodeProxy gNP1) { NewPayLoad a1Payload = ExecuteOnPlugin.CreateActionPayload(a1); NewPayLoad rc = gNP1.RunAction(a1Payload); ExecuteOnPlugin.ParseActionResult(rc, a1); }
public ActPlugInEditPage(ActPlugIn act) { InitializeComponent(); mAct = act; LoadEditPage(); AutoCreateEditPage(); }
public ActPlugInEditPage(ActPlugIn act) { InitializeComponent(); mAct = act; InputGrid.ItemsSource = mAct.InputValues;//TODO: Hide it SetActionInputsControls(); }
private static void UpdateParamsType(ActPlugIn actPlugIn) { List <ActionInputValueInfo> paramsList = WorkSpace.Instance.PlugInsManager.GetActionEditInfo(actPlugIn.PluginId, actPlugIn.ServiceId, actPlugIn.ActionId); foreach (ActInputValue AP in actPlugIn.InputValues) { ActionInputValueInfo actionInputValueInfo = (from x in paramsList where x.Param == AP.Param select x).SingleOrDefault(); AP.ParamType = actionInputValueInfo.ParamType; } }
internal static GingerNodeInfo GetGingerNodeInfoForPluginAction(ActPlugIn actPlugin) { GingerNodeInfo GNI = GetGingerNodeInfo(actPlugin.PluginId, actPlugin.ServiceId); if (GNI == null) { actPlugin.Error = "GNI not found, Timeout waiting for service to be available in GingerGrid"; } return(GNI); }
public static void ExecuteActionOnRemotePlugin(ActPlugIn actPlugin) { NewPayLoad p = CreateActionPayload(actPlugin); string serviceID = actPlugin.ServiceId; RemoteServiceGrid remoteServiceGrid = FindRemoteGrid(actPlugin.ServiceId); // Temp !!!!!!!!!!!!!!!!! change to get GingerNodePorxy for Remote grid GingerNodeInfo gingerNodeInfo = new GingerNodeInfo(); GingerNodeProxy gingerNodeProxy = new GingerNodeProxy(gingerNodeInfo, true); NewPayLoad RC = gingerNodeProxy.RunAction(p); }
private void LoadPluginsActions() { ObservableList <PluginPackage> plugins = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <PluginPackage>(); ObservableList <Act> PlugInsActions = new ObservableList <Act>(); foreach (PluginPackage pluginPackage in plugins) { pluginPackage.PluginPackageOperations = new PluginPackageOperations(pluginPackage); try { foreach (PluginServiceInfo pluginServiceInfo in ((PluginPackageOperations)pluginPackage.PluginPackageOperations).Services) { foreach (PluginServiceActionInfo pluginServiceAction in pluginServiceInfo.Actions) { ActPlugIn act = new ActPlugIn(); act.Description = pluginServiceAction.Description; act.PluginId = pluginPackage.PluginId; act.ServiceId = pluginServiceInfo.ServiceId; act.ActionId = pluginServiceAction.ActionId; foreach (var v in pluginServiceAction.InputValues) { if (v.Param == "GA") { continue; // not needed } act.InputValues.Add(new ActInputValue() { Param = v.Param, ParamTypeEX = v.ParamTypeStr }); } act.Active = true; PlugInsActions.Add(act); } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to get the Action of the Plugin '" + pluginPackage.PluginId + "'", ex); } } SetActionsListViewData(xPlatformPlugInsActionsListView, PlugInsActions); }
// Use for Actions which run without agent and are of the generic type ActPlugin - public static void ExecuteActionOnPlugin(ActPlugIn actPlugin, GingerNodeInfo gingerNodeInfo) { try { // first verify we have service ready or start service Stopwatch st = Stopwatch.StartNew(); GingerNodeProxy gingerNodeProxy = WorkSpace.Instance.LocalGingerGrid.GetNodeProxy(gingerNodeInfo); // FIXME for remote grid //!!!!!!!!!!!!! TODO: check if null set err NewPayLoad p = CreateActionPayload(actPlugin); NewPayLoad RC = gingerNodeProxy.RunAction(p); // release the node as soon as the result came in bool IsSessionService = WorkSpace.Instance.PlugInsManager.IsSessionService(actPlugin.PluginId, gingerNodeInfo.ServiceId); if (!IsSessionService) { // standalone plugin action release the node gingerNodeInfo.Status = GingerNodeInfo.eStatus.Ready; } ParseActionResult(RC, actPlugin); gingerNodeInfo.IncreaseActionCount(); st.Stop(); long millis = st.ElapsedMilliseconds; actPlugin.ExInfo += "Elapsed: " + millis + "ms"; } catch (Exception ex) { Console.WriteLine(ex.Message); string errorMessage = ""; if (gingerNodeInfo == null) { errorMessage += "Cannot find GingerNodeInfo in service grid for: " + ((ActPlugIn)actPlugin).PluginId + ", Service " + ((ActPlugIn)actPlugin).ServiceId + Environment.NewLine; } errorMessage += "Error while executing Plugin Service action " + Environment.NewLine; errorMessage += ex.Message; actPlugin.Error = errorMessage; } }
public void MemoPluginSpeedTest() { // Reporter.ToConsole(eLogLevel.INFO, ">>>>> test MemoPluginSpeedTest <<<<<<<<<"); Console.WriteLine(">>>>> test MemoPluginSpeedTest <<<<<<<<<"); lock (mBusinessFlow) { //Arrange ResetBusinessFlow(); Activity activitiy1 = new Activity() { Active = true, TargetApplication = mAppName }; mBusinessFlow.Activities.Add(activitiy1); int count = 100; for (int i = 0; i < count; i++) { ActPlugIn act1 = new ActPlugIn() { PluginId = "Memo", ServiceId = "SpeechService", ActionId = "Say", Active = true }; act1.AddOrUpdateInputParamValue("text", "hello " + i); activitiy1.Acts.Add(act1); } //Act mGingerRunner.RunRunner(); //Assert for (int i = 0; i < count; i++) { Assert.AreEqual(eRunStatus.Passed, activitiy1.Acts[i].Status, "Status of Act #" + i); } Assert.AreEqual(eRunStatus.Passed, activitiy1.Status); Assert.IsTrue(activitiy1.Elapsed < 20000, "a0.Elapsed Time less than 20000ms/20sec"); } }
private void LoadPlugInsActions() { ObservableList <Act> PlugInsActions = new ObservableList <Act>(); ObservableList <PlugInWrapper> PlugInsList = App.LocalRepository.GetSolutionPlugIns(); foreach (PlugInWrapper PW in PlugInsList) { try { if (PW.Actions != null && PW.Actions.Count > 0) { foreach (PlugInAction PIA in PW.Actions) { ActPlugIn act = new ActPlugIn(); act.Description = PIA.Description; act.Active = true; act.PlugInName = PW.Name; act.GetOrCreateInputParam(ActPlugIn.Fields.PluginID, PW.ID); act.GetOrCreateInputParam(ActPlugIn.Fields.PlugInActionID, PIA.ID); act.GetOrCreateInputParam(ActPlugIn.Fields.PluginDescription, PIA.Description); act.GetOrCreateInputParam(ActPlugIn.Fields.PluginUserDescription, PIA.UserDescription); act.GetOrCreateInputParam(ActPlugIn.Fields.PluginUserRecommendedUseCase, PIA.UserRecommendedUseCase); PlugInsActions.Add(act); } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to get the Action of the Plugin '" + PW.Name + "'", ex); } } if (PlugInsActions.Count > 0) { IsPlugInAvailable = true; } PlugInsActionsGrid.DataSourceList = PlugInsActions; }
private void LoadPluginsActions() { ObservableList <PluginPackage> plugins = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <PluginPackage>(); ObservableList <Act> PlugInsActions = new ObservableList <Act>(); foreach (PluginPackage pluginPackage in plugins) { try { List <StandAloneAction> actions = pluginPackage.LoadServicesInfoFromFile(); // GetStandAloneActions(); foreach (StandAloneAction standAloneAction in actions) { ActPlugIn act = new ActPlugIn(); act.Description = standAloneAction.Description; act.GetOrCreateInputParam(nameof(ActPlugIn.PluginId), pluginPackage.PluginID); act.GetOrCreateInputParam(nameof(ActPlugIn.ServiceId), standAloneAction.ServiceID); act.GetOrCreateInputParam(nameof(ActPlugIn.GingerActionId), standAloneAction.ID); foreach (var v in standAloneAction.InputValues) { act.InputValues.Add(new ActInputValue() { Param = v.Param }); } act.Active = true; PlugInsActions.Add(act); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to get the Action of the Plugin '" + pluginPackage.PluginID + "'", ex); } } PlugInsActionsGrid.DataSourceList = PlugInsActions; }
public void PluginSay() { mTestHelper.Log("test PluginSay"); lock (mBusinessFlow) { //Arrange ResetBusinessFlow(); Activity a1 = new Activity() { Active = true, TargetApplication = mAppName }; mBusinessFlow.Activities.Add(a1); ActPlugIn act1 = new ActPlugIn() { PluginId = "Memo", ServiceId = "SpeechService", ActionId = "Say", Active = true, AddNewReturnParams = true }; act1.AddOrUpdateInputParamValue("text", "hello"); a1.Acts.Add(act1); //Act mTestHelper.Log("Before Ginger Runner"); mGingerRunner.RunRunner(); // mGingerRunner.CloseAgents(); mTestHelper.Log("After Ginger Runner"); //Assert Assert.AreEqual(eRunStatus.Passed, act1.Status); Assert.AreEqual(eRunStatus.Passed, a1.Status); Assert.AreEqual(eRunStatus.Passed, mBusinessFlow.RunStatus); string outVal = act1.GetReturnValue("I said").Actual; Assert.AreEqual("hello", outVal, "outVal=hello"); } }
public void SendActionToRemoteGridOnProcess() { // TODO: start the service batch + plugin to connect, for now we use manual bat file for testing // Arrange ActPlugIn actPlugin = new ActPlugIn() { ServiceId = "DummyService", ActionId = "Sum" }; actPlugin.GetOrCreateInputParam("a").Value = "4"; actPlugin.GetOrCreateInputParam("a").ParamType = typeof(int); actPlugin.GetOrCreateInputParam("b").Value = "3"; actPlugin.GetOrCreateInputParam("b").ParamType = typeof(int); //Act GingerNodeProxy.RemoteGridIP = RemoteGridIP; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GingerNodeProxy.RemoteGridPort = 15555; // RemoteGridPort; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GingerNodeInfo gingerNodeInfo = new GingerNodeInfo() { }; GingerNodeProxy gingerNodeProxy = new GingerNodeProxy(gingerNodeInfo, true); NewPayLoad actionPayLoad = ExecuteOnPlugin.CreateActionPayload(actPlugin); for (int i = 0; i < 1000; i++) { NewPayLoad actionResult = gingerNodeProxy.RunAction(actionPayLoad); ExecuteOnPlugin.ParseActionResult(actionResult, actPlugin); } //Assert Assert.AreEqual(RemoteGingerGrid.NodeList.Count, 2); // Assert.AreEqual("A1 Result", actPlugin.ExInfo); }
/// <summary> /// In case object of type Act was passed, adds relevant action being Legacy/PlugIn/One that Adds via Wizard /// </summary> /// <param name="selectedAction"></param> /// <param name="mContext"></param> /// <returns></returns> static Act GenerateSelectedAction(Act selectedAction, Context mContext) { if (selectedAction.AddActionWizardPage != null) { string classname = selectedAction.AddActionWizardPage; Type t = System.Reflection.Assembly.GetExecutingAssembly().GetType(classname); if (t == null) { throw new Exception("Action edit page not found - " + classname); } WizardBase wizard = (WizardBase)Activator.CreateInstance(t, mContext); WizardWindow.ShowWizard(wizard); return(null); } else { Act instance = null; if (selectedAction.IsSharedRepositoryInstance || selectedAction.ContainingFolder.Contains("SharedRepository")) { instance = (Act)selectedAction.CreateInstance(true); } else { instance = (Act)selectedAction.CreateCopy(); } if (selectedAction is IObsoleteAction && (selectedAction as IObsoleteAction).IsObsoleteForPlatform(mContext.Platform)) { eUserMsgSelection userSelection = Reporter.ToUser(eUserMsgKey.WarnAddLegacyActionAndOfferNew, ((IObsoleteAction)selectedAction).TargetActionTypeName()); if (userSelection == eUserMsgSelection.Yes) { instance = ((IObsoleteAction)selectedAction).GetNewAction(); instance.Description = instance.ActionType; } else if (userSelection == eUserMsgSelection.Cancel) { return(null); //do not add any action } } for (int i = 0; i < selectedAction.InputValues.Count; i++) { instance.InputValues[i].ParamTypeEX = selectedAction.InputValues[i].ParamTypeEX; } instance.SolutionFolder = WorkSpace.Instance.Solution.Folder.ToUpper(); if (instance is ActPlugIn) { ActPlugIn p = (ActPlugIn)instance; // TODO: add per group or... !!!!!!!!! //Check if target already exist else add it // TODO: search only in targetplugin type TargetPlugin targetPlugin = (TargetPlugin)(from x in mContext.BusinessFlow.TargetApplications where x.Name == p.ServiceId select x).SingleOrDefault(); if (targetPlugin == null) { // check if interface add it // App.BusinessFlow.TargetApplications.Add(new TargetPlugin() { AppName = p.ServiceId }); mContext.BusinessFlow.TargetApplications.Add(new TargetPlugin() { PluginId = p.PluginId, ServiceId = p.ServiceId }); //Search for default agent which match mContext.Runner.UpdateApplicationAgents(); // TODO: update automate page target/agent // if agent not found auto add or ask user } } return(instance); } }
public void ParallelRunTest() { //Arrange ActPlugIn a1 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn a2 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn a3 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn a4 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn a5 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b1 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b2 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b3 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b4 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b5 = new ActPlugIn() { ActionId = "A1" }; // Act // We run on 2 drivers in parralel Task t1 = Task.Factory.StartNew(() => { GingerNodeInfo GNI1 = GG.NodeList[0]; GingerNodeProxy GNP1 = new GingerNodeProxy(GNI1); GNP1.GingerGrid = GG; GNP1.Reserve(); GNP1.StartDriver(); RunAction(a1, GNP1); RunAction(a2, GNP1); RunAction(a3, GNP1); RunAction(a4, GNP1); RunAction(a5, GNP1); GNP1.CloseDriver(); }); Task t2 = Task.Factory.StartNew(() => { GingerNodeInfo GNI2 = GG.NodeList[1]; GingerNodeProxy GNP2 = new GingerNodeProxy(GNI2); GNP2.GingerGrid = GG; GNP2.Reserve(); GNP2.StartDriver(); RunAction(b1, GNP2); RunAction(b2, GNP2); RunAction(b3, GNP2); RunAction(b4, GNP2); RunAction(b5, GNP2); GNP2.CloseDriver(); }); t1.Wait(); t2.Wait(); // Assert Assert.AreEqual(a1.Error, null); Assert.AreEqual(a1.ExInfo, "A1 Result"); Assert.AreEqual(a2.Error, null); Assert.AreEqual(a2.ExInfo, "A1 Result"); Assert.AreEqual(a3.Error, null); Assert.AreEqual(a3.ExInfo, "A1 Result"); Assert.AreEqual(a4.Error, null); Assert.AreEqual(a4.ExInfo, "A1 Result"); Assert.AreEqual(a5.Error, null); Assert.AreEqual(a5.ExInfo, "A1 Result"); Assert.AreEqual(b1.Error, null); Assert.AreEqual(b1.ExInfo, "A1 Result"); Assert.AreEqual(b2.Error, null); Assert.AreEqual(b2.ExInfo, "A1 Result"); Assert.AreEqual(b3.Error, null); Assert.AreEqual(b3.ExInfo, "A1 Result"); Assert.AreEqual(b4.Error, null); Assert.AreEqual(b4.ExInfo, "A1 Result"); Assert.AreEqual(b5.Error, null); Assert.AreEqual(b5.ExInfo, "A1 Result"); }
private void AddAction() { if (ActionsTabs.SelectedContent != null && ((ucGrid)ActionsTabs.SelectedContent).CurrentItem != null) { Act selectedAction = (Act)(((ucGrid)ActionsTabs.SelectedContent).CurrentItem); //warn regarding Leagacy Actions if (LegacyActionsTab.IsSelected) { if (selectedAction is IObsoleteAction) { eUserMsgSelection userSelection = Reporter.ToUser(eUserMsgKey.WarnAddLegacyActionAndOfferNew, ((IObsoleteAction)selectedAction).TargetActionTypeName()); if (userSelection == eUserMsgSelection.Yes) { selectedAction = ((IObsoleteAction)selectedAction).GetNewAction(); } else if (userSelection == eUserMsgSelection.Cancel) { return;//do not add any action } } else { if (Reporter.ToUser(eUserMsgKey.WarnAddLegacyAction) == eUserMsgSelection.No) { return;//do not add any action } } } if (selectedAction.AddActionWizardPage != null) { _pageGenericWin.Close(); string classname = selectedAction.AddActionWizardPage; Type t = Assembly.GetExecutingAssembly().GetType(classname); if (t == null) { throw new Exception("Action edit page not found - " + classname); } WizardBase wizard = (GingerWPF.WizardLib.WizardBase)Activator.CreateInstance(t, mContext); WizardWindow.ShowWizard(wizard); } else { Act newAction = null; newAction = (Act)selectedAction.CreateCopy(); newAction.Context = mContext; // copy param ex info for (int i = 0; i < selectedAction.InputValues.Count; i++) { newAction.InputValues[i].ParamTypeEX = selectedAction.InputValues[i].ParamTypeEX; } newAction.SolutionFolder = WorkSpace.Instance.Solution.Folder.ToUpper(); //adding the new act after the selected action in the grid //TODO: Add should be after the last, Insert should be in the middle... int selectedActIndex = -1; if (mActionsList.CurrentItem != null) { selectedActIndex = mActionsList.IndexOf((IAct)mActionsList.CurrentItem); } mActionsList.Add(newAction); if (selectedActIndex >= 0) { mActionsList.Move(mActionsList.Count - 1, selectedActIndex + 1); } _pageGenericWin.Close(); //allowing to edit the action ActionEditPage actedit = new ActionEditPage(newAction); actedit.ShowAsWindow(); if (newAction is ActPlugIn) { ActPlugIn p = (ActPlugIn)newAction; // TODO: add per group or... !!!!!!!!! //Check if target already exist else add it // TODO: search only in targetplugin type TargetPlugin targetPlugin = (TargetPlugin)(from x in mBusinessFlow.TargetApplications where x.Name == p.ServiceId select x).SingleOrDefault(); if (targetPlugin == null) { // check if interface add it // App.BusinessFlow.TargetApplications.Add(new TargetPlugin() { AppName = p.ServiceId }); mBusinessFlow.TargetApplications.Add(new TargetPlugin() { PluginId = p.PluginId, ServiceId = p.ServiceId }); //Search for default agent which match mContext.Runner.UpdateApplicationAgents(); // TODO: update automate page target/agent // if agent not found auto add or ask user } } } } else { Reporter.ToUser(eUserMsgKey.NoItemWasSelected); return; } }
// Move code to the ActPlugIn and make it impl IACtPlug... public static NewPayLoad CreateActionPayload(ActPlugIn ActPlugIn) { // Here we decompose the GA and create Payload to transfer it to the agent NewPayLoad PL = new NewPayLoad("RunAction"); PL.AddValue(ActPlugIn.ActionId); //Add Params List <NewPayLoad> Params = new List <NewPayLoad>(); // if this is the first time the action run it will not have param type // so read it from plugin action info if (ActPlugIn.InputValues.Count > 0) { if (ActPlugIn.InputValues[0].ParamType == null) { UpdateParamsType(ActPlugIn); } } foreach (ActInputValue AP in ActPlugIn.InputValues) { // Why we need GA? if (AP.Param == "GA") { continue; } // TODO: use const NewPayLoad p = new NewPayLoad("P"); // To save network traffic we send just one letter p.AddValue(AP.Param); if (AP.ParamType == typeof(string)) { p.AddValue(AP.ValueForDriver.ToString()); } else if (AP.ParamType == typeof(int)) { p.AddValue(AP.IntValue); } else if (AP.ParamType == typeof(bool)) { p.AddValue(AP.BoolValue); } else if (AP.ParamType == typeof(DynamicListWrapper)) { p.AddValue(AP.ValueForDriver.ToString()); } else if (AP.ParamType == typeof(EnumParamWrapper)) { p.AddValue(AP.ValueForDriver.ToString()); } else { throw new Exception("Unknown param type to pack: " + AP.ParamType.FullName); } p.ClosePackage(); Params.Add(p); } PL.AddListPayLoad(Params); PL.ClosePackage(); return(PL); }
private void AddAction() { if (ActionsTabs.SelectedContent != null && ((ucGrid)ActionsTabs.SelectedContent).CurrentItem != null) { if (((Act)(((ucGrid)ActionsTabs.SelectedContent).CurrentItem)).AddActionWizardPage != null) { _pageGenericWin.Close(); string classname = ((Act)(((ucGrid)ActionsTabs.SelectedContent).CurrentItem)).AddActionWizardPage; Type t = Assembly.GetExecutingAssembly().GetType(classname); if (t == null) { throw new Exception("Action edit page not found - " + classname); } WizardBase wizard = (GingerWPF.WizardLib.WizardBase)Activator.CreateInstance(t); WizardWindow.ShowWizard(wizard); } else { Act aNew = null; if (ActionsTabs.SelectedContent != null && ((ucGrid)ActionsTabs.SelectedContent).CurrentItem != null) { Act selectedAction = (Act)(((ucGrid)ActionsTabs.SelectedContent).CurrentItem); aNew = (Act)selectedAction.CreateCopy(); // copy param ex info for (int i = 0; i < selectedAction.InputValues.Count; i++) { aNew.InputValues[i].ParamTypeEX = selectedAction.InputValues[i].ParamTypeEX; } } else { Reporter.ToUser(eUserMsgKeys.NoItemWasSelected); return; } aNew.SolutionFolder = App.UserProfile.Solution.Folder.ToUpper(); //adding the new act after the selected action in the grid //TODO: Add should be after the last, Insert should be in the middle... int selectedActIndex = -1; if (mActionsList.CurrentItem != null) { selectedActIndex = mActionsList.IndexOf((Act)mActionsList.CurrentItem); } mActionsList.Add(aNew); if (selectedActIndex >= 0) { mActionsList.Move(mActionsList.Count - 1, selectedActIndex + 1); } _pageGenericWin.Close(); //allowing to edit the action ActionEditPage actedit = new ActionEditPage(aNew); actedit.ShowAsWindow(); if (aNew is ActPlugIn) { ActPlugIn p = (ActPlugIn)aNew; // TODO: add per group or... !!!!!!!!! //Check if target already exist else add it // TODO: search only in targetplugin type TargetPlugin targetPlugin = (TargetPlugin)(from x in App.BusinessFlow.TargetApplications where x.Name == p.ServiceId select x).SingleOrDefault(); if (targetPlugin == null) { // check if interface add it // App.BusinessFlow.TargetApplications.Add(new TargetPlugin() { AppName = p.ServiceId }); App.BusinessFlow.TargetApplications.Add(new TargetPlugin() { PluginId = p.PluginId, ServiceId = p.ServiceId }); //Search for default agent which match App.AutomateTabGingerRunner.UpdateApplicationAgents(); // TODO: update automate page target/agent // if agent not found auto add or ask user } } } } }