예제 #1
0
 public ResidentSupportAnnex ToModel()
 {
     return(new ResidentSupportAnnex
     {
         Id = Id,
         IsDuplicate = IsDuplicate,
         OngoingFoodNeed = OngoingFoodNeed,
         OngoingPrescriptionNeed = OngoingPrescriptionNeed,
         FormId = FormId.ToString(),
         FormVersion = FormVersion,
         DateTimeRecorded = ParseNullableDateTime(DateTimeRecorded),
         FirstName = FirstName,
         LastName = LastName,
         DobMonth = ParseNullableDateTime(DateOfBirth)?.Month.ToString(),
         DobYear = ParseNullableDateTime(DateOfBirth)?.Year.ToString(),
         DobDay = ParseNullableDateTime(DateOfBirth)?.Day.ToString(),
         Postcode = Postcode,
         Uprn = Uprn,
         Ward = Ward,
         AddressFirstLine = AddressFirstLine,
         AddressSecondLine = AddressSecondLine,
         AddressThirdLine = AddressThirdLine,
         ContactTelephoneNumber = ContactTelephoneNumber,
         ContactMobileNumber = ContactMobileNumber,
         EmailAddress = EmailAddress,
         IsOnBehalf = IsOnBehalf,
         OnBehalfFirstName = OnBehalfFirstName,
         OnBehalfLastName = OnBehalfLastName,
         OnBehalfEmailAddress = OnBehalfEmailAddress,
         OnBehalfContactNumber = OnBehalfContactNumber,
         RelationshipWithResident = RelationshipWithResident,
         AnythingElse = AnythingElse,
         GpSurgeryDetails = GpSurgeryDetails,
         FoodNeed = FoodNeed,
         NumberOfPeopleInHouse = NumberOfPeopleInHouse.ToString(),
         DaysWorthOfFood = DaysWorthOfFood.ToString(),
         AnyFoodHouseholdCannotEat = AnyFoodHouseholdCannotEat,
         StrugglingToPayForFood = StrugglingToPayForFood,
         IsPharmacistAbleToDeliver = IsPharmacistAbleToDeliver,
         NameAddressPharmacist = NameAddressPharmacist,
         IsPackageOfCareAsc = IsPackageOfCareAsc,
         IsUrgentFoodRequired = IsUrgentFoodRequired,
         DaysWorthOfMedicine = DaysWorthOfMedicine.ToString(),
         IsUrgentMedicineRequired = IsUrgentMedicineRequired,
         IsAddressConfirmed = IsAddressConfirmed,
         IsHouseholdHelpAvailable = IsHouseholdHelpAvailable,
         IsUrgentFood = IsUrgentFood,
         IsUrgentPrescription = IsUrgentPrescription,
         AnyHelpAvailable = AnyHelpAvailable,
         IsAnyAgedUnder15 = IsAnyAgedUnder15,
         LastConfirmedFoodDelivery = ParseNullableDateTime(LastConfirmedFoodDelivery),
         RecordStatus = RecordStatus,
         DeliveryNotes = DeliveryNotes,
         CaseNotes = CaseNotes,
     });
 }
예제 #2
0
        private IReadOnlyDictionary <string, string> GetProperties(MessageProperties properties)// DiscordGuild guild, WhConfig whConfig, string city, string pokemonImageUrl)
        {
            var pkmnInfo         = MasterFile.GetPokemon(Id, FormId);
            var pkmnName         = Translator.Instance.GetPokemonName(Id);
            var form             = Translator.Instance.GetFormName(FormId);
            var costume          = Translator.Instance.GetCostumeName(Costume);
            var gender           = Gender.GetPokemonGenderIcon();
            var genderEmoji      = Gender.GetGenderEmojiIcon();
            var level            = Level;
            var size             = Size?.ToString();
            var weather          = Weather?.ToString();
            var hasWeather       = Weather.HasValue && Weather != WeatherCondition.None;
            var isWeatherBoosted = pkmnInfo?.IsWeatherBoosted(Weather ?? WeatherCondition.None);
            var weatherKey       = $"weather_{Convert.ToInt32(Weather ?? WeatherCondition.None)}";
            var weatherEmoji     = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[weatherKey])
                ? MasterFile.Instance.CustomEmojis.ContainsKey(weatherKey) && Weather != WeatherCondition.None
                    ? (Weather ?? WeatherCondition.None).GetWeatherEmojiIcon()
                    : string.Empty
                : MasterFile.Instance.CustomEmojis[weatherKey];
            var move1        = int.TryParse(FastMove, out var fastMoveId) ? Translator.Instance.GetMoveName(fastMoveId) : "Unknown";
            var move2        = int.TryParse(ChargeMove, out var chargeMoveId) ? Translator.Instance.GetMoveName(chargeMoveId) : "Unknown";
            var type1        = pkmnInfo?.Types?[0];
            var type2        = pkmnInfo?.Types?.Count > 1 ? pkmnInfo.Types?[1] : PokemonType.None;
            var type1Emoji   = pkmnInfo?.Types?[0].GetTypeEmojiIcons();
            var type2Emoji   = pkmnInfo?.Types?.Count > 1 ? pkmnInfo?.Types?[1].GetTypeEmojiIcons() : string.Empty;
            var typeEmojis   = $"{type1Emoji} {type2Emoji}";
            var catchPokemon = IsDitto ? Translator.Instance.GetPokemonName(DisplayPokemonId ?? Id) : pkmnName;
            var isShiny      = Shiny ?? false;
            var height       = double.TryParse(Height, out var realHeight) ? Math.Round(realHeight).ToString() : "";
            var weight       = double.TryParse(Weight, out var realWeight) ? Math.Round(realWeight).ToString() : "";

            var gmapsLink               = string.Format(Strings.GoogleMaps, Latitude, Longitude);
            var appleMapsLink           = string.Format(Strings.AppleMaps, Latitude, Longitude);
            var wazeMapsLink            = string.Format(Strings.WazeMaps, Latitude, Longitude);
            var scannerMapsLink         = string.Format(properties.Config.Urls.ScannerMap, Latitude, Longitude);
            var staticMapLink           = StaticMap.GetUrl(properties.Config.Urls.StaticMap, properties.Config.StaticMaps["pokemon"], Latitude, Longitude, properties.ImageUrl);
            var gmapsLocationLink       = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, gmapsLink);
            var appleMapsLocationLink   = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, appleMapsLink);
            var wazeMapsLocationLink    = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, wazeMapsLink);
            var scannerMapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, scannerMapsLink);
            var address = new Location(null, properties.City, Latitude, Longitude).GetAddress(properties.Config);
            //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink);
            var pokestop = Pokestop.Pokestops.ContainsKey(PokestopId) ? Pokestop.Pokestops[PokestopId] : null;

            var greatLeagueEmoji = PvPLeague.Great.GetLeagueEmojiIcon();
            var ultraLeagueEmoji = PvPLeague.Ultra.GetLeagueEmojiIcon();
            var pvpStats         = GetPvP();

            const string defaultMissingValue = "?";
            var          dict = new Dictionary <string, string>
            {
                // Main properties
                { "pkmn_id", Convert.ToString(Id) },
                { "pkmn_id_3", Id.ToString("D3") },
                { "pkmn_name", pkmnName },
                { "pkmn_img_url", properties.ImageUrl },
                { "form", form },
                { "form_id", Convert.ToString(FormId) },
                { "form_id_3", FormId.ToString("D3") },
                { "costume", costume ?? defaultMissingValue },
                { "costume_id", Convert.ToString(Costume) },
                { "costume_id_3", Costume.ToString("D3") },
                { "cp", CP ?? defaultMissingValue },
                { "lvl", level ?? defaultMissingValue },
                { "gender", gender },
                { "gender_emoji", genderEmoji },
                { "size", size ?? defaultMissingValue },
                { "move_1", move1 ?? defaultMissingValue },
                { "move_2", move2 ?? defaultMissingValue },
                { "moveset", $"{move1}/{move2}" },
                { "type_1", type1?.ToString() ?? defaultMissingValue },
                { "type_2", type2?.ToString() ?? defaultMissingValue },
                { "type_1_emoji", type1Emoji },
                { "type_2_emoji", type2Emoji },
                { "types", $"{type1} | {type2}" },
                { "types_emoji", typeEmojis },
                { "atk_iv", Attack ?? defaultMissingValue },
                { "def_iv", Defense ?? defaultMissingValue },
                { "sta_iv", Stamina ?? defaultMissingValue },
                { "iv", IV ?? defaultMissingValue },
                { "iv_rnd", IVRounded ?? defaultMissingValue },
                { "is_shiny", Convert.ToString(isShiny) },

                // Catch rate properties
                { "has_capture_rates", Convert.ToString(CatchRate1.HasValue && CatchRate2.HasValue && CatchRate3.HasValue) },
                { "capture_1", CatchRate1.HasValue ? Math.Round(CatchRate1.Value * 100).ToString() : string.Empty },
                { "capture_2", CatchRate2.HasValue ? Math.Round(CatchRate2.Value * 100).ToString() : string.Empty },
                { "capture_3", CatchRate3.HasValue ? Math.Round(CatchRate3.Value * 100).ToString() : string.Empty },
                { "capture_1_emoji", CaptureRateType.PokeBall.GetCaptureRateEmojiIcon() },
                { "capture_2_emoji", CaptureRateType.GreatBall.GetCaptureRateEmojiIcon() },
                { "capture_3_emoji", CaptureRateType.UltraBall.GetCaptureRateEmojiIcon() },

                // PvP stat properties
                { "is_great", Convert.ToString(MatchesGreatLeague) },
                { "is_ultra", Convert.ToString(MatchesUltraLeague) },
                { "is_pvp", Convert.ToString(MatchesGreatLeague || MatchesUltraLeague) },
                //{ "great_league_stats", greatLeagueStats },
                //{ "ultra_league_stats", ultraLeagueStats },
                { "great_league_emoji", greatLeagueEmoji },
                { "ultra_league_emoji", ultraLeagueEmoji },
                { "pvp_stats", pvpStats },

                // Other properties
                { "height", height ?? defaultMissingValue },
                { "weight", weight ?? defaultMissingValue },
                { "is_ditto", Convert.ToString(IsDitto) },
                { "original_pkmn_id", Convert.ToString(DisplayPokemonId) },
                { "original_pkmn_id_3", (DisplayPokemonId ?? 0).ToString("D3") },
                { "original_pkmn_name", catchPokemon },
                { "is_weather_boosted", Convert.ToString(isWeatherBoosted) },
                { "has_weather", Convert.ToString(hasWeather) },
                { "weather", weather ?? defaultMissingValue },
                { "weather_emoji", weatherEmoji ?? defaultMissingValue },
                { "username", Username ?? defaultMissingValue },
                { "spawnpoint_id", SpawnpointId ?? defaultMissingValue },
                { "encounter_id", EncounterId ?? defaultMissingValue },

                // Time properties
                { "despawn_time", DespawnTime.ToString("hh:mm:ss tt") },
                { "despawn_time_24h", DespawnTime.ToString("HH:mm:ss") },
                { "despawn_time_verified", DisappearTimeVerified ? "" : "~" },
                { "is_despawn_time_verified", Convert.ToString(DisappearTimeVerified) },
                { "time_left", SecondsLeft.ToReadableString(true) ?? defaultMissingValue },

                // Location properties
                { "geofence", properties.City ?? defaultMissingValue },
                { "lat", Convert.ToString(Latitude) },
                { "lng", Convert.ToString(Longitude) },
                { "lat_5", Latitude.ToString("0.00000") },
                { "lng_5", Longitude.ToString("0.00000") },

                // Location links
                { "tilemaps_url", staticMapLink },
                { "gmaps_url", gmapsLocationLink },
                { "applemaps_url", appleMapsLocationLink },
                { "wazemaps_url", wazeMapsLocationLink },
                { "scanmaps_url", scannerMapsLocationLink },

                { "address", address?.Address },

                // Pokestop properties
                { "near_pokestop", Convert.ToString(pokestop != null) },
                { "pokestop_id", PokestopId ?? defaultMissingValue },
                { "pokestop_name", pokestop?.Name ?? defaultMissingValue },
                { "pokestop_url", pokestop?.Url ?? defaultMissingValue },

                // Discord Guild properties
                { "guild_name", properties.Guild?.Name },
                { "guild_img_url", properties.Guild?.IconUrl },

                // Event properties
                { "is_event", Convert.ToString(IsEvent.HasValue && IsEvent.Value) },

                { "date_time", DateTime.Now.ToString() },

                // Misc properties
                { "br", "\r\n" }
            };

            return(dict);
        }
예제 #3
0
 public override string ToString()
 {
     return(FormId.ToString());
 }
예제 #4
0
        private async Task <IReadOnlyDictionary <string, string> > GetProperties(DiscordClient client, WhConfig whConfig, string city)
        {
            var pkmnInfo         = Database.Instance.Pokemon[Id];
            var form             = Id.GetPokemonForm(FormId.ToString());
            var costume          = Id.GetCostume(Costume.ToString());
            var gender           = Gender.GetPokemonGenderIconValue();
            var level            = Level;
            var size             = Size?.ToString();
            var weather          = Weather?.ToString();
            var weatherEmoji     = string.Empty;
            var hasWeather       = Weather.HasValue && Weather != WeatherType.None;
            var isWeatherBoosted = pkmnInfo?.IsWeatherBoosted(Weather ?? WeatherType.None);

            if (Weather.HasValue && Strings.WeatherEmojis.ContainsKey(Weather.Value) && Weather != WeatherType.None)
            {
                //TODO: Security check
                weatherEmoji = Weather.Value.GetWeatherEmojiIcon(client.Guilds[whConfig.Discord.EmojiGuildId]);//Strings.WeatherEmojis[Weather.Value];
            }
            var move1 = string.Empty;
            var move2 = string.Empty;

            if (int.TryParse(FastMove, out var fastMoveId) && MasterFile.Instance.Movesets.ContainsKey(fastMoveId))
            {
                move1 = MasterFile.Instance.Movesets[fastMoveId].Name;
            }
            if (int.TryParse(ChargeMove, out var chargeMoveId) && MasterFile.Instance.Movesets.ContainsKey(chargeMoveId))
            {
                move2 = MasterFile.Instance.Movesets[chargeMoveId].Name;
            }
            var type1      = pkmnInfo?.Types?[0];
            var type2      = pkmnInfo?.Types?.Count > 1 ? pkmnInfo.Types?[1] : PokemonType.None;
            var type1Emoji = client.Guilds.ContainsKey(whConfig.Discord.EmojiGuildId) ?
                             pkmnInfo?.Types?[0].GetTypeEmojiIcons(client.Guilds[whConfig.Discord.EmojiGuildId]) :
                             string.Empty;
            var type2Emoji = client.Guilds.ContainsKey(whConfig.Discord.EmojiGuildId) && pkmnInfo?.Types?.Count > 1 ?
                             pkmnInfo?.Types?[1].GetTypeEmojiIcons(client.Guilds[whConfig.Discord.EmojiGuildId]) :
                             string.Empty;
            var typeEmojis   = $"{type1Emoji} {type2Emoji}";
            var catchPokemon = IsDitto ? Database.Instance.Pokemon[DisplayPokemonId ?? Id] : Database.Instance.Pokemon[Id];

            var pkmnImage             = Id.GetPokemonImage(whConfig.Urls.PokemonImage, Gender, FormId, Costume);
            var gmapsLink             = string.Format(Strings.GoogleMaps, Latitude, Longitude);
            var appleMapsLink         = string.Format(Strings.AppleMaps, Latitude, Longitude);
            var wazeMapsLink          = string.Format(Strings.WazeMaps, Latitude, Longitude);
            var staticMapLink         = Utils.PrepareStaticMapUrl(whConfig.Urls.StaticMap, pkmnImage, Latitude, Longitude);
            var gmapsLocationLink     = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? gmapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink);
            var appleMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? appleMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink);
            var wazeMapsLocationLink  = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? wazeMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink);
            //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink);
            var pokestop = Pokestop.Pokestops.ContainsKey(PokestopId) ? Pokestop.Pokestops[PokestopId] : null;

            //var matchesGreatLeague = MatchesGreatLeague();
            //var matchesUltraLeague = MatchesUltraLeague();
            //var isPvP = matchesGreatLeague || matchesUltraLeague;
            //var pvpStats = await GetPvP();

            const string defaultMissingValue = "?";
            var          dict = new Dictionary <string, string>
            {
                //Main properties
                { "pkmn_id", Convert.ToString(Id) },
                { "pkmn_name", pkmnInfo.Name },
                { "pkmn_img_url", pkmnImage },
                { "form", form },
                { "form_id", Convert.ToString(FormId) },
                { "form_id_3", FormId.ToString("D3") },
                { "costume", costume ?? defaultMissingValue },
                { "costume_id", Convert.ToString(Costume) },
                { "costume_id_3", Costume.ToString("D3") },
                { "cp", CP ?? defaultMissingValue },
                { "lvl", level ?? defaultMissingValue },
                { "gender", gender },
                { "size", size ?? defaultMissingValue },
                { "move_1", move1 ?? defaultMissingValue },
                { "move_2", move2 ?? defaultMissingValue },
                { "moveset", $"{move1}/{move2}" },
                { "type_1", type1?.ToString() ?? defaultMissingValue },
                { "type_2", type2?.ToString() ?? defaultMissingValue },
                { "type_1_emoji", type1Emoji },
                { "type_2_emoji", type2Emoji },
                { "types", $"{type1} | {type2}" },
                { "types_emoji", typeEmojis },
                { "atk_iv", Attack ?? defaultMissingValue },
                { "def_iv", Defense ?? defaultMissingValue },
                { "sta_iv", Stamina ?? defaultMissingValue },
                { "iv", IV ?? defaultMissingValue },
                { "iv_rnd", IVRounded ?? defaultMissingValue },

                //PvP stat properties
                //{ "is_great", Convert.ToString(matchesGreatLeague) },
                //{ "is_ultra", Convert.ToString(matchesUltraLeague) },
                //{ "is_pvp", Convert.ToString(isPvP) },
                ////{ "great_league_stats", greatLeagueStats },
                ////{ "ultra_league_stats", ultraLeagueStats },
                //{ "pvp_stats", pvpStats },

                //Other properties
                { "height", Height ?? defaultMissingValue },
                { "weight", Weight ?? defaultMissingValue },
                { "is_ditto", Convert.ToString(IsDitto) },
                { "original_pkmn_id", Convert.ToString(DisplayPokemonId) },
                { "original_pkmn_id_3", (DisplayPokemonId ?? 0).ToString("D3") },
                { "original_pkmn_name", catchPokemon?.Name },
                { "is_weather_boosted", Convert.ToString(isWeatherBoosted) },
                { "has_weather", Convert.ToString(hasWeather) },
                { "weather", weather ?? defaultMissingValue },
                { "weather_emoji", weatherEmoji ?? defaultMissingValue },
                { "username", Username ?? defaultMissingValue },
                { "spawnpoint_id", SpawnpointId ?? defaultMissingValue },
                { "encounter_id", EncounterId ?? defaultMissingValue },

                //Time properties
                { "despawn_time", DespawnTime.ToString("hh:mm:ss tt") },
                { "despawn_time_verified", DisappearTimeVerified ? "" : "~" },
                { "is_despawn_time_verified", Convert.ToString(DisappearTimeVerified) },
                { "time_left", SecondsLeft.ToReadableString(true) ?? defaultMissingValue },

                //Location properties
                { "geofence", city ?? defaultMissingValue },
                { "lat", Convert.ToString(Latitude) },
                { "lng", Convert.ToString(Longitude) },
                { "lat_5", Convert.ToString(Math.Round(Latitude, 5)) },
                { "lng_5", Convert.ToString(Math.Round(Longitude, 5)) },

                //Location links
                { "tilemaps_url", staticMapLink },
                { "gmaps_url", gmapsLocationLink },
                { "applemaps_url", appleMapsLocationLink },
                { "wazemaps_url", wazeMapsLocationLink },

                //Pokestop properties
                { "near_pokestop", Convert.ToString(pokestop != null) },
                { "pokestop_id", PokestopId ?? defaultMissingValue },
                { "pokestop_name", pokestop?.Name ?? defaultMissingValue },
                { "pokestop_url", pokestop?.Url ?? defaultMissingValue },

                //Misc properties
                { "br", "\r\n" }
            };

            return(await Task.FromResult(dict));
        }
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Version", Version.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "FormId", FormId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "FormName", application.CoreObjectGetNameById("Form", formId));

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "StoreImage", StoreImage.ToString());

            #endregion


            #region Contents

            System.Xml.XmlNode componentsNode = document.CreateElement("Contents");

            document.LastChild.AppendChild(componentsNode);

            foreach (Int32 currentContentIndex in content.Keys)
            {
                componentsNode.AppendChild(document.ImportNode(content [currentContentIndex].XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
예제 #6
0
        public override string GetValue(ValueElement element)
        {
            FormId data = element.data;

            return(data.ToString());
        }