public SelectUXActionType() { InitializeComponent(); SelectedMappableUXObject = null; SelectedAction = null; NoDrilldowns = false; dialogService = MetaManagerServices.GetDialogService(); appService = MetaManagerServices.GetApplicationService(); modelService = MetaManagerServices.GetModelService(); actionService = MetaManagerServices.GetUXActionService(); }
private void lvSelectObject_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { btnOK.Enabled = false; if (lvSelectObject.SelectedItems.Count == 1) { if (lvSelectObject.SelectedItems[0].Tag is UXAction) { SelectedAction = lvSelectObject.SelectedItems[0].Tag as UXAction; SelectedMappableUXObject = null; SelectedActionType = SelectedUXActionType.Unmapped; } else if (lvSelectObject.SelectedItems[0].Tag is ServiceMethod) { SelectedAction = null; SelectedMappableUXObject = lvSelectObject.SelectedItems[0].Tag as ServiceMethod; SelectedActionType = SelectedUXActionType.ServiceMethod; } else if (lvSelectObject.SelectedItems[0].Tag is Cdc.MetaManager.DataAccess.Domain.Workflow) { SelectedAction = null; SelectedMappableUXObject = lvSelectObject.SelectedItems[0].Tag as Cdc.MetaManager.DataAccess.Domain.Workflow; SelectedActionType = SelectedUXActionType.Workflow; } else if (lvSelectObject.SelectedItems[0].Tag is Dialog) { SelectedAction = null; SelectedMappableUXObject = lvSelectObject.SelectedItems[0].Tag as Dialog; if (rbtnDialog.Checked) { SelectedActionType = SelectedUXActionType.Dialog; } else if (rbtnDrilldown.Checked) { SelectedActionType = SelectedUXActionType.DrillDown; } else if (rbtnJumpTo.Checked) { SelectedActionType = SelectedUXActionType.JumpTo; } } else { return; } btnOK.Enabled = true; } }
public UXAction CreateUXActionForMappableObject(IMappableUXObject uxObject, Application application, string name, string caption) { uxObject = (IMappableUXObject)ModelService.GetDomainObject(uxObject.Id, ModelService.GetDomainObjectType(uxObject)); application = ModelService.GetDomainObject <Application>(application.Id); UXAction uxAction = CreateUXAction(uxObject, application, name, caption); if (uxAction != null) { CreateUXActionMap(uxAction, uxObject); ModelService.MergeSaveDomainObject(uxAction); } return(uxAction); }
public IList <UXAction> GetUXActionForMappableObject(IMappableUXObject uxObject) { IList <UXAction> actionList = null; if (uxObject is Dialog) { actionList = UXActionDao.FindAllByDialogId(uxObject.Id); } else if (uxObject is CustomDialog) { actionList = UXActionDao.FindAllByCustomDialogId(uxObject.Id); } else if (uxObject is Workflow) { actionList = UXActionDao.FindAllByWorkflowId(uxObject.Id); } else if (uxObject is ServiceMethod) { actionList = UXActionDao.FindAllByServiceMethodId(uxObject.Id); } if ((actionList != null) && (actionList.Count > 0)) { foreach (UXAction action in actionList) { if (action.MappedToObject is Dialog) { NHibernateUtil.Initialize(action.Dialog); } if (action.MappedToObject is CustomDialog) { NHibernateUtil.Initialize(action.CustomDialog); } if (action.MappedToObject is ServiceMethod) { NHibernateUtil.Initialize(action.ServiceMethod); } } return(actionList); } return(null); }
private void CreateUXActionMap(UXAction action, IMappableUXObject uxObject) { action.RequestMap = new PropertyMap(); IDomainObject targetObject = uxObject; if (uxObject is Dialog) { Dialog currentDialog = ModelService.GetDomainObject <Dialog>(uxObject.Id); if (currentDialog != null) { // Check if the interfaceview is defined. if (currentDialog.InterfaceView == null) { throw new Exception(string.Format("The dialog ({0}) {1} has no interfaceview defined!" , currentDialog.Id.ToString() , currentDialog.Name)); } // Check if the interfaceviews servicemethod is defined. if (currentDialog.InterfaceView.ServiceMethod == null) { throw new Exception(string.Format("The dialog ({0}) {1} has an interfaceview but there is no defined ServiceMethod for the view ({2}) {3}!" , currentDialog.Id.ToString() , currentDialog.Name , currentDialog.InterfaceView.Id.ToString() , currentDialog.InterfaceView.Name)); } } else { throw new Exception(string.Format("The dialog that had the id {0} doesn't exist!" , uxObject.Id)); } targetObject = ((Dialog)uxObject).InterfaceView; } ModelService.CreateAndSynchronizePropertyMaps(targetObject, action); }
private UXAction CreateUXAction(IMappableUXObject uxObject, Application application, string name, string caption) { UXAction uxAction = new UXAction(); if (uxObject is Dialog) { Dialog d = ModelService.GetDomainObject <Dialog>(uxObject.Id); if (d != null) { if (string.IsNullOrEmpty(caption)) { uxAction.Caption = "Show " + d.Title; } else { uxAction.Caption = caption; } if (string.IsNullOrEmpty(name)) { uxAction.Name = "Show" + d.Name; } else { uxAction.Name = name; } } uxAction.MappedToObject = d; uxAction.Application = application; } else if (uxObject is ServiceMethod) { ServiceMethod s = ModelService.GetDomainObject <ServiceMethod>(uxObject.Id); if (s != null) { if (string.IsNullOrEmpty(caption)) { uxAction.Caption = s.Name; } else { uxAction.Caption = caption; } if (string.IsNullOrEmpty(name)) { uxAction.Name = "Run" + s.Name; } else { uxAction.Name = name; } } uxAction.MappedToObject = s; uxAction.Application = application; } else if (uxObject is Workflow) { Workflow workflow = ModelService.GetDomainObject <Workflow>(uxObject.Id); if (string.IsNullOrEmpty(caption)) { uxAction.Caption = workflow.Name; } else { uxAction.Caption = caption; } if (string.IsNullOrEmpty(name)) { uxAction.Name = string.Format("Run{0}Workflow", workflow.Name); } else { uxAction.Name = name; } uxAction.MappedToObject = workflow; uxAction.Application = application; } else if (uxObject is CustomDialog) { CustomDialog cd = ModelService.GetDomainObject <CustomDialog>(uxObject.Id); if (string.IsNullOrEmpty(caption)) { uxAction.Caption = cd.Name; } else { uxAction.Caption = caption; } if (string.IsNullOrEmpty(name)) { uxAction.Name = "ShowCustom" + cd.Name; } else { uxAction.Name = name; } uxAction.MappedToObject = cd; uxAction.Application = application; } else { return(null); } // Get all actions to be able to change the name automatically if needed. IList <UXAction> allActions = ModelService.GetAllDomainObjectsByApplicationId <UXAction>(application.Id); if (allActions != null) { int i = 1; string testName = uxAction.Name.ToUpper(); // Create a new unique name if it exists while (allActions.Count(action => action.Name.ToUpper() == testName) > 0) { i++; testName = uxAction.Name.ToUpper() + i.ToString(); } // Set the new name if (i > 1) { uxAction.Name = uxAction.Name + i.ToString(); } } return(uxAction); }
private void btnOK_Click(object sender, EventArgs e) { try { if (SelectedMappableUXObject != null) { SelectedAction = null; // Check if a servicemethod is selected. Then we need to do additional // select from database to retrieve correct data. if (SelectedMappableUXObject is ServiceMethod) { ServiceMethod readServiceMethod = appService.GetServiceMethodWithRequestMap((SelectedMappableUXObject as ServiceMethod).Id); SelectedMappableUXObject = readServiceMethod; } // Find all actions connected to this Dialog/CustomDialog/ServiceMethod IList <UXAction> FoundActions = null; FoundActions = actionService.GetUXActionForMappableObject(SelectedMappableUXObject); // If any actions is found for this object then show another dialog where you can select // to reuse the actions or create new ones. if (FoundActions != null && FoundActions.Count > 0) { // In all other cases show the dialog to select or create a new action using (SelectCreateUXAction selectCreateAction = new SelectCreateUXAction()) { selectCreateAction.FrontendApplication = FrontendApplication; selectCreateAction.BackendApplication = BackendApplication; selectCreateAction.FoundActions = FoundActions; selectCreateAction.MappableUXObject = SelectedMappableUXObject; if (selectCreateAction.ShowDialog() == DialogResult.OK) { SelectedAction = selectCreateAction.SelectedAction; } } } else { if (SelectedMappableUXObject != null) { FrontendApplication = modelService.GetInitializedDomainObject <DataAccess.Domain.Application>(FrontendApplication.Id); if (rbtnJumpTo.Checked) { Dialog d = SelectedMappableUXObject as Dialog; // Create the action and interface SelectedAction = MetaManagerServices.Helpers.UXActionHelper.CreateUXActionForMappableObject(SelectedMappableUXObject, FrontendApplication, string.Format("JumpTo{0}", d.Name), string.Format("Jump To {0}", d.Title)); } else { // Create the action and interface SelectedAction = MetaManagerServices.Helpers.UXActionHelper.CreateUXActionForMappableObject(SelectedMappableUXObject, FrontendApplication, null, null); } // Leave the action as checked out CheckOutInObject(SelectedAction, true); } } } } catch (Exception ex) { SelectedAction = null; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (SelectedAction != null) { DialogResult = DialogResult.OK; Close(); } }