コード例 #1
0
        ControllerConfiguration IPlugIn.Create(ControllerConfiguration config)
        {
            if (config.Navigator.CanEdit)
            {
                return(config);
            }
            XmlDocument document = new XmlDocument();

            document.LoadXml(config.Navigator.OuterXml);
            return(new ControllerConfiguration(document.CreateNavigator()));
        }
コード例 #2
0
 public ViewPage ToResult(ControllerConfiguration configuration, XPathNavigator mainView)
 {
     if (!(_requiresMetaData))
     {
         Fields.Clear();
         Expressions = null;
     }
     else
     {
         XPathNodeIterator viewIterator = configuration.Select("/c:dataController/c:views/c:view[not(@virtualViewId!=\'\')]");
         while (viewIterator.MoveNext())
         {
             Views.Add(new View(viewIterator.Current, mainView, configuration.Resolver));
         }
         XPathNodeIterator actionGroupIterator = configuration.Select("/c:dataController/c:actions//c:actionGroup");
         while (actionGroupIterator.MoveNext())
         {
             ActionGroups.Add(new ActionGroup(actionGroupIterator.Current, configuration.Resolver));
         }
         foreach (DataField field in Fields)
         {
             PopulateStaticItems(field, null);
         }
     }
     if (_originalFilter != null)
     {
         _filter = _originalFilter;
     }
     if (new ControllerUtilities().SupportsLastEnteredValues(this.Controller))
     {
         if (RequiresMetaData && ((HttpContext.Current != null) && (HttpContext.Current.Session != null)))
         {
             LEVs = ((FieldValue[])(HttpContext.Current.Session[String.Format("{0}$LEVs", _controller)]));
         }
     }
     return(this);
 }
コード例 #3
0
        public virtual ControllerConfiguration EnsureVitalElements()
        {
            // verify that the data controller has views and actions
            XPathNavigator root = SelectSingleNode("/c:dataController[c:views/c:view and c:actions/c:actionGroup]");

            if (root != null)
            {
                return(this);
            }
            // add missing configuration elements
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(_navigator.OuterXml);
            ControllerConfiguration config     = new ControllerConfiguration(doc.CreateNavigator());
            XPathNavigator          fieldsNode = config.SelectSingleNode("/c:dataController/c:fields[not(c:field[@isPrimaryKey=\'true\'])]");

            if (fieldsNode != null)
            {
                fieldsNode.AppendChild("<field name=\"PrimaryKey\" type=\"Int32\" isPrimaryKey=\"true\" readOnly=\"true\"/>");
            }
            root = config.SelectSingleNode("/c:dataController");
            EnsureChildNode(root, "views");
            XPathNavigator viewsNode = config.SelectSingleNode("/c:dataController/c:views[not(c:view)]");

            if (viewsNode != null)
            {
                StringBuilder sb = new StringBuilder("<view id=\"view1\" type=\"Form\" label=\"Form\"><categories><category id=\"c1\" newColumn" +
                                                     "=\"true\"><dataFields>");
                XPathNodeIterator fieldIterator = config.Select("/c:dataController/c:fields/c:field");
                while (fieldIterator.MoveNext())
                {
                    string fieldName = fieldIterator.Current.GetAttribute("name", String.Empty);
                    bool   hidden    = (fieldName == "PrimaryKey");
                    string length    = fieldIterator.Current.GetAttribute("length", String.Empty);
                    if (String.IsNullOrEmpty(length) && (((bool)(fieldIterator.Current.Evaluate("not(c:items/@style!=\'\')", _resolver))) == true))
                    {
                        if (fieldIterator.Current.GetAttribute("type", String.Empty) == "String")
                        {
                            length = "50";
                        }
                        else
                        {
                            length = "20";
                        }
                    }
                    sb.AppendFormat("<dataField fieldName=\"{0}\" hidden=\"{1}\"", fieldName, hidden.ToString().ToLower());
                    if (!(String.IsNullOrEmpty(length)))
                    {
                        sb.AppendFormat(" columns=\"{0}\"", length);
                    }
                    sb.Append(" />");
                }
                sb.Append("</dataFields></category></categories></view>");
                viewsNode.AppendChild(sb.ToString());
            }
            EnsureChildNode(root, "actions");
            XPathNavigator actionsNode = config.SelectSingleNode("/c:dataController/c:actions[not(c:actionGroup)]");

            if (actionsNode != null)
            {
                actionsNode.AppendChild(@"<actionGroup id=""ag1"" scope=""Form"">
<action id=""a1"" commandName=""Confirm"" causesValidation=""true"" whenLastCommandName=""New"" />
<action id=""a2"" commandName=""Cancel"" whenLastCommandName=""New"" />
<action id=""a3"" commandName=""Confirm"" causesValidation=""true"" whenLastCommandName=""Edit"" />
<action id=""a4"" commandName=""Cancel"" whenLastCommandName=""Edit"" />
<action id=""a5"" commandName=""Edit"" causesValidation=""true"" />
</actionGroup>");
            }
            XPathNavigator plugIn = config.SelectSingleNode("/c:dataController/@plugIn");

            if (plugIn != null)
            {
                plugIn.DeleteSelf();
                config._plugIn = null;
            }
            return(config);
        }