private static bool FindActionPredicate(CellActionsCollection collection) { foreach (IAction action in collection.Actions) { if (action.Name.Value == m_actionPredicate) return true; } return false; }
/// <summary> /// Checks if any of the specified actions will modify the contents of a file/message when executed. /// </summary> /// <param name="collection"></param> /// <returns>True if at least one action intends to modify the contents of a file/message when executed.</returns> private static bool ActionModifiesFileContents(CellActionsCollection collection) { foreach (IAction action in collection.Actions) { foreach (IDataElement elem in action.DataElements) { if (0 == string.Compare("MODIFIES_CONTENTS", elem.DisplayName.Value, StringComparison.InvariantCultureIgnoreCase)) { if (((IDataItem) (elem.Data)).Value is bool) { if ((bool) (((IDataItem) (elem.Data)).Value)) { m_actionPredicate = action.Name.Value; return true; } } } } } return false; }
public static List<CellActionsCollection> GetActions(IPolicyChannel channel, IPolicySet policyset, bool checkForAllowInterpolicyDuplicates) { List<CellActionsCollection> returnVal = new List<CellActionsCollection>(); IActionMatrix matrix = channel.Actions; IActionMatrixCell cell = null; if (matrix.HasOffline) { CellActionsCollection collection = new CellActionsCollection(); collection.Actions = ExtractActionsFromActionGroups(matrix.Offline.ActionConditionGroups, policyset, checkForAllowInterpolicyDuplicates); collection.ChannelType = channel.Type; returnVal.Add(collection); } switch (ExpressionHelpers.GetRoutingType(channel.Routing)) { case ExpressionHelpers.RoutingType.Undefined: return returnVal; case ExpressionHelpers.RoutingType.SingleCell: IRoutingTable singleCelledRoutingTable = channel.Routing as IRoutingTable; cell = channel.Actions[singleCelledRoutingTable.DefaultSource, singleCelledRoutingTable.DefaultDestination]; if (null == cell) return returnVal; CellActionsCollection collection = new CellActionsCollection(); collection.Actions = ExtractActionsFromActionGroups(cell.ActionConditionGroups, policyset, checkForAllowInterpolicyDuplicates); collection.ChannelType = channel.Type; returnVal.Add(collection); break; default: IRoutingTable multiCelledRoutingTable = channel.Routing; foreach (IRoutingItemCollection sender in multiCelledRoutingTable.Sources) { foreach (IRoutingItemCollection recipient in multiCelledRoutingTable.Destinations) { cell = channel.Actions[sender, recipient]; if (null == cell) continue; collection = new CellActionsCollection(); collection.Actions = ExtractActionsFromActionGroups(cell.ActionConditionGroups, policyset, checkForAllowInterpolicyDuplicates); collection.ChannelType = channel.Type; returnVal.Add(collection); } } break; } return returnVal; }
private static bool ValidateThatPolicyRaisesIncidentIfAnyActionRequires(IPolicySet policyset, PolicySetValidator.AddViolationMessageHandler AddMessage) { bool retVal = true; for (int i = 0; i < policyset.Policies.Count; i++) { IPolicy policy = policyset.Policies[i]; foreach (IPolicyChannel channel in policy.Channels) { IActionMatrixCell cell; IPolicyObject routingCell; switch (ExpressionHelpers.GetRoutingType(channel.Routing)) { case ExpressionHelpers.RoutingType.Undefined: continue; case ExpressionHelpers.RoutingType.SingleCell: IRoutingTable singleCelledRoutingTable = channel.Routing; cell = channel.Actions[singleCelledRoutingTable.DefaultSource, singleCelledRoutingTable.DefaultDestination]; if (null == cell) continue; CellActionsCollection collection = new CellActionsCollection(); collection.Actions = ExpressionHelpers.ExtractActionsFromActionGroups(cell.ActionConditionGroups, policyset, false); collection.ChannelType = channel.Type; routingCell = singleCelledRoutingTable[singleCelledRoutingTable.DefaultSource, singleCelledRoutingTable.DefaultDestination]; foreach (IAction action in collection.Actions) { if (GetResourceAction(action).ImpliesIncident && string.IsNullOrEmpty(routingCell[m_raiseIncidentProperty].Value)) { if (AddMessage != null) AddMessage(policy.Name.Value, string.Format(CultureInfo.CurrentCulture, Properties.Resources.VALIDATION_INTRAPOLICY_ACTION_REQUIRE_INCIDENT, action.Name.Value), true); retVal = false; } } break; default: IRoutingTable multiCelledRoutingTable = channel.Routing; foreach (IRoutingItemCollection sender in multiCelledRoutingTable.Sources) { foreach (IRoutingItemCollection recipient in multiCelledRoutingTable.Destinations) { cell = channel.Actions[sender, recipient]; if (null == cell) continue; collection = new CellActionsCollection(); collection.Actions = ExpressionHelpers.ExtractActionsFromActionGroups(cell.ActionConditionGroups, policyset, false); collection.ChannelType = channel.Type; routingCell = multiCelledRoutingTable[sender, recipient]; foreach (IAction action in collection.Actions) { if (GetResourceAction(action).ImpliesIncident && string.IsNullOrEmpty(routingCell[m_raiseIncidentProperty].Value)) { if (AddMessage != null) AddMessage(policy.Name.Value, string.Format(CultureInfo.CurrentCulture, Properties.Resources.VALIDATION_INTRAPOLICY_ACTION_REQUIRE_INCIDENT, action.Name.Value), true); retVal = false; } } } } break; } } } return retVal; }