Ejemplo n.º 1
0
 public void Include(Row row)
 {
     if (IncludeAll || FileDatabase.NeedsUpdate(row.Path, row.GetJsonHashCode()))
     {
         _rows.Add(row);
     }
 }
Ejemplo n.º 2
0
        void WriteFish(string lang)
        {
            foreach (var spot in _db.FishingSpots)
            {
                var wrapper = new JsWrapper(lang, "fishing", spot);
                AddPartials(wrapper, spot);
                _update.IncludeDocument((string)spot.id, "fishing", lang, 2, Wrapper(wrapper));
            }

            // Garland Bell and FFXIVFisher data.

            var parts = new List <string>();

            // Bait
            var baitData = new JObject();

            foreach (var bait in _db.Baits)
            {
                baitData.Add((string)bait.name, bait);
            }
            parts.Add("gt.bell.bait = " + Json(baitData, Formatting.Indented));

            // Fish
            var fishData = new JArray();

            foreach (var fish in _db.Fish)
            {
                fishData.Add(fish);
            }
            parts.Add("gt.bell.fish = " + Json(fishData, Formatting.Indented));

            parts.Add("");
            FileDatabase.Write("bell\\fish.js", string.Join(";\r\n\r\n", parts));
        }
Ejemplo n.º 3
0
        void WriteNodes(string lang)
        {
            foreach (var node in _db.Nodes)
            {
                var wrapper = new JsWrapper(lang, "node", node);
                AddPartials(wrapper, node);
                _update.IncludeDocument((string)node.id, "node", lang, 2, Wrapper(wrapper));
            }

            // Garland Bell node data.

            var contents = "gt.bell.nodes = " + Json(_db.NodeViews, Formatting.Indented) + ";\r\n";

            FileDatabase.Write("bell\\nodes.js", contents);
        }
Ejemplo n.º 4
0
        void WriteNodes(string lang)
        {
            Parallel.ForEach(_db.Nodes, node =>
            {
                var wrapper = new JsWrapper(lang, "node", node);
                AddPartials(wrapper, node);
                _update.IncludeDocument((string)node.id, "node", lang, 2, Wrapper(wrapper));
            });

            // Garland Bell node data.

            var contents = "gt.bell.nodes = " + Json(_db.NodeViews, Formatting.Indented) + ";\r\n";

            FileDatabase.WriteFile("Garland.Web\\bell\\nodes.js", contents);
        }
Ejemplo n.º 5
0
        static void ExportZoneWeather()
        {
            var db    = GarlandDatabase.Instance;
            var parts = new List <string>();

            // Weather index
            var weatherIndex = string.Join(",", db.Weather.Select(w => "\"" + w + "\""));

            parts.Add($"$weatherIndex = array({weatherIndex})");

            // Zone weather
            var zoneWeather = new List <string>();

            foreach (var location in db.Locations)
            {
                if (!db.LocationReferences.Contains((int)location.id))
                {
                    continue;
                }

                if (location.weatherRate == null)
                {
                    continue;
                }

                string zoneName = location.name;
                if (string.IsNullOrEmpty(zoneName))
                {
                    continue;
                }

                var weatherRateId = (int)location.weatherRate;
                var weatherRate   = db.WeatherRates.First(r => r.id == weatherRateId);

                JArray rates    = weatherRate.rates;
                var    rateList = string.Join(", ", rates.Select(r => $"array('Rate' => {r["rate"]}, 'Weather' => {r["weather"]})"));
                zoneWeather.Add($"'{PhpEscape(zoneName)}' => array({rateList})");
            }

            parts.Add($"$zoneWeather = array({string.Join(",\r\n    ", zoneWeather)})");

            // Done
            parts.Add("");
            var result = "<?php\r\n\r\n" + string.Join(";\r\n\r\n", parts) + "?>\r\n";

            FileDatabase.WriteFile("Garland.Server\\api\\weather.inc.php", result);
        }