Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        public static void BuildMatrixCells(List<string[]> cellsData, RoutingTable routingTable, IRoutingItemCollections senders, IRoutingItemCollections recipients)
        {
            IRoutingItemCollection sender = new RoutingItemCollection(Guid.NewGuid(), "");
            IRoutingItemCollection recipient = new RoutingItemCollection(Guid.NewGuid(), "");

            // There is a cell for each intersection of sources and destinations
            // This method assumes that the cell data collection is of the correct size
            int i = 0;
            foreach (IRoutingItemCollection senderCollection in senders)
            {
                foreach (IRoutingItemCollection recipientCollection in recipients)
                {
                    IRoutingMatrixCell cell = new RoutingMatrixCell(new TranslateableLanguageItem(cellsData[i][0]), new TranslateableLanguageItem(cellsData[i][1]), new TranslateableLanguageItem(cellsData[i][2]), Convert.ToInt32(cellsData[i][3]), sender, recipient);
                    routingTable[senderCollection, recipientCollection] = cell;
                    i++;
                }
            }
        }
Ejemplo n.º 5
0
        public static void BuildActionMatrix(IPolicy policy, ActionMatrix actionMatrix, ActionGroup actionGroup, IRoutingItemCollections senders, IRoutingItemCollections recipients)
        {
            ConditionGroup conditionGroup = new ConditionGroup(new Guid("{661EDD6F-D750-493A-9932-E56C8C22E2CF}"), new TranslateableLanguageItem("Test condition group"), ConditionLogic.AND, false);
            policy.Conditions.Add(conditionGroup);

            // Just fill out each cell with the same condition group for now...
            int i = 0;
            foreach (IRoutingItemCollection senderCollection in senders)
            {
                foreach (IRoutingItemCollection recipientCollection in recipients)
                {
                    ActionMatrixCell cell = new ActionMatrixCell(senderCollection, recipientCollection);
                    cell.AddActionCondition(conditionGroup, actionGroup, false);
                    actionMatrix[senderCollection, recipientCollection] = cell;
                    i++;
                }
            }

        }
Ejemplo n.º 6
0
        private void WriteRoutingItems(string routingItemCollectionsNodeName, XmlNode xmlRoutingNode, IRoutingItemCollections routingItemCollections)
        {
            XmlNode routingItemCollectionsNode = m_xmlDocument.CreateElement(routingItemCollectionsNodeName);
            xmlRoutingNode.AppendChild(routingItemCollectionsNode);

            XmlHelpers.AddReadOnlyAttribute(routingItemCollectionsNode, routingItemCollections.ReadOnly);

            foreach (IRoutingItemCollection routingItemCollection in routingItemCollections)
            {
                WriteRoutingItemCollection(routingItemCollectionsNode, routingItemCollection);
            }
        }
Ejemplo n.º 7
0
 public RoutingMatrixEventArgs(IPolicyChannel channel, IRoutingItemCollections addressGroup, IRoutingItemCollection addressCollection)
 {
     m_channel = channel;
     m_addressGroup = addressGroup;
     m_addressCollection = addressCollection;
 }
Ejemplo n.º 8
0
 private void WriteDestinations(XmlNode xmlRoutingNode, IRoutingItemCollections destinations)
 {
     WriteRoutingItems("Destinations", xmlRoutingNode, destinations);
 }
Ejemplo n.º 9
0
 private void WriteSources(XmlNode xmlRoutingNode, IRoutingItemCollections sources)
 {
     WriteRoutingItems("Sources", xmlRoutingNode, sources);
 }
Ejemplo n.º 10
0
        private void AppendNonDefaultRoutingItems(NxAnd and, string lookupId, IRoutingItemCollections routingItems)
        {
            foreach (IRoutingItemCollection routingItem in routingItems)
            {
                if ("true" == routingItem["DefaultGroup"].Value.ToLower(CultureInfo.InvariantCulture))
                    continue;

                string objectId = GetRoutingItemCollectionObjectId(routingItem);

                string isNotMemberOfGroupId = CreateIsThingNotMemberOfGroupLookupIfNecessary(objectId, lookupId, routingItem.Identifier.ToString());
                string isRouterEnabledId = CreateIsRouterEnabledIfNecessary(objectId);

                NxIsTrue isTrueRoutingItemNotMember = new NxIsTrue(isNotMemberOfGroupId);
                NxIsTrue isRouterEnabled = new NxIsTrue(isRouterEnabledId);
                and.Append(isTrueRoutingItemNotMember);
                and.Append(isRouterEnabled);
            }
        }
Ejemplo n.º 11
0
        public void Initialise(IRoutingTable routingTable, IRoutingItemCollection routingItemCollection, bool bExistingCollection, IRoutingItemCollections matrixAxisNeighbours)
        {
            m_routingTableIn = routingTable;
            m_originalRoutingItemCollection = routingItemCollection;
            m_matrixAxisNeighbours = matrixAxisNeighbours;
            m_originalRoutingDetailName = bExistingCollection ? m_originalRoutingItemCollection.Name.Value : String.Empty;

            InitialiseRoutingDetailContextPanel();
            EnableDisableControls();

            m_currentContextSpecificRoutingDetailController.Initialise(m_originalRoutingItemCollection);
        }
Ejemplo n.º 12
0
        private IRoutingItemCollections ReadAddressGroup(XmlNodeList addressCollectionIdNode, IRoutingItemCollections entireAddressGroup, bool routingTableReadOnly)
        {
            bool addressCollectionsReadOnly = false;
            
            if (addressCollectionIdNode.Count > 0)
            {
                XmlNode node = addressCollectionIdNode[0].ParentNode;
                addressCollectionsReadOnly = PolicyUtilities.IsReadOnly(node);
            }

            IRoutingItemCollections addressGroup = new RoutingItemCollections(Guid.Empty, "", routingTableReadOnly || addressCollectionsReadOnly);

            List<string> exclusions = new List<string>();
            exclusions.Add("id");
            exclusions.Add("readonly");             
            
            foreach (XmlNode addressIdNode in addressCollectionIdNode)
            {                
                string addressId = addressIdNode.Attributes.GetNamedItem("id").InnerText;
                bool readOnly = PolicyUtilities.IsReadOnly(addressIdNode);
                RoutingItemCollection currentCollection = entireAddressGroup[new Guid(addressId)] as RoutingItemCollection;

                if (currentCollection != null)
                {
                    RoutingItemCollection copiedCollection = new RoutingItemCollection(currentCollection, readOnly, false);
                    new XmlCustomAttributesReader(copiedCollection, addressIdNode.Attributes, exclusions).Read();
                    addressGroup.Add(copiedCollection);
                }
            }

            return addressGroup;
        }