Пример #1
0
        private ScanNode ProcessElements(JournalScan sc, ISystem sys, SystemNode sn, string customname, List <string> elements, ScanNodeType starscannodetype, bool isbeltcluster, bool isring = false)
        {
            SortedList <string, ScanNode> cnodes = sn.starnodes;
            ScanNode node = null;
            List <JournalScan.BodyParent> ancestors      = sc.Parents?.AsEnumerable()?.ToList();
            List <JournalScan.BodyParent> ancestorbodies = ancestors?.Where(a => a.Type == "Star" || a.Type == "Planet" || a.Type == "Belt")?.Reverse()?.ToList();
            ScanNode toplevelnode = null;

            if ((ancestorbodies != null) && (starscannodetype != ScanNodeType.star))
            {
                ancestorbodies.Insert(0, null);
            }

            for (int lvl = 0; lvl < elements.Count; lvl++)
            {
                ScanNode     sublv;
                ScanNodeType sublvtype;
                string       ownname = elements[lvl];

                if (lvl == 0)
                {
                    sublvtype = starscannodetype;
                }
                else if (isbeltcluster)
                {
                    sublvtype = lvl == 1 ? ScanNodeType.belt : ScanNodeType.beltcluster;
                }
                else if (isring && lvl == elements.Count - 1)
                {
                    sublvtype = ScanNodeType.ring;
                }
                else
                {
                    sublvtype = ScanNodeType.body;
                }

                if (cnodes == null || !cnodes.TryGetValue(elements[lvl], out sublv))
                {
                    if (node != null && node.children == null)
                    {
                        node.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>());
                        cnodes        = node.children;
                    }

                    sublv = new ScanNode
                    {
                        ownname        = ownname,
                        fullname       = lvl == 0 ? (sys.Name + (ownname.Contains("Main") ? "" : (" " + ownname))) : node.fullname + " " + ownname,
                        ScanData       = null,
                        children       = null,
                        type           = sublvtype,
                        level          = lvl,
                        IsTopLevelNode = lvl == 0
                    };

                    cnodes.Add(ownname, sublv);
                }

                if (ancestorbodies != null && lvl < ancestorbodies.Count && ancestorbodies[lvl] != null)
                {
                    if (sublv.BodyID == null)
                    {
                        sublv.BodyID = ancestorbodies[lvl].BodyID;
                        sn.NodesByID[(int)sublv.BodyID] = sublv;
                    }
                }

                node   = sublv;
                cnodes = node.children;

                if (lvl == elements.Count - 1)
                {
                    node.ScanData   = sc;
                    node.customname = customname;

                    if (sc.BodyID != null)
                    {
                        node.BodyID = sc.BodyID;
                    }
                }

                if (lvl == 0)
                {
                    toplevelnode = node;
                }

                if (node.BodyID != null)
                {
                    if (lvl == 0 && node.BodyID > sn.MaxTopLevelBodyID)
                    {
                        sn.MaxTopLevelBodyID = (int)node.BodyID;
                    }
                    else if (lvl > 0 && node.BodyID < sn.MinPlanetBodyID)
                    {
                        sn.MinPlanetBodyID = (int)node.BodyID;
                    }
                }
            }

            if (ancestors != null && ancestorbodies != null && ancestorbodies.Count > 0 && ancestorbodies[0] == null && toplevelnode.BodyID == null)
            {
                for (int lvl = 1; lvl < ancestors.Count; lvl++)
                {
                    if (ancestors[lvl - 1].BodyID >= sn.MinPlanetBodyID && ancestors[lvl].BodyID <= sn.MaxTopLevelBodyID)
                    {
                        toplevelnode.BodyID = ancestors[lvl].BodyID;
                        sn.NodesByID[(int)toplevelnode.BodyID] = toplevelnode;
                    }
                }
            }

            return(node);
        }
Пример #2
0
 public NodeFilePath DacProfilePath(DistId distId, string PackageName, N DstNode)
 => SqlDacDistDir(distId)
 + DacFileName(PackageName).ChangeExtension($"{DstNode}.{CommonFileExtensions.DacProfile}");
Пример #3
0
        private bool Process(JournalScan sc, ISystem sys, bool reprocessPrimary = false)  // background or foreground.. FALSE if you can't process it
        {
            SystemNode sn = GetOrCreateSystemNode(sys);

            // handle Earth, starname = Sol
            // handle Eol Prou LW-L c8-306 A 4 a and Eol Prou LW-L c8-306
            // handle Colonia 4 , starname = Colonia, planet 4
            // handle Aurioum B A BELT
            // Kyloasly OY-Q d5-906 13 1

            ScanNodeType starscannodetype = ScanNodeType.star;          // presuming..
            bool         isbeltcluster    = false;
            bool         isring           = false;

            // Extract elements from name
            List <string> elements = ExtractElements(sc, sys, out isbeltcluster, out starscannodetype, out isring);

            // Bail out if no elements extracted
            if (elements.Count == 0)
            {
                System.Diagnostics.Trace.WriteLine($"Failed to add body {sc.BodyName} to system {sys.Name} - not enough elements");
                return(false);
            }
            // Bail out if more than 5 elements extracted
            else if (elements.Count > 5)
            {
                System.Diagnostics.Trace.WriteLine($"Failed to add body {sc.BodyName} to system {sys.Name} - too deep");
                return(false);
            }

            // Get custom name if different to designation
            string customname = GetCustomName(sc, sys);

            // Process elements
            ScanNode node = ProcessElements(sc, sys, sn, customname, elements, starscannodetype, isbeltcluster, isring);

            if (node.BodyID != null)
            {
                sn.NodesByID[(int)node.BodyID] = node;
            }

            // Process top-level star
            if (elements.Count == 1)
            {
                // Process any belts if present
                ProcessBelts(sc, node);

                // Process primary star in multi-star system
                if (elements[0].Equals("A", StringComparison.InvariantCultureIgnoreCase))
                {
                    CachePrimaryStar(sc, sys);

                    // Reprocess if we've encountered the primary (A) star and we already have a "Main Star"
                    if (reprocessPrimary && sn.starnodes.Any(n => n.Key.Length > 1 && n.Value.type == ScanNodeType.star))
                    {
                        ReProcess(sn);
                    }
                }
            }

            return(true);
        }
Пример #4
0
 public static Option <CommandSubmission <TSpec> > Submit <TSpec>(this ICommandPatternSystem CPS, TSpec Command, SystemNode DstNode, CorrelationToken?ct)
     where TSpec : CommandSpec <TSpec>, new()
 => CPS.Submit(array(Command), DstNode, ct).Map(x => x.FirstOrDefault());
Пример #5
0
 public AssetNavigator(IApplicationContext C, N Host)
     : this(C.NodeContext(Host))
 {
 }
Пример #6
0
        public bool Process(JournalScan sc, EliteDangerous.ISystem sys)           // FALSE if you can't process it
        {
            Tuple <string, long> withedsm = new Tuple <string, long>(sys.name, sys.id_edsm);

            SystemNode sn = null;

            if (scandata.ContainsKey(withedsm))         // if with edsm (if id_edsm=0, then thats okay)
            {
                sn = scandata[withedsm];
            }
            else if (scandataByName.ContainsKey(sys.name))  // if we now have an edsm id, see if we have one without it
            {
                foreach (SystemNode _sn in scandataByName[sys.name])
                {
                    if (_sn.system.Equals(sys))
                    {
                        if (sys.id_edsm != 0)             // yep, replace
                        {
                            scandata.Add(new Tuple <string, long>(sys.name, sys.id_edsm), _sn);
                        }
                        sn = _sn;
                        break;
                    }
                }
            }

            if (sn == null)
            {
                sn = new SystemNode()
                {
                    system = sys, starnodes = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>())
                };

                if (!scandataByName.ContainsKey(sys.name))
                {
                    scandataByName[sys.name] = new List <SystemNode>();
                }

                scandataByName[sys.name].Add(sn);

                if (sys.id_edsm != 0)
                {
                    scandata.Add(new Tuple <string, long>(sys.name, sys.id_edsm), sn);
                }
            }

            // handle Earth, starname = Sol
            // handle Eol Prou LW-L c8-306 A 4 a and Eol Prou LW-L c8-306
            // handle Colonia 4 , starname = Colonia, planet 4
            // handle Aurioum B A BELT
            // Kyloasly OY-Q d5-906 13 1

            List <string> elements;

            ScanNodeType starscannodetype = ScanNodeType.star;          // presuming..

            string rest = sc.IsStarNameRelatedReturnRest(sys.name);

            if (rest != null)                                   // if we have a relationship..
            {
                if (rest.Length > 0)
                {
                    elements = rest.Split(' ').ToList();

                    if (char.IsDigit(elements[0][0]))       // if digits, planet number, no star designator
                    {
                        elements.Insert(0, "Main Star");    // no star designator, main star, add MAIN
                    }
                    else if (elements[0].Length > 1)        // designator, is it multiple chars..
                    {
                        starscannodetype = ScanNodeType.barycentre;
                    }
                }
                else
                {
                    elements = new List <string>();         // only 1 item, the star, which is the same as the system name..
                    elements.Add("Main Star");              // Sol / SN:Sol should come thru here
                }
            }
            else
            {                                               // so not part of starname
                elements = sc.BodyName.Split(' ').ToList(); // not related in any way (earth) so assume all bodyparts, and
                elements.Insert(0, "Main Star");            // insert the MAIN designator as the star designator
            }

            string customname = null;

            if (sc.BodyName.StartsWith(sys.name, StringComparison.InvariantCultureIgnoreCase))
            {
                customname = sc.BodyName.Substring(sys.name.Length).TrimStart(' ', '-');

                if (customname == "" && !sc.IsStar)
                {
                    customname = sc.BodyName;
                }
                else if (customname == "" || customname == rest)
                {
                    customname = null;
                }
            }
            else if (rest == null || !sc.BodyName.EndsWith(rest))
            {
                customname = sc.BodyName;
            }

            if (elements.Count >= 1)                          // okay, we have an element.. first is the star..
            {
                ScanNode sublv0;

                if (!sn.starnodes.TryGetValue(elements[0], out sublv0))     // not found this node, add..
                {
                    sublv0 = new ScanNode()
                    {
                        ownname  = elements[0],
                        fullname = sys.name + (elements[0].Contains("Main") ? "" : (" " + elements[0])),
                        ScanData = null,
                        children = null,
                        type     = starscannodetype
                    };

                    sn.starnodes.Add(elements[0], sublv0);
                    //System.Diagnostics.Debug.WriteLine("Added star " + star.fullname + " '" + star.ownname + "'" + " under '" + designator + "' type " + ty);
                }

                if (elements.Count >= 2)                        // we have a sub designator..
                {
                    ScanNode sublv1;

                    if (sublv0.children == null || !sublv0.children.TryGetValue(elements[1], out sublv1))
                    {
                        if (sublv0.children == null)
                        {
                            sublv0.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>());
                        }

                        sublv1 = new ScanNode()
                        {
                            ownname = elements[1], fullname = sublv0.fullname + " " + elements[1], ScanData = null, children = null, type = ScanNodeType.body
                        };
                        sublv0.children.Add(elements[1], sublv1);
                    }

                    if (elements.Count >= 3)
                    {
                        ScanNode sublv2;

                        if (sublv1.children == null || !sublv1.children.TryGetValue(elements[2], out sublv2))
                        {
                            if (sublv1.children == null)
                            {
                                sublv1.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>());
                            }

                            sublv2 = new ScanNode()
                            {
                                ownname = elements[2], fullname = sublv0.fullname + " " + elements[1] + " " + elements[2], ScanData = null, children = null, type = ScanNodeType.body
                            };
                            sublv1.children.Add(elements[2], sublv2);
                        }

                        if (elements.Count >= 4)
                        {
                            ScanNode sublv3;

                            if (sublv2.children == null || !sublv2.children.TryGetValue(elements[3], out sublv3))
                            {
                                if (sublv2.children == null)
                                {
                                    sublv2.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>());
                                }

                                sublv3 = new ScanNode()
                                {
                                    ownname = elements[3], fullname = sublv0.fullname + " " + elements[1] + " " + elements[2] + " " + elements[3], ScanData = null, children = null, type = ScanNodeType.body
                                };
                                sublv2.children.Add(elements[3], sublv3);
                            }

                            if (elements.Count == 4)            // okay, need only 4 elements now.. if not, we have not coped..
                            {
                                sublv3.customname = customname;
                                sublv3.ScanData   = sc;
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine("Failed to add system " + sc.BodyName + " too long");
                                return(false);
                            }
                        }
                        else
                        {
                            sublv2.customname = customname;
                            sublv2.ScanData   = sc;
                        }
                    }
                    else
                    {
                        sublv1.customname = customname;
                        sublv1.ScanData   = sc;
                    }
                }
                else
                {
                    sublv0.customname = customname;
                    sublv0.ScanData   = sc;
                }

                return(true);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Failed to add system " + sc.BodyName + " not enough elements");
                return(false);
            }
        }
 /// <summary>
 /// Create point-to-point topic routing key between two nodes.
 /// This key serves both for Publishing and Subscription Queue Configuration.  
 /// </summary>
 /// <remarks>
 ///                         [From]       [To]
 /// 
 /// Controller Publish:     [Controller].[Memory]
 /// Controller Subscribe:   [*]         .[Controller]
 ///                                                   
 /// Memory Publish:         [Memory]    .[Controller]
 /// Memory Subscribe:       [*]         .[Memory]
 /// </remarks>
 /// <param name="_from">source component</param>
 /// <param name="_to">destination Component</param>
 /// <returns>Topic RouteKey</returns>
 public String RouteKey(SystemNode _from,SystemNode _to)
 {
     return (_to.ToString()+"."+_from.ToString());
 }
        private bool ProcessSAASignalsFound(JournalSAASignalsFound jsaa, ISystem sys, bool saveprocessinglater = true)  // background or foreground.. FALSE if you can't process it
        {
            SystemNode sn          = GetOrCreateSystemNode(sys);
            ScanNode   relatednode = null;

            if (sn.NodesByID.ContainsKey((int)jsaa.BodyID)) // find by ID
            {
                relatednode = sn.NodesByID[(int)jsaa.BodyID];
                if (relatednode.ScanData != null && relatednode.ScanData.BodyDesignation != null)
                {
                    jsaa.BodyDesignation = relatednode.ScanData.BodyDesignation;
                }
            }
            else if (jsaa.BodyDesignation != null && jsaa.BodyDesignation != jsaa.BodyName)
            {
                foreach (var body in sn.Bodies)
                {
                    if (body.FullName == jsaa.BodyDesignation)
                    {
                        relatednode = body;
                        break;
                    }
                }
            }

            if (relatednode != null && relatednode.NodeType == ScanNodeType.ring && relatednode.ScanData != null && relatednode.ScanData.Parents != null && sn.NodesByID.ContainsKey(relatednode.ScanData.Parents[0].BodyID))
            {
                relatednode = sn.NodesByID[relatednode.ScanData.Parents[0].BodyID];
            }

            if (relatednode == null || relatednode.NodeType == ScanNodeType.ring)
            {
                bool   ringname    = jsaa.BodyName.EndsWith("A Ring") || jsaa.BodyName.EndsWith("B Ring") || jsaa.BodyName.EndsWith("C Ring") || jsaa.BodyName.EndsWith("D Ring");
                string ringcutname = ringname ? jsaa.BodyName.Left(jsaa.BodyName.Length - 6).TrimEnd() : null;

                foreach (var body in sn.Bodies)
                {
                    if ((body.FullName == jsaa.BodyName || body.CustomName == jsaa.BodyName) &&
                        (body.FullName != sys.Name || body.Level != 0))
                    {
                        relatednode = body;
                        break;
                    }
                    else if (ringcutname != null && body.FullName.Equals(ringcutname))
                    {
                        relatednode = body;
                        break;
                    }
                }
            }

            if (relatednode != null)
            {
                //  System.Diagnostics.Debug.WriteLine("Setting SAA Signals Found for " + jsaa.BodyName + " @ " + sys.Name + " body "  + jsaa.BodyDesignation);
                if (relatednode.Signals == null)
                {
                    relatednode.Signals = new List <JournalSAASignalsFound.SAASignal>();
                }

                foreach (var x in jsaa.Signals)
                {
                    if (relatednode.Signals.Find(y => y.Type == x.Type && y.Count == x.Count) == null)
                    {
                        relatednode.Signals.Add(x);
                    }
                }
            }

            else
            {
                if (saveprocessinglater)
                {
                    SaveForProcessing(jsaa, sys);
                }
                //  System.Diagnostics.Debug.WriteLine("No body to attach data found for " + jsaa.BodyName + " @ " + sys.Name + " body " + jsaa.BodyDesignation);
            }

            return(false);
        }
        private bool ProcessSAASignalsFound(JournalSAASignalsFound jsaa, ISystem sys, bool reprocessPrimary = false)  // background or foreground.. FALSE if you can't process it
        {
            SystemNode sn          = GetOrCreateSystemNode(sys);
            ScanNode   relatednode = null;

            if (sn.NodesByID.ContainsKey((int)jsaa.BodyID)) // find by ID
            {
                relatednode = sn.NodesByID[(int)jsaa.BodyID];
                if (relatednode.ScanData != null && relatednode.ScanData.BodyDesignation != null)
                {
                    jsaa.BodyDesignation = relatednode.ScanData.BodyDesignation;
                }
            }
            else if (jsaa.BodyDesignation != null && jsaa.BodyDesignation != jsaa.BodyName)
            {
                foreach (var body in sn.Bodies)
                {
                    if (body.fullname == jsaa.BodyDesignation)
                    {
                        relatednode = body;
                        break;
                    }
                }
            }

            if (relatednode != null && relatednode.type == ScanNodeType.ring && relatednode.ScanData != null && relatednode.ScanData.Parents != null && sn.NodesByID.ContainsKey(relatednode.ScanData.Parents[0].BodyID))
            {
                relatednode = sn.NodesByID[relatednode.ScanData.Parents[0].BodyID];
            }

            if (relatednode == null || relatednode.type == ScanNodeType.ring)
            {
                bool   ringname    = jsaa.BodyName.EndsWith("A Ring") || jsaa.BodyName.EndsWith("B Ring") || jsaa.BodyName.EndsWith("C Ring") || jsaa.BodyName.EndsWith("D Ring");
                string ringcutname = ringname ? jsaa.BodyName.Left(jsaa.BodyName.Length - 6).TrimEnd() : null;

                foreach (var body in sn.Bodies)
                {
                    if ((body.fullname == jsaa.BodyName || body.customname == jsaa.BodyName) &&
                        (body.fullname != sys.Name || body.level != 0))
                    {
                        relatednode = body;
                        break;
                    }
                    else if (ringcutname != null && body.fullname.Equals(ringcutname))
                    {
                        relatednode = body;
                        break;
                    }
                }
            }

            if (relatednode != null)
            {
                //System.Diagnostics.Debug.WriteLine("Setting SAA Signals Found for " + jsaa.BodyName + " @ " + sys.Name + " body "  + jsaa.BodyDesignation);

                if (relatednode.Signals == null)
                {
                    relatednode.Signals = new List <JournalSAASignalsFound.SAASignal>();
                }

                relatednode.Signals.AddRange(jsaa.Signals); // add signals to list of signals of this entity

                return(true);                               // all ok
            }

            return(false);
        }
Пример #10
0
 public static NodeFilePath CreateTempFile(N Node, string data = null)
 => new NodeFilePath(Node, TextFile.CreateTempFile(data));
 /// <summary>
 /// Base Constructor - defined by SystemController
 /// </summary>
 /// <param name="_component">Service Identifier</param>
 public NodeServiceBase(SystemNode _component)
 {
     this.thisComponent = _component;            //  node identifier
 }
Пример #12
0
 public NodeFilePath(N Node, FilePath AbsolutePath)
     : base(Node, AbsolutePath)
 {
 }
Пример #13
0
 public static NodeFilePath Empty(N node = null)
 => new NodeFilePath(node ?? SystemNode.Local, FilePath.Empty);
Пример #14
0
        public void SetFSSDiscoveryScan(JournalFSSDiscoveryScan je, ISystem sys)
        {
            SystemNode sn = GetOrCreateSystemNode(sys);

            sn.TotalBodies = je.BodyCount;
        }
Пример #15
0
 public FP AbsoluteLocation(N node, RelativePath relative)
 => UncShare(node, relative).Share.SharePath;
Пример #16
0
 public static NodeFilePath file(N node, string path)
 => new NodeFilePath(node, path);
Пример #17
0
        public MainWindow()
        {
            InitializeComponent();



            using (var ele = new eveLocationEntities())
            {
                #region Regions
                var regions = ele.mapRegions;
                regions.Load();

                foreach (var region in regions)
                {
                    var node = new RegionNode
                    {
                        Name       = region.regionName,
                        NodeID     = region.regionID,
                        IsSelected = false
                    };

                    _locationNodes.Nodes.Add(node);
                }
                #endregion

                #region Systems
                var systems = ele.mapSolarSystems;
                systems.Load();

                foreach (var system in systems)
                {
                    var node = new SystemNode
                    {
                        Name         = system.solarSystemName,
                        NodeID       = system.solarSystemID,
                        ParentNodeID = system.regionID,
                        IsFiltered   = false
                    };

                    _locationNodes.Nodes.Add(node);
                }
                #endregion
            }

            using (var eie = new eveInventoryEntities())
            {
                #region Market Groups
                var groups = eie.invMarketGroups;
                groups.Load();

                //var groups = _eaw.GetMarketGroups().Result;

                foreach (var group in groups)
                {
                    //var tmp = @group.ParentGroup?.InferredId ?? 0;
                    var node = new MarketGroupNode
                    {
                        Name         = group.marketGroupName,
                        NodeID       = group.marketGroupID,
                        ParentNodeID = group.parentGroupID
                    };

                    _marketItemNodes.Nodes.Add(node);
                }
                #endregion

                #region Market Items

                var items = eie.invTypes;
                items.Load();

                //var items = _eaw.GetMarketTypes().Result;

                foreach (var item in items)
                {
                    switch (item.marketGroupID)
                    {
                    case 2155:
                        continue;

                    case null:
                        continue;

                    case 354496:
                        continue;

                    case 354341:
                        continue;

                    case 356922:
                        continue;

                    case 354395:
                        continue;

                    case 354396:
                        continue;
                    }

                    var node = new MarketItemNode
                    {
                        Name         = item.typeName,
                        NodeID       = item.typeID + 2000000000000000,
                        ParentNodeID = item.marketGroupID
                    };

                    _marketItemNodes.Nodes.Add(node);
                }

                #endregion
            }

            locationTreeView.ItemsSource = _locationNodes.Nodes;
            locationTreeView.Columns["Name"].SortOrder = ColumnSortOrder.Ascending;

            locationTreeView.View.NodeChanged += NodeChecked;


            marketItemTreeView.ItemsSource = _marketItemNodes.Nodes;
            marketItemTreeView.Columns["Name"].SortOrder = ColumnSortOrder.Ascending;
        }
Пример #18
0
 public static NodeFolderPath folder(N node, string path)
 => new NodeFolderPath(node, FolderPath.Parse(path));
Пример #19
0
        /// <summary>
        /// Default Constructor-connect to service bus
        /// <list type="bullet">Memory Exchange Construction
        ///     <item>Start the publishing task</item>
        ///     <item>Topic Routing - requires node based RouteKey</item>
        ///     <item>Auto-delete (exchange andQueues are deleted when all queues have closed)</item>
        /// </list>
        /// <list type="bullet">Local Persistent Exchange Construction
        ///     <item>Topic Routing - requires node based RouteKey</item>
        ///     <item>Durable (exchange & Queues persist)</item>
        /// </list>
        /// <list type="bullet">Queue Construction
        ///     <item>Instantiate uniquely named transient queue</item>
        ///     <item>Bind the queue to the exchange</item>
        /// </list>
        /// </summary>
        /// 
        /// <param name="_service">
        /// <list type="bullet">Host service for this node interface, for directly accessing following:
        ///     <item>Cancellation token for process control by owning process</item>
        ///     <item>Message handler to be invoked by the incoming topic queue</item>
        ///     <item>Service component type for queue naming and topic routing identification</item>
        /// </list>
        /// </param>
        /// <param name="_topology">Define Exchange type to be used by this node  </param>
        public NodeInterface(NodeServiceBase _service)
        {
            #region Node Overhead
            this.m_cancellation = _service.m_nodetoken;                              //  cancellation token
            this.m_outgoingqueue = new BlockingCollection<IMessage<NodeMessage>>(this.m_outgoingqueuebase);

            m_messaging[1] = new Task(() => { this.PublishQueuedMessage(); }, TaskCreationOptions.LongRunning);
            m_messaging[1].Start();        //  asynchronous start
            #endregion
            #region Exchange Configuration
            this.thisComponent = _service.thisComponent;   //  this node identifier
            this.SubscriptionTopics.Add(this.thisComponent.ToString() + MQNetwork.Wildcard);
            this.memoryExchange =               //  (2) Instantiate Topic Only MTA - routes on a routing pattern and is deleted when all references close.
                Exchange.DeclareTopic(ConfigurationManager.AppSettings["SBmemoryExchange"]);
            #endregion
        }
Пример #20
0
        private void CheckNodeObjects(SystemObject obj)
        {
            var currentParent = ExtractParents(obj);

            if (currentParent.Ring.HasValue)
            {
                var parentnode = _nodes.Where(m => m.BodyId == currentParent.Ring).FirstOrDefault();
                var childnode  = _nodes.Where(m => m.BodyId == obj.Id).FirstOrDefault();

                if (parentnode == null)
                {
                    parentnode = new RingNode(currentParent.Ring.Value);
                    _nodes.Add(parentnode);
                }

                if (childnode == null)
                {
                    childnode = SystemNode.CreateNodeFromObject(obj);
                    _nodes.Add(childnode);
                }

                parentnode.ChildList.Add(childnode);
                childnode.ParentList.Add(parentnode);

                UpdateStarsystemMap?.Invoke(childnode);

                return;
            }

            if (currentParent.Planet.HasValue)
            {
                var parentnode = _nodes.Where(m => m.BodyId == currentParent.Planet).FirstOrDefault();
                var childnode  = _nodes.Where(m => m.BodyId == obj.Id).FirstOrDefault();

                if (parentnode == null)
                {
                    parentnode = new PlanetNode(currentParent.Planet.Value);
                    _nodes.Add(parentnode);
                }

                if (childnode == null)
                {
                    childnode = SystemNode.CreateNodeFromObject(obj);
                    _nodes.Add(childnode);
                }

                parentnode.ChildList.Add(childnode);
                childnode.ParentList.Add(parentnode);

                UpdateStarsystemMap?.Invoke(childnode);

                return;
            }

            if (currentParent.Star.HasValue)
            {
                var parentnode = _nodes.Where(m => m.BodyId == currentParent.Star).FirstOrDefault();
                var childnode  = _nodes.Where(m => m.BodyId == obj.Id).FirstOrDefault();

                if (parentnode == null)
                {
                    parentnode = new StarNode(currentParent.Star.Value);
                    _nodes.Add(parentnode);
                }

                if (childnode == null)
                {
                    childnode = SystemNode.CreateNodeFromObject(obj);
                    _nodes.Add(childnode);
                }


                parentnode.ChildList.Add(childnode);
                childnode.ParentList.Add(parentnode);

                UpdateStarsystemMap?.Invoke(childnode);

                return;
            }

            if (currentParent.Null.HasValue)
            {
                var parentnode = _nodes.Where(m => m.BodyId == currentParent.Null).FirstOrDefault();
                var childnode  = _nodes.Where(m => m.BodyId == obj.Id).FirstOrDefault();

                if (parentnode == null)
                {
                    parentnode = new BarycenterNode(currentParent.Null.Value);
                    _nodes.Add(parentnode);
                }

                if (childnode == null)
                {
                    childnode = SystemNode.CreateNodeFromObject(obj);
                    _nodes.Add(childnode);
                }

                parentnode.ChildList.Add(childnode);
                childnode.ParentList.Add(parentnode);

                UpdateStarsystemMap?.Invoke(childnode);

                return;
            }
        }
Пример #21
0
 public static Option <ReadOnlyList <CommandSubmission <TSpec> > > Enqueue <TSpec, TPayload>(this IApplicationContext C, IEnumerable <TSpec> specs, SystemNode target)
     where TSpec : CommandSpec <TSpec, TPayload>, new()
 => from p in C.CPS().Pattern <TSpec, TPayload>()
 from q in p.Queue.Enqueue(specs, target)
 select q;
Пример #22
0
 public IEnumerable <SystemNode> GetChildNodes(SystemNode item)
 {
     return(item.ChildList);
 }
Пример #23
0
 public static Option <CommandSubmission> Submit(this ICommandPatternSystem CPS, ICommandSpec Command, SystemNode DstNode, CorrelationToken?ct)
 => CPS.Submit(array(Command), DstNode, ct).Map(x => x.FirstOrDefault());
Пример #24
0
 public NodeFileSystemNavigator(N Host, NodeFileSystemRoot Root)
 {
     this.Root = Root;
     this.Host = Host;
 }
Пример #25
0
 public AssetNavigator(IApplicationContext C, N Host, FolderPath HostRoot)
     : this(C.NodeContext(Host), HostRoot)
 {
 }
Пример #26
0
 public static Option <S> SysOpSet <S>(this IApplicationContext C, SystemNode ActiveNode)
     where S : SysOpComponent <S>
 => C.SysOpProvider().RequestOperationSet <S>(ActiveNode);
Пример #27
0
        public bool HasWebLookupOccurred(ISystem sys)       // have we had a web checkup on this system?  false if sys does not exist
        {
            SystemNode sn = FindSystemNode(sys);

            return(sn != null && sn.EDSMWebChecked);
        }
Пример #28
0
 public static Option <IOperationProvider> SysOpSet(this IApplicationContext C, Type ComponentType, SystemNode ActiveNode)
 => C.SysOpProvider().RequestOperationSet(ComponentType, ActiveNode);
Пример #29
0
        private bool Process(IBodyNameAndID sc, ISystem sys, bool reprocessPrimary = false)  // background or foreground.. FALSE if you can't process it
        {
            SystemNode sn          = GetOrCreateSystemNode(sys);
            ScanNode   relatedScan = null;

            if ((sc.BodyDesignation == null || sc.BodyDesignation == sc.Body) && (sc.Body != sc.StarSystem || sc.BodyType != "Star"))
            {
                foreach (var body in sn.Bodies)
                {
                    if ((body.fullname == sc.Body || body.customname == sc.Body) &&
                        (body.fullname != sc.StarSystem || (sc.BodyType == "Star" && body.level == 0) || (sc.BodyType != "Star" && body.level != 0)))
                    {
                        relatedScan        = body;
                        sc.BodyDesignation = body.fullname;
                        break;
                    }
                }
            }

            if (relatedScan == null)
            {
                foreach (var body in sn.Bodies)
                {
                    if ((body.fullname == sc.Body || body.customname == sc.Body) &&
                        (body.fullname != sc.StarSystem || (sc.BodyType == "Star" && body.level == 0) || (sc.BodyType != "Star" && body.level != 0)))
                    {
                        relatedScan = body;
                        break;
                    }
                }
            }

            if (relatedScan != null && relatedScan.ScanData == null)
            {
                relatedScan.BodyLoc = sc;
                return(true); // We already have the scan
            }

            // handle Earth, starname = Sol
            // handle Eol Prou LW-L c8-306 A 4 a and Eol Prou LW-L c8-306
            // handle Colonia 4 , starname = Colonia, planet 4
            // handle Aurioum B A BELT
            // Kyloasly OY-Q d5-906 13 1

            ScanNodeType starscannodetype = ScanNodeType.star;          // presuming..
            bool         isbeltcluster    = false;

            // Extract elements from name
            List <string> elements = ExtractElements(sc, sys, out isbeltcluster, out starscannodetype);

            // Bail out if no elements extracted
            if (elements.Count == 0)
            {
                System.Diagnostics.Trace.WriteLine($"Failed to add body {sc.Body} to system {sys.Name} - not enough elements");
                return(false);
            }
            // Bail out if more than 5 elements extracted
            else if (elements.Count > 5)
            {
                System.Diagnostics.Trace.WriteLine($"Failed to add body {sc.Body} to system {sys.Name} - too deep");
                return(false);
            }

            // Get custom name if different to designation
            string customname = GetCustomName(sc, sys);

            // Process elements
            ScanNode node = ProcessElements(sc, sys, sn, customname, elements, starscannodetype, isbeltcluster);

            if (node.BodyID != null)
            {
                sn.NodesByID[(int)node.BodyID] = node;
            }

            return(true);
        }
Пример #30
0
        // see above for elements

        private ScanNode ProcessElementsJournalScan(JournalScan sc, ISystem sys, SystemNode systemnode, string customname, List <string> elements,
                                                    ScanNodeType starscannodetype, bool isbeltcluster, bool isring)
        {
            List <JournalScan.BodyParent> ancestors = sc.Parents?.AsEnumerable()?.ToList();      // this includes Rings, Barycentres(Nulls) that frontier put into the list..

            // remove all rings and barycenters first, since thats not in our element list. We just want the bodies and belts
            List <JournalScan.BodyParent> ancestorbodies = ancestors?.Where(a => a.Type == "Star" || a.Type == "Planet" || a.Type == "Belt")?.Reverse()?.ToList();

            // but we need to add back the barycenter at the top, since we do add that that in the element list
            if (ancestorbodies != null && ancestorbodies.Count > 0 && starscannodetype == ScanNodeType.barycentre)
            {
                // this checks out, but disable for safety.  System.Diagnostics.Debug.Assert(ancestors[ancestors.Count - 1].Type == "Null");     // double check its a barycentre, it should be
                ancestorbodies.Insert(0, ancestors[ancestors.Count - 1]);
            }

            // for each element we process into the tree

            SortedList <string, ScanNode> currentnodelist = systemnode.StarNodes;           // current operating node list, always made
            ScanNode previousnode = null;                                                   // trails subnode by 1 to point to previous node

            for (int lvl = 0; lvl < elements.Count; lvl++)
            {
                ScanNodeType sublvtype = starscannodetype;                                  // top level, element[0] type is starscannode (star/barycentre)

                if (lvl > 0)                                                                // levels pass 0, we need to determine what it is
                {
                    if (isbeltcluster)                                                      // a belt cluster is in three levels (star, belt, cluster number)
                    {
                        if (lvl == 1)                                                       // next level, its a belt
                        {
                            sublvtype = ScanNodeType.belt;
                        }
                        else
                        {
                            sublvtype = ScanNodeType.beltcluster;                           // third level, cluster
                        }
                    }
                    else if (isring && lvl == elements.Count - 1)                           // and level, and a ring, mark as a ring
                    {
                        sublvtype = ScanNodeType.ring;
                    }
                    else
                    {
                        sublvtype = ScanNodeType.body;                                      // default is body for levels 1 on
                    }
                }

                // if not got a node list (only happens when we have a scannode from another scannode), or we are not in the node list

                if (currentnodelist == null || !currentnodelist.TryGetValue(elements[lvl], out ScanNode subnode)) // either no nodes, or not found the element name in the node list.
                {
                    if (currentnodelist == null)                                                                  // no node list, happens when we are at least 1 level down as systemnode always has a node list, make one
                    {
                        currentnodelist = previousnode.Children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>());
                    }

                    string ownname = elements[lvl];

                    subnode = new ScanNode
                    {
                        OwnName  = ownname,
                        FullName = previousnode == null ? (sys.Name + (ownname.Contains("Main") ? "" : (" " + ownname))) : previousnode.FullName + " " + ownname,
                        ScanData = null,
                        Children = null,
                        NodeType = sublvtype,
                        Level    = lvl,
                    };

                    currentnodelist.Add(ownname, subnode);
                }

                if (ancestorbodies != null && lvl < ancestorbodies.Count)       // if we have the ancestor list, we can fill in the bodyid for each part.
                {
                    subnode.BodyID = ancestorbodies[lvl].BodyID;
                    systemnode.NodesByID[(int)subnode.BodyID] = subnode;
                }

                if (lvl == elements.Count - 1)                                                  // if we are at the end node..
                {
                    subnode.ScanData = sc;                                                      // only overwrites if scan is better
                    subnode.ScanData.SetMapped(subnode.IsMapped, subnode.WasMappedEfficiently); // pass this data to node, as we may have previously had a SAA Scan
                    subnode.CustomName = customname;                                            // and its custom name

                    if (sc.BodyID != null)                                                      // if scan has a body ID, pass it to the node
                    {
                        subnode.BodyID = sc.BodyID;
                    }
                }

                previousnode    = subnode;                                      // move forward 1 step
                currentnodelist = previousnode.Children;
            }

            return(previousnode);
        }
Пример #31
0
        private ScanNode ProcessElements(IBodyNameAndID sc, ISystem sys, SystemNode sn, string customname, List <string> elements, ScanNodeType starscannodetype, bool isbeltcluster)
        {
            SortedList <string, ScanNode> cnodes = sn.starnodes;
            ScanNode node = null;

            for (int lvl = 0; lvl < elements.Count; lvl++)
            {
                ScanNode     sublv;
                ScanNodeType sublvtype;
                string       ownname = elements[lvl];

                if (lvl == 0)
                {
                    sublvtype = starscannodetype;
                }
                else if (isbeltcluster)
                {
                    sublvtype = lvl == 1 ? ScanNodeType.belt : ScanNodeType.beltcluster;
                }
                else
                {
                    sublvtype = ScanNodeType.body;
                }

                if (cnodes == null || !cnodes.TryGetValue(elements[lvl], out sublv))
                {
                    if (node != null && node.children == null)
                    {
                        node.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>());
                        cnodes        = node.children;
                    }

                    sublv = new ScanNode
                    {
                        ownname        = ownname,
                        fullname       = lvl == 0 ? (sys.Name + (ownname.Contains("Main") ? "" : (" " + ownname))) : node.fullname + " " + ownname,
                        ScanData       = null,
                        children       = null,
                        type           = sublvtype,
                        level          = lvl,
                        IsTopLevelNode = lvl == 0
                    };

                    cnodes.Add(ownname, sublv);
                }

                node   = sublv;
                cnodes = node.children;

                if (lvl == elements.Count - 1)
                {
                    node.BodyLoc    = sc;
                    node.customname = customname;

                    if (sc.BodyID != null)
                    {
                        node.BodyID = sc.BodyID;
                    }

                    if (sc.BodyType == "" || sc.BodyType == "Null")
                    {
                        node.type = ScanNodeType.barycentre;
                    }
                    else if (sc.BodyType == "Belt")
                    {
                        node.type = ScanNodeType.belt;
                    }
                }
            }

            return(node);
        }
Пример #32
0
        // take the journal scan and add it to the node tree

        private bool ProcessJournalScan(JournalScan sc, ISystem sys, bool reprocessPrimary = false)  // background or foreground.. FALSE if you can't process it
        {
            SystemNode sn = GetOrCreateSystemNode(sys);

            // handle Earth, starname = Sol
            // handle Eol Prou LW-L c8-306 A 4 a and Eol Prou LW-L c8-306
            // handle Colonia 4 , starname = Colonia, planet 4
            // handle Aurioum B A BELT
            // Kyloasly OY-Q d5-906 13 1

            // Extract elements from name, and extract if belt, top node type, if ring
            List <string> elements = ExtractElementsJournalScan(sc, sys, out ScanNodeType starscannodetype, out bool isbeltcluster, out bool isring);

            // Bail out if no elements extracted
            if (elements.Count == 0)
            {
                System.Diagnostics.Trace.WriteLine($"Failed to add body {sc.BodyName} to system {sys.Name} - not enough elements");
                return(false);
            }
            // Bail out if more than 5 elements extracted
            else if (elements.Count > 5)
            {
                System.Diagnostics.Trace.WriteLine($"Failed to add body {sc.BodyName} to system {sys.Name} - too deep");
                return(false);
            }

            //System.Diagnostics.Debug.WriteLine("Made body JS " + sc.BodyName);

            // Get custom name if different to designation
            string customname = GetCustomNameJournalScan(sc, sys);

            // Process elements,
            ScanNode node = ProcessElementsJournalScan(sc, sys, sn, customname, elements, starscannodetype, isbeltcluster, isring);

            if (node.BodyID != null)
            {
                sn.NodesByID[(int)node.BodyID] = node;
            }

            // Process top-level star
            if (elements.Count == 1)
            {
                // Process any belts if present
                ProcessBelts(sc, node);

                // Process primary star in multi-star system
                if (elements[0].Equals("A", StringComparison.InvariantCultureIgnoreCase))
                {
                    BodyDesignations.CachePrimaryStar(sc, sys);

                    // Reprocess if we've encountered the primary (A) star and we already have a "Main Star", we reprocess to
                    // allow any updates to PrimaryCache to make a difference

                    if (reprocessPrimary && sn.StarNodes.Any(n => n.Key.Length > 1 && n.Value.NodeType == ScanNodeType.star))
                    {
                        // get bodies with scans
                        List <JournalScan> bodies = sn.Bodies.Where(b => b.ScanData != null).Select(b => b.ScanData).ToList();

                        // reset the nodes to zero
                        sn.StarNodes = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>());
                        sn.NodesByID = new SortedList <int, ScanNode>();

                        foreach (JournalScan js in bodies)              // replay into process the body scans.. using the newly updated body designation (primary star cache) to correct any errors
                        {
                            js.BodyDesignation = BodyDesignations.GetBodyDesignation(js, sn.System.Name);
                            ProcessJournalScan(js, sn.System);
                        }
                    }
                }
            }

            ProcessedSaved();  // any saved JEs due to no scan, add

            return(true);
        }
Пример #33
0
 DriveLetter _UncDriveLetter(N n)
 => Nodes.Single(d => d.Node.Equals(n)).DriveLetter;
 /// <summary>
 /// Default Service constructor 
 /// </summary>
 public NodeServiceGeneric(SystemNode _component)
     : base(_component)
 {
 }