private void grdActions_ItemDropped(object sender, EventArgs e) { Act a = (Act)((DragInfo)sender).Data; Act instance = (Act)a.CreateInstance(true); mCurrentActivity.Acts.Add(instance); int selectedActIndex = -1; ObservableList <IAct> actsList = mBusinessFlow.CurrentActivity.Acts; if (actsList.CurrentItem != null) { selectedActIndex = actsList.IndexOf((Act)actsList.CurrentItem); } if (selectedActIndex >= 0) { actsList.Move(actsList.Count - 1, selectedActIndex + 1); } }
/// <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); } }