Пример #1
0
        /// <summary>
        ///
        /// </summary>
        private void ValidateState()
        {
            RouteTreeNode Node = MainTreeView.SelectedNode == null ? null : MainTreeView.SelectedNode.Tag as RouteTreeNode;

            deleteToolStripMenuItem.Enabled = (Node != null);
            addTagToolStripMenuItem.Enabled = true;
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditClicked(object sender, EventArgs e)
        {
            RouteTreeNode Node = MainTreeView.SelectedNode == null ? null : MainTreeView.SelectedNode.Tag as RouteTreeNode;

            if (Node == null)
            {
                return;
            }

            using (AddRouteForm form = new AddRouteForm())
            {
                form.SourceTagId      = Node.Route.SourceTagId;
                form.DestinationTagId = Node.Route.DestinationTagId;
                form.Blacklisted      = Node.Route.Blacklisted;
                form.BandwidthLimit   = Node.Route.BandwidthLimit;
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    Node.Route.SourceTagId      = form.SourceTagId;
                    Node.Route.DestinationTagId = form.DestinationTagId;
                    Node.Route.Blacklisted      = form.Blacklisted;
                    Node.Route.BandwidthLimit   = form.BandwidthLimit;

                    Node.Source         = Program.TagRegistry.IdToString(form.SourceTagId);
                    Node.Destination    = Program.TagRegistry.IdToString(form.DestinationTagId);
                    Node.Blacklisted    = form.Blacklisted ? "Yes" : "No";
                    Node.BandwidthLimit = form.BandwidthLimit == 0 ? "Unlimited" : StringUtils.FormatAsTransferRate(form.BandwidthLimit);

                    Program.NetClient.UpdateRoute(Node.Route.Id, form.SourceTagId, form.DestinationTagId, form.Blacklisted, form.BandwidthLimit);
                    Program.NetClient.RequestRouteList();
                }
            }
        }
Пример #3
0
        public void AddRoute(string method, string path, IHandleRequest action)
        {
            var split = path.Split('/', StringSplitOptions.RemoveEmptyEntries);

            if (split.Length < 1)
            {
                throw new ArgumentException("Path cannot be empty");
            }
            var paths = new Stack <string>(split);

            method = method.ToUpper();

            RouteTreeNode <IHandleRequest> node;

            //always have an empty root node
            if (!_hostMethodRoutes.ContainsKey(method))
            {
                node = new RouteTreeNode <IHandleRequest>(null);
                _hostMethodRoutes.Add(method, node);
            }
            else
            {
                node = _hostMethodRoutes[method];
            }

            if (!node.TryAdd(paths, action))
            {
                throw new ArgumentException("Route already exists");
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteClicked(object sender, EventArgs e)
        {
            RouteTreeNode Node = MainTreeView.SelectedNode == null ? null : MainTreeView.SelectedNode.Tag as RouteTreeNode;

            if (Node == null)
            {
                return;
            }

            Program.NetClient.DeleteRoute(Node.Route.Id);
            Program.NetClient.RequestRouteList();
        }
Пример #5
0
    public RouteTreeNode MessageFlowTree(string instanceId)
    {
        try
        {
            if (string.IsNullOrEmpty(instanceId))
            {
                throw new ArgumentNullException("instanceId");
            }

            RouteTreeNode root = bizTalkQuery.RouteTree(instanceId);
            return(root);
        }
        catch (System.Exception ex)
        {
            // log and throw new error
            EventLogger.LogMessage(EventFormatter.FormatEvent(MethodInfo.GetCurrentMethod(), ex),
                                   EventLogEntryType.Error, (int)EventLogger.EventId.BizTalkQueryService);

            throw new SoapException(GetErrorDescription(BizTalkQueryServiceMessageFlowMessage, instanceId), SoapException.ServerFaultCode, ex);
        }
    }
Пример #6
0
            public bool TryAdd(Stack <string> paths, T value)
            {
                var path = paths.Pop();
                RouteTreeNode <T> node = null;

                if (Nodes.ContainsKey(path))
                {
                    if (paths.Count == 0)
                    {
                        if (Nodes[path].Value != null)
                        {
                            return(false);
                        }
                        else
                        {
                            Nodes[path].Value = value;
                            return(true);
                        }
                    }
                    else
                    {
                        node = Nodes[path];
                    }
                }
                else
                {
                    node = new RouteTreeNode <T>(null);
                    Nodes.Add(path, node);
                    if (paths.Count == 0)
                    {
                        node.Value = value;
                        return(true);
                    }
                }

                return(node.TryAdd(paths, value));
            }
Пример #7
0
        /// <summary>
        /// </summary>
        /// <param name="Users"></param>
        private void RoutesRecieved(List <Route> InRoutes)
        {
            // Add new tags.
            foreach (Route Route in InRoutes)
            {
                RouteTreeNode ExistingRoute = null;

                foreach (RouteTreeNode Node in Model.Nodes)
                {
                    if (Node.Route.Id == Route.Id)
                    {
                        ExistingRoute = Node;
                        break;
                    }
                }

                if (ExistingRoute == null)
                {
                    ExistingRoute       = new RouteTreeNode();
                    ExistingRoute.Route = Route;
                    Model.Nodes.Add(ExistingRoute);
                }

                ExistingRoute.SourceTags         = new Tag[1];
                ExistingRoute.SourceTags[0]      = Program.TagRegistry.GetTagById(Route.SourceTagId);
                ExistingRoute.Source             = Program.TagRegistry.IdToString(Route.SourceTagId);
                ExistingRoute.Destination        = Program.TagRegistry.IdToString(Route.DestinationTagId);
                ExistingRoute.DestinationTags    = new Tag[1];
                ExistingRoute.DestinationTags[0] = Program.TagRegistry.GetTagById(Route.DestinationTagId);
                ExistingRoute.Blacklisted        = Route.Blacklisted ? "Yes" : "No";
                ExistingRoute.BandwidthLimit     = Route.BandwidthLimit == 0 ? "Unlimited" : StringUtils.FormatAsTransferRate(Route.BandwidthLimit);
                ExistingRoute.Icon = Resources.appbar_arrow_up_down;
            }

            // Remove old tags.
            List <RouteTreeNode> RemovedNodes = new List <RouteTreeNode>();

            foreach (RouteTreeNode Node in Model.Nodes)
            {
                bool Found = false;

                foreach (Route Route in InRoutes)
                {
                    if (Node.Route.Id == Route.Id)
                    {
                        Found = true;
                        break;
                    }
                }

                if (!Found)
                {
                    RemovedNodes.Add(Node);
                }
            }

            foreach (RouteTreeNode Node in RemovedNodes)
            {
                Model.Nodes.Remove(Node);
            }

            this.Invalidate();
            this.Refresh();
        }