/// <summary>
        /// Builds the Network for the specified file in a background thread
        /// </summary>
        public void BuildSourceNetworkMessages(Action <object, bool> callback, object m, bool lineChanged, FileData file)
        {
            ThreadPool.QueueUserWorkItem(delegate(object state)
            {
                lock (this)
                {
                    Log.WriteWarning("Network Mapping - Entering BuildNetworkAsync", typeof(NetworkMapingViewModel).FullName, MethodBase.GetCurrentMethod().Name);
                    var model = state as BuildNetworkCallbackModel;
                    if (model == null)
                    {
                        return;
                    }

                    NetworkService.CheckNetworkMessages(model.File, View.StatusUpdate, "Source");

                    model.Callback(model.Model, model.LineChanged);
                    Log.Write("Network Mapping - Exiting BuildNetworkAsync", typeof(NetworkMapingViewModel).FullName, MethodBase.GetCurrentMethod().Name);
                }
            },
                                         new BuildNetworkCallbackModel
            {
                File        = file,
                Callback    = callback,
                Model       = m,
                LineChanged = false
            });
        }
        /// <summary>
        /// Builds the Network for the specified file in a background thread
        /// </summary>
        public void BuildTargetNetworkMessages(Action callback, FileData file)
        {
            Log.WriteEnter(typeof(NetworkMapingViewModel).FullName, MethodBase.GetCurrentMethod().Name);
            ThreadPool.QueueUserWorkItem(delegate(object m)
            {
                lock (this)
                {
                    Log.WriteWarning("Network Mapping - Entering BuildNetwork2Async", typeof(NetworkMapingViewModel).FullName, MethodBase.GetCurrentMethod().Name);
                    var model = m as BuildNetwork2CallbackModel;
                    if (model == null)
                    {
                        return;
                    }

                    NetworkService.CheckNetworkMessages(model.File, View.StatusUpdate, "Target");

                    model.Callback();
                    Log.WriteWarning("Network Mapping - Exiting BuildNetwork2Async", typeof(NetworkMapingViewModel).FullName, MethodBase.GetCurrentMethod().Name);
                }
            }, new BuildNetwork2CallbackModel
            {
                File     = file,
                Callback = callback
            });
        }
Пример #3
0
        /// <summary>
        /// Used to quickly rebuild the active documents cache.  Used to speed up development and exercise code
        /// </summary>
        public static void RebuildActiveDocument()
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                OutputService.ClearOutputWindow?.Invoke();
                PerformanceService.StartEvent($"Rebuild Active Document for {Current.Model.File.Path}");
                Thread.CurrentThread.Name = "Rebuild.Active.Document";

                var file = Current.Model.File;
                file.Clear();
                FileService.Build(file, true);
                file.IsCached_Lazy_NetworkMessages = false;
                NetworkService.CheckNetworkMessages(file, View.StatusUpdate, "Source");

                // Invalidate will force dependent Components to Render
                file.DataController.Invalidate();
            });
        }
Пример #4
0
        private void BuildNodes(NetworkMapModel model)
        {
            var anchorFile = XmlDal.CacheModel.GetFile(model.NetworkMap.AnchorFilePath);

            var nodes     = new List <NetworkMapFile>();
            var tempNodes = new List <NetworkMapFile>();

            NetworkService.CheckNetworkMessages(anchorFile, View.StatusUpdate, "Anchor");

            // Add Anchor
            var map = AddFileAsNode(anchorFile, nodes, true);

            AddFileAsNode(anchorFile, tempNodes, true);
            model.CurrentAnchor        = NodeBase.NodeToString(anchorFile.SourceType, anchorFile.Ip, anchorFile.Host);
            model.CurrentAnchorMapFile = map;

            // Only use the prior selected if we are on the same file
            if (LastAnchorFilePath == anchorFile.Path)
            {
                // Add Selected
                foreach (var selectedFile in model.NetworkMap.Nodes.Where(n => n.Selected))
                {
                    AddNode(selectedFile.Node, nodes, true, anchorFile.Path);
                    AddNode(selectedFile.Node, tempNodes, true, anchorFile.Path);
                }
            }
            LastAnchorFilePath = anchorFile.Path;

            // Expand Selected
            foreach (var selectedNode in tempNodes)
            {
                // For the selected Node find any files that match
                var expandNodes = NetworkService.GetNetworkFilesByNode(selectedNode.Node);
                foreach (var expandFile in expandNodes)
                {
                    NetworkService.CheckNetworkMessages(expandFile, View.StatusUpdate, "Extended");
                    ExpandNodes(expandFile, nodes);
                }
            }

            model.NetworkMap.Nodes = nodes;
        }
Пример #5
0
        protected override void RunItem(string path)
        {
            if (Args.IsCancelled)
            {
                Cancel();
                return;
            }

            var stopwatch = new Stopwatch(MethodBase.GetCurrentMethod().Name, true);

            try
            {
                Log.WriteWarning("---", typeof(AnalyzeNetworkLoop).FullName, MethodBase.GetCurrentMethod().Name);
                Log.WriteWarning($"Running AnalyzeNetwork for file \"{path}\"", typeof(AnalyzeNetworkLoop).FullName, MethodBase.GetCurrentMethod().Name);
                var file = XmlDal.CacheModel.GetFile(path);
                Log.WriteWarning("BuildNetwork on Source", typeof(AnalyzeNetworkLoop).FullName, MethodBase.GetCurrentMethod().Name);
                NetworkService.CheckNetworkMessages(file, null, "");

                Log.WriteWarning($"{file.Network.NetworkMessages.Count} Network Messages to process...", typeof(AnalyzeNetworkLoop).FullName, MethodBase.GetCurrentMethod().Name);

                lock (file.Network)
                {
                    var loop = new AnalyzeNetworkMessageLoop
                    {
                        Queue      = new Queue <NetworkMessageInfo>(file.Network.NetworkMessages),
                        Report     = Args.Report,
                        SourcePath = file.Path
                    };
                    loop.Run();
                }
            }
            finally
            {
                Log.WriteWarning($"Completed AnalyzeNetwork for file \"{path}\"", typeof(AnalyzeNetworkLoop).FullName, MethodBase.GetCurrentMethod().Name);
                stopwatch.Stop();
            }
        }