Beispiel #1
0
        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
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <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);
            }
        }
Beispiel #3
0
        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;
            }
        }