/// <summary> /// Determines whether it is logical to edit the name of an location collection, based on the /// routing table and location collection. /// Note that this is informational only; the user is not prevented from editing the name of the collection. /// </summary> /// <param name="routingTable">The routing table that contains the location collection</param> /// <param name="locationCollection">The location collection</param> /// <returns>A boolean indicating whether it is logical to edit the name of the location collection.</returns> public static bool AllowNameEdit(IRoutingTable routingTable, IRoutingItemCollection addressCollection) { if ((null == routingTable) || (null == addressCollection)) { Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage( "INVALID_STATE_DATA", "Workshare.PolicyDesigner.Properties.Resources", Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); throw new ArgumentException(errorMessage.DisplayString); } // Only InternalExternal routing tables will have this property populated. // Therefore, if it is populated then it is an InternalExternal routing table and don't allow an edit. if (RoutingHelper.IsInternalExternalRoutingTable(routingTable)) { return false; } if ((Workshare.Policy.ChannelType.SMTP == routingTable.Type) || (Workshare.Policy.ChannelType.RemoveableDevice == routingTable.Type)) { if (AddressCollectionHelper.IsDefaultAddressCollection(addressCollection)) { return false; } } if (Workshare.Policy.ChannelType.Mta == routingTable.Type) { return false; } return true; }
public RoutingMatrixCell(RoutingMatrixCell rhs, bool readOnly, bool createNewId, IRoutingItemCollection senders, IRoutingItemCollection recipients) : base(rhs, readOnly, createNewId, senders, recipients) { m_identifier = Guid.Empty; IPolicyLanguageItem description = createNewId ? rhs.Description.Clone() : rhs.Description; IPolicyLanguageItem color = createNewId ? rhs.Color.Clone() : rhs.Color; SetDefaults(description, color, rhs.Precedence); }
public ActionMatrixEventArgs(IPolicy policy, IPolicyChannel channel, IRoutingItemCollection senderCollection, IRoutingItemCollection recipientCollection, Workshare.Policy.ObjectModel.IAction action) { m_policy = policy; m_channel = channel; m_senderCollection = senderCollection; m_recipientCollection = recipientCollection; m_action = action; }
/// <summary> /// Returns a string representing a type of routing detail. Remove this /// when we can read this from the object model /// </summary> /// <returns></returns> public static string GetRoutingDetailTypeForRoutingItemCollection(IRoutingTable routingTable, IRoutingItemCollection routingItemCollection) { switch (routingTable.Type) { case ChannelType.SMTP: return "ldap"; case ChannelType.RemoveableDevice: foreach (IRoutingItemCollection collection in routingTable.Sources) { //we compare the identifier, as we may be working with a copy of the IRoutingItemCollection if (collection.Identifier == routingItemCollection.Identifier) { return "ldap"; } } return "removeableMedia"; default: return string.Empty; } }
/// <summary> /// Returns the 'neighbours' of an RoutingItem Collection. /// </summary> /// <param name="locationCollection">The location collection whose neighbours we're looking for</param> /// <param name="routingTable">The routing table we're looking in</param> /// <returns>If <paramref name="locationCollection"/> is on the 'row' axis of <paramref name="routingTable"/>, returns the Sources property of <paramref name="routingTable"/>. Otherwise, returns the Destinations property, or null if <paramref name="locationCollection"/> does not belong in the routing table</returns> /// <remarks>Return value will always contain <paramref name="locationCollection"/>. /// This method assumes that all Identifiers within the matrix are unique.</remarks> internal static IRoutingItemCollections GetNeighbours(IRoutingItemCollection addressCollection, RoutingTable routingTable) { if ((null != addressCollection) && (null != routingTable)) { foreach (IRoutingItemCollection ac in routingTable.Destinations) { if (0 == ac.Identifier.CompareTo(addressCollection.Identifier)) { return routingTable.Destinations; } } foreach (IRoutingItemCollection ac in routingTable.Sources) { if (0 == ac.Identifier.CompareTo(addressCollection.Identifier)) { return routingTable.Sources; } } } return null; }
public MatrixCellBase(IRoutingItemCollection sources, IRoutingItemCollection destinations) :base() { m_sources = sources; m_destinations = destinations; }
public MatrixCellBase(Guid guid, IPolicyLanguageItem name, bool readOnly, IRoutingItemCollection sources, IRoutingItemCollection destinations) :base(guid, name, readOnly) { m_sources = sources; m_destinations = destinations; }
void routingTable_AddActionGroupClickedEvent(object sender, AddActionEventArgs args) { m_activeRecipientAddressCollection = args.Receiver as IRoutingItemCollection; m_activeSenderAddressCollection = args.Sender as IRoutingItemCollection; if (Action_AddingGroup != null) { Action_AddingGroup(sender, new ActionMatrixEventArgs(m_policy, m_channel, m_activeSenderAddressCollection, m_activeRecipientAddressCollection, null)); } }
private static void RefreshRoutingMatrixTableRowPrecedences(IRoutingTable routingTable, IRoutingItemCollection senderAddressCollection, IRoutingItemCollections recipientAddressCollections, ref int precedence) { IRoutingItemCollection defaultRecipientAddressCollection = null; foreach (IRoutingItemCollection recipientAddressCollection in recipientAddressCollections) { if (AddressCollectionHelper.IsDefaultAddressCollection(recipientAddressCollection)) { //ensure that we treat the default column as the last column in the routing matrix defaultRecipientAddressCollection = recipientAddressCollection; continue; } else { IRoutingMatrixCell routingMatrixCell = routingTable[senderAddressCollection.Identifier, recipientAddressCollection.Identifier]; if (null != routingMatrixCell) { routingMatrixCell.Precedence = ++precedence; } } } if (null != defaultRecipientAddressCollection) { ((IRoutingMatrixCell)routingTable[senderAddressCollection.Identifier, defaultRecipientAddressCollection.Identifier]).Precedence = ++precedence; } }
public static void RemoveCellFromActionMatrix(IActionMatrix actionMatrix, IRoutingItemCollection senderAddressCollection, IRoutingItemCollection recipientAddressCollection) { actionMatrix.Remove(senderAddressCollection, recipientAddressCollection); }
public static void RemoveCollectionFromAddressGroup(IPolicyChannel channel, IRoutingItemCollections addressGroup, IRoutingItemCollection addressCollection) { IRoutingTable routingTable = channel.Routing; if (null == routingTable) { return; } if (AddressCollectionHelper.AllowCollectionDelete(routingTable, addressCollection)) { if (Object.ReferenceEquals(routingTable.Sources, addressGroup)) { // Removing location collection from sources group routingTable.Sources.Remove(addressCollection); //remove cells from action matrix foreach (IRoutingItemCollection recipient in routingTable.Destinations) { if (channel.Actions.HasCell(addressCollection, recipient)) { RemoveCellFromActionMatrix(channel.Actions, addressCollection, recipient); } } if (1 == routingTable.Sources.Count) { IRoutingItemCollection defaultSenders = routingTable.DefaultSource; defaultSenders.Name.Value = Properties.Resources.ROUTING_EVERYONE; } } else if (Object.ReferenceEquals(routingTable.Destinations, addressGroup)) { // Removing location collection from destinations group routingTable.Destinations.Remove(addressCollection); //remove cells from action matrix foreach (IRoutingItemCollection recipient in routingTable.Destinations) { if (channel.Actions.HasCell(addressCollection, recipient)) { RemoveCellFromActionMatrix(channel.Actions, addressCollection, recipient); } } if (1 == routingTable.Destinations.Count) { IRoutingItemCollection defaultRecipients = routingTable.DefaultDestination; defaultRecipients.Name.Value = Properties.Resources.ROUTING_EVERYONE; } } else { // group is neither sources nor destinations Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage( "ADDRESSGROUPTYPE_INVALID", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); throw new ArgumentException(errorMessage.DisplayString); } RefreshRoutingMatrixTablePrecedences(routingTable); } }
public void Initialise(IRoutingItemCollection routingItems) { // Convert the routing item collection to an LdapServerInformation object, and try and find an appropriate directory analyzer // that matches that information LdapServerInformation ls = RoutingHelper.PolicyObjectToLdapInfo(routingItems); DirectoryAnalyzer routingAnalyzer = DirectoryAnalyzers.Instance.FindAnalyzer(ls); // If no matching directory analyzer can be found, then what's probably happened is that the policy has been loaded on // a different box, or the registry has been manually abused. Persist the LdapServerInformation to the registry and // create a new DirectoryAnalyzer from it if (routingAnalyzer == null) { ls.SaveToRegistry(); routingAnalyzer = new DirectoryAnalyzer(ls); DirectoryAnalyzers.Instance.Add(routingAnalyzer); } PopulateLdapServerList(routingAnalyzer); StringBuilder sb = new StringBuilder(); foreach (Policy.ObjectModel.IRoutingItem routingItem in routingItems) { sb.AppendFormat("{0};", routingItem.Content); } GroupMembers = sb.ToString(); }
public RoutingMatrixEventArgs(IPolicyChannel channel, IRoutingItemCollections addressGroup, IRoutingItemCollection addressCollection) { m_channel = channel; m_addressGroup = addressGroup; m_addressCollection = addressCollection; }
private void SetRoutingItemCollection(IRoutingItemCollection routingItemCollection) { //reset the our internal record of the last checked item, else things will screw up when we //next call GetRoutingItemCollection m_changedDeviceTypeIndex = -1; m_changedDeviceTypeNewCheckState = CheckState.Unchecked; Dictionary<string, bool> deviceTypesDictionary = new Dictionary<string, bool>(); DeviceTypeDisplayTranslator displayTranslator = DeviceTypeDisplayTranslator.Instance; StringBuilder volumeNames = new StringBuilder(); StringBuilder volumeIDs = new StringBuilder(); //set all device types supported by us foreach (string deviceType in displayTranslator.DataTypes) { deviceTypesDictionary.Add(displayTranslator.GetDisplayType(deviceType), false); } //ASSUMPTION: if the members input panel is disabled, assume that this is the default group and //check all the checkboxes. This is purely cosmetic. if (!m_ui.MembersInputPanelEnabled) { Dictionary<string, bool> copyOfDictionary = new Dictionary<string, bool>(deviceTypesDictionary); foreach (string deviceType in copyOfDictionary.Keys) { deviceTypesDictionary[deviceType] = true; } } else { //now, check those that are currently members foreach (IRoutingItem routingItem in routingItemCollection) { string contentType = CustomAttributes.GetContentType(routingItem); if (0 == String.Compare(contentType, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.DeviceType, false, CultureInfo.InvariantCulture)) { try { string displayableSelectedDeviceType = displayTranslator.GetDisplayType(routingItem.Content); if (deviceTypesDictionary.ContainsKey(displayableSelectedDeviceType)) { deviceTypesDictionary[displayableSelectedDeviceType] = true; } } catch (ArgumentException ex) { ErrorMessage errorMessage = new ErrorMessage( "DEVICETYPE_UNKNOWN", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); Logger.LogError(ex); } catch (KeyNotFoundException ex) { ErrorMessage errorMessage = new ErrorMessage( "DEVICETYPE_UNKNOWN", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); Logger.LogError(ex); } } else if (0 == String.Compare(contentType, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.VolumeName, false, CultureInfo.InvariantCulture)) { if (volumeNames.Length == 0) { volumeNames.AppendFormat(routingItem.Content); } else { volumeNames.AppendFormat("; {0}", routingItem.Content); } } else if (0 == String.Compare(contentType, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.VolumeID, false, CultureInfo.InvariantCulture)) { if (volumeIDs.Length == 0) { volumeIDs.AppendFormat(routingItem.Content); } else { volumeIDs.AppendFormat("; {0}", routingItem.Content); } } else { string message = String.Format(CultureInfo.InvariantCulture, Properties.Resources.ROUTINGITEMTYPE_UNKNOWN, routingItem.Content); Logger.LogError(message); } } } //finally, update the ui CheckedListBox.ObjectCollection deviceTypes = m_ui.DeviceTypes; deviceTypes.Clear(); foreach (string key in deviceTypesDictionary.Keys) { deviceTypes.Add(key, deviceTypesDictionary[key]); } m_ui.VolumeName = volumeNames.ToString(); m_ui.VolumeID = volumeIDs.ToString(); }
public ActionMatrixCell(IRoutingItemCollection senders, IRoutingItemCollection recipients) : base(senders,recipients) { }
private void WriteRoutingItemCollection(XmlNode addressGroupNode, IRoutingItemCollection routingItemCollection) { XmlNode xmlRoutingItemCollectionNode = m_xmlDocument.CreateElement("RoutingItemCollection"); addressGroupNode.AppendChild(xmlRoutingItemCollectionNode); XmlHelpers.AddIdAttribute(xmlRoutingItemCollectionNode, routingItemCollection); XmlHelpers.AddReadOnlyAttribute(xmlRoutingItemCollectionNode, routingItemCollection.ReadOnly); // Need to dump the data to the catalogue as well... m_policyCatalogueWriter.WriteLocationCollection(routingItemCollection); foreach (IRoutingItem routingItem in routingItemCollection) { m_policyCatalogueWriter.WriteLocation(routingItem); } }
public MatrixCellBase(MatrixCellBase rhs) : base(rhs) { m_sources = rhs.m_sources; m_destinations = rhs.m_destinations; }
public void RetrieveServerProperties(IRoutingItemCollection routingItems) { DirectoryAnalyzer analyzer = CurrentDirectoryAnalyzer; if (analyzer == null) { // should never happen (controller only retrieves properties when server is changed) return; } LdapServerInformation info = analyzer.CreationInfo; SetPropertyIfNotNullOrEmpty(routingItems, LDAPRouter.SERVERNAMEPROPERTY, info.ServerName); SetPropertyIfNotNullOrEmpty(routingItems, LDAPRouter.CONTEXTPROPERTY, info.Context); SetPropertyIfNotNullOrEmpty(routingItems, LDAPRouter.PORTPROPERTY, info.Port.ToString(CultureInfo.InvariantCulture)); SetPropertyIfNotNullOrEmpty(routingItems, LDAPRouter.USERNAMEPROPERTY, info.UserName); SetPropertyIfNotNullOrEmpty(routingItems, LDAPRouter.PASSWORDPROPERTY, info.Password); }
public MatrixCellBase(MatrixCellBase rhs, bool readOnly, bool createNewId, IRoutingItemCollection sources, IRoutingItemCollection destinations) : base(rhs, readOnly, createNewId) { m_sources = sources; m_destinations = destinations; }
private void SetRoutingItemCollection(IRoutingItemCollection routingItemCollection) { m_routingItems = routingItemCollection; StringBuilder sb = new StringBuilder(); foreach (IRoutingItem routingItem in routingItemCollection) { sb.AppendFormat("{0};", routingItem.Content); } m_ui.GroupMembers = sb.ToString(); }
public static void AddCellToActionMatrix(IActionMatrix actionMatrix, IRoutingItemCollection senderAddressCollection, IRoutingItemCollection recipientAddressCollection) { if (!actionMatrix.HasCell(senderAddressCollection, recipientAddressCollection)) { actionMatrix[senderAddressCollection, recipientAddressCollection] = ActionMatrixCellFactory(senderAddressCollection, recipientAddressCollection); } }
public void Initialise(IRoutingItemCollection routingItemCollection) { if (null == routingItemCollection) { Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage("UI_CONTROLLER_UNINITIALIZED", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); throw new NullReferenceException(errorMessage.DisplayString); } m_ui.SearchTerms = string.Empty; m_ui.SearchResults.Clear(); SetRoutingItemCollection(routingItemCollection); m_ui.Initialise(routingItemCollection); }
public static IActionMatrixCell ActionMatrixCellFactory(IRoutingItemCollection senderAddressCollection, IRoutingItemCollection recipientAddressCollection) { ActionMatrixCell amc = new ActionMatrixCell(senderAddressCollection, recipientAddressCollection); amc.ActionConditionGroups.Add(ActionConditionGroupFactory()); return amc; }
public static void AddCollectionToAddressGroup(IRoutingTable routingTable, IRoutingItemCollections addressGroup, IRoutingItemCollection addressCollection) { if (null == routingTable) { Debug.Assert(false); return; } bool isSender = Object.ReferenceEquals(routingTable.Sources, addressGroup); bool isDestination = Object.ReferenceEquals(routingTable.Destinations, addressGroup); if (!isSender && !isDestination) { // group is neither sources nor destinations Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage( "ADDRESSGROUPTYPE_INVALID", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); throw new ArgumentException(errorMessage.DisplayString); } if (!CanEditRoutingItemCollections(routingTable, isSender)) { return; } if (isSender) { // Adding location collection to sources group routingTable.Sources.Add(addressCollection); foreach (IRoutingItemCollection recipients in routingTable.Destinations) { IRoutingMatrixCell routingMatrixCell = routingTable[addressCollection.Identifier, recipients.Identifier]; routingMatrixCell.Name = new NonTranslateableLanguageItem(addressCollection.Name.Value + Properties.Resources.ROUTING_TO_LOWER + recipients.Name.Value); } if (2 == routingTable.Sources.Count) { IRoutingItemCollection defaultSenders = routingTable.DefaultSource; defaultSenders.Name.Value = Properties.Resources.ROUTING_EVERYONEELSE; } } else { // Adding location collection to destinations group routingTable.Destinations.Add(addressCollection); foreach (IRoutingItemCollection senders in routingTable.Sources) { IRoutingMatrixCell routingMatrixCell = routingTable[senders.Identifier, addressCollection.Identifier]; if (senders == routingTable.DefaultSource) { routingMatrixCell.Name = new NonTranslateableLanguageItem(Properties.Resources.ROUTING_TO + addressCollection.Name.Value); } else { routingMatrixCell.Name = new NonTranslateableLanguageItem(senders.Name.Value + Properties.Resources.ROUTING_TO_LOWER + addressCollection.Name.Value); } } if (2 == routingTable.Destinations.Count) { IRoutingItemCollection defaultRecipients = routingTable.DefaultDestination; defaultRecipients.Name.Value = Properties.Resources.ROUTING_EVERYONEELSE; } } RefreshRoutingMatrixTablePrecedences(routingTable); }
public static void SetRouterProperties(IRoutingTable routingTable, IRoutingItemCollection routingItems, bool isSourceRoutingItemCollection) { switch (routingTable.Type) { case ChannelType.SMTP: if (IsInternalExternalRoutingTable(routingTable)) { CustomAttributes.SetAssembly(routingItems, INTEXT_ROUTER_ASSEMBLY); CustomAttributes.SetClass(routingItems,INTEXT_ROUTER_CLASS); } else { CustomAttributes.SetAssembly(routingItems, LDAP_ROUTER_ASSEMBLY); CustomAttributes.SetClass(routingItems, LDAP_ROUTER_CLASS); SetDefaultLdapContext(routingItems); } break; case ChannelType.RemoveableDevice: if (isSourceRoutingItemCollection) { CustomAttributes.SetAssembly(routingItems, LDAP_ROUTER_ASSEMBLY); CustomAttributes.SetClass(routingItems, LDAP_ROUTER_CLASS); SetDefaultLdapContext(routingItems); } else { CustomAttributes.SetAssembly(routingItems, DEVICE_ROUTER_ASSEMBLY); CustomAttributes.SetClass(routingItems, DEVICE_ROUTER_CLASS); } break; case ChannelType.Mta: CustomAttributes.SetAssembly(routingItems, DEVICE_ROUTER_ASSEMBLY); CustomAttributes.SetClass(routingItems, MTA_ROUTER_CLASS); break; case ChannelType.Default: case ChannelType.HTTP: case ChannelType.ActiveContent: case ChannelType.IM: CustomAttributes.SetAssembly(routingItems, string.Empty); CustomAttributes.SetClass(routingItems, string.Empty); break; default: string message = Utilities.CultureSpecificString.InvariantResourceString("ROUTERTYPE_UNKNOWN", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(message); CustomAttributes.SetAssembly(routingItems, string.Empty); CustomAttributes.SetClass(routingItems, string.Empty); break; } }
private void WriteAssemblyInformation(XmlNode xmlLocationCollectionNode, IRoutingItemCollection locationCollection) { if (null == locationCollection) return; string propertyName = "DefaultGroup"; Dictionary<string, IPolicyLanguageItem>.Enumerator attributeEnumerator = (locationCollection as IPolicyObject).GetAttributeEnumerator(); while (attributeEnumerator.MoveNext()) { KeyValuePair<string, IPolicyLanguageItem> property = attributeEnumerator.Current; if (0 != string.Compare(propertyName, property.Key, true, CultureInfo.InvariantCulture)) continue; IPolicyLanguageItem defaultGroupProperty = property.Value; if ((null != defaultGroupProperty) && (!string.IsNullOrEmpty(defaultGroupProperty.Value)) && !System.Convert.ToBoolean(defaultGroupProperty.Value, System.Globalization.CultureInfo.InvariantCulture)) { XmlHelpers.AddAttribute(xmlLocationCollectionNode, "assembly", locationCollection.Assembly.Assembly); XmlHelpers.AddAttribute(xmlLocationCollectionNode, "class", locationCollection.Assembly.Class); return; } } }
private static IRoutingMatrixCell RoutingMatrixCellFactory(IRoutingItemCollection senderCollection, IRoutingItemCollection recipientCollection) { string name = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", senderCollection.Name, recipientCollection.Name); string description = name; return new RoutingMatrixCell(new TranslateableLanguageItem(name), new TranslateableLanguageItem(description), new NonTranslateableLanguageItem("green"), -1, senderCollection, recipientCollection); }
public RoutingMatrixCell(IPolicyLanguageItem name, IPolicyLanguageItem description, IPolicyLanguageItem color, int precedence, bool readOnly, IRoutingItemCollection senders, IRoutingItemCollection recipients) : base(Guid.Empty, name, readOnly, senders, recipients) { SetDefaults(description, color, precedence); }
/// <summary> /// Setup constructor /// </summary> public RoutingPropertyControls(DataCache cache, Control owner, Rectangle gridRect, IRoutingItemCollection sender, IRoutingItemCollection receiver, ICollection<Control> controls, IRoutingMatrixCell cell, bool policyAudits) { m_Sender = sender; m_Receiver = receiver; }
/// <summary> /// Removes an RoutingItemCollection from a policy set's master catalogue /// </summary> /// <param name="policySet">The policy set from whose catalogue we will remove the RoutingItemCollection</param> /// <param name="locationCollection">The RoutingItemCollection to remove</param> private static void RemoveAddressCollection(IPolicySet policySet, IRoutingItemCollection addressCollection) { if (null == policySet || null == addressCollection) { return; } foreach (IRoutingItem address in addressCollection) { RemoveAddress(policySet, address); } policySet.MasterCatalogue.LocationsCollection.Remove(addressCollection); }