Exemplo n.º 1
0
        private void ImportLocation(LocationData locationData)
        {
            if (Locations.ContainsKey(locationData.id))
            {
                return;
            }
            var characterGroup = new CharacterGroup()
            {
                AvaiableDirectSlots = 0,
                CharacterGroupName  = locationData.name.Trim(),
                ProjectId           = Project.ProjectId,
                Project             = Project,
                IsRoot = false,
                ParentCharacterGroupIds = new int[] { GetGroupByAllrpgId(locationData.parent).CharacterGroupId },
                IsActive            = true,
                HaveDirectSlots     = false,
                IsPublic            = locationData.rights == 0,
                Description         = new MarkdownString(locationData.description.Trim()),
                ChildGroupsOrdering = $"allrpg!{locationData.code:00000}",
                CharacterGroupId    = -Locations.Count
            };

            Locations.Add(locationData.id, characterGroup);

            _operationLog.Info($"GROUP.CREATE {characterGroup}");

            LocationParentRelation.Add(new ParentRelation(locationData.parent, locationData.id));
        }
Exemplo n.º 2
0
        public static void ApplyLocationAdded(dynamic metadata, dynamic content)
        {
            var data                = content;
            var groupKey            = metadata.GroupKey.ToString();
            var key                 = groupKey;
            var location            = data.Location.ToString();
            List <BadgeItem> badges = GetDashboardSectionBadges(key, "UsedLocations");

            if (!badges.Any(b => b.Text == location))
            {
                badges.Add(new BadgeItem {
                    Text = location, Type = BadgeType.Location
                });
                if (!Locations.ContainsKey(key))
                {
                    Locations.Add(key, new HashSet <string> {
                        location
                    });
                }
                else if (!Locations[key].Contains(location))
                {
                    Locations[key].Add(location);
                }
            }
            GetDashboardOrAdd(key).Locations.Add(location);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialises the Icarus instance. You can specify multiple paths by using
        /// the location tag parameter.
        /// </summary>
        /// <param name="icarusLocation">The location of where the Icarus data stores are held.</param>
        /// <param name="locationTag">The location tag, if left blank will be the default tag.</param>
        /// <returns>
        /// The IcarusClient for chaining
        /// </returns>
        /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
        /// <exception cref="DirectoryNotFoundException">If Icarus store cannot be found.</exception>
        public IIcarus Initialise(string icarusLocation, string locationTag = "")
        {
            var path = Path.GetFullPath(icarusLocation);

            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException(string.Format("Icarus location does not exist: {0}", icarusLocation));
            }

            if (string.IsNullOrEmpty(locationTag))
            {
                locationTag = DefaultTag;
            }

            if (Locations.ContainsKey(locationTag))
            {
                Locations[locationTag] = path;
            }
            else
            {
                Locations.Add(locationTag, path);
            }

            return(this);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the data store from Icarus, you can optionally speicify the location tag to use.
        /// If the location tag is left blank, the default tag will be used.
        /// The isNew out flag will be true if teh data store had to be created, false otherwise.
        /// </summary>
        /// <param name="dataStoreName">Name of the data store.</param>
        /// <param name="isNew">if set to <c>true</c> then the data store was created as a part of this call.</param>
        /// <param name="locationTag">The location tag, if left blank will be the default tag.</param>
        /// <param name="isAccessEveryone">if set to <c>true</c> the Icarus datastore is accessible by everyone.</param>
        /// <returns>
        /// The data store.
        /// </returns>
        public IIcarusDataStore GetDataStore(string dataStoreName, out bool isNew, string locationTag = "", bool isAccessEveryone = false)
        {
            isNew = false;

            if (!Locations.Any())
            {
                return(default(IIcarusDataStore));
            }

            if (string.IsNullOrEmpty(locationTag))
            {
                locationTag = Locations.ContainsKey(DefaultTag)
                    ? DefaultTag
                    : Locations.Keys.First();
            }

            var storeTagKey = string.Format("{0}|{1}", locationTag, dataStoreName);

            if (!_dataStores.ContainsKey(storeTagKey))
            {
                var path = string.Empty;
                isNew = !IcarusDataStore.Exists(Locations[locationTag], dataStoreName, out path);

                _dataStores.Add(storeTagKey,
                                new IcarusDataStore(
                                    Locations[locationTag],
                                    dataStoreName,
                                    (IsAccessEveryone || isAccessEveryone)));
            }

            return(_dataStores[storeTagKey]);
        }
Exemplo n.º 5
0
 public void LoadSubLocations(string fileName)
 {
     try
     {
         string path;
         if (!Locations.ContainsKey(fileName))
         {
             path = @"Location\SubLoc\Empty.xml";
         }
         else
         {
             path = string.Format(@"Location\SubLoc\{0}.xml", fileName.Replace(" ", string.Empty));
         }
         if (path == "Location\\SubLoc\\ПовсейРоссии.xml")
         {
             path = @"Location\SubLoc\Empty.xml";
         }
         FileStream    FS       = new FileStream(path, FileMode.Open);
         XmlSerializer XMLDeser = new XmlSerializer(typeof(UserCollection <string, string>));
         SubLocations = (UserCollection <string, string>)XMLDeser.Deserialize(FS);
         FS.Close();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 6
0
        private void OnLocationsRetrieved(object sender, ServiceEventArgs e)
        {
            List <RhitLocation> locations = DataCollector.Instance.GetAllLocations(null);

            foreach (RhitLocation location in locations)
            {
                if (location.Id < 0)
                {
                    continue;
                }
                if (Locations.ContainsKey(location.Id))
                {
                    continue;
                }
                Locations[location.Id] = location;
            }

            TempDict = new Dictionary <int, LocationNode>();

            foreach (RhitLocation location in locations)
            {
                AddNode(location);
            }

            ChangeLocation(LocationTree[0] as object);
        }
Exemplo n.º 7
0
 protected void gLocations_Delete(object sender, Rock.Web.UI.Controls.RowEventArgs e)
 {
     if (Locations.ContainsKey(e.RowKeyId))
     {
         Locations.Remove(e.RowKeyId);
     }
     BindLocations();
 }
Exemplo n.º 8
0
 public LazinatorLocationAwareTree <T> GetTreeForItem(T item)
 {
     InitializeLocationsIfNecessary();
     if (Locations.ContainsKey(item))
     {
         var locationAsLazinatorList = Locations[item];
         var locationAsList          = ConvertToRegularList(locationAsLazinatorList);
         return((LazinatorLocationAwareTree <T>)GetTreeAtLocation(locationAsList));
     }
     return(null);
 }
Exemplo n.º 9
0
        public void ChangeLocation(object selectedObject)
        {
            LocationNode node = selectedObject as LocationNode;

            if (!Locations.ContainsKey(node.Id))
            {
                return;
            }
            CurrentLocation = Locations[node.Id];
            UpdateLocationData();
            LocationSelected = true;
        }
Exemplo n.º 10
0
        private void ResolveLocations(IntPtr baseAddress, IntPtr searchStart, IntPtr searchEnd, ref List <Signature> notFound)
        {
            const int bufferSize      = 0x1200;
            const int regionIncrement = 0x1000;

            var buffer      = new byte[bufferSize];
            var temp        = new List <Signature>();
            var regionCount = 0;

            while (searchStart.ToInt64() < searchEnd.ToInt64())
            {
                try
                {
                    IntPtr lpNumberOfBytesRead;
                    var    regionSize = new IntPtr(bufferSize);
                    if (IntPtr.Add(searchStart, bufferSize)
                        .ToInt64() > searchEnd.ToInt64())
                    {
                        regionSize = (IntPtr)(searchEnd.ToInt64() - searchStart.ToInt64());
                    }
                    if (UnsafeNativeMethods.ReadProcessMemory(MemoryHandler.Instance.ProcessHandle, searchStart, buffer, regionSize, out lpNumberOfBytesRead))
                    {
                        foreach (var signature in notFound)
                        {
                            var index = FindSuperSignature(buffer, SignatureToByte(signature.Value, WildCardChar));
                            if (index < 0)
                            {
                                temp.Add(signature);
                                continue;
                            }

                            var baseResult   = new IntPtr((long)(baseAddress + regionCount * regionIncrement));
                            var searchResult = IntPtr.Add(baseResult, index + signature.Offset);

                            signature.SigScanAddress = new IntPtr(searchResult.ToInt64());

                            if (!Locations.ContainsKey(signature.Key))
                            {
                                Locations.Add(signature.Key, signature);
                            }
                        }
                        notFound = new List <Signature>(temp);
                        temp.Clear();
                    }
                    regionCount++;
                    searchStart = IntPtr.Add(searchStart, regionIncrement);
                }
                catch (Exception ex)
                {
                    MemoryHandler.Instance.RaiseException(Logger, ex, true);
                }
            }
        }
Exemplo n.º 11
0
 private static IntPtr GetLocations(string key)
 {
     if (Locations.ContainsKey(key))
     {
         MemoryPointer = Locations[key];
     }
     else
     {
         MemoryPointer = IntPtr.Zero;
     }
     return(MemoryPointer);
 }
Exemplo n.º 12
0
        internal static (double latitude, double longitude) GetCurrentLocation(int id)
        {
            if (!Locations.ContainsKey(id))
            {
                Locations.Add(id, default((double latitude, double longitude)));
            }

            //This method updates the last known location for the car and simulates its movement
            UpdateLocation(id);

            return(Locations[id]);
        }
Exemplo n.º 13
0
 private CharacterGroup GetGroupByAllrpgId(int parentAllrpgId)
 {
     if (parentAllrpgId == 0)
     {
         return(Project.RootGroup);
     }
     if (Locations.ContainsKey(parentAllrpgId))
     {
         return(Locations[parentAllrpgId]);
     }
     _operationLog.Info($"LOCATION NOT FOUND ALLRPG_ID = {parentAllrpgId}");
     return(Project.RootGroup);
 }
Exemplo n.º 14
0
        public void LoadOffsets(IEnumerable <Signature> signatures, bool scanAllMemoryRegions = false)
        {
            if (MemoryHandler.Instance.ProcessModel?.Process == null)
            {
                return;
            }

            IsScanning = true;

            Func <bool> scanningFunc = delegate
            {
                var sw = new Stopwatch();
                sw.Start();

                if (scanAllMemoryRegions)
                {
                    LoadRegions();
                }

                var scanable = signatures as List <Signature> ?? signatures.ToList();
                if (scanable.Any())
                {
                    foreach (var signature in scanable)
                    {
                        if (signature.Value == string.Empty)
                        {
                            // doesn't need a signature scan
                            Locations[signature.Key] = signature;
                            continue;
                        }
                        signature.Value = signature.Value.Replace("*", "?"); // allows either ? or * to be used as wildcard
                    }
                    scanable.RemoveAll(a => Locations.ContainsKey(a.Key));

                    FindExtendedSignatures(scanable, scanAllMemoryRegions);
                }

                sw.Stop();

                MemoryHandler.Instance.RaiseSignaturesFound(Logger, Locations, sw.ElapsedMilliseconds);

                IsScanning = false;

                return(true);
            };

            scanningFunc.BeginInvoke(delegate { }, scanningFunc);
        }
Exemplo n.º 15
0
        /// <summary>
        /// </summary>
        /// <param name="pSignatures"> </param>
        public void LoadOffsets(IEnumerable <Signature> pSignatures)
        {
            IsScanning = true;

            Func <bool> d = delegate
            {
                var sw = new Stopwatch();
                sw.Start();
                if (MemoryHandler.Instance.ProcessModel?.Process == null)
                {
                    return(false);
                }
                var signatures = new List <Signature>(pSignatures);
                LoadRegions();
                if (signatures.Any())
                {
                    foreach (var signature in signatures)
                    {
                        if (signature.Value == string.Empty)
                        {
                            // doesn't need a signature scan
                            Locations[signature.Key] = signature;
                            continue;
                        }
                        signature.Value = signature.Value.Replace("*", "?"); // allows either ? or * to be used as wildcard
                    }
                    signatures.RemoveAll(a => Locations.ContainsKey(a.Key));
                    FindExtendedSignatures(signatures);
                }
                foreach (var kvp in Locations)
                {
                    Logger.Log(LogLevel.Info, $"Signature [{kvp.Key}] Found At Address: [{((IntPtr) kvp.Value).ToString("X")}]");
                }
                sw.Stop();

                RaiseSignaturesFound(Logger, Locations, sw.ElapsedMilliseconds);

                IsScanning = false;

                return(true);
            };

            d.BeginInvoke(null, null);
        }
Exemplo n.º 16
0
        private void AddNode(RhitLocation location)
        {
            if (location.Id < 0)
            {
                return;
            }
            if (TempDict.ContainsKey(location.Id))
            {
                return;
            }
            LocationNode node = new LocationNode()
            {
                Name = location.Label,
                Id   = location.Id,
            };

            if (location.ParentId <= 0)
            {
                LocationTree.Add(node);
                TempDict[location.Id] = node;
                return;
            }

            if (TempDict.ContainsKey(location.ParentId))
            {
                TempDict[location.ParentId].ChildLocations.Add(node);
                TempDict[location.Id] = node;
                return;
            }

            if (Locations.ContainsKey(location.ParentId))
            {
                AddNode(Locations[location.ParentId]);
                TempDict[location.ParentId].ChildLocations.Add(node);
                TempDict[location.Id] = node;
                return;
            }

            LocationTree.Add(node);
            TempDict[location.Id] = node;
        }
Exemplo n.º 17
0
        public void Move(int wo_id, string source_name, string destination_name)
        {
            if (!Workorders.ContainsKey(wo_id))
            {
                throw new System.ArgumentOutOfRangeException("Workorder does not exist");
            }

            if (!Locations.ContainsKey(source_name))
            {
                throw new System.ArgumentException("Source Location does not exist");
            }

            if (!Locations.ContainsKey(destination_name))
            {
                throw new System.ArgumentException("Destination Location does not exist");
            }

            VirtualWorkorder wo = (VirtualWorkorder)Workorders[wo_id];

            LocationInventories[source_name].Remove(wo);
            LocationInventories[destination_name].Add(wo);
        }
Exemplo n.º 18
0
            public override void OnResponse(NetState state, RelayInfo info)
            {
                if (info.ButtonID > 0)
                {
                    int id = info.ButtonID;

                    if (Locations.ContainsKey(id))
                    {
                        Point3D p = Locations[id];

                        if (CheckTravel(p))
                        {
                            Effects.SendPacket(User.Location, User.Map, new ParticleEffect(EffectType.FixedFrom, User.Serial, Server.Serial.Zero, 0x3728, User.Location, User.Location, 10, 10, false, false, 0, 0, 0, 2023, 1, User.Serial, 80, 0));
                            Effects.PlaySound(User.Location, User.Map, 496);

                            BaseCreature.TeleportPets(User, p, Map.Ilshenar);
                            User.MoveToWorld(p, Map.Ilshenar);
                            Effects.PlaySound(p, Map.Ilshenar, 0x1FE);
                        }
                    }
                }
            }
Exemplo n.º 19
0
            public override void OnResponse(NetState state, RelayInfo info)
            {
                if (info.ButtonID > 0)
                {
                    int id = info.ButtonID;

                    if (Locations.ContainsKey(id))
                    {
                        Point3D p = Locations[id];

                        if (CheckTravel(p))
                        {
                            BaseCreature.TeleportPets(User, p, Map.Ilshenar);
                            User.Combatant = null;
                            User.Warmode   = false;
                            User.Hidden    = true;

                            User.MoveToWorld(p, Map.Ilshenar);

                            Effects.PlaySound(p, Map.Ilshenar, 0x1FE);
                        }
                    }
                }
            }
Exemplo n.º 20
0
 public bool IsInMetaLocation(string metaLocationName)
 {
     return(Locations.ContainsKey(metaLocationName));
 }
Exemplo n.º 21
0
        public void ProduceKml(string file)
        {
            Kml      doc = new Kml();
            Document d   = new Document()
            {
                Name = Path.GetFileName(file)
            };

            doc.Feature = d;

            Folder root = new Folder()
            {
                Name = "Network"
            };

            d.AddFeature(root);
            StyleMapCollection style_default = GenerateNewStyle("default", d, null);

            List <string> folders = (from i in Locations.Values where !string.IsNullOrWhiteSpace(i.ParentName) select i.ParentName).Distinct().ToList();

            foreach (var str in folders)
            {
                Folder fPlacemark = new Folder()
                {
                    Name = str
                };
                Folder fPath = new Folder()
                {
                    Name = "Paths"
                };
                root.AddFeature(fPlacemark);
                if (!Locations.ContainsKey(str))
                {
                    Locations.Add(str, new Location()
                    {
                        Name = str, PlacemarkFolder = fPlacemark
                    });
                }
                else
                {
                    fPlacemark.AddFeature(fPath);
                    Locations[str].PathFolder      = fPath;
                    Locations[str].PlacemarkFolder = fPlacemark;
                }
                GenerateNewStyle(str.Sanitize(), d, Locations[str]);
            }
            foreach (var loc in Locations.Values)
            {
                var parent = (from i in Locations.Values where i.Name == loc.ParentName select i).FirstOrDefault();
                loc.Parent = parent;
            }

            foreach (var loc in Locations.Values)
            {
                if (loc.Coordinates == null)
                {
                    continue;
                }
                Placemark plPoint = new Placemark();
                Placemark plPath  = new Placemark();

                if (loc.Parent != null)
                {
                    switch (Labels)
                    {
                    case LabelMode.All:
                        plPoint.StyleUrl = new Uri($"#msn_{loc.ParentName.Sanitize()}", UriKind.Relative);
                        break;

                    case LabelMode.Some:
                        if (IsImportant(loc.Name))
                        {
                            plPoint.StyleUrl = new Uri($"#msn_{loc.ParentName.Sanitize()}", UriKind.Relative);
                        }
                        else
                        {
                            plPoint.StyleUrl = new Uri($"#msn_{loc.ParentName.Sanitize()}_nolabels", UriKind.Relative);
                        }
                        break;

                    case LabelMode.None:
                        plPoint.StyleUrl = new Uri($"#msn_{loc.ParentName.Sanitize()}_nolabels", UriKind.Relative);
                        break;
                    }
                }
                else if (loc.StyleMap != null)
                {
                    switch (Labels)
                    {
                    case LabelMode.All:
                    case LabelMode.Some:
                        plPoint.StyleUrl = new Uri($"#{loc.StyleMap.Id}", UriKind.Relative);
                        break;

                    case LabelMode.None:
                        plPoint.StyleUrl = new Uri($"#{loc.StyleMapNoLabels.Id}", UriKind.Relative);
                        break;
                    }
                }
                else
                {
                    plPoint.StyleUrl = new Uri($"#{style_default.Id}", UriKind.Relative);
                }
                plPoint.Name     = loc.Name;
                plPoint.Geometry = new SharpKml.Dom.Point()
                {
                    Coordinate = loc.Coordinates
                };
                Folder placemarkFolder = loc.Parent?.PlacemarkFolder ?? loc.PlacemarkFolder ?? root;
                placemarkFolder.AddFeature(plPoint);
                if (loc.Parent?.Coordinates != null)
                {
                    plPath.StyleUrl = new Uri($"#msn_{loc.ParentName.Sanitize()}", UriKind.Relative);
                    plPath.Name     = loc.Name + " Path";
                    LineString l = new LineString();
                    l.Coordinates = new CoordinateCollection();
                    l.Coordinates.Add(loc.Coordinates);
                    l.Coordinates.Add(loc.Parent.Coordinates);
                    plPath.Geometry = l;
                    loc.Parent.PathFolder.AddFeature(plPath);
                }
            }
            Folder linksFolder = new Folder()
            {
                Name = "Links"
            };
            Style s = new Style()
            {
                Id   = $"sn_links",
                Line = new LineStyle()
                {
                    Color = new Color32(255, 255, 0, 0),
                    Width = 4.0
                }
            };

            root.AddStyle(s);
            if (Links.Count > 0)
            {
                root.AddFeature(linksFolder);
            }
            foreach (Link link in Links)
            {
                Placemark p = new Placemark()
                {
                    Name = link.Name
                };
                LineString l = new LineString();
                l.Coordinates = new CoordinateCollection();
                l.Coordinates.Add(link.Location1.Coordinates);
                l.Coordinates.Add(link.Location2.Coordinates);
                p.Geometry = l;
                linksFolder.AddFeature(p);
                p.StyleUrl = new Uri($"#{s.Id}", UriKind.Relative);
            }
            Serializer serializer = new Serializer();

            serializer.Serialize(doc);
            File.WriteAllText(file, serializer.Xml);
        }