コード例 #1
0
    private void VisitNode(XmlElement elem, ItemReference masterRef)
    {
      var textChildren = elem.ChildNodes.OfType<XmlText>().ToList();

      // Add a dependency to the relevant itemTypes
      if (elem.LocalName == "Item" && elem.HasAttribute("type"))
      {
        ItemType itemType;
        if (_metadata.ItemTypeByName(elem.Attribute("type").ToLowerInvariant(), out itemType))
        {
          AddDependency(itemType.Reference, elem, elem, masterRef);
        }
        else
        {
          AddDependency(new ItemReference("ItemType", ItemTypeByNameWhere + elem.Attributes["type"].Value + "'")
          {
            KeyedName = elem.Attributes["type"].Value
          }, elem, elem, masterRef);
        }
      }

      // Item property node
      if (elem.HasAttribute("type") && textChildren.Count == 1 && !string.IsNullOrEmpty(textChildren[0].Value))
      {
        AddDependency(ItemReference.FromItemProp(elem), elem.Parent(), elem, masterRef);
      }
      else if (elem.LocalName == "sqlserver_body" && elem.Parent().LocalName == "Item" && elem.Parent().Attribute("type") == "SQL")
      {
        var names = GetInnovatorNames(elem.InnerText)
          .Select(n => n.FullName.StartsWith("innovator.", StringComparison.OrdinalIgnoreCase) ?
                       n.FullName.Substring(10).ToLowerInvariant() :
                       n.FullName.ToLowerInvariant())
          .Distinct();

        ItemType itemType;
        ItemReference sql;
        foreach (var name in names)
        {
          if (_metadata.ItemTypeByName(name.Replace('_', ' '), out itemType))
          {
            AddDependency(itemType.Reference, elem.Parent(), elem, masterRef);
          }
          else if (_metadata.SqlRefByName(name, out sql))
          {
            AddDependency(sql, elem.Parent(), elem, masterRef);
          }
        }
      }
      else if (elem.LocalName == "data_source" && textChildren.Count == 1 && !string.IsNullOrEmpty(textChildren[0].Value))
      {
        // Property data source dependencies
        var parent = elem.ParentNode as XmlElement;
        if (parent != null && parent.LocalName == "Item" && parent.Attribute("type") == "Property")
        {
          var keyedName = elem.Attribute("keyed_name");
          var itemtype = _metadata.ItemTypes.FirstOrDefault(i => i.Reference.Unique == elem.Parent().Parent().Parent().Attribute("id") && i.IsPolymorphic);
          if (itemtype == null)
          {
            var dataType = parent.Element("data_type");
            if (dataType != null)
            {
              switch (dataType.InnerText.ToLowerInvariant())
              {
                case "list":
                case "mv_list":
                case "filter list":
                  AddDependency(new ItemReference("List", textChildren[0].Value) { KeyedName = keyedName }, parent, elem, masterRef);
                  break;
                case "item":
                  AddDependency(new ItemReference("ItemType", textChildren[0].Value) { KeyedName = keyedName }, parent, elem, masterRef);
                  break;
                case "sequence":
                  AddDependency(new ItemReference("Sequence", textChildren[0].Value) { KeyedName = keyedName }, parent, elem, masterRef);
                  break;
              }
            }
          }
        }
      }
      else if (elem != _elem && elem.LocalName == "Item" && elem.HasAttribute("type")
        && elem.Attribute("action", "") == "get"
        && (elem.HasAttribute("id") || elem.HasAttribute("where")))
      {
        // Item queries
        AddDependency(ItemReference.FromFullItem(elem, true), elem.Parent().Parent(), elem.Parent(), masterRef);
      }
      else if (textChildren.Count == 1 && textChildren[0].Value.StartsWith("vault:///?fileId=", StringComparison.OrdinalIgnoreCase))
      {
        // Vault Id references for image properties
        AddDependency(new ItemReference("File", textChildren[0].Value.Substring(17)), elem.Parent(), elem, masterRef);
      }
      else
      {
        if (elem != _elem && elem.LocalName == "Item" && elem.HasAttribute("type") && elem.HasAttribute("id"))
        {
          _definitions.Add(ItemReference.FromFullItem(elem, elem.Attribute("type") == "ItemType"));
        }
        var isItem = (elem.LocalName == "Item" && elem.HasAttribute("type"));
        ItemProperty newProp;
        ItemReference propRef;

        foreach (var child in elem.Elements())
        {
          if (isItem)
          {
            newProp = new ItemProperty()
            {
              ItemType = elem.Attributes["type"].Value,
              ItemTypeId = (elem.HasAttribute("typeid") ? elem.Attributes["typeid"].Value : null),
              Property = child.LocalName
            };
            if (_metadata.CustomPropertyByPath(newProp, out propRef))
            {
              propRef = propRef.Clone();
              AddDependency(propRef, elem, child, masterRef);
            }
          }
          VisitNode(child, masterRef);
        }
      }
    }
コード例 #2
0
        public static InstallItem FromScript(XmlElement elem)
        {
            var result = new InstallItem();
              result._elem = elem;
              result._itemRef = ItemReference.FromFullItem(elem, true);
              if (result._itemRef.Type.IsGuid())
              {
            result.InstalledId = result._itemRef.Type;
              }
              else
              {
            result.InstalledId = elem.Attribute("id", "");
              }

              if (elem.HasAttribute("_dependency_check"))
              {
            result._type = InstallType.DependencyCheck;
              }
              else if (elem.HasAttribute("action"))
              {
            switch (elem.Attributes["action"].Value)
            {
              case "add":
              case "merge":
              case "create":
            result._type = InstallType.Create;
            break;
              case "ActivateActivity":
              case "AddItem":
              case "AddHistory":
              case "ApplyUpdate":
              case "BuildProcessReport":
              case "CancelWorkflow":
              case "checkImportedItemType":
              case "closeWorkflow":
              case "copy":
              case "copyAsIs":
              case "copyAsNew":
              case "delete":
              case "edit":
              case "EmailItem":
              case "EvaluateActivity":
              case "exportItemType":
              case "get":
              case "getItemAllVersions":
              case "getAffectedItems":
              case "getItemConfig":
              case "getItemLastVersion":
              case "getItemNextStates":
              case "getItemRelationships":
              case "GetItemRepeatConfig":
              case "getItemWhereUsed":
              case "GetMappedPath":
              case "getPermissions":
              case "getRelatedItem":
              case "GetUpdateInfo":
              case "instantiateWorkflow":
              case "lock":
              case "New Workflow Map":
              case "PromoteItem":
              case "purge":
              case "recache":
              case "replicate":
              case "resetAllItemsAccess":
              case "resetItemAccess":
              case "resetLifecycle":
              case "setDefaultLifecycle":
              case "skip":
              case "startWorkflow":
              case "unlock":
              case "update":
              case "ValidateWorkflowMap":
              case "version":
            if ((elem.Attributes["type"].Value != "Form" && elem.Attributes["type"].Value != "View")
              || elem.Attributes["action"].Value != "delete")
            result._dependencies = Enumerable.Repeat(result._itemRef, 1);
            result._itemRef = new ItemReference("*Script", result._itemRef.ToString() + " " + Utils.GetChecksum(Encoding.UTF8.GetBytes(elem.OuterXml)))
            {
              KeyedName = RenderAttributes(elem)
            };
            result._type = InstallType.Script;
            break;
              default:
            result._dependencies = Enumerable.Repeat(new ItemReference("Method", "[Method].[name] = '" + elem.Attributes["action"].Value + "'")
            {
              KeyedName = elem.Attributes["action"].Value
            }, 1);
            result._itemRef = new ItemReference("*Script", result._itemRef.ToString() + " " + Utils.GetChecksum(Encoding.UTF8.GetBytes(elem.OuterXml)))
            {
              KeyedName = RenderAttributes(elem)
            };
            result._type = InstallType.Script;
            break;
            }
              }

              if (elem.Attribute(XmlFlags.Attr_IsScript) == "1")
              {
            if (string.IsNullOrEmpty(result._itemRef.KeyedName))
            {
              result._itemRef.KeyedName = RenderAttributes(elem);
            }
            result._type = InstallType.Script;
              }
              return result;
        }
コード例 #3
0
    internal static string RenderAttributes(XmlElement elem, string keyedName = null)
    {
      var builder = new StringBuilder();

      if (elem.HasAttribute("action"))
      {
        var action = elem.Attribute("action");
        builder.Append(char.ToUpper(action[0]))
          .Append(action.Substring(1))
          .Append(" of");
      }
      if (elem.HasAttribute("where"))
      {
        builder.Append(" ").Append(elem.Attribute("where"));
      }
      else
      {
        if (elem.HasAttribute("type"))
        {
          builder.Append(" ").Append(elem.Attribute("type")).Append(":");
        }
        if (!string.IsNullOrEmpty(keyedName))
        {
          builder.Append(" ").Append(keyedName);
        }
        else if (elem.HasAttribute("id"))
        {
          builder.Append(" ").Append(elem.Attribute("id"));
        }
      }

      if (elem.HasAttribute(XmlFlags.Attr_ScriptType))
      {
        builder.Append(" (").Append(elem.Attribute(XmlFlags.Attr_ScriptType)).Append(")");
      }

      return builder.ToString();
    }