public NodeServer(NodeInfo nodeInfo, IRoutingTable routingTable, INodeServerClientFactory clientFactory) { this.nodeInfo = nodeInfo ?? throw new ArgumentNullException(); this.routingTable = routingTable ?? throw new ArgumentNullException(); this.clientFactory = clientFactory ?? throw new ArgumentNullException(); this.localClient = clientFactory.CreateLocalClient(); }
private async Task UpdateAsync(IRoutingTable newRoutingTable) { IRoutingTable UpdateRoutingTable(IRoutingTable oldTable, IRoutingTable newTable, out IEnumerable <Uri> added, out IEnumerable <Uri> removed) { var allNew = newTable.All().ToArray(); var allKnown = oldTable == null?Array.Empty <Uri>() : oldTable.All().ToArray(); added = allNew.Except(allKnown); removed = allKnown.Except(allNew); return(newTable); } IEnumerable <Uri> addedServers = null, removedServers = null; _routingTables.AddOrUpdate(newRoutingTable.Database, _ => UpdateRoutingTable(null, newRoutingTable, out addedServers, out removedServers), (_, oldTable) => UpdateRoutingTable(oldTable, newRoutingTable, out addedServers, out removedServers)); await _poolManager.UpdateConnectionPoolAsync(addedServers, removedServers).ConfigureAwait(false); PurgeAged(); _logger?.Info("Routing table is updated => {0}", newRoutingTable); }
public static IRoutingTable MapControllers(this IRoutingTable routingTable) { IEnumerable <MethodInfo> controllerActions = GetControllerActions(); foreach (var controllerAction in controllerActions) { string controllerName = controllerAction .DeclaringType .Name .Replace(nameof(Controller), string.Empty); string actionName = controllerAction.Name; string path = $"/{ controllerName}/{ actionName}"; var responseFunction = GetResponseFunction(controllerAction); Method httpMethod = Method.Get; var actionMethodAttribute = controllerAction.GetCustomAttribute <HttpMethodAttribute>(); if (actionMethodAttribute != null) { httpMethod = actionMethodAttribute.HttpMethod; } routingTable.Map(httpMethod, path, responseFunction); } return(routingTable); }
public DefaultDeliveryHandler(IRoutingTable routingTable) { if (routingTable == null) throw new ArgumentNullException("routingTable"); this.routingTable = routingTable; }
public static IRoutingTable MapControllers(this IRoutingTable routingTable) { var controllerActions = GetControllerActions(); foreach (var controllerAction in controllerActions) { var controllerName = controllerAction.DeclaringType.GetControllerName(); var actionName = controllerAction.Name; var path = $"/{controllerName}/{actionName}"; var responseFunction = GetResponseFunction(controllerAction); var httpMethod = HttpMethod.Get; var httpMethodAttribute = controllerAction .GetCustomAttribute <HttpMethodAttribute>(); if (httpMethodAttribute != null) { httpMethod = httpMethodAttribute.HttpMethod; } routingTable.Map(httpMethod, path, responseFunction); MapDefaultRoutes( routingTable, httpMethod, controllerName, actionName, responseFunction); } return(routingTable); }
/// <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 static IRoutingTable MapDelete <ТController>( this IRoutingTable routingTable, string path, Func <ТController, HttpResponse> controlerFunction) where ТController : Controller => routingTable.MapDelete(path, request => controlerFunction(CreateController <ТController>(request)));
public static IRoutingTable MapGet <TController>( this IRoutingTable routingTable, string path, Func <TController, Response> controllerFunction) where TController : Controller => routingTable.MapGet(path, request => controllerFunction( CreateController <TController>(request)));
public void TestRoutingTableGUID() { IRoutingTable <string> routingTable = _erector.Container.Resolve <IRoutingTable <string> >(); string routingTableGUID = routingTable.RoutingTableGUID; Assert.IsFalse(String.IsNullOrEmpty(routingTableGUID)); }
public void RoutingServiceCompositionRoute(IRoutingService <string> routingService, ISkyWatch skyWatch) { IMessageBus <string> messageBus = _erector.Container.Resolve <IMessageBus <string> >(); messageBus.JsonSchema = (message) => { IEnvelope envelope = _marshaller.UnMarshall <IEnvelope>(message); string serviceName = envelope.ServiceRoute.Split('.')[1]; if (serviceName == ChatServiceNames.ModifyChatMessageService || serviceName == ChatServiceNames.GetNextChatMessageService) { return(_erector.Container.Resolve <IChatMessageEnvelope>().GetMyJSONSchema()); } else { return(String.Empty); } }; IMessageBusReaderBank <string> messageBusReaderBank = _erector.Container.Resolve <IMessageBusReaderBank <string> >(); messageBusReaderBank.SpecifyTheMessageBus(messageBus); IRoutingTable <string> routingTable = _erector.Container.Resolve <IRoutingTable <string> >(); routingTable.MessageBusBank = _messageBusBankRouters; routingService.RoutingTable = routingTable; routingService.MessageBusReaderBank = messageBusReaderBank; //NOTE: Set up two readers routingService.InitializeReaders(2); _messageBusBankRouters.RegisterMessageBus(routingService.RoutingServiceGUID, messageBus); _serviceList.Add(routingService); }
public DefaultRepository(IRoutingTable routes, HydratableGraveyard graveyard) { graveyard = graveyard ?? new HydratableGraveyard(); this.catalog[graveyard.Key] = this.graveyard = graveyard; this.routes = routes; }
public static IRoutingTable MapGet <TController>(this IRoutingTable routingTable, string path, Func <TController, HttpResponse> controllerFunction) where TController : Controller => routingTable.MapGet(path, request => { var controller = CreateController <TController>(request); return(controllerFunction(controller)); });
public override async Task Process(Controller controller) { var protocolDriver = (NewDriver)ObjManager.GetObject(data.driverId); var driver = (Neo4j.Driver.Internal.Driver)protocolDriver.Driver; RoutingTable = driver.GetRoutingTable(data.database); await Task.CompletedTask; }
internal async Task <IRoutingTable> UpdateRoutingTableAsync(IRoutingTable routingTable, AccessMode mode, string database, Bookmark bookmark, ISet <Uri> triedUris = null) { if (database == null) { throw new ArgumentNullException(nameof(database)); } var knownRouters = routingTable?.Routers ?? throw new ArgumentNullException(nameof(routingTable)); foreach (var router in knownRouters) { triedUris?.Add(router); try { var conn = await _poolManager.CreateClusterConnectionAsync(router).ConfigureAwait(false); if (conn == null) { routingTable.Remove(router); } else { var newRoutingTable = await _discovery.DiscoverAsync(conn, database, bookmark).ConfigureAwait(false); if (!newRoutingTable.IsStale(mode)) { return(newRoutingTable); } _logger?.Debug("Skipping stale routing table received from server '{0}' for database '{1}'", router, database); } } catch (SecurityException e) { _logger?.Error(e, "Failed to update routing table from server '{0}' for database '{1}' because of a security exception.", router, database); throw; } catch (FatalDiscoveryException e) { _logger?.Error(e, "Failed to update routing table from server '{0}' for database '{1}' because of a fatal discovery exception.", router, database); throw; } catch (Exception e) { _logger?.Warn(e, "Failed to update routing table from server '{0}' for database '{1}'.", router, database); } } return(null); }
// for test only internal LoadBalancer( IClusterConnectionPool clusterConnPool, IRoutingTable routingTable, Uri seed = null) { _clusterConnectionPool = clusterConnPool; _routingTable = routingTable; _seed = seed; }
public static void Add <TContainer, TMessage>( this IRoutingTable table, Func <TContainer, IMessageHandler <TMessage> > callback, int sequence = int.MaxValue, Type handlerType = null) where TContainer : class { table.Add(x => callback(x.CurrentResolver.As <TContainer>()), sequence, handlerType); }
public DefaultDeliveryHandler(IRoutingTable routingTable) { if (routingTable == null) { throw new ArgumentNullException("routingTable"); } this.routingTable = routingTable; }
public HttpServer(string address, int port, Action <IRoutingTable> routingTableConfiguration) { this.ipAddress = IPAddress.Parse(address); this.port = port; this.tcpListener = new TcpListener(this.ipAddress, port); this.routingTable = new RoutingTable(); routingTableConfiguration(this.routingTable); }
public virtual IMessagingHost StartWithReceive(IRoutingTable table, Func<IHandlerContext, IMessageHandler<ChannelMessage>> handler = null) { Log.Info("Starting host in full-duplex mode."); table.Add(handler ?? (context => new DefaultChannelMessageHandler(context, table))); var host = this.StartHost(); host.BeginReceive(this.BuildDeliveryChain(table).Handle); return host; }
private HttpServer(string ipAddress, int port, IRoutingTable routingTable) { this.ipAddress = IPAddress.Parse(ipAddress); this.port = port; this.listener = new TcpListener(this.ipAddress, port); this.routingTable = (RoutingTable)routingTable; this.serviceCollection = new ServiceCollection(); }
public virtual IMessagingHost StartWithReceive(IRoutingTable table, Func <IHandlerContext, IMessageHandler <ChannelMessage> > handler = null) { Log.Info("Starting host in full-duplex mode."); table.Add(handler ?? (context => new DefaultChannelMessageHandler(context, table)), 0, typeof(DefaultChannelMessageHandler)); var host = this.StartHost(); host.BeginReceive(this.BuildDeliveryChain(table).Handle); return(host); }
public static IRoutingTable MapPost <TController>( this IRoutingTable routingTable, string path, Func <TController, HttpResponse> controllerFunction) where TController : Controller { return(routingTable.MapPost(path, request => { return controllerFunction(CreateController <TController>(request)); })); }
internal static RoutingTableManager NewRoutingTableManager( IRoutingTable routingTable, IClusterConnectionPoolManager poolManager) { var seedUri = new Uri("bolt+routing://neo4j.com:6060"); return(new RoutingTableManager( routingTable, new RoutingSettings(seedUri, new Dictionary <string, string>(), Config.DefaultConfig), poolManager, null)); }
public NodeServer(NodeInfo nodeInfo, IRoutingTable routingTable, INodeServerClientFactory clientFactory) { Throw.IfNull(nodeInfo, nameof(nodeInfo)); Throw.IfNull(routingTable, nameof(routingTable)); Throw.IfNull(clientFactory, nameof(clientFactory)); this.nodeInfo = nodeInfo; this.routingTable = routingTable; this.clientFactory = clientFactory; this.localClient = clientFactory.CreateLocalClient(); }
internal static RoutingTableManager NewRoutingTableManager( IRoutingTable routingTable, IClusterConnectionPoolManager poolManager, IInitialServerAddressProvider addressProvider = null) { if (addressProvider == null) { addressProvider = new InitialServerAddressProvider(InitialUri, new PassThroughServerAddressResolver()); } return(new RoutingTableManager(addressProvider, new Dictionary <string, string>(), routingTable, poolManager, null)); }
protected virtual IDeliveryHandler BuildDeliveryChain(IRoutingTable table) { IDeliveryHandler handler = new DefaultDeliveryHandler(table); if (this.handlerCallback != null) handler = this.handlerCallback(handler) ?? handler; if (this.transactionScope) handler = new TransactionScopeDeliveryHandler(handler); return new TransactionalDeliveryHandler(handler); }
public RoutingTableManager( IInitialServerAddressProvider initialServerAddressProvider, IDiscovery discovery, IRoutingTable routingTable, IClusterConnectionPoolManager poolManager, IDriverLogger logger) { _initialServerAddressProvider = initialServerAddressProvider; _discovery = discovery; _routingTable = routingTable; _poolManager = poolManager; _logger = logger; }
public RoutingTableManager( IInitialServerAddressProvider initialServerAddressProvider, IDictionary <string, string> routingContext, IRoutingTable routingTable, IClusterConnectionPoolManager poolManager, IDriverLogger logger) { _initialServerAddressProvider = initialServerAddressProvider; _routingContext = routingContext; _routingTable = routingTable; _poolManager = poolManager; _logger = logger; }
internal void Update(IRoutingTable newTable) { var added = newTable.All(); added.ExceptWith(_routingTable.All()); var removed = _routingTable.All(); removed.ExceptWith(newTable.All()); _poolManager.UpdateConnectionPool(added, removed); _routingTable = newTable; _logger?.Info("Updated routingTable to be {0}", _routingTable); }
private static void MapDefaultRoutes(IRoutingTable routingTable, Method httpMethod, string controllerName, string actionName, Func <Request, Response> responseFunction) { const string defaultActionName = "Index"; const string defaultControllerName = "Home"; if (actionName == defaultActionName) { routingTable.Map(httpMethod, $"/{controllerName}", responseFunction); if (controllerName == defaultControllerName) { routingTable.Map(httpMethod, "/", responseFunction); } } }
private void CopyChannel(PolicyChannel rhs, bool readOnly, bool createNewId) { m_policySetObserver = rhs.m_policySetObserver; if (null != rhs.Routing) { m_routing = RoutingTableFactory.Instance.Copy(rhs.Routing, readOnly, createNewId); SetRoutingTableObserver(); } if (null != rhs.Actions) { m_actions = (rhs.Actions as ActionMatrix).DeepCopy(readOnly, createNewId) as IActionMatrix; SetActionMatrixObserver(); } }
private void EnsureRoutingTableForMode(AccessMode mode) { lock (_syncLock) { if (!IsRoutingTableStale(_routingTable, mode)) { return; } var routingTable = UpdateRoutingTableWithInitialUriFallback(); _clusterConnectionPool.Update(routingTable.All()); _routingTable = routingTable; _logger?.Info($"Updated routingTable to be {_routingTable}"); } }
public DefaultChannelMessageHandler(IHandlerContext context, IRoutingTable routes) { if (context == null) { throw new ArgumentNullException("context"); } if (routes == null) { throw new ArgumentNullException("routes"); } this.context = context; this.routes = routes; }
internal async Task UpdateAsync(IRoutingTable newTable) { var added = newTable.All(); added.ExceptWith(_routingTable.All()); var removed = _routingTable.All(); removed.ExceptWith(newTable.All()); await _poolManager.UpdateConnectionPoolAsync(added, removed).ConfigureAwait(false); _routingTable = newTable; _logger?.Info("Updated routingTable to be {0}", _routingTable); }
public void TestInit() { // Setup routingTableMockHash var hashGenerator = new Mock <IConsistentHashGenerator>(); hashGenerator .Setup(x => x.Hash(It.IsAny <string>())) .Returns(() => { return((UInt32)random.Next()); }); this.routingTableMockHash = new RoutingTable(hashGenerator.Object); // Setup routingTableRealHash var realHashGenerator = new Sha256HashGenerator(); this.routingTableRealHash = new RoutingTable(realHashGenerator); }
/// <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; } }
public static bool IsInternalExternalRoutingTable(IRoutingTable routingTable) { if (null == routingTable) return false; string propertyName = "resolve"; Dictionary<string, IPolicyLanguageItem>.Enumerator attributeEnumerator = routingTable.GetAttributeEnumerator(); while (attributeEnumerator.MoveNext()) { KeyValuePair<string, IPolicyLanguageItem> property = attributeEnumerator.Current; if (0 == string.Compare(propertyName, property.Key, true, CultureInfo.InvariantCulture)) { return (0 == string.Compare("emailclient", property.Value.Value, true, System.Globalization.CultureInfo.InvariantCulture)); } } return false; }
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; } }
public static RoutingHelper.RoutingType GetRoutingType(IRoutingTable routingTable) { // Only InternalExternal routing tables will have this property populated. if (IsInternalExternalRoutingTable(routingTable)) { return RoutingHelper.RoutingType.InternalExternal; } if (ChannelType.Default == routingTable.Type) { return RoutingHelper.RoutingType.SingleCell; } if (ChannelType.SMTP == routingTable.Type) { return RoutingHelper.RoutingType.Ldap; } if ((ChannelType.HTTP == routingTable.Type) || (ChannelType.ActiveContent == routingTable.Type)) { return RoutingHelper.RoutingType.SingleCell; } if (ChannelType.RemoveableDevice == routingTable.Type) { return RoutingHelper.RoutingType.LdapToDevice; } if (ChannelType.Mta == routingTable.Type) { return RoutingHelper.RoutingType.Mta; } Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage( "ROUTINGTABLETYPE_UNSUPPORTED", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly(), routingTable.ToString()); Logger.LogError(errorMessage.LogString); throw new ArgumentException(errorMessage.DisplayString); }
public static bool CanEditRoutingItemCollections(IRoutingTable routingTable, bool isSender) { if (null == routingTable) { Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage( "PARAMETER_NULL", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); throw new ArgumentException(errorMessage.DisplayString); } RoutingType routingType = GetRoutingType(routingTable); if ((routingType == RoutingType.LdapToDevice /*&& !isSender*/) || (routingType == RoutingType.Ldap)) { return true; } return false; }
public static void RefreshRoutingMatrixTablePrecedences(IRoutingTable routingTable) { IRoutingItemCollection defaultSenderAddressCollection = null; int precedence = 0; foreach (IRoutingItemCollection senderAddressCollection in routingTable.Sources) { if (AddressCollectionHelper.IsDefaultAddressCollection(senderAddressCollection)) { //ensure that we treat the default row as the last row in the routing matrix defaultSenderAddressCollection = senderAddressCollection; continue; } else { RefreshRoutingMatrixTableRowPrecedences(routingTable, senderAddressCollection, routingTable.Destinations, ref precedence); } } if (null != defaultSenderAddressCollection) { RefreshRoutingMatrixTableRowPrecedences(routingTable, defaultSenderAddressCollection, routingTable.Destinations, ref precedence); } }
public void WriteRoutingTable(IRoutingTable routingTable) { if (null == routingTable) return; CollectionInserter<IRoutingTable>.Insert(m_routings, routingTable); }
private void ValidateRoutingTable(IRoutingTable routingTable) { Assert.IsTrue(routingTable.ReadOnly, "Expected the routing table to be read only"); Dictionary<KeyValuePair<Guid, Guid>, IRoutingMatrixCell>.Enumerator enumer = routingTable.GetEnumerator(); //while (enumer.MoveNext()) //{ // Assert.IsTrue(enumer.Current.Value.ReadOnly, "Expected the routing table matrix cell to be read only"); //} Assert.AreEqual(4, routingTable.CellCount, "Expected the routing table matrix to have one cell"); Assert.AreEqual(2, routingTable.Sources.Count, "Expected there to be two sources"); Assert.AreEqual(routingTable.DefaultSource.Identifier, routingTable.Sources[0].Identifier); Assert.AreEqual(routingTable.DefaultDestination.Identifier, routingTable.Destinations[0].Identifier); }
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; } }
/// <summary> /// Determines whether a routing table supports transparent processing /// </summary> /// <param name="routingTable">The routing table to evaluate</param> /// <returns>True if the routing table supports offline actions</returns> public static bool SupportTransparentProcessing(IRoutingTable routingTable) { if ((routingTable.Type == ChannelType.SMTP) || (routingTable.Type == ChannelType.RemoveableDevice)) { return true; } return false; }
/// <summary> /// Gets the type of router object to be used by the policy engine when processing a particular routingItemCollection /// </summary> /// <param name="routingTable">Routing table containing the RoutingItemCollection</param> /// <param name="isSourceRoutingItemCollection">True if requesting the router object for a sender collection</param> /// <param name="routerAssembly">output parameter containing the router assembly</param> /// <param name="routerClass">output parameter containing the router class</param> /// <returns></returns> // NOTE: AP: Use SetRouterProperties() instead. This method has not been marked as [Obsolete()] because it's handy for testing // NOTE: AP: If this method is modified, please remember to update SetRouterProperties() also public static void GetRouterInfo(IRoutingTable routingTable, bool isSourceRoutingItemCollection, out string routerAssembly, out string routerClass) { switch (routingTable.Type) { case ChannelType.SMTP: if (IsInternalExternalRoutingTable(routingTable)) { routerAssembly = INTEXT_ROUTER_ASSEMBLY; routerClass = INTEXT_ROUTER_CLASS; } else { routerAssembly = LDAP_ROUTER_ASSEMBLY; routerClass = LDAP_ROUTER_CLASS; } break; case ChannelType.RemoveableDevice: if (isSourceRoutingItemCollection) { routerAssembly = LDAP_ROUTER_ASSEMBLY; routerClass = LDAP_ROUTER_CLASS; } else { routerAssembly = DEVICE_ROUTER_ASSEMBLY; routerClass = DEVICE_ROUTER_CLASS; } break; case ChannelType.Default: case ChannelType.HTTP: case ChannelType.ActiveContent: case ChannelType.IM: case ChannelType.Mta: routerAssembly = string.Empty; routerClass = string.Empty; break; default: string message = Utilities.CultureSpecificString.InvariantResourceString("ROUTERTYPE_UNKNOWN", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); Logger.LogError(message); routerAssembly = string.Empty; routerClass = string.Empty; break; } }
public void RefreshRoutingTable() { m_singleCelledRoutingTable = null; m_multiCelledRoutingTable = null; addRecipientButton.Enabled = RoutingHelper.CanEditRoutingItemCollections(m_channel.Routing, false); addSenderButton.Enabled = RoutingHelper.CanEditRoutingItemCollections(m_channel.Routing, true); routingTable.Clear(); switch (RoutingHelper.GetRoutingType(m_channel.Routing)) { case RoutingHelper.RoutingType.SingleCell: m_singleCelledRoutingTable = m_channel.Routing; DisplaySingleCellActions(); break; default: m_multiCelledRoutingTable = m_channel.Routing; DisplayMulticellActions(); break; } }
/// <summary> /// Removes a RoutingTable from a policy set's master catalogue /// </summary> /// <param name="policySet">The policy set from whose catalogue we will remove the RoutingTable</param> /// <param name="routingTable">The Routingtable to remove</param> private static void RemoveRoutingTable(IPolicySet policySet, IRoutingTable routingTable) { if (null == policySet || null == routingTable) { return; } IRoutingItemCollections addressGroup = routingTable.Sources; foreach (IRoutingItemCollection addressCollection in addressGroup) { RemoveAddressCollection(policySet, addressCollection); } addressGroup = routingTable.Destinations; foreach (IRoutingItemCollection addressCollection in addressGroup) { RemoveAddressCollection(policySet, addressCollection); } policySet.MasterCatalogue.RoutingTables.Remove(routingTable); }
private DataTable BuildRoutingTable(IRoutingTable tableData) { DataTable table = CreateEmptyRoutingTable(); //add Senders column { DataColumn column = new DataColumn("Senders", Type.GetType("PolicyDesigner.MatrixCellControl")); table.Columns.Add(column); } //add Recipients columns foreach (IAddressCollection recipientCollection in tableData.Recipients) { DataColumn column = new DataColumn(recipientCollection.Name, Type.GetType("PolicyDesigner.MatrixCellControl")); table.Columns.Add(column); } //add "New" column { DataColumn column = new DataColumn("AddRecipient", Type.GetType("PolicyDesigner.MatrixControlCellControl")); table.Columns.Add(column); } //populate column header cells DataRow headerRow = table.NewRow(); foreach (DataColumn column in table.Columns) { if (String.Compare("Senders", column.ColumnName) == 0) { headerRow[column.ColumnName] = new MatrixCellControl(); } else if (String.Compare("AddRecipient", column.ColumnName) == 0) { headerRow[column.ColumnName] = new MatrixControlCellControl("Add Recipient Group"); } else { MatrixHeaderCellControl control = new MatrixHeaderCellControl(column.ColumnName); headerRow[column.ColumnName] = control; control.OnLinkLabelClicked += new MatrixHeaderCellControl.OnLinkLabelClickedHandler(control_OnLinkLabelClicked); } } table.Rows.Add(headerRow); //populate rows foreach (IAddressCollection senderCollection in tableData.Senders) { DataRow row = table.NewRow(); for (int i = 0; i < table.Columns.Count; i++) { if (i == 0) { MatrixHeaderCellControl control = new MatrixHeaderCellControl(senderCollection.Name); row[0] = control; control.OnLinkLabelClicked += new MatrixHeaderCellControl.OnLinkLabelClickedHandler(control_OnLinkLabelClicked); } else if (i == table.Columns.Count - 1) { row[i] = new MatrixControlCellControl(""); } else { MatrixContentCellControl control = new MatrixContentCellControl(null); row[i] = control; control.OnContentCellClicked += new MatrixContentCellControl.OnContentCellClickedHandler(control_OnContentCellClicked); } } table.Rows.Add(row); } //populate "New" row { DataRow row = table.NewRow(); for (int i = 0; i < table.Columns.Count; i++) { if (i == 0) { row[0] = new MatrixControlCellControl("Add Sender Group"); } else { row[i] = new MatrixControlCellControl(""); } } table.Rows.Add(row); } return table; }
private void AddNonDefaultPrecedences(SortedList<int, NxElement> precedences, IRoutingTable routing) { foreach (IRoutingItemCollection source in routing.Sources) { if ("true" == source["DefaultGroup"].Value.ToLower(CultureInfo.InvariantCulture)) continue; foreach (IRoutingItemCollection destination in routing.Destinations) { if ("true" == destination["DefaultGroup"].Value.ToLower(CultureInfo.InvariantCulture)) continue; string destinationObjectId = GetRoutingItemCollectionObjectId(destination); string sourceObjectId = GetRoutingItemCollectionObjectId(source); string trustedSourceLookup = CreateIsThingMemberOfGroupLookupIfNecessary(sourceObjectId, m_currentUserId, source.Identifier.ToString()); string trustedDestinationLookup = CreateIsThingMemberOfGroupLookupIfNecessary(destinationObjectId, m_destinationListId, destination.Identifier.ToString()); string isSourceEnabledLookup = CreateIsRouterEnabledIfNecessary(sourceObjectId); string isDestinationEnabledLookup = CreateIsRouterEnabledIfNecessary(destinationObjectId); string sourceId = source.Identifier.ToString(); string destinationId = destination.Identifier.ToString(); if (m_policyChannel.Routing == null) continue; // No routing IRoutingMatrixCell routingMatrixCell = routing[sourceId, destinationId]; if (m_policyChannel.Actions == null) continue; // No actions IActionMatrixCell actionMatrixCell = m_policyChannel.Actions[sourceId, destinationId]; if (routingMatrixCell == null) continue; // No routing for source/destination NxIsTrue isTrueTrustedSource = new NxIsTrue(trustedSourceLookup); NxIsTrue isTrueTrustedDestination = new NxIsTrue(trustedDestinationLookup); NxIsTrue isTrueSourceEnabled = new NxIsTrue(isSourceEnabledLookup); NxIsTrue isTrueDestinationEnabled = new NxIsTrue(isDestinationEnabledLookup); NxAnd and = new NxAnd(); and.Append(isTrueSourceEnabled); if (isDestinationEnabledLookup != isSourceEnabledLookup) { and.Append(isTrueDestinationEnabled); } and.Append(isTrueTrustedSource); and.Append(isTrueTrustedDestination); NxControl condStatement = CreateConditionalStatement(routingMatrixCell.Precedence); condStatement.Append(and); NxDo routingDo = new NxDo(); AddActionSetsForRoutingMatrixCell(routingDo, routingMatrixCell, actionMatrixCell); condStatement.Append(routingDo); precedences.Add(routingMatrixCell.Precedence, condStatement); } } }
public XmlPolicyRoutingsWriter(XmlNode xmlParentNode, XmlPolicyCatalogueWriter policyCatalogueWriter, IRoutingTable routingTable) : base(xmlParentNode, policyCatalogueWriter) { m_routingTable = routingTable; }
/// <summary> /// Determines whether a routing table supports offline actions /// </summary> /// <param name="routingTable">The routing table to evaluate</param> /// <returns>True if the routing table supports offline actions</returns> public static bool SupportsOfflineActions(IRoutingTable routingTable) { if (routingTable.Type == ChannelType.HTTP) { return true; } if (routingTable.Type == ChannelType.SMTP) { return (RoutingType.Ldap == GetRoutingType(routingTable)); } return false; }
private void AddMatrixCells(XmlNodeList cellNodes, IRoutingTable routingTable) { List<string> exclusions = new List<string>(); exclusions.Add("name"); exclusions.Add("description"); exclusions.Add("color"); exclusions.Add("precedence"); exclusions.Add("readonly"); foreach (XmlNode cellNode in cellNodes) { string senderId = cellNode.Attributes.GetNamedItem("SenderAddressCollectionId").InnerText; string recipientId = cellNode.Attributes.GetNamedItem("RecipientAddressCollectionId").InnerText; string name = cellNode.Attributes.GetNamedItem("name").InnerText; string description = cellNode.Attributes.GetNamedItem("description").InnerText; string color = cellNode.Attributes.GetNamedItem("color").InnerText; string precedence = cellNode.Attributes.GetNamedItem("precedence").InnerText; bool readOnly = PolicyUtilities.IsReadOnly(cellNode); IRoutingMatrixCell matrixCell = new RoutingMatrixCell(name, description, color, Convert.ToInt32(precedence), routingTable.ReadOnly || readOnly); new XmlCustomAttributesReader(matrixCell, cellNode.Attributes, exclusions).Read(); routingTable[senderId, recipientId] = matrixCell; } }
/// <summary> /// Determines whether a routing table supports exception actions /// </summary> /// <param name="routingTable">The routing table to evaluate</param> /// <returns>True if the routing table supports exception actions</returns> public static bool SupportsExceptionActions(IRoutingTable routingTable) { if ((routingTable.Type == ChannelType.ActiveContent) || (routingTable.Type == ChannelType.HTTP)) { return false; } return true; }
protected static void TryBuild(IHandlerContext context, IRoutingTable routes) { Try(() => handler = new DefaultChannelMessageHandler(context, routes)); }
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); }
private void AddMatrixCells(XmlNodeList cellNodes, IRoutingTable routingTable, bool cellsReadOnly) { foreach (XmlNode cellNode in cellNodes) { string senderId = cellNode.Attributes.GetNamedItem("SourceRoutingItemCollectionId").InnerText; string recipientId = cellNode.Attributes.GetNamedItem("DestinationRoutingItemCollectionId").InnerText; routingTable[senderId, recipientId] = ReadRoutingCell(cellNode, cellsReadOnly || routingTable.ReadOnly); } }
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); }
internal static ExpressionHelpers.RoutingType GetRoutingType(IRoutingTable routingTable) { // Only InternalExternal routing tables will have this property populated. if (ChannelValidator.IsInternalExternalRoutingTable(routingTable)) { return ExpressionHelpers.RoutingType.InternalExternal; } if (ChannelType.SMTP == routingTable.Type) return ExpressionHelpers.RoutingType.Ldap; if ((ChannelType.HTTP == routingTable.Type) || (ChannelType.ActiveContent == routingTable.Type) || (ChannelType.Default == routingTable.Type)) return ExpressionHelpers.RoutingType.SingleCell; if (ChannelType.RemoveableDevice == routingTable.Type) return ExpressionHelpers.RoutingType.RemovableDevice; if (ChannelType.Mta == routingTable.Type) return ExpressionHelpers.RoutingType.Mta; return ExpressionHelpers.RoutingType.Undefined; }