internal ActionUIItem(IResourceAction action) { m_language = action.LanguageSupport; m_actionName = action.Name; m_displayName = m_actionName; m_useTranslation = m_language != null && m_language.DefaultTwoLetterISOLanguageName != m_currentCulture && m_language.Supports(m_currentCulture); }
/// <summary> /// 资源树的双击事件 /// </summary> void OnTreeListDoubleClick(object sender, MouseEventArgs e) { TreeList tree = sender as TreeList; TreeListHitInfo treeListHitInfo = tree.CalcHitInfo(e.Location); if (treeListHitInfo.HitInfoType == HitInfoType.Cell) { tree.SetFocusedNode(treeListHitInfo.Node); } if (tree.FocusedNode != null) { var item = navigationTreeList.GetRow(tree.FocusedNode.Id); if (item is ResourceItem) { ResourceItem _item = item as ResourceItem; IResource resource = _item.Resource; if (resource.ResourceMetaData != null && resource.ResourceMetaData.DoubleClickResourceActionType != null) { IType <IResourceAction> resourceActionType = resource.ResourceMetaData.DoubleClickResourceActionType; IResourceAction resourceAction = IocManager.Instance.Resolve(resourceActionType.Type) as IResourceAction; resourceAction.Resource = resource; resourceAction.Excute(); } } else if (item is FileItem) { IResourceMetaDataProvider resourceMetaDataProvider = IocManager.Instance.Resolve <IResourceMetaDataProvider>(); ITypeList <IDocumentResourceMetaData> resourceMetaDatas = resourceMetaDataProvider.DocumentResourceMetaDataProviders; if (resourceMetaDatas.Count > 0) { foreach (var mt in resourceMetaDatas) { var m = IocManager.Instance.Resolve(mt); if (m is ISingleFileDocumentResourceMetaData) { if (((ISingleFileDocumentResourceMetaData)m).Identified(((FileItem)item).FullName)) { ISingleFileDocumentResource singleFileDocumentResource = IocManager.Instance.Resolve(((ISingleFileDocumentResourceMetaData)m).ResourceType.Type) as ISingleFileDocumentResource; singleFileDocumentResource.FullName = ((FileItem)item).FullName; singleFileDocumentResource.Open(); } } } } } } }
public ActionDetailUI(IResourceManager manager, IResourceAction action) { InitializeComponent(); m_controller = new ActionDetailController(); m_controller.ResourceManager = manager; cmdExecOptions.DropDownStyle = ComboBoxStyle.DropDownList; m_controller.ActionNameControl = edActionName; m_controller.PolicySupportControl = lbPolicySupport; m_controller.FileTypeSupportControl = lbFileTypes; m_controller.PropertiesControl = pnlPropertyList; m_controller.TransparentSendControl = cbTransparent; m_controller.AutoExpandItemControl = cbExpandFirstFileItem; m_controller.ExecuteOptionsComboBox = cmdExecOptions; m_controller.Connect(action); }
// Check that the resource action has been populated from XML as expected public static void CheckDrmActionFromXml(IResourceAction resourceAction) { Assert.IsTrue(String.Compare(resourceAction.Name, "DRM") == 0, "DRM default display name not as expected"); Assert.IsTrue(String.Compare(resourceAction.ActionClass, "Workshare.Policy.Action.DRMDocAction") == 0, "DRM action class not as expected"); Assert.IsFalse(resourceAction.IsExclusive, "DRM action should not be exclusive"); // Go through all the properties foreach (IResourceActionProperty property in resourceAction.Properties) { switch (property.DefaultDisplayName) { // They're all the same in the XML being used for the test case "Allow Editing": case "Allow Copying": case "Allow Printing": case "Allow Automation": case "Document Expires": Assert.IsNull(property.MappedSystemProperty); Assert.IsTrue(property.DisplayType == PropertyDisplayType.Checkbox, String.Format("{0} should be set to a check box for display type", property.DefaultDisplayName)); Assert.IsTrue(property.DataType == typeof(bool), String.Format("{0} should have a boolean data type", property.DefaultDisplayName)); Assert.IsTrue(property.Override, String.Format("{0} override should be true", property.DefaultDisplayName)); Assert.IsTrue(property.Visible, String.Format("{0} visible should be true", property.DefaultDisplayName)); Assert.IsTrue((bool)property.Value, String.Format("{0} value should be true", property.DefaultDisplayName)); break; default: Assert.Fail("Invalid display name in DRM properties"); break; } } // Check the execution target settings Assert.IsTrue(resourceAction.ExecutionTarget.Length == 1, "DRM action should only run at client"); Assert.IsTrue(resourceAction.ExecutionTarget[0] == RunAt.Client, "DRM action should only run at client"); // Check the supported file list settings Assert.IsTrue(resourceAction.SupportedFileCollectionSetting.SupportedFiles().Length == 3, "Should be 3 supported file types for DRM"); Assert.AreEqual(0, resourceAction.SupportedFileCollectionSetting.UnsupportedFiles().Length, "Should be a SUPPORTED file list for DRM"); Assert.IsTrue(resourceAction.SupportedFileCollectionSetting.Supports(".doc"), "DRM should support .doc"); Assert.IsTrue(resourceAction.SupportedFileCollectionSetting.Supports(".ppt"), "DRM should support .ppt"); Assert.IsTrue(resourceAction.SupportedFileCollectionSetting.Supports(".xls"), "DRM should support .xls"); // Check the channels Assert.IsTrue(resourceAction.SupportedPolicySetting.Length == 1, "Should only be a single channel for DRM"); //Assert.IsTrue(resourceAction.SupportedChannelSetting[0] == ChannelType.SMTP, "The channel for DRM should be SMTP"); }
public static void AddActionClassNodeAttributes(XmlNode actionClassNode, IResourceAction resourceAction) { AddAttribute(actionClassNode, "enabled", resourceAction.Enabled.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "display", resourceAction.Name); // the unique name of the action AddAttribute(actionClassNode, "name", resourceAction.ActionClass); AddAttribute(actionClassNode, "isexclusive", resourceAction.IsExclusive.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "cancoexist", resourceAction.CanCoexist.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "allowtransparent", resourceAction.AllowTransparent.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "blocking", resourceAction.Blocking.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "allowException", resourceAction.AllowException.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "expandFirstFileItem", resourceAction.AutoExpand.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "executionOptions", resourceAction.ExecutionOption.ToString()); AddAttribute(actionClassNode, "supportsmime", resourceAction.SupportsMime.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "supportscontainers", resourceAction.SupportsContainers.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); AddAttribute(actionClassNode, "impliesincident", resourceAction.ImpliesIncident.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture)); string customdatatypehandler = null; if (resourceAction.CustomDataTypeUI != null) customdatatypehandler = resourceAction.CustomDataTypeUI.GetType().FullName; else customdatatypehandler = (resourceAction as ResourceAction).CustomDataTypeUITypeName; AddAttribute(actionClassNode, "icustomdatatypehandler", customdatatypehandler == null ? "" : customdatatypehandler); }
public static void AddActionToResource(XPathNavigator actionNode, IResourceAction resourceAction) { XPathNavigator actionClassNode = actionNode.SelectSingleNode(@"ActionClass"); //Backwards compatibility if (actionClassNode == null) actionClassNode = actionNode.SelectSingleNode(@"ActionClasses/ActionClass"); if (actionClassNode != null) { resourceAction.Assembly = actionNode.GetAttribute("assembly", RESOURCE_NAMESPACE_URI); resourceAction.ActionClass = actionClassNode.GetAttribute("name", RESOURCE_NAMESPACE_URI); resourceAction.Name = actionClassNode.GetAttribute("display", RESOURCE_NAMESPACE_URI); if (HasAttribute("cancoexist", actionClassNode)) { resourceAction.CanCoexist = Convert.ToBoolean(actionClassNode.GetAttribute("cancoexist", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.CanCoexist = true; } if (HasAttribute("isexclusive", actionClassNode)) { resourceAction.IsExclusive = Convert.ToBoolean(actionClassNode.GetAttribute("isexclusive", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.IsExclusive = false; } if (HasAttribute("enabled", actionClassNode)) { resourceAction.Enabled = Convert.ToBoolean(actionClassNode.GetAttribute("enabled", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.Enabled = false; } if (HasAttribute("allowtransparent", actionClassNode)) { resourceAction.AllowTransparent = Convert.ToBoolean(actionClassNode.GetAttribute("allowtransparent", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.AllowTransparent = false; } if (HasAttribute("allowException", actionClassNode)) { resourceAction.AllowException = Convert.ToBoolean(actionClassNode.GetAttribute("allowException", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.AllowException = false; } if (HasAttribute("blocking", actionClassNode)) { resourceAction.Blocking = Convert.ToBoolean(actionClassNode.GetAttribute("blocking", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.Blocking = false; } if (HasAttribute("expandFirstFileItem", actionClassNode)) { resourceAction.AutoExpand = Convert.ToBoolean(actionClassNode.GetAttribute("expandFirstFileItem", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.AutoExpand = false; } if (HasAttribute("supportsmime", actionClassNode)) { resourceAction.SupportsMime = Convert.ToBoolean(actionClassNode.GetAttribute("supportsmime", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.SupportsMime = false; } if (HasAttribute("supportscontainers", actionClassNode)) { resourceAction.SupportsContainers = Convert.ToBoolean(actionClassNode.GetAttribute("supportscontainers", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.SupportsContainers = false; } if (HasAttribute("impliesincident", actionClassNode)) { resourceAction.ImpliesIncident = Convert.ToBoolean(actionClassNode.GetAttribute("impliesincident", RESOURCE_NAMESPACE_URI), CultureInfo.InvariantCulture); } else { resourceAction.ImpliesIncident = false; } if (HasAttribute("icustomdatatypehandler", actionClassNode)) (resourceAction as ResourceAction).CustomDataTypeUITypeName = actionClassNode.GetAttribute("icustomdatatypehandler", RESOURCE_NAMESPACE_URI); if (HasAttribute("alwaysexecute", actionClassNode)) //possibly an old res downloaded from server { resourceAction.ExecutionOption = ExecutionOption.AlwaysExecute; } else if (HasAttribute("executionOptions", actionClassNode)) { ExecutionOption opts = (ExecutionOption)Enum.Parse(typeof(ExecutionOption), actionClassNode.GetAttribute("executionOptions", RESOURCE_NAMESPACE_URI)); resourceAction.ExecutionOption = opts; } AddExecutionTargetToResource(actionClassNode, "ExecutionTargetCapabilities", resourceAction); AddExecutionTargetToResource(actionClassNode, "ExecutionTargetSettings", resourceAction); AddSupportedFileCollectionToResource(actionClassNode, "SupportedFileTypeCapabilities", resourceAction); AddSupportedFileCollectionToResource(actionClassNode, "SupportedFileTypeSettings", resourceAction); AddSupportedPolicyTypesToResource(actionClassNode, "SupportedPolicyCapabilities", resourceAction); AddSupportedPolicyTypesToResource(actionClassNode, "SupportedPolicySettings", resourceAction); // Do something with ActionMethods? What? AddDataElementsToResource(actionClassNode, resourceAction); AddPropertySetLayoutToResource(actionClassNode, resourceAction); AddLanguagesToResource(actionClassNode, resourceAction); } }
/// <summary> /// The check is performed against the action class name. /// </summary> /// <param name="item">The resource action being checked</param> /// <returns>true if the input resource action is already in the list, false otherwise</returns> public bool Contains(IResourceAction item) { return Contains(item.Name); }
private XmlNode AddResourceAction(IResourceAction resourceAction) { XmlNode actionNode; XmlNode actionClassNode = GetActionNode(resourceAction.Name); if (actionClassNode == null) { actionNode = m_xmlDoc.CreateElement("Action"); actionClassNode = m_xmlDoc.CreateElement("ActionClass"); actionNode.AppendChild(actionClassNode); XmlResourceHelper.AddAttribute(actionNode, "assembly", resourceAction.Assembly); } else { // Shouldn't get here as we are rewriting the node from scratch each time Logger.LogError("XmlResourceWriter.AddResourceAction: action classes node not null i.e. has not been deleted"); throw new ApplicationException(Properties.Resources.COULD_NOT_WRITE_RESOURCES); } try { XmlResourceHelper.AddActionClassNodeAttributes(actionClassNode, resourceAction); XmlResourceHelper.AddSupportedFileCollection(actionClassNode, "SupportedFileTypeCapabilities", resourceAction.SupportedFileCollectionCapabilities); XmlResourceHelper.AddSupportedFileCollection(actionClassNode, "SupportedFileTypeSettings", resourceAction.SupportedFileCollectionSetting); XmlResourceHelper.AddSupportedPolicyTypes(actionClassNode, "SupportedPolicySettings", resourceAction.SupportedPolicySetting); XmlResourceHelper.AddExecutionTarget(actionClassNode, "ExecutionTargetCapabilities", resourceAction.ExecutionTargetCapabilities); XmlResourceHelper.AddExecutionTarget(actionClassNode, "ExecutionTargetSettings", resourceAction.ExecutionTarget); XmlResourceHelper.AddActionMethods(actionClassNode); XmlResourceHelper.AddProperties(actionClassNode, resourceAction.Properties); XmlResourceHelper.AddPropertySetLayout(actionClassNode, resourceAction.PropertySetLayout); XmlResourceHelper.AddLanguageSupport(actionClassNode, resourceAction); } catch (Exception ex) { Logger.LogError("XmlResourceWriter.AddResourceAction: action could not be loaded as it was invalid"); Logger.LogError(ex); throw new ApplicationException(Properties.Resources.COULD_NOT_WRITE_RESOURCES); } return actionNode; }
private bool CanLoadActionHelper(AddEditActionsForm form, IResourceAction action) { return (bool)AccessInternals.InvokeMethod(form, "CanLoadAction", new object[] { action }); }
public static void AddDataElementsToResource(XPathNavigator actionClassNode, IResourceAction resourceAction) { IResourceActionProperties resourceActionProperties = new ResourceActionProperties(); XPathNodeIterator dataElementNodes = actionClassNode.Select(@"DataElements/DataElement"); if (dataElementNodes != null && dataElementNodes.Count > 0) { while (dataElementNodes.MoveNext()) { IResourceActionProperty resourceActionProperty = new ResourceActionProperty(); XPathNavigator dataElementNode = dataElementNodes.Current; AddDataElementToResource(dataElementNode, resourceActionProperty); //ignore old EXECUTE property if (!resourceActionProperty.Name.Equals("EXECUTE", StringComparison.InvariantCultureIgnoreCase)) resourceActionProperties.Add(resourceActionProperty); else { bool value = Convert.ToBoolean(resourceActionProperty.Value, CultureInfo.InvariantCulture); bool overridable = Convert.ToBoolean(resourceActionProperty.Override, CultureInfo.InvariantCulture); if (overridable) { resourceAction.ExecutionOption = value ? ExecutionOption.OverridableDefaultTrue : ExecutionOption.OverridableDefaultFalse; } else { resourceAction.ExecutionOption = ExecutionOption.AlwaysExecute; } } } } (resourceAction as ResourceAction).Properties = resourceActionProperties; }
/// <summary> /// Add the language information under the input ActionClass node to the resources /// </summary> /// <param name="actionClassNode">The node containing the language information</param> /// <param name="resourceAction">The resource being written to</param> public static void AddLanguagesToResource(XPathNavigator actionClassNode, IResourceAction resourceAction) { Dictionary<string, ILanguageItem> languages = new Dictionary<string, ILanguageItem>(); XPathNavigator languagesNode = actionClassNode.SelectSingleNode(@"Languages"); if (languagesNode == null) { return; //ContextObject.Instance.LogError("XmlResourceHelper.AddLanguageToResource: no Languages node"); //throw new ApplicationException(Properties.Resources.COULD_NOT_READ_RESOURCES); } string defaultCode = languagesNode.GetAttribute("defaultcode", RESOURCE_NAMESPACE_URI); XPathNodeIterator languageNodes = languagesNode.Select(@"Language"); if (languageNodes != null && languageNodes.Count > 0) { while (languageNodes.MoveNext()) { XPathNavigator languageNode = languageNodes.Current; XPathNodeIterator languageItemNodes = languageNode.Select(@"LanguageItem"); Dictionary<string, string> languageItems = new Dictionary<string, string>(); string name = languageNode.GetAttribute("name", RESOURCE_NAMESPACE_URI); string code = languageNode.GetAttribute("code", RESOURCE_NAMESPACE_URI); if (languageItemNodes != null && languageItemNodes.Count > 0) { while (languageItemNodes.MoveNext()) { string itemName = languageItemNodes.Current.GetAttribute("name", RESOURCE_NAMESPACE_URI); string itemTranslatedName = languageItemNodes.Current.Value; languageItems.Add(itemName, itemTranslatedName); } } ResourceLanguageItem languageItem = new ResourceLanguageItem(name, languageItems); languages.Add(code, languageItem); } } (resourceAction as ResourceAction).LanguageSupport = new ResourceLanguageExtension(defaultCode, languages); }
public static void AddExecutionTargetToResource(XPathNavigator actionClassNode, string capabilitiesOrSettings, IResourceAction resourceAction) { XPathNodeIterator runAtNodes = actionClassNode.Select(capabilitiesOrSettings + @"/RunAt"); List<RunAt> supportedTargets = new List<RunAt>(); if (runAtNodes != null && runAtNodes.Count > 0) { while (runAtNodes.MoveNext()) { XPathNavigator runAtNode = runAtNodes.Current; try { supportedTargets.Add((RunAt)(Enum.Parse(typeof(RunAt), runAtNode.Value, true))); } catch (ArgumentException ex) { Logger.LogError(String.Format(CultureInfo.InvariantCulture, "XmlResourceHelper.AddExecutionTargetToResource: invalid run at: {0}", runAtNode.Value)); Logger.LogError(ex); throw new ApplicationException(Properties.Resources.COULD_NOT_READ_RESOURCES); } } } if (capabilitiesOrSettings.EndsWith("Capabilities")) { (resourceAction as ResourceAction).ExecutionTargetCapabilities = supportedTargets.ToArray(); } else { resourceAction.ExecutionTarget = supportedTargets.ToArray(); } }
/// <summary> /// This method looks for duplicate resource actions in the list. /// Two resource actions with the same name constitutes a duplicate /// </summary> /// <param name="resourceAction">The action that was about to be added to the list</param> /// <returns>True if there's already an action with the same name.</returns> private bool DuplicateFoundInList(IResourceAction resourceAction) { foreach (object resObj in List) { IResourceAction action = resObj as IResourceAction; if (action != null) { if (0 == string.Compare(action.Name, resourceAction.Name, StringComparison.InvariantCultureIgnoreCase)) return true; } } return false; }
/// <summary> /// Create an ActionPropertySet that is empty for actions that do not /// implement their own property set /// </summary> /// <param name="resourceAction">The ResourceAction that will store the action properties</param> private void CreateActionProperties(IResourceAction resourceAction) { Logger.LogDebug("Creating action property set for action " + resourceAction.Name); ActionPropertySet actionProperties = new ActionPropertySet(); resourceAction.PropertyClass = "EmptyActionPropertySet"; IResourceActionProperties resourceActionProperties = new ResourceActionProperties(); (resourceActionProperties as ResourceActionProperties).SetActionProperties(actionProperties); (resourceAction as ResourceAction).Properties = resourceActionProperties; }
/// <summary> /// Load the action properties contained in the assembly of the given type /// into the ResourceActionProperties /// </summary> /// <param name="actionAssembly">The assembly containing the action properties to be loaded</param> /// <param name="resourceAction">The ResourceAction that will store the action properties</param> /// <param name="actionPropertyType">The type of the aciton properties to be loaded</param> private void LoadActionProperties(Assembly actionAssembly, IResourceAction resourceAction, Type actionPropertyType) { Logger.LogDebug("Loading action properties class: " + actionPropertyType.FullName); resourceAction.PropertyClass = actionPropertyType.FullName; IActionPropertySet actionProperties = (IActionPropertySet)(actionAssembly.CreateInstance(actionPropertyType.FullName)); IResourceActionProperties resourceActionProperties = new ResourceActionProperties(); (resourceActionProperties as ResourceActionProperties).SetActionProperties(actionProperties); (resourceAction as ResourceAction).Properties = resourceActionProperties; }
/// <summary> /// Load the action contained in the assembly of the given type into the /// ResourceAction /// </summary> /// <param name="actionAssembly">The assembly containing the action to be loaded</param> /// <param name="resourceAction">The ResourceAction representing the action</param> /// <param name="actionType">The type of the action to be loaded</param> private void LoadAction(Assembly actionAssembly, IResourceAction resourceAction, Type actionType) { Logger.LogDebug("Loading action class: " + actionType.FullName); resourceAction.ActionClass = actionType.FullName; (resourceAction as ResourceAction).SetAction(actionAssembly.CreateInstance(actionType.FullName) as IAction3); }
public bool Remove(IResourceAction item) { // We want to remove based on the action name foreach (IResourceAction resourceAction in List) { if (item.Name == resourceAction.Name) { List.Remove(resourceAction); // Make sure that the items above the one just removed // have their sequence numbers updated return true; } } return false; }
public void CopyTo(IResourceAction[] array, int arrayIndex) { List.CopyTo(array, arrayIndex); }
public ResourceActionEventArgs(IResourceAction action) { ResourceAction = action; }
public static void AddPropertySetLayoutToResource(XPathNavigator actionClassNode, IResourceAction resourceAction) { XPathNavigator propertySetLayoutNode = actionClassNode.SelectSingleNode("PropertySetLayout"); if (null == propertySetLayoutNode) { resourceAction.PropertySetLayout = null; return; } bool showSelectAll = bool.Parse(propertySetLayoutNode.GetAttribute("showselectall", string.Empty)); ColumnLayoutStyle style = (ColumnLayoutStyle)Enum.Parse(typeof(ColumnLayoutStyle), propertySetLayoutNode.GetAttribute("layoutstyle", string.Empty)); PropertySetLayout psl = new PropertySetLayout(style, showSelectAll); resourceAction.PropertySetLayout = psl as IPropertySetLayout; }
private static bool ActionsContainExactMatch(Policy.Resources.IResourceManager resMgr, IResourceAction secondaryAction) { foreach (IResourceAction masterAction in resMgr.ResourceActions) { if (masterAction.Name == secondaryAction.Name) { if (masterAction.ActionClass != secondaryAction.ActionClass) return false; if (masterAction.AllowException != secondaryAction.AllowException) return false; if (masterAction.AllowTransparent != secondaryAction.AllowTransparent) return false; if (masterAction.Assembly != secondaryAction.Assembly) return false; if (masterAction.AutoExpand != secondaryAction.AutoExpand) return false; if (masterAction.Blocking != secondaryAction.Blocking) return false; if (masterAction.CanCoexist != secondaryAction.CanCoexist) return false; if (masterAction.Enabled != secondaryAction.Enabled) return false; if (!CompareRunAtArray(masterAction.ExecutionTarget, secondaryAction.ExecutionTarget)) return false; if (!CompareRunAtArray(masterAction.ExecutionTargetCapabilities, secondaryAction.ExecutionTargetCapabilities)) return false; if (masterAction.IsExclusive != secondaryAction.IsExclusive) return false; if (masterAction.PropertyClass != secondaryAction.PropertyClass) return false; if (masterAction.Sequence != secondaryAction.Sequence) return false; if (!ComparePolicyArray(masterAction.SupportedPolicySetting, secondaryAction.SupportedPolicySetting)) return false; if (!CompareFileList(masterAction.SupportedFileCollectionCapabilities, secondaryAction.SupportedFileCollectionCapabilities)) return false; if (!CompareFileList(masterAction.SupportedFileCollectionSetting, secondaryAction.SupportedFileCollectionSetting)) return false; if (masterAction.Template != secondaryAction.Template) return false; return true; } } return false; }
public static void AddSupportedFileCollectionToResource(XPathNavigator actionClassNode, string capabilitiesOrSettings, IResourceAction resourceAction) { XPathNavigator supportedFileTypesNode = actionClassNode.SelectSingleNode(capabilitiesOrSettings); if (supportedFileTypesNode == null) return; if (supportedFileTypesNode.SelectSingleNode("Included") == null) { #region old resource files string supportedFileTypes = ReadFileTypes(supportedFileTypesNode.Select(@"FileType")); string include = supportedFileTypesNode.GetAttribute("include", RESOURCE_NAMESPACE_URI); if (!String.IsNullOrEmpty(include) && (String.Compare(include, "false", true, CultureInfo.InvariantCulture) == 0)) { ISupportedFilesSet fileset = SupportedFileSet.CreateFileCollection(".*", supportedFileTypes); if (capabilitiesOrSettings.EndsWith("Capabilities")) (resourceAction as ResourceAction).SupportedFileCollectionCapabilities = fileset; else resourceAction.SupportedFileCollectionSetting = fileset; } else { // Take the default as a supported list ISupportedFilesSet fileset = SupportedFileSet.CreateFileCollection(supportedFileTypes); if (capabilitiesOrSettings.EndsWith("Capabilities")) (resourceAction as ResourceAction).SupportedFileCollectionCapabilities = fileset; else resourceAction.SupportedFileCollectionSetting = fileset; // old resource file means old actions that use the following semantics if (fileset.Supports(".email")) { resourceAction.SupportsMime = true; fileset.RemoveSupportFor(".email"); } if (fileset.Supports(".fld")) { resourceAction.SupportsContainers = true; fileset.RemoveSupportFor(".fld"); } } #endregion } else { string supportedFiles = ""; string unsupportedFiles = ""; supportedFiles = ReadFileTypes(supportedFileTypesNode.Select("Included/FileType")); unsupportedFiles = ReadFileTypes(supportedFileTypesNode.Select("Excluded/FileType")); ISupportedFilesSet fileset = SupportedFileSet.CreateFileCollection(supportedFiles, unsupportedFiles); if (capabilitiesOrSettings.EndsWith("Capabilities")) (resourceAction as ResourceAction).SupportedFileCollectionCapabilities = fileset; else resourceAction.SupportedFileCollectionSetting = fileset; } }
private void LoadActionPropertyLayout(Assembly actionAssembly, IResourceAction resourceAction, Type actionType) { Logger.LogDebug("Loading " + actionType.FullName); IPropertySetLayout layout = (IPropertySetLayout)actionAssembly.CreateInstance(actionType.FullName); resourceAction.PropertySetLayout = layout; }
public static void AddSupportedChannelsToResource(XPathNavigator actionClassNode, string capabilitiesOrSettings, IResourceAction resourceAction) { if (capabilitiesOrSettings.EndsWith("Capabilities")) return; XPathNodeIterator channelNodes = actionClassNode.Select(capabilitiesOrSettings + @"/Channel"); List<PolicyType> channels = new List<PolicyType>(); if (channelNodes != null && channelNodes.Count > 0) { while (channelNodes.MoveNext()) { XPathNavigator channelNode = channelNodes.Current; try { channels.Add(TypeConverters.ConvertChannelType(channelNode.Value)); } catch (ArgumentException ex) { // The channel is not supported Logger.LogError(String.Format(CultureInfo.InvariantCulture, "XmlResourceHelper.AddSupportedChannelsToResource: invalid channel: {0}", channelNode.Value)); Logger.LogError(ex); throw new ApplicationException(Properties.Resources.COULD_NOT_READ_RESOURCES); } } } resourceAction.SupportedPolicySetting = channels.ToArray(); }
public void CopyTo(IResourceAction[] array, int arrayIndex) { throw new NotImplementedException(); }
public void Connect(IResourceAction action) { m_action = action; PopulateControls(); }
private void LoadNewActionData(IResourceAction resourceAction) { ActionObjectDefinition aoDef = new ActionObjectDefinition(resourceAction.Name); aoDef.AssemblyName = resourceAction.Assembly; aoDef.ClassName = resourceAction.ActionClass; aoDef.Precedence = resourceAction.Sequence; aoDef.ActionName = resourceAction.Name; aoDef.AllowTransparent = m_allowTransparent && resourceAction.AllowTransparent; aoDef.PropertySetLayout = resourceAction.PropertySetLayout; if (aoDef.ActionName.Length == 0) { string[] strs = (resourceAction.Name).Split(new Char[] { '.' }); aoDef.ActionName = strs[strs.Length - 1]; } foreach (IResourceActionProperty resourceActionProperty in resourceAction.Properties) { try { ActionDataElement ade = new ActionDataElement(); ade.Override = resourceActionProperty.Override; //false; ade.Visible = resourceActionProperty.Visible; //true; if (resourceActionProperty.MappedSystemProperty != null) { ade.IsDataSource = true; ade.IsSystemProperty = true; ade.MappedSystemProperty = resourceActionProperty.MappedSystemProperty; } else { ade.IsDataSource = false; ade.IsSystemProperty = false; } ade.IsCustomProperty = resourceActionProperty.CustomProperty; ade.Value = resourceActionProperty.Value; ade.Name = resourceActionProperty.Name; ade.DisplayName = resourceActionProperty.DefaultDisplayName; ade.Identifier = Guid.NewGuid(); ade.ShowInUI = ShowPropertyInUIForType(resourceAction.Name, resourceActionProperty.Name); ade.IsCustomDisplayType = resourceActionProperty.DisplayType == PropertyDisplayType.CustomUI; aoDef.ActionProperties[ade.Identifier] = ade; aoDef.AutoExpand = resourceAction.AutoExpand; aoDef.CustomDataTypeUIHandler = resourceAction.CustomDataTypeUI; aoDef.ExecutionOption = resourceAction.ExecutionOption; } catch (ArgumentException ex) { Logger.LogError(string.Format(CultureInfo.CurrentCulture, Properties.Resources.ACTION_UNSUPPORTED_ERROR, ex.Message)); Logger.LogError(ex); ShowUnsupportedTypeMessageBox(); } } AddBaseFileTypes(ref aoDef); m_actions[aoDef.ActionName] = aoDef; }
public void WriteAction(IResourceAction resourceAction) { AddResourceAction(resourceAction); }
/// <summary> /// Add the Languages node to the ActionClass node /// </summary> /// <remarks> /// The action must supply a different set of strings for each /// language that it supports. /// </remarks> /// <param name="actionClassNode">The ActionClass node that the languages will be added to</param> /// <param name="resourceAction">The ResourceAction containing the language support</param> public static void AddLanguageSupport(XmlNode actionClassNode, IResourceAction resourceAction) { ILanguageExtension languages = resourceAction.LanguageSupport; if (languages == null) return; XmlDocument xmlDocument = actionClassNode.OwnerDocument; XmlNode languagesNode = xmlDocument.CreateElement("Languages"); AddAttribute(languagesNode, "defaultcode", languages.DefaultTwoLetterISOLanguageName); foreach (KeyValuePair<string, ILanguageItem> kvp in languages.Languages) { XmlNode languageNode = xmlDocument.CreateElement("Language"); AddAttribute(languageNode, "code", kvp.Key); AddAttribute(languageNode, "name", kvp.Value.TranslatedName); foreach (KeyValuePair<string, string> kvpTranslations in kvp.Value.TranslatedProperties) { XmlNode languageItemNode = xmlDocument.CreateElement("LanguageItem"); AddAttribute(languageItemNode, "name", kvpTranslations.Key); languageItemNode.InnerText = kvpTranslations.Value; languageNode.AppendChild(languageItemNode); } languagesNode.AppendChild(languageNode); } actionClassNode.AppendChild(languagesNode); }
/// <summary> /// This method returns true if the specified action is allowed to be added to the current /// routing matrix cell. /// </summary> private bool CanLoadAction(IResourceAction resourceAction) { //If the routing cell has 1 or more items, you can't add any another action that has CoExist = false. //Once a type of Action is added to the cell, no more of that type can be added. bool canAdd = true; if (m_currentActions.Count > 0 && !resourceAction.CanCoexist) { canAdd = false; } if (m_currentActionTypes.ContainsKey(resourceAction.Name)) { canAdd = false; } return canAdd; }
/// <summary> /// Add the resource action to the internal list. /// </summary> /// <remarks> /// Before the resource action is added to the list, its sequence is set. /// This is based purely on the number of items already in the list. The /// sequence numbers start at 1001 and go up in chunks of 1000. /// </remarks> /// <param name="item">The item being added to the collection</param> public void Add(IResourceAction item) { List.Add(item); }