コード例 #1
0
ファイル: Router.cs プロジェクト: worms618/FormeleMethoden
 public void AddRoute(FormId id, Form f)
 {
     if (!_routes.ContainsKey(id))
     {
         _routes.Add(id, f);
     }
 }
コード例 #2
0
 public DATAField(BinaryFileReader r, int dataSize)
 {
     Flags     = r.ReadUInt32();
     BaseCost  = r.ReadSingle();
     AssocItem = r.ReadInt32();
     //wbUnion('Assoc. Item', wbMGEFFAssocItemDecider, [
     //  wbFormIDCk('Unused', [NULL]),
     //  wbFormIDCk('Assoc. Weapon', [WEAP]),
     //  wbFormIDCk('Assoc. Armor', [ARMO, NULL{?}]),
     //  wbFormIDCk('Assoc. Creature', [CREA, LVLC, NPC_]),
     //  wbInteger('Assoc. Actor Value', itS32, wbActorValueEnum)
     MagicSchool        = r.ReadInt32();
     ResistValue        = r.ReadInt32();
     CounterEffectCount = r.ReadUInt16();
     r.Skip(2); // Unused
     Light           = new FormId <LIGHRecord>(r.ReadUInt32());
     ProjectileSpeed = r.ReadSingle();
     EffectShader    = new FormId <EFSHRecord>(r.ReadUInt32());
     if (dataSize == 36)
     {
         return;
     }
     EnchantEffect = new FormId <EFSHRecord>(r.ReadUInt32());
     CastingSound  = new FormId <SOUNRecord>(r.ReadUInt32());
     BoltSound     = new FormId <SOUNRecord>(r.ReadUInt32());
     HitSound      = new FormId <SOUNRecord>(r.ReadUInt32());
     AreaSound     = new FormId <SOUNRecord>(r.ReadUInt32());
     ConstantEffectEnchantmentFactor = r.ReadSingle();
     ConstantEffectBarterFactor      = r.ReadSingle();
 }
コード例 #3
0
 public override dynamic ConvertLabel(GroupRecord group, byte[] label)
 {
     return(FormId.FromSource(
                group.file,
                BitConverter.ToUInt32(label)
                ));
 }
コード例 #4
0
ファイル: UserController.cs プロジェクト: FPskyline/DC
        public IActionResult SaveForm(FormIdDto model)
        {
            try
            {
                var user = _context.User.Where(x => x.OpenId == model.OpenId).FirstOrDefault();



                var FormIdInfo = new FormId()
                {
                    UserId    = user.UserId,
                    FormIds   = model.FormIds,
                    CreatDate = DateTime.Now,
                };
                _context.FormIds.Add(FormIdInfo);
                _context.SaveChanges();



                return(Ok("新增成功"));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
コード例 #5
0
ファイル: FormTable.cs プロジェクト: 7topsoft/OpenCube
 public override void Validate()
 {
     FormId.ThrowIfEmpty(nameof(FormId));
     Name.ThrowIfNullOrWhiteSpace(nameof(Name));
     SortOrder.ThrowIfOutOfRange(nameof(SortOrder), 0);
     CreatorId.ThrowIfNullOrWhiteSpace(nameof(CreatorId));
 }
        /// <summary>
        /// Get the ID of a recently created form. Can be used to find the ID of the form to delete using GetFormToDelete(string ID)
        /// </summary>
        /// <returns>The ID of a form</returns>
        public int GetFormId()
        {
            // wait until the form id element is populated
            var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10));

            wait.Until(d => FormId.GetAttribute("value") != 0.ToString());

            return(int.Parse(FormId.GetAttribute("value")));
        }
コード例 #7
0
 public LNAMField(BinaryFileReader r, int dataSize)
 {
     Direct = new FormId <Record>(r.ReadUInt32());
     //if (dataSize == 0)
     IndirectWorld = new FormId <WRLDRecord>(r.ReadUInt32());
     //if (dataSize == 0)
     IndirectGridX = r.ReadInt16();
     IndirectGridY = r.ReadInt16();
 }
コード例 #8
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,
     });
 }
コード例 #9
0
 public PGRLField(BinaryFileReader r, int dataSize)
 {
     Reference = new FormId <REFRRecord>(r.ReadUInt32());
     PointIds  = new short[(dataSize - 4) >> 2];
     for (var i = 0; i < PointIds.Length; i++)
     {
         PointIds[i] = r.ReadInt16();
         r.Skip(2); // Unused (can merge back)
     }
 }
コード例 #10
0
ファイル: Record+Fields.cs プロジェクト: libcs/game-estates
        public FormId <Record> Item;      // The ID of the item

        public CNTOField(BinaryFileReader r, int dataSize, GameFormat format)
        {
            if (format == GameFormat.TES3)
            {
                ItemCount = r.ReadUInt32();
                Item      = new FormId <Record>(r.ReadASCIIString(32, ASCIIFormat.ZeroPadded));
                return;
            }
            Item      = new FormId <Record>(r.ReadUInt32());
            ItemCount = r.ReadUInt32();
        }
コード例 #11
0
 public RecordHeader(BinaryReader reader)
 {
     Type = reader.ReadId4();
     Size = reader.ReadUInt32();
     Flags = (RecordFlags)reader.ReadUInt32();
     Id = new FormId(reader.ReadUInt32());
     Revision = reader.ReadUInt32();
     Version = reader.ReadUInt16();
     Unknown = reader.ReadUInt16();
     StartOffset = reader.BaseStream.Position;
 }
コード例 #12
0
 public XLOCField(BinaryFileReader r, int dataSize)
 {
     LockLevel = r.ReadByte();
     r.Skip(3); // Unused
     Key = new FormId <KEYMRecord>(r.ReadUInt32());
     if (dataSize == 16)
     {
         r.Skip(4); // Unused
     }
     Flags = r.ReadByte();
     r.Skip(3); // Unused
 }
コード例 #13
0
ファイル: Router.cs プロジェクト: worms618/FormeleMethoden
        public void AddRoute(FormId id, Form f, bool routeTo)
        {
            if (!_routes.ContainsKey(id))
            {
                _routes.Add(id, f);
            }

            if (routeTo)
            {
                this.RouteTo(id);
            }
        }
コード例 #14
0
ファイル: 345-REGN.Region.cs プロジェクト: libcs/game-estates
 public RDSDField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         Sound  = new FormId <SOUNRecord>(r.ReadASCIIString(32, ASCIIFormat.ZeroPadded));
         Flags  = 0;
         Chance = r.ReadByte();
         return;
     }
     Sound  = new FormId <SOUNRecord>(r.ReadUInt32());
     Flags  = r.ReadUInt32();
     Chance = r.ReadUInt32(); //: float with TES5
 }
コード例 #15
0
        public override int GetHashCode()
        {
            int hash = 17;

            hash = hash * 23 + FormId.GetHashCode();
            hash = hash * 23 + MultipleIteration.GetHashCode();
            hash = hash * 23 + CurrentRow.GetHashCode();
            foreach (var otherRow in this.OtherRows)
            {
                hash = hash * 23 + otherRow.GetHashCode();
            }
            return(hash);
        }
コード例 #16
0
 internal List <object> GetExportVals()
 {
     return(new List <object>
     {
         Id,
         SiteId.DBExport(),
         HfId.DBExport(),
         Reason.DBExport(Reasons),
         ReasonId.DBExport(),
         Circumstance.DBExport(Circumstances),
         CircumstanceId.DBExport(),
         FormId.DBExport()
     });
 }
コード例 #17
0
 public LVLOField(UnityBinaryReader r, int dataSize)
 {
     Level = r.ReadLEInt16();
     r.SkipBytes(2); // Unused
     ItemFormId = new FormId <Record>(r.ReadLEUInt32());
     if (dataSize == 12)
     {
         Count = r.ReadLEInt16();
         r.SkipBytes(2); // Unused
     }
     else
     {
         Count = 0;
     }
 }
コード例 #18
0
 public LVLOField(BinaryFileReader r, int dataSize)
 {
     Level = r.ReadInt16();
     r.Skip(2); // Unused
     ItemFormId = new FormId <Record>(r.ReadUInt32());
     if (dataSize == 12)
     {
         Count = r.ReadInt16();
         r.Skip(2); // Unused
     }
     else
     {
         Count = 0;
     }
 }
コード例 #19
0
ファイル: PanelConfigMapEntry.cs プロジェクト: angellcq/src
        /// <summary>
        /// Checks if the specified map entry is the
        /// same as this object
        /// </summary>
        /// <param name="mapEntry">entry to compare</param>
        /// <returns>true if it is</returns>
        public bool IsEqual(PanelConfigMapEntry mapEntry)
        {
            bool retVal;

            if (mapEntry.FormId != Guid.Empty && FormId != Guid.Empty)
            {
                retVal = FormId.Equals(mapEntry.FormId);
            }
            else
            {
                retVal = String.Compare(ConfigName, mapEntry.ConfigName, true) == 0;
            }

            return(retVal);
        }
コード例 #20
0
        internal void UpdateContainedIn(GroupRecord group, MainRecord rec)
        {
            if (group == null || !group.hasRecordParent)
            {
                return;
            }
            var parentRec      = group.GetParentRecord();
            var containedInDef = parentRec.mrDef.containedInDef;

            if (containedInDef == null)
            {
                return;
            }
            var element = (ValueElement)rec.FindElementForDef(containedInDef);

            element._data = FormId.FromSource(parentRec._file, parentRec.fileFormId);
        }
コード例 #21
0
        public void TestRecordHeaderData()
        {
            var fileHeader = plugin.header;
            var rh         = fileHeader.GetElement("Record Header");

            Assert.AreEqual("TES4", rh.GetData("Signature"));
            Assert.AreEqual(113, rh.GetData("Data Size"));
            Assert.AreEqual(0, rh.GetData("Record Flags"));
            FormId formId = rh.GetData("FormID");

            Assert.AreEqual(formId.localFormId, 0);
            byte[] vc1 = rh.GetData("Version Control Info 1");
            Assert.AreEqual(vc1[0], 0);
            Assert.AreEqual(44, rh.GetData("Form Version"));
            byte[] vc2 = rh.GetData("Version Control Info 2");
            Assert.AreEqual(vc2[0], 0);
        }
コード例 #22
0
ファイル: Router.cs プロジェクト: worms618/FormeleMethoden
        public bool RouteTo(FormId id, bool getSizeOfPrevious)
        {
            if (!this._routes.TryGetValue(id, out Form nextForm))
            {
                return(false);
            }

            _current?.Hide();
            if (_current != null && getSizeOfPrevious)
            {
                nextForm.Width  = _current.Width;
                nextForm.Height = _current.Height;
            }
            _current = nextForm;
            _current.Show();
            return(true);
        }
コード例 #23
0
ファイル: 345-REGN.Region.cs プロジェクト: libcs/game-estates
            public ColorRef4       VertexShading; // RGB + Shading radius (0 - 200) %

            public RDOTField(BinaryFileReader r, int dataSize)
            {
                Object    = new FormId <Record>(r.ReadUInt32());
                ParentIdx = r.ReadUInt16();
                r.Skip(2); // Unused
                Density         = r.ReadSingle();
                Clustering      = r.ReadByte();
                MinSlope        = r.ReadByte();
                MaxSlope        = r.ReadByte();
                Flags           = r.ReadByte();
                RadiusWrtParent = r.ReadUInt16();
                Radius          = r.ReadUInt16();
                MinHeight       = r.ReadSingle();
                MaxHeight       = r.ReadSingle();
                Sink            = r.ReadSingle();
                SinkVariance    = r.ReadSingle();
                SizeVariance    = r.ReadSingle();
                AngleVariance   = new Vector3Int(r.ReadUInt16(), r.ReadUInt16(), r.ReadUInt16());
                r.Skip(2); // Unused
                VertexShading = r.ReadT <ColorRef4>(dataSize);
            }
コード例 #24
0
ファイル: Image.cs プロジェクト: nematzadehsppc/Android.dll
        protected override System.Drawing.Image Execute(CodeActivityContext context)
        {
            try
            {
                string ip         = "localhost";
                string port       = Port.Get <string>(context);
                string db         = dbName.Get <string>(context);
                string version    = Version.Get <string>(context);
                string group      = Group.Get <string>(context);
                string entity     = Entity.Get <string>(context);
                string function   = Function.Get <string>(context);
                int    merchId    = MerchId.Get <int>(context);
                int    fpid       = FPId.Get <int>(context);
                int    sysId      = SysId.Get <int>(context);
                int    formId     = FormId.Get <int>(context);
                string serviceKey = ServiceKey.Get <string>(context);
                int    imageId    = ImageId.Get <int>(context);

                string url = string.Format("http://{0}:{1}/{2}/{3}/{4}/{5}/{6}?MerchId={7}&SysId={8}&FormId={9}&FPId={10}&key={11}&ImageId={12}",
                                           ip, port, db, version, group, entity, function, merchId, sysId, formId, fpid, serviceKey, imageId);

                HttpClient client = new HttpClient();
                Task <HttpResponseMessage> message = client.GetAsync(url);
                message.Wait();
                Task <string> messageResult = message.Result.Content.ReadAsStringAsync();
                messageResult.Wait();

                System.Drawing.Image result = null;
                byte[] imageByteArray       = Convert.FromBase64String(messageResult.Result.Replace("\"", ""));
                using (MemoryStream stream = new MemoryStream(imageByteArray))
                {
                    result = System.Drawing.Image.FromStream(stream);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #25
0
        public StructElement ToStructElement(
            MainRecord rec, PluginFileSource source
            )
        {
            var headerDef     = rec.mrDef.headerDef;
            var structElement = new StructElement(rec, headerDef);
            var defs          = headerDef.elementDefs;
            int i             = 0;

            ValueElement.Init(structElement, defs[i++], signature.ToString());
            ValueElement.Init(structElement, defs[i++], dataSize);
            ValueElement.Init(structElement, defs[i++], flags);
            var targetFile = rec.file.OrdinalToFile((byte)(formId >> 24), false);
            var fid        = new FormId(targetFile, formId & 0xFFFFFF);

            ValueElement.Init(structElement, defs[i++], fid);
            source.stream.Position += 16;
            for (; i < defs.Count; i++)
            {
                defs[i].ReadElement(structElement, source);
            }
            return(structElement);
        }
コード例 #26
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (MonsterBaseId != 0)
            {
                hash ^= MonsterBaseId.GetHashCode();
            }
            if (ActorId.Length != 0)
            {
                hash ^= ActorId.GetHashCode();
            }
            if (ActorNumber != 0)
            {
                hash ^= ActorNumber.GetHashCode();
            }
            if (ActorVariant != 0)
            {
                hash ^= ActorVariant.GetHashCode();
            }
            if (U5 != 0)
            {
                hash ^= U5.GetHashCode();
            }
            if (JpName.Length != 0)
            {
                hash ^= JpName.GetHashCode();
            }
            if (U7 != 0)
            {
                hash ^= U7.GetHashCode();
            }
            if (Gender != 0)
            {
                hash ^= Gender.GetHashCode();
            }
            if (U9 != 0)
            {
                hash ^= U9.GetHashCode();
            }
            if (Strength != 0)
            {
                hash ^= Strength.GetHashCode();
            }
            if (U11 != 0)
            {
                hash ^= U11.GetHashCode();
            }
            if (FormPassiveId != 0)
            {
                hash ^= FormPassiveId.GetHashCode();
            }
            if (U13 != 0)
            {
                hash ^= U13.GetHashCode();
            }
            if (U14 != 0)
            {
                hash ^= U14.GetHashCode();
            }
            if (FormId != 0)
            {
                hash ^= FormId.GetHashCode();
            }
            if (MonsterNameId != 0)
            {
                hash ^= MonsterNameId.GetHashCode();
            }
            if (IsShiny != false)
            {
                hash ^= IsShiny.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #27
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);
        }
コード例 #28
0
        protected string RenderJavascript()
        {
            StringBuilder script = new StringBuilder();

            script.Append(" $(function () {").AppendLine();
            //多语弹出框关闭
            script.AppendLine(" $(\".multilangpopoverclose\").on(ace.click_event, function () {     $(this).closest(\".popover\").css(\"display\",\"none\");  });");
            //参照弹出事件、上传附件、数值控件
            //开启textarea 校验
            bool hasTextArea = false;
            //开启jqueryvalidate校验的条件
            bool needValidate = false;

            foreach (FapField field in formFields)
            {
                FapColumn column = field.CurrentColumn;
                if (column.ColName == "Id" || column.ColName == "Fid" || column.ShowAble == 0)
                {
                    continue;
                }
                if (!hasTextArea && column.CtrlType == FapColumn.CTRL_TYPE_MEMO)
                {
                    hasTextArea = true;
                }
                if (!needValidate && ((column.NullAble == 0 && column.ShowAble == 1) || column.RemoteChkURL.IsPresent()))
                {
                    needValidate = true;
                }
                #region 日期
                if (column.CtrlType == FapColumn.CTRL_TYPE_DATE)
                {
                    string model      = "0";
                    string dateFormat = column.DisplayFormat;
                    string minDate    = "1900-1-1";
                    string maxDate    = "2999-12-12";
                    if (dateFormat.IsMissing())
                    {
                        dateFormat = "yyyy-mm-dd";
                        model      = "0";
                    }
                    else if (dateFormat.Length > 4 && dateFormat.Length < 10)
                    {
                        dateFormat = "yyyy-mm";
                        model      = "1";
                    }
                    else
                    {
                        dateFormat = "yyyy";
                        model      = "2";
                    }
                    if (column.MinValue != 0)
                    {
                        minDate = DateTimeUtils.DateFormat(DateTime.Now.AddDays((double)column.MinValue));
                    }
                    if (column.MaxValue != 0)
                    {
                        maxDate = DateTimeUtils.DateFormat(DateTime.Now.AddDays((double)column.MaxValue));
                    }
                    if (dateFormat == "yyyy-mm-dd")
                    {
                        script.AppendLine(" $(\"###formid## #" + column.ColName + "\").scroller('destroy').scroller($.extend({preset:'date', minDate:moment('" + minDate + "').toDate(),maxDate:moment('" + maxDate + "').toDate()},{ theme: 'android-ics light', mode: 'scroller', display:'modal', lang: 'zh' }));");
                    }
                    else
                    {
                        script.AppendLine("$(\"###formid## #" + column.ColName + "\").datePicker({  followOffset: [0, 24],onselect:function(date){ var formatDate = DatePicker.formatDate(date, '" + dateFormat + "');this.shell.val(formatDate).change();  return false;},minDate:'" + minDate + "',maxDate:'" + maxDate + "', altFormat:'" + dateFormat + "',showMode:" + model + " }).next().on(ace.click_event, function () {$(this).prev().focus(); });");
                    }
                }
                else if (column.CtrlType == FapColumn.CTRL_TYPE_DATETIME)
                {
                    //moment.js的格式
                    //string format = column.DisplayFormat;
                    //string startDate = "1900-1-1";
                    //string endDate = "2999-12-12";
                    //string startView = "2";
                    //if (column.MinValue.HasValue)
                    //{
                    //    startDate = DateTime.Now.AddDays((column.MinValue).ToDouble()).ToString(PublicUtils.DateFormat);
                    //}
                    //if (column.MaxValue.HasValue)
                    //{
                    //    endDate = DateTime.Now.AddDays((column.MaxValue).ToDouble()).ToString(PublicUtils.DateFormat);
                    //}
                    //if (format.IsMissing())
                    //{
                    //    format = "yyyy-mm-dd hh:ii:ss";
                    //}
                    //else if (format.EqualsWithIgnoreCase("HH:mm"))
                    //{
                    //    format = "hh:ii";
                    //    startView = "0";
                    //}


                    //script.AppendLine(" $(\"#" + column.ColName + "\").datetimepicker({ format:\"" + format + "\",startDate:'" + startDate + "',endDate:'" + endDate + "',startView:" + startView + ",todayBtn:true,todayHighlight:true, language: \"zh-CN\" }).next().on(ace.click_event, function () {            $(this).prev().focus();        });");

                    string format    = column.DisplayFormat;
                    string startDate = "1900-1-1";
                    string endDate   = "2999-12-12";

                    if (column.MinValue != 0)
                    {
                        startDate = DateTimeUtils.DateFormat(DateTime.Now.AddDays((double)column.MinValue));
                    }
                    if (column.MaxValue != 0)
                    {
                        endDate = DateTimeUtils.DateFormat(DateTime.Now.AddDays((double)column.MaxValue));
                    }
                    if (format.IsMissing())
                    {
                        //format = "datetime";
                        //script.AppendLine("opt.datetime = { preset : 'datetime', minDate:moment('" + startDate + "').toDate(), maxDate: minDate:moment('" + endDate + "').toDate() , stepMinute: 5  };");
                        script.AppendLine(" $(\"###formid## #" + column.ColName + "\").scroller('destroy').scroller($.extend({ preset:'datetime', minDate:moment('" + startDate + "').toDate(), maxDate:moment('" + endDate + "').toDate() , stepMinute: 5  }, { theme:'android-ics light', mode: 'scroller', display:'modal', lang: 'zh' }));");
                    }
                    else if (format.EqualsWithIgnoreCase("HH:mm"))
                    {
                        format = "time";
                        //script.AppendLine("opt.time = {preset : 'time'};");
                        script.AppendLine(" $(\"###formid## #" + column.ColName + "\").scroller('destroy').scroller($.extend({preset:'time'}, { theme: 'android-ics light', mode: 'scroller', display:'modal', lang: 'zh' }));");
                    }
                }
                #endregion

                #region 参照
                else if (column.CtrlType == FapColumn.CTRL_TYPE_REFERENCE && !field.ReadOnly)
                {
                    //去除自定义列
                    if (column.IsCustomColumn == 1)
                    {
                        continue;
                    }
                    //编码已经和地址一样了
                    string refUrl = column.RefType;
                    //if (column.RefType == "GRID")
                    //{
                    //    refUrl = "GridReference";
                    //}
                    //else if (column.RefType == "TREE")
                    //{
                    //    refUrl = "TreeReference";
                    //}
                    //else
                    //{
                    //    refUrl = "TreeGridReference";
                    //}
                    string dispalyName = _multiLangService.GetMultiLangValue(MultiLanguageOriginEnum.FapColumn, $"{column.TableName}_{column.ColName}");
                    script.AppendLine("$(\"###formid## #" + column.ColName + "MC\").next().on(ace.click_event, function(){");
                    //script.AppendLine("//不可编辑字段不能弹出");
                    script.AppendLine(" if($(this).prev().attr(\"disabled\")==\"disabled\"){return;}");
                    //扩展参考值,参照参数用
                    script.AppendLine("var extra=[];");

                    //针对某些参照要用表单上的控件数据
                    if (column.RefCondition.IsPresent())
                    {
                        //DeptUid='${DeptUid}',@后面为表单上的控件
                        string fieldName = "";
                        string pattern   = FapPlatformConstants.VariablePattern;
                        Regex  regex     = new Regex(pattern);
                        var    mat       = regex.Matches(column.RefCondition);
                        foreach (Match item in mat)
                        {
                            int length = item.ToString().Length - 3;
                            fieldName = item.ToString().Substring(2, length);
                            //fieldName = item.Groups[1].ToString();

                            FapColumn col = _fapColumns.FirstOrDefault(f => f.ColName.EqualsWithIgnoreCase(fieldName));
                            if (col != null)
                            {
                                script.AppendLine("var conv=$('#" + fieldName + "').val();if(conv==''){bootbox.alert('【" + _multiLangService.GetMultiLangValue(MultiLanguageOriginEnum.FapColumn, $"{col.TableName}_{col.ColName}") + "】为空,请先设置。');return;}");
                                script.AppendLine("extra.push('" + fieldName + "='+conv)");
                            }
                        }
                    }
                    script.AppendLine("loadRefMessageBox('" + dispalyName + "','##formid##','" + column.Fid + "','" + column.ColName + "','" + refUrl + "',extra)");
                    script.AppendLine("});");
                    script.AppendLine("$(\"###formid## #" + column.ColName + "MC\").on(ace.click_event,function(e){$(this).next().trigger(ace.click_event);e.preventDefault();});");
                }
                #endregion

                #region 附件

                else if (column.CtrlType == FapColumn.CTRL_TYPE_FILE)
                {
                    script.AppendLine("$(\"###formid## #file" + FormId + column.ColName + "\").on(ace.click_event, function () {");
                    string tempFid = UUIDUtils.Fid;
                    if (field.FieldValue.ToString().IsMissing())
                    {
                        field.FieldValue = tempFid;
                    }
                    script.AppendLine("loadFileMessageBox('" + tempFid + "','##formid##',initFile" + FormId.Replace('-', '_') + tempFid + ");");

                    script.AppendLine("});");
                    string allowExt = string.Empty;
                    if (column.FileSuffix.IsPresent())
                    {
                        List <string> suffix = column.FileSuffix.SplitComma();
                        if (suffix.Any())
                        {
                            allowExt = string.Join(",", suffix.Select(s => "'" + s + "'").ToList());
                        }
                    }
                    //建立初始化附件控件js函数
                    script.AppendLine("var initFile" + FormId.Replace('-', '_') + tempFid + "=function(){");
                    script.AppendLine("$(\"###formid##" + tempFid + "-FILE\").fileinput({");
                    script.AppendLine("language: language,");
                    script.AppendLine($"uploadUrl:\"{ _applicationContext.BaseUrl }/Component/UploadFile/{ field.FieldValue }\",");
                    //script.AppendLine("deleteUrl:\"http://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath  + "/Api/Core/deletefile\",");
                    if (allowExt.IsPresent())
                    {
                        script.AppendLine($"allowedFileExtensions : [{ allowExt }],");
                    }
                    if (column.FileSize > 0)
                    {
                        script.AppendLine($"maxFileSize: {column.FileSize},");
                    }
                    script.AppendLine("uploadExtraData:{fid:'" + field.FieldValue + "'},");
                    script.AppendLine("allowedPreviewTypes: ['image', 'text'],");
                    script.AppendLine($"maxFileCount:{(column.FileCount == 0 ? 1 : column.FileCount)},");
                    script.AppendLine("showUpload: true,");
                    //script.AppendLine("showCaption: false,");
                    //script.AppendLine("overwriteInitial: false,");
                    script.AppendLine("slugCallback: function(filename) {");
                    script.AppendLine(" return filename.replace('(', '_').replace(']', '_');");
                    script.AppendLine("},");
                    //浏览按钮样式
                    //script.AppendLine("browseClass: \"btn btn-primary btn-block\",");
                    //浏览按钮图标
                    script.AppendLine("previewFileIcon: \"<i class='glyphicon glyphicon-king'></i>\"})");
                    //script.AppendLine(@".on('fileloaded', function(event, file, previewId, index, reader) {
                    //    var files =$(this).fileinput('getFileStack');
                    //    $(this).fileinput('uploadSingle',index,files,false);})");
                    script.AppendLine(@".on('fileuploaded', function (event, data, previewId, index) {  if(data.response.success==false){bootbox.alert(data.response.msg);}else{loadFileList('" + FormId + "', '" + column.ColName + "', '" + field.FieldValue.ToString() + "');                } });       ");
                    script.AppendLine("}");
                    if (_formStatus == FormStatus.Edit)
                    {
                        string bid = field.FieldValue.ToString();
                        script.AppendLine("loadFileList('" + FormId + "','" + column.ColName + "','" + bid + "');");
                    }
                }
                #endregion

                #region 图片头像
                else if (column.CtrlType == FapColumn.CTRL_TYPE_IMAGE && !field.ReadOnly)
                {
                    if (field.FieldValue.ToString().IsMissing())
                    {
                        field.FieldValue = UUIDUtils.Fid;
                    }
                    script.AppendLine("loadImageControl('avatar" + column.ColName + "')");
                }
                #endregion

                #region 富文本控件
                else if (column.CtrlType == FapColumn.CTRL_TYPE_RICHTEXTBOX)
                {
                    script.AppendLine("var wysiwyg_" + column.ColName + " =$(\"###formid## #" + column.ColName + ".wysiwyg-editor\").ace_wysiwyg({" + @"
						toolbar:
						[
                            'font',
			                null,
			                'fontSize',
			                null,
							'bold',
							'italic',
							'strikethrough',
							'underline',
							null,
                            'insertunorderedlist',
                            'insertorderedlist',
                            'outdent',
                            'indent', 
                            null,
							'justifyleft',
							'justifycenter',
							'justifyright',
							null,
							'createLink',
							'unlink',
							null,
                            'insertImage',
                            null,
                            'foreColor',
		                    null,
							'undo',
							'redo',
                            null,
						'viewSource'
						]
					}).prev().addClass('wysiwyg-style1');"                    );
                    //script.AppendLine("$(\"#frm-" + _id + " #" + column.ColName + "\").html('" + StringUtil.TextToHtml(field.FieldValue.ToString()) + "');");
                }
                #endregion

                #region 数值控件
                else if (column.CtrlType == FapColumn.CTRL_TYPE_INT || column.CtrlType == FapColumn.CTRL_TYPE_DOUBLE || column.CtrlType == FapColumn.CTRL_TYPE_MONEY)
                {
                    if (column.EditAble != 1)
                    {
                        continue;
                    }
                    int min = column.MinValue;
                    int max = column.MaxValue;
                    if (min == 0 && max == 0)
                    {
                        min = int.MinValue;
                        max = int.MaxValue;
                    }
                    string unit = "";
                    if (column.CtrlType == FapColumn.CTRL_TYPE_MONEY)
                    {
                        unit = " postfix: '¥'";
                    }
                    string step      = "1";
                    int    precision = column.ColPrecision;
                    if (precision > 0)
                    {
                        step = "0." + "1".PadLeft(precision, '0');
                    }
                    script.AppendLine(" $(\"###formid## input[name='" + column.ColName + "']\").TouchSpin({");
                    script.AppendLine(@"
                        min: " + min + @",
                        max: " + max + @",
                        step: " + step + @",
                        decimals: " + precision + @",
                        boostat: 5,
                        maxboostedstep: 10,
                     
                        " + unit + @"
                    });
                   ");
                }
                #endregion

                #region 数值范围
                else if (column.CtrlType == FapColumn.CTRL_TYPE_RANGE)
                {
                    StringBuilder sr = new StringBuilder("[");
                    for (int i = column.MinValue; i <= column.MaxValue; i++)
                    {
                        sr.Append($"{i},");
                    }
                    string r = sr.ToString().TrimEnd(',');
                    r += "]";
                    script.AppendLine(@"$('###formid## #" + column.ColName + @"').jRange({
                        from: " + column.MinValue + @",
                        to: " + column.MaxValue + @",
                        step: 1,
                        scale: " + r + @",
                        format: '%s',
                        width: 680,
                        disable:" + ((column.EditAble == 0 || field.ReadOnly) ? "true," : "false,") + @"
                        theme:'theme-blue',
                        showLabels: true,
                        isRange: true
                    });");
                }
                #endregion

                #region 籍贯

                else if (column.CtrlType == FapColumn.CTRL_TYPE_NATIVE)
                {
                    //籍贯
                    script.AppendLine("$(\"###formid## #" + column.ColName + "\").citypicker();");
                }

                #endregion

                #region 城市

                else if (column.CtrlType == FapColumn.CTRL_TYPE_CITY)
                {
                    //城市
                    script.AppendLine("$(\"###formid## #" + column.ColName + "\").cityselect();");
                }

                #endregion
                #region 评星级
                else if (column.CtrlType == FapColumn.CTRL_TYPE_STAR)
                {
                    if (field.FieldValue?.ToString().IsMissing() ?? true)
                    {
                        field.FieldValue = "0";
                    }
                    //评星级
                    script.AppendLine("if(!$(\"###formid## #" + column.ColName + "\").prop(\"disabled\")){ $(\"###formid## #rat-" + column.ColName + "\").raty({number: 5,score:" + field.FieldValue +
                                      @", cancel: true,  'starType' : 'i',
                    'click': function(score,evt) {" +
                                      "$(\"###formid## #" + column.ColName + "\").val(score);" +
                                      @"},					
                    })}else{" + "$(\"###formid## #rat-" + column.ColName + "\").raty({number: 5,score:" + field.FieldValue +
                                      @",  'starType' : 'i',readOnly: true			
                    })}");
                }
                #endregion
                #region 多語
                else if (column.CtrlType == FapColumn.CTRL_TYPE_TEXT && column.IsMultiLang == 1)
                {
                    string oriCtrl = column.ColName;

                    string ctrmultiLang = oriCtrl + _multiLangService.CurrentLanguageName;

                    script.AppendLine("$(\"###formid## #" + oriCtrl + "\").on(\"blur\",function(){$(\"###formid## #" + ctrmultiLang + "\").val($(this).val())}).next().on(ace.click_event, function(){");
                    script.AppendLine(" document.addEventListener(\"mousedown\", onMultiLangPoverMouseDown, false);");
                    script.AppendLine("var fid=$(this).data(\"fid\");");
                    script.AppendLine("var X1 = $(\"###formid## #" + oriCtrl + "\").offset().top-55;var Y1 =$(\"###formid## #" + oriCtrl + "\").offset().left;");
                    script.AppendLine("var bg=$(\"#\"+fid).closest(\".modal-lg\");var top=X1;var left=Y1");
                    script.AppendLine("if(bg){ var bgo=bg.offset();   top=X1-bgo.top;left=Y1-bgo.left;}");
                    script.AppendLine("$(\"#\"+fid).css({\"position\": \"fixed\",\"display\":\"inline-grid\",\"top\":top+'px',\"left\":left+'px'});");
                    script.AppendLine("})");
                }
                #endregion
            }
            #region 多语公共js
            if (formFields.Exists(f => f.CurrentColumn.IsMultiLang == 1))
            {
                //关闭按钮事件
                script.AppendLine(" $(\".multilangpopoverclose\").on(ace.click_event, function () {     $(this).closest(\".popover\").css(\"display\",\"none\");  });");
                script.AppendLine(@"function multiLangPoverClose() {" +
                                  @"$('.popovermultilang').css('display','none');" +
                                  "document.removeEventListener(\"mousedown\", onMultiLangPoverMouseDown, false);}" +
                                  "function onMultiLangPoverMouseDown(event) {" +
                                  "if (!(event.target.className.indexOf(\"popovermultilang\")>0 || $(event.target).parents(\".popovermultilang\").length > 0)) {" +
                                  "multiLangPoverClose();" +
                                  "}}");
            }
            #endregion

            #region TextArea
            if (hasTextArea)
            {
                script.AppendLine(@"$('textarea.limited').inputlimiter({
					remText: '%n 字符剩余...',
					limitText: '最大字符数 : %n.'
				});"                );
            }
            #endregion

            #region 表单校验

            if (needValidate)
            {
                //校验
                script.AppendLine("$('###formid##').validate({");
                script.AppendLine("		errorElement: 'div',");
                script.AppendLine("		errorClass: 'error',");
                script.AppendLine("		focusInvalid: false,");
                script.AppendLine("		ignore: \"\",");
                script.AppendLine("		rules: {");
                foreach (FapColumn col in _fapColumns)
                {
                    //非空可见
                    if ((col.NullAble == 0 && col.ShowAble == 1) || col.RemoteChkURL.IsPresent())
                    {
                        if (col.CtrlType == FapColumn.CTRL_TYPE_REFERENCE)
                        {
                            script.AppendLine("                " + col.ColName + "MC" + ": {");
                        }
                        else
                        {
                            script.AppendLine("             " + col.ColName + ": {");
                        }
                        if (col.NullAble == 0 && col.ShowAble == 1)
                        {
                            script.AppendLine("				required: true,");
                        }
                        if (col.RemoteChkURL.IsPresent())
                        {
                            string oriValue = FormData.Get(col.ColName).ToString();
                            script.AppendLine("				remote: '"+ _applicationContext.BaseUrl + col.RemoteChkURL + "&fid=" + HttpUtility.UrlEncode(FidValue) + "&orivalue=" + HttpUtility.UrlEncode(oriValue) + "&currcol=" + HttpUtility.UrlEncode(col.ColName) + "',");
                        }
                        script.AppendLine("			},");
                    }
                }


                script.AppendLine("			},");

                script.AppendLine("		messages: {");

                foreach (FapColumn col in _fapColumns)
                {
                    //非空可见
                    if ((col.NullAble == 0 && col.ShowAble == 1) || col.RemoteChkURL.IsPresent())
                    {
                        if (col.CtrlType == FapColumn.CTRL_TYPE_REFERENCE)
                        {
                            script.AppendLine("                " + col.ColName + "MC" + ": {");
                        }
                        else
                        {
                            script.AppendLine("                " + col.ColName + ": {");
                        }
                        if (col.NullAble == 0 && col.ShowAble == 1)
                        {
                            script.AppendLine("				required: \"["+ col.ColComment + "]必须填写!\",");
                        }
                        if (col.RemoteChkURL.IsPresent())
                        {
                            string msg = col.RemoteChkMsg;
                            if (msg.IsMissing())
                            {
                                msg = "[" + col.ColComment + "]此项值已经存在,请更换";
                            }
                            script.AppendLine("				remote: \""+ msg + "\",");
                        }
                        script.AppendLine("			},");
                    }
                }
                script.AppendLine("		},");
                //校验容器
                script.AppendLine("errorLabelContainer: $(\"###formid## div.error\"),");
                script.AppendLine("		highlight: function (e) {");
                script.AppendLine("			$(e).closest('.form-group').removeClass('has-info').addClass('has-error');");
                script.AppendLine("		},");

                script.AppendLine("		success: function (e) {");
                script.AppendLine("			$(e).closest('.form-group').removeClass('has-error');//.addClass('has-info');");
                script.AppendLine("			$(e).remove();");
                script.AppendLine("		},");

                script.AppendLine("		errorPlacement: function (error, element) {");
                script.AppendLine("			if(element.is('input[type=checkbox]') || element.is('input[type=radio]')) {");
                script.AppendLine("				var controls = element.closest('div[class*=\"col-\"]');");
                script.AppendLine("				if(controls.find(':checkbox,:radio').length > 1) controls.append(error);");
                script.AppendLine("				else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));");
                script.AppendLine("			}");
                //script.AppendLine("			else if(element.is('.select2')) {");
                //script.AppendLine("				error.insertAfter(element.siblings('[class*=\"select2-container\"]:eq(0)'));");
                //script.AppendLine("			}");
                script.AppendLine("			else if(element.is('.chosen-select')) {");
                script.AppendLine("				error.insertAfter(element.siblings('[class*=\"chosen-container\"]:eq(0)'));");
                script.AppendLine("			}");
                script.AppendLine("			else error.insertAfter(element.parent());");
                script.AppendLine("		},");

                script.AppendLine("		submitHandler: function (form) {");
                script.AppendLine("		},");
                script.AppendLine("		invalidHandler: function (form) {");
                script.AppendLine("		}");
                script.AppendLine("	});");
            }
            #endregion

            #region 表单联动脚本
            DynamicParameters pm = new DynamicParameters();
            pm.Add("TableName", _fapTable.TableName);
            var formInjections = _dbContext.QueryWhere <FapFormInjection>("TableName=@TableName and IsEnabled=1", pm);
            if (formInjections != null && formInjections.Any())
            {
                foreach (var inject in formInjections)
                {
                    var changCol = _fapColumns.FirstOrDefault(f => f.ColName == inject.ChangeColumn);
                    //可见可编辑
                    if (changCol != null && changCol.EditAble == 1 && changCol.ShowAble == 1)
                    {
                        string ctrlName = changCol.ColName;

                        if (changCol.CtrlType == FapColumn.CTRL_TYPE_REFERENCE)
                        {
                            ctrlName = changCol.ColName + "MC";
                        }
                        script.AppendLine("$('#" + ctrlName + "').change(function(){");
                        string jsonData = "{'Fid':'" + inject.Fid + "','" + changCol.ColName + "':$('#" + changCol.ColName + "').val()";
                        if (inject.ParamColumns.IsPresent())
                        {
                            var paramCols = inject.ParamColumns.SplitComma();
                            foreach (var pc in paramCols)
                            {
                                jsonData += ",'" + pc + "':$('#" + pc + "').val()";
                            }
                        }
                        jsonData += "}";
                        script.AppendLine("$.post(basePath+'/Api/Core/frminjection'," + jsonData + ",function(result){");
                        script.AppendLine("$.each(result,function(name,value) {");
                        script.AppendLine("$('#'+name).val(value)");
                        script.AppendLine("});");
                        script.AppendLine("});");
                        script.AppendLine("})");
                    }
                }
            }

            #endregion

            #region 注入script脚本
            //元数据表注入
            if (_fapTable.ScriptInjection.IsPresent())
            {
                script.AppendLine(_fapTable.ScriptInjection);
            }
            //js文件注入
            string jsfilePath = Path.Combine(new string[] { Directory.GetCurrentDirectory(), "wwwroot", "Scripts", "FapFormPlugin", $"frm.plugin.{_fapTable.TableName}.js" });
            if (File.Exists(jsfilePath))
            {
                script.AppendLine(File.ReadAllText(jsfilePath, Encoding.UTF8));
            }
            #endregion

            script.AppendLine(" });");
            return(script.ToString());
        }
コード例 #29
0
 public WLSTField(BinaryFileReader r, int dataSize)
 {
     Weather = new FormId <WTHRRecord>(r.ReadUInt32());
     Chance  = r.ReadInt32();
 }
コード例 #30
0
            public uint                Type;  // Sound Type - 0=Default, 1=Precipitation, 2=Wind, 3=Thunder

            public SNAMField(BinaryFileReader r, int dataSize)
            {
                Sound = new FormId <SOUNRecord>(r.ReadUInt32());
                Type  = r.ReadUInt32();
            }
コード例 #31
0
 public override string ToString()
 {
     return(FormId.ToString());
 }