コード例 #1
0
        public static Type CreateActionContext(UXAction action, Cdc.MetaManager.DataAccess.Domain.Module module)
        {
            Type userSessionType = LoadUserSessionType(module.Application);

            ActionParametersTemplate template = new ActionParametersTemplate();

            template.SetProperty("action", action);
            template.SetProperty("module", module);

            string source = template.RenderToString();

            CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary <string, string>()
            {
                { "CompilerVersion", "v3.5" }
            });

            CompilerParameters options = new CompilerParameters();

            options.GenerateInMemory = true;
            options.ReferencedAssemblies.Add("System.dll");
            options.ReferencedAssemblies.Add("System.Core.dll");

            CompilerResults results = provider.CompileAssemblyFromSource(options, source);

            Type resultType = results.CompiledAssembly.GetTypes()[0];

            Type ruleContextType = typeof(ActionRuleContext <,>);

            return(ruleContextType.MakeGenericType(resultType, userSessionType));
        }
コード例 #2
0
        public UXAction GetUXActionByIdWithMap(Guid uxActionId)
        {
            UXAction action = UXActionDao.FindById(uxActionId);

            if (action.ServiceMethod != null)
            {
                NHibernateUtil.Initialize(action.ServiceMethod.MappedToAction);

                if (action.ServiceMethod.MappedToAction != null)
                {
                    NHibernateUtil.Initialize(action.ServiceMethod.MappedToAction.MappedToObject);
                }
            }

            if (action.RequestMap != null)
            {
                MetaManagerUtil.InitializePropertyMap(action.RequestMap);
            }

            if ((action.Dialog != null) && (action.Dialog.InterfaceView != null))
            {
                if (action.Dialog.InterfaceView.ServiceMethod != null)
                {
                    NHibernateUtil.Initialize(action.Dialog.InterfaceView.ServiceMethod);
                    NHibernateUtil.Initialize(action.Dialog.InterfaceView.ServiceMethod.MappedToAction);
                }
            }

            return(action);
        }
コード例 #3
0
 public UXAction Save(UXAction action)
 {
     if (action.Id == Guid.Empty)
     {
         action.Id = Guid.NewGuid();
     }
     HibernateTemplate.Save(action);
     return(action);
 }
コード例 #4
0
        public EditUXAction()
        {
            InitializeComponent();

            UXAction = null;
            IsNew    = false;

            uxActionService = MetaManagerServices.GetUXActionService();
            modelService    = MetaManagerServices.GetModelService();
        }
コード例 #5
0
        private static MenuItemModel GetUXActionsFromNode(XmlNode aViewActionNode, ApplicationXMLModel anApplicationModel)
        {
            string        errorMessageString = "{0} was null in function ActionParser.GetUXActionsFromNode";
            MenuItemModel menuItem           = new MenuItemModel();

            UXAction uXAction = new UXAction();

            XmlNode actionIdentityNode = aViewActionNode.SelectSingleNode("Action/UXAction/Id");

            ThrowIfNull(actionIdentityNode, string.Format(errorMessageString, "actionIdentityNode"));
            uXAction.Identity = actionIdentityNode.InnerText;

            XmlNode uXActionNode = anApplicationModel.UXActionXMLDocuments.Documents[uXAction.Identity];

            ThrowIfNull(uXActionNode, string.Format(errorMessageString, "uXActionNode"));

            XmlNode uXActionCaptionNode = uXActionNode.SelectSingleNode("/UXAction/Caption");

            ThrowIfNull(uXActionCaptionNode, string.Format(errorMessageString, "uXActionCaptionNode"));

            menuItem.Caption = uXActionCaptionNode.InnerText;

            XmlNode viewActionTypeNode = aViewActionNode.SelectSingleNode("Type");

            if (viewActionTypeNode != null)
            {
                if (viewActionTypeNode.InnerText == "JumpTo")
                {
                    AddShowActionToCorrectStartAction(aViewActionNode, anApplicationModel);
                    return(null);
                }
                else if (viewActionTypeNode.InnerText == "Drilldown")
                {
                    menuItem.Caption += " (Drilldown)";
                    AddDrilldownsActionChildren(uXActionNode, menuItem, anApplicationModel);
                }
            }

            XmlNode uxActionDialogNode = aViewActionNode.SelectSingleNode("/UXAction/Dialog/Dialog/Id");

            if (uxActionDialogNode != null)
            {
                menuItem.Identity = uxActionDialogNode.InnerText;
            }

            menuItem.Actions = new List <UXAction>();
            menuItem.Actions.Add(uXAction);

            return(menuItem);
        }
コード例 #6
0
        private static MenuItemModel LoadMenu(XmlNode aNode, int depth = 0)
        {
            try
            {
                MenuItemModel menu = new MenuItemModel();
                menu.Identity = aNode.SelectSingleNode("Id").InnerText;
                menu.Caption  = aNode.SelectSingleNode("Caption").InnerText;
                if (menu.Actions == null)
                {
                    menu.Actions = new List <UXAction>();
                }
                XmlNode actionsNode = aNode.SelectSingleNode("Actions");
                if (actionsNode.ChildNodes != null)
                {
                    foreach (XmlNode actionNode in actionsNode.ChildNodes)
                    {
                        XmlNode identityNode = actionNode.SelectSingleNode("Id");
                        if (identityNode == null)
                        {
                            continue;
                        }
                        UXAction newAction = new UXAction();
                        newAction.Identity = identityNode.InnerText;
                        menu.Actions.Add(newAction);
                    }
                }

                XmlNode children = aNode.SelectSingleNode("Children");
                if (children != null)
                {
                    foreach (XmlNode child in children)
                    {
                        //Recursive call if child has additional children
                        MenuItemModel childMenuItem = LoadMenu(child, ++depth);
                        if (childMenuItem != null && menu.Children == null)
                        {
                            menu.Children = new List <MenuItemModel>();
                        }
                        menu.Children.Add(childMenuItem);
                    }
                }
                return(menu);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public UXAction SaveOrUpdate(UXAction action)
        {
            UXAction saveAction = null;

            if (action != null && action.Id != Guid.Empty && !action.IsTransient)
            {
                saveAction = Session.Merge(action) as UXAction;
            }
            else
            {
                saveAction = action;
            }

            HibernateTemplate.SaveOrUpdate(saveAction);

            return(saveAction);
        }
コード例 #9
0
        public UXAction SaveOrUpdateMerge(UXAction action)
        {
            UXAction saveAction = null;

            if (action != null && action.Id != Guid.Empty)
            {
                saveAction = Session.Merge(action) as UXAction;
            }
            else
            {
                saveAction = action;
            }

            object mergedObj = Session.Merge(action);

            HibernateTemplate.SaveOrUpdate(mergedObj);

            return((UXAction)mergedObj);
        }
コード例 #10
0
        public ViewAction AddToView(UXAction action, ViewNode viewNode, ViewActionType viewActionType, MappedProperty mappedProperty)
        {
            ViewNode readViewNode = ViewNodeDao.FindById(viewNode.Id);
            UXAction readAction   = UXActionDao.FindById(action.Id);

            NHibernateUtil.Initialize(readAction);
            NHibernateUtil.Initialize(readAction.Dialog);
            NHibernateUtil.Initialize(readAction.ServiceMethod);
            NHibernateUtil.Initialize(readAction.CustomDialog);
            NHibernateUtil.Initialize(readViewNode.View);

            IList <ViewAction> viewActions = ViewActionDao.FindAllByViewNodeId(viewNode.Id);

            int nextSequence = 1;

            if (viewActions != null && viewActions.Count > 0)
            {
                // Get the maxsequence
                nextSequence = viewActions.Max(vAction => vAction.Sequence);

                // Add one so we get a unique sequence.
                nextSequence++;
            }

            // Create the new Viewaction
            ViewAction viewAction = new ViewAction();

            viewAction.ViewNode = readViewNode;
            viewAction.Action   = readAction;
            viewAction.Sequence = nextSequence;
            viewAction.Type     = viewActionType;
            viewAction.DrilldownFieldMappedProperty = ((viewActionType == ViewActionType.Drilldown) || (viewActionType == ViewActionType.JumpTo)) ? mappedProperty : null;

            viewAction = ViewActionDao.Save(viewAction);

            NHibernateUtil.Initialize(viewAction.ViewNode);
            NHibernateUtil.Initialize(viewAction.ViewNode.ViewActions);
            NHibernateUtil.Initialize(viewAction.Action);
            NHibernateUtil.Initialize(viewAction.DrilldownFieldMappedProperty);

            return(viewAction);
        }
コード例 #11
0
        private void EditUXAction_Load(object sender, EventArgs e)
        {
            // Get the action if there is an Id
            if (ContaindDomainObjectIdAndType.Key != Guid.Empty)
            {
                //UXAction = modelService.GetInitializedDomainObject<UXAction>(ContaindDomainObjectIdAndType.Key);
                UXAction = modelService.GetDynamicInitializedDomainObject <UXAction>(ContaindDomainObjectIdAndType.Key, new List <string>()
                {
                    "RequestMap", "RequestMap.MappedProperties", "RuleSet"
                });
                IsNew = false;
            }
            else
            {
                UXAction             = new UXAction();
                UXAction.Application = FrontendApplication;
                IsNew = true;
            }

            this.IsEditable = UXAction.IsLocked && UXAction.LockedBy == Environment.UserName;

            // Check if new action or editing old
            if (IsNew)
            {
                this.Text = "New Action";
            }
            else
            {
                this.Text = "Edit Action";
            }

            if (!this.IsEditable)
            {
                TypeDescriptor.AddAttributes(UXAction, new Attribute[] { new ReadOnlyAttribute(true) });
            }

            propertyGrid.SelectedObject = UXAction;

            EnableDisableButtons();

            Cursor.Current = Cursors.Default;
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        private void editRuleBtn_Click(object sender, EventArgs e)
        {
            Module temp = new Module();

            temp.Application = FrontendApplication;
            temp.Name        = "temp";

            UXAction action = uxActionService.GetUXActionByIdWithMap(UXAction.Id);

            Type context = RuleContextFactory.CreateActionContext(action, temp);

            using (RuleSetDialog ruleSetDialog = new RuleSetDialog(context, null, UXAction.RuleSet))
            {
                ruleSetDialog.Text += string.Format(" [{0}]", UXAction.Name);

                if (ruleSetDialog.ShowDialog() == DialogResult.OK)
                {
                    if (this.IsEditable)
                    {
                        if (ruleSetDialog.RuleSet.Rules.Count == 0)
                        {
                            UXAction.RuleSet = null;
                        }
                        else
                        {
                            UXAction.RuleSet = ruleSetDialog.RuleSet;
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("Your changes will not be saved since the action is not locked for editing. Check out the action and try again");
                        return;
                    }
                }
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
 public void Delete(UXAction action)
 {
     HibernateTemplate.Delete(action);
 }
コード例 #16
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // Check Action Name
            if (UXAction.MappedToObject != null)
            {
                // Check if mapped to Dialog
                if (UXAction.MappedToObject.ActionType == UXActionType.Dialog)
                {
                    if (!NamingGuidance.CheckUXActionDialogName(UXAction.Name, true))
                    {
                        return;
                    }

                    if (!string.IsNullOrEmpty(UXAction.AlarmId) && (UXAction.Dialog.InterfaceView.ServiceMethod != null))
                    {
                        MessageBox.Show("AlarmId can only be used if the target Dialog has a Service Method defined.", "Action", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                // Check if mapped to Service
                else if (UXAction.MappedToObject.ActionType == UXActionType.ServiceMethod)
                {
                    if (!NamingGuidance.CheckUXActionServiceName(UXAction.Name, true))
                    {
                        return;
                    }
                }
            }
            else
            {
                // Check if not mapped
                if (!NamingGuidance.CheckName(UXAction.Name, "UXAction Name", true))
                {
                    return;
                }

                if (!string.IsNullOrEmpty(UXAction.AlarmId))
                {
                    MessageBox.Show("AlarmId can only be used when the Action points to a Dialog or Service Method.", "Action", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            if (!NamingGuidance.CheckCaption(UXAction.Caption, "UXAction Caption", true))
            {
                return;
            }

            if (UXAction.MappedToObject == null)
            {
                if (MessageBox.Show("You haven't mapped the Action to any object. Do you want to save the Action anyway?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.No)
                {
                    return;
                }
            }

            if (UXAction.OriginalDialog == null)
            {
                UXAction.OriginalDialog = string.Empty;
            }

            Cursor = Cursors.WaitCursor;

            // Save
            try
            {
                if (addedMappedPropertiesInRequestMap.Count > 0 || deletedMappedPropertiesInRequestMap.Count > 0)
                {
                    modelService.StartSynchronizePropertyMapsInObjects(UXAction, new List <IDomainObject>(), deletedMappedPropertiesInRequestMap.Cast <IDomainObject>().ToList());
                }

                UXAction = (UXAction)modelService.SaveDomainObject(UXAction);

                ContaindDomainObjectIdAndType = new KeyValuePair <Guid, Type>(UXAction.Id, typeof(UXAction));

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            Cursor = Cursors.Default;
        }
コード例 #17
0
        /// <summary>
        /// Method that searches for children of a MenuItem
        /// and connects that child to the parent MenuItem
        /// </summary>
        /// <param name="aNode">A menuItem</param>
        /// <param name="depth">0 = children, 1 = grandchildren, etc</param>
        /// <returns>A child MenuItem</returns>
        private static MenuItemModel LoadMenu(XmlNode aNode, ApplicationXMLModel anApplication, int depth = 0)
        {
            try
            {
                MenuItemModel menu = new MenuItemModel();
                menu.Identity = aNode.SelectSingleNode("Id").InnerText;
                menu.Caption = aNode.SelectSingleNode("Caption").InnerText;
                if (IdentityExceptionHelper.Contains(menu.Caption)) return null;

                XmlNode sequenceNode = aNode.SelectSingleNode("Sequence");
                if (sequenceNode != null) menu.Sequence = int.Parse(sequenceNode.InnerText);

                UXAction action = new UXAction();
                XmlNode uXActionIdentityNode = aNode.SelectSingleNode("Action/UXAction/Id");
                if (uXActionIdentityNode != null)
                {
                    action.Identity = uXActionIdentityNode.InnerText;
                    //load ux-file
                    XmlDocument uXDoc = anApplication.UXActionXMLDocuments.Documents[action.Identity];
                    XmlNode uXDialogNode = uXDoc.SelectSingleNode("/UXAction/Dialog/Dialog/Id");
                    //insert check if has dialog and if dialog is a Start-operation
                    if (uXDialogNode != null)
                    {
                        XmlDocument dialogDoc = anApplication.DialogXmlDocuments.Documents[uXDialogNode.InnerText];
                        XmlNode dialogIdNode = dialogDoc.SelectSingleNode("/Dialog/Id");
                        if (dialogIdNode != null)
                        {
                                //if it is a start-action, swap action.Identity for the dialog identity
                                action.Parent = dialogIdNode.InnerText;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(action.Identity))
                {
                    if (menu.Actions == null)
                    {
                        menu.Actions = new List<UXAction>();
                    }
                    menu.Actions.Add(action);
                }

                XmlNode children = aNode.SelectSingleNode("Children");
                if (children != null)
                {
                    foreach (XmlNode child in children)
                    {
                        //Recursive call to this method in case there are grandchildren and beyond.
                        MenuItemModel childMenuItem = LoadMenu(child, anApplication, ++depth);
                        if (childMenuItem != null && menu.Children == null)
                        {
                            menu.Children = new List<MenuItemModel>();
                        }
                        if (childMenuItem != null)
                        {
                            menu.Children.Add(childMenuItem);
                        }
                    }
                }
                return menu;
            }
            catch (Exception)
            {
                return null;
            }
        }