Пример #1
0
        public FinalResults Execute(IServiceProvider serviceProvider,
                                    Dictionary <string, object> attributes,
                                    Dictionary <string, object> parameters)
        {
            FinalResults finalResults = new FinalResults();

            m_TraceSource.TraceEvent(TraceEventType.Information, 0, "Executing MFJobHost");


            //Todo: get the data we need to run the job

            m_MFRegion = new RegionLocation()
            {
                RegionName    = "",
                DbInstance    = "",
                DispatcherUrl = "",
                ExtensionData = null
            };



            m_MFMonitor.RunJob(m_MFRegion, m_MFSpoolId);


            //Todo: get the job results from MF and populate finalResults

            return(finalResults);
        }
Пример #2
0
 public Region(double xDim, double yDim, double height, double x, double y, double z, RegionLocation regionLocation, Direction dir)
 {
     IfLocation     = new IfLocation(x, y, z);
     IfDimension    = new IfDimension(xDim, yDim, height);
     RegionLocation = regionLocation;
     Direction      = dir;
 }
Пример #3
0
 public RegionRecord(WorldMerger merger, int rx, int rz)
 {
     loc            = new RegionLocation(rx, rz);
     filename       = $"r.{rx}.{rz}.mca";
     existsInWorld1 = File.Exists(Path.Combine(merger.world1Path, filename));
     existsInWorld2 = File.Exists(Path.Combine(merger.world2Path, filename));
 }
        public string GetAllRegions()
        {
            var result = "";

            using (diplomaDBContext = new DiplomaDBContext())
            {
                var regions = diplomaDBContext.Region.Where(r => r.Map != "").ToArray();

                var regionLocations = new RegionLocation[regions.Length];
                for (int i = 0; i < regionLocations.Length; i++)
                {
                    regionLocations[i] = new RegionLocation
                    {
                        Id   = regions[i].Id,
                        Name = regions[i].Name,
                        Map  = regions[i].Map
                    };
                }

                result = JsonSerializer.Serialize(regionLocations, JsonOptions);
            }

            Response.Headers.Add("Access-Control-Allow-Origin", "http://localhost:3000");
            return(result);
        }
Пример #5
0
        public async Task <IActionResult> Create([Bind("IdRegion,Name")] Region region, string[] selectedTrails)
        {
            if (selectedTrails != null)
            {
                region.RegionLocation = new List <RegionLocation>();
                foreach (var trail in selectedTrails)
                {
                    var trailToAdd = new RegionLocation {
                        IdRegion = region.IdRegion, IdTrail = int.Parse(trail)
                    };
                    region.RegionLocation.Add(trailToAdd);
                }
            }

            if (ModelState.IsValid)
            {
                await _regionRepository.AddRegionAsync(region);

                return(RedirectToAction(nameof(Index)));
            }

            PopulateRegion(region);

            return(View(region));
        }
Пример #6
0
        private void UpdateRegion(string[] selectedTrails, Region regionToUpdate)
        {
            if (selectedTrails == null)
            {
                regionToUpdate.RegionLocation = new List <RegionLocation>();

                return;
            }

            var selectedTrailsHS = new HashSet <string>(selectedTrails);
            var regionTrails     = new HashSet <int>
                                       (regionToUpdate.RegionLocation.Select(c => c.Trail.IdTrail));

            foreach (var trail in _regionRepository.GetAllTrails())
            {
                if (selectedTrailsHS.Contains(trail.IdTrail.ToString()))
                {
                    if (!regionTrails.Contains(trail.IdTrail))
                    {
                        regionToUpdate.RegionLocation.Add(new RegionLocation {
                            IdRegion = regionToUpdate.IdRegion, IdTrail = trail.IdTrail
                        });
                    }
                }
                else
                {
                    if (regionTrails.Contains(trail.IdTrail))
                    {
                        RegionLocation trailToRemove = regionToUpdate.RegionLocation.FirstOrDefault(i => i.IdTrail == trail.IdTrail);
                        _regionRepository.RemoveTrail(trailToRemove);
                    }
                }
            }
        }
Пример #7
0
 public bool AddRegion(int rx, int rz)
 {
     if (regions.ContainsKey(new RegionLocation(rx, rz)))
     {
         var rloc = new RegionLocation(rx, rz);
         var r    = new Region(rloc);
         r.containingWorld = this;
         regions.Add(rloc, r);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #8
0
        public void Run()
        {
            MCUtilsConsole.WriteLine("Enter path to world 1's region files:");
            world1Path = GetFilePath(true);
            if (world1Path == null)
            {
                return;
            }
            MCUtilsConsole.WriteLine("Enter path to world 2's region files:");
            world2Path = GetFilePath(true);
            if (world2Path == null)
            {
                return;
            }

            MCUtilsConsole.WriteLine("Enter the lower coordinate for the merge (inclusive):");
            lowerBound = ParseCoordinates(MCUtilsConsole.GetInput());
            MCUtilsConsole.WriteLine("Enter the upper coordinate for the merge (inclusive):");
            upperBound = ParseCoordinates(MCUtilsConsole.GetInput());

            int sizeX = upperBound.x - lowerBound.x + 1;
            int sizeZ = upperBound.z - lowerBound.z + 1;

            MCUtilsConsole.WriteLine($"Enter path to map image (Must be {sizeX * 512}x{sizeZ * 512} or {sizeX * 32}x{sizeZ * 32}:");
            string map = GetFilePath(false);

            if (map == null)
            {
                return;
            }
            Bitmap worldMergeMap = new Bitmap(map);
            byte   mergeMode     = 0;

            if (worldMergeMap.Width == sizeX * 512 && worldMergeMap.Height == sizeZ * 512)
            {
                mergeMode = 1;
            }
            if (worldMergeMap.Width == sizeX * 32 && worldMergeMap.Height == sizeZ * 32)
            {
                mergeMode = 2;
            }
            if (mergeMode == 0)
            {
                MCUtilsConsole.WriteError("Map was not the correct size!");
                return;
            }

            MCUtilsConsole.WriteLine("Enter path to output file:");
            outputPath = GetFilePath(true);

            List <RegionRecord> records = new List <RegionRecord>();

            for (int rz = lowerBound.z; rz <= upperBound.z; rz++)
            {
                for (int rx = lowerBound.x; rx <= upperBound.x; rx++)
                {
                    records.Add(new RegionRecord(this, rx, rz));
                }
            }

            int w1only    = 0;
            int w2only    = 0;
            int mergeable = 0;

            foreach (var r in records)
            {
                if (r.CanMerge)
                {
                    mergeable++;
                }
                else
                {
                    if (r.existsInWorld1)
                    {
                        w1only++;
                    }
                    else if (r.existsInWorld2)
                    {
                        w2only++;
                    }
                }
            }

            if (w1only > 0)
            {
                MCUtilsConsole.WriteWarning($"There are {w1only} regions that only exist in world 1.");
            }
            if (w2only > 0)
            {
                MCUtilsConsole.WriteWarning($"There are {w2only} regions that only exist in world 2.");
            }
            MCUtilsConsole.WriteLine($"{mergeable} out of {records.Count} can be merged. Press any key to start.");
            Console.ReadKey();

            MCUtilsConsole.WriteLine("Starting world merge...");
            foreach (var r in records)
            {
                int    localX  = r.loc.x - lowerBound.x;
                int    localZ  = r.loc.z - lowerBound.z;
                int    scale   = mergeMode == 1 ? 512 : 32;
                Bitmap section = worldMergeMap.Clone(new Rectangle(localX * scale, localZ * scale, scale, scale), worldMergeMap.PixelFormat);

                MCUtilsConsole.WriteLine($"Merging {r.loc.x}.{r.loc.z}.mca ...");
                var region1      = RegionLoader.LoadRegion(Path.Combine(world1Path, r.filename));
                var region2      = RegionLoader.LoadRegion(Path.Combine(world2Path, r.filename));
                var merger       = new RegionMerger(region1, region2, section);
                var mergedRegion = merger.Merge();

                MCUtilsConsole.WriteLine("Writing file...");
                FileStream stream = new FileStream(Path.Combine(outputPath, r.filename), FileMode.Create);
                RegionSerializer.WriteRegionToStream(mergedRegion, stream, Version.DefaultVersion);
                stream.Close();
            }
        }
 public void EditRegionLocation(RegionLocation regionLocation)
 {
     _appDbContext.RegionLocations.Update(regionLocation);
     _appDbContext.SaveChanges();
 }
 public void DeleteRegionLocation(RegionLocation regionLocation)
 {
     _appDbContext.RegionLocations.Remove(regionLocation);
     _appDbContext.SaveChanges();
 }
 public void AddRegionLocation(RegionLocation regionLocation)
 {
     _appDbContext.RegionLocations.Add(regionLocation);
     _appDbContext.SaveChanges();
 }
Пример #12
0
 void IRegionRepository.RemoveTrail(RegionLocation regionLocation)
 {
     _appDbContext.Remove(regionLocation);
 }