static void Main(string[] args) { int[] iArray = new int[] { 22, 15, 3, 16, 30, 45, 9, 27, 7, 12, 44, 85, 24, 47, 33, 67, 55, 1, 93, 16 }; System.Console.WriteLine("Metodo de Ordenamiento: Shell"); SH sh = new SH(); sh.Sort(iArray); System.Console.WriteLine("Se imprimen: "); for (int m = 0; m <= 19; m++) Console.WriteLine("Valor {0}: {1}", m + 1, iArray[m]); Console.ReadKey(); }
public void ReplaceManyFromStringTest() { string testString = @"Assert.Equal -> Assert.AreEqual Assert.AreEqual<*> -> CollectionAssert.AreEqual [Fact] -> [TestMethod] using Xunit; -> using Microsoft.VisualStudio.TestTools.UnitTesting;"; testString = "Assert.AreEqual<*> -> CollectionAssert.AreEqual"; string file = @"E:\Documents\vs\Projects\sunamo.Tests\sunamo.Tests.Data\ReplaceManyFromString\In_ReplaceManyFromString.cs"; var s = TF.ReadFile(file); s = SH.ReplaceManyFromString(s, testString, Consts.transformTo); TF.SaveFile(s, file); }
public void ReturnWhichContainsTest() { var input = @"a b d a b c"; var inputLines = SH.GetLines(input); // first line var c = CA.ReturnWhichContains(inputLines, "a d", ContainsCompareMethod.SplitToWords); // first line var c2 = CA.ReturnWhichContains(inputLines, "a !c", ContainsCompareMethod.Negations); // nothing var c3 = CA.ReturnWhichContains(inputLines, "a d", ContainsCompareMethod.WholeInput); // second line var c4 = CA.ReturnWhichContains(inputLines, "a c", ContainsCompareMethod.SplitToWords); int i = 0; }
private void btnBrowse_Click(object sender, System.EventArgs e) { try { String sDir = SH.BrowseForFolder(); if (sDir != null) { m_sFixedDir = sDir; textFixedDir.Text = sDir; } } catch (MissingMethodException) { // Does not happen if SH.BrowseForFolder works. // GetTempPath() (="/tmp" on unix) is friendlier than do nothing. m_sFixedDir = Path.GetTempPath(); textFixedDir.Text = Path.GetTempPath(); } }
public string TelephonesToString() { var tel = string.Empty; if (Telephones != null) { var tels = Telephones.Select(t => t.Number); if (wrapTelInQm) { tels = CA.ChangeContent(new ChangeContentArgs { }, tels.ToList(), SH.WrapWithQm); } tel = SH.Join(tels, ","); } return(tel); }
public void GetLineIndexFromCharIndexTest() { var excepted = 2; // length is 10 var input = @"ab cd ef"; var l = input.Length; var lineF = SH.GetLineIndexFromCharIndex(input, 9); var lineE = SH.GetLineIndexFromCharIndex(input, 8); var lineD = SH.GetLineIndexFromCharIndex(input, 5); Assert.Equal(2, lineF); Assert.Equal(2, lineE); Assert.Equal(1, lineD); }
private void btnBrowse_Click(object sender, System.EventArgs e) { try { String sDir = SH.BrowseForFolder(); if (sDir != null) { m_sFixedDir = sDir; textFixedDir.Text = sDir; } } catch (Exception what) { // Does not happen if SH.BrowseForFolder works. // "/tmp" is friendlier than do nothing. m_sFixedDir = "/tmp"; textFixedDir.Text = "/tmp"; } }
public void SplitAndKeepDelimiters() { var input = HtmlHelper.StripAllTags(splitAndKeepInput); var actual = SH.SplitAndKeepDelimiters(splitAndKeepInput, CA.ToListString(AllStrings.gt, AllStrings.lt)); CA.ChangeContent(null, actual, d => { if (d.EndsWith(AllStrings.gt)) { d = string.Empty; } return(d.TrimEnd(AllChars.lt).Trim()); } ); CA.RemoveStringsEmpty(actual); Assert.Equal <string>(expected, actual); }
public void SplitToPartsFromEndTest() { var expected1 = @"E:\Documents\vs\Haskell_Projects\LearnHaskell"; var expected2 = @"3Types.hs"; var input = expected1 + "\\" + expected2; var p = SH.SplitToPartsFromEnd(input, 2, AllChars.bs); Assert.Equal(expected1, p[0]); Assert.Equal(expected2, p[1]); input = expected2; expected1 = string.Empty; // expected2 keep as is p = SH.SplitToPartsFromEnd(input, 2, AllChars.bs); Assert.Equal(expected1, p[0]); Assert.Equal(expected2, p[1]); }
public void XCharsBeforeAndAfterWholeWordsTest() { //ClipboardHelper.Instance = ClipboardHelperWinStd. var s = "12\"45" + Environment.NewLine + "12\"45"; var occ = SH.ReturnOccurencesOfString(s, "\""); StringBuilder sb = new StringBuilder(); foreach (var item in occ) { var r = SH.XCharsBeforeAndAfterWholeWords(s, item, 2); sb.AppendLine(r); } // Cant use Clipboard, its sunamo and cant reference win //ClipboardHelper.SetText(sb); }
private static IEnumerator RunLoop(float interval, float from, float to, Func <float, bool> action) { bool isCancelled = false; for (float i = from; i < to; i++) { if (!action(i)) { isCancelled = true; break; } yield return(new WaitForSeconds(interval)); } if (!isCancelled) { SH.StartCoroutine(RunLoop(interval, from, to, action)); } }
public void EncryptDecrypBytesTest() { var inputString = SH.Join("", RandomHelper.vsZnaky); var input = Encoding.UTF8.GetBytes(inputString).ToList(); var encrypted = CryptHelper.RijndaelBytes.Instance.Encrypt(input); var hexEncrypted = HexHelper.ToHex(encrypted); var encryptedBytes = HexHelper.FromHex(hexEncrypted); var decrypted = CryptHelper.RijndaelBytes.Instance.Decrypt(encryptedBytes); CA.RemovePadding <byte>(decrypted, 0); var s = Encoding.UTF8.GetString(decrypted.ToArray()); Assert.Equal(inputString, s); }
public void WildcardTest() { var input = @"https://www.facebook.com/name.surname/photos_albums"; var wildcard = @"https://www.facebook.com/*/photos_albums"; var expected = @"name.surname"; Wildcard wc = new Wildcard(wildcard); var regex = Wildcard.WildcardToRegex(wildcard); var matches = SH.SplitAndReturnRegexMatches(input, new System.Text.RegularExpressions.Regex(regex)); int i = 0; #region Not working //var matches = wc.Matches(input); //var first = matches[0]; //Assert.Equal(expected, first.Value); #endregion }
public void WildcardTest1() { var input = "<M C=\"a\">"; var wildcard = @""; var expected = @"name.surname"; Wildcard wc = new Wildcard(wildcard); var regex = Wildcard.WildcardToRegex(wildcard); var matches = SH.SplitAndReturnRegexMatches(input, new System.Text.RegularExpressions.Regex(regex)); int i = 0; #region Not working //var matches = wc.Matches(input); //var first = matches[0]; //Assert.Equal(expected, first.Value); #endregion }
public void TabOrSpaceNextToTest() { var b = "b nopCommerce"; var c = "SimplCommerce"; var d = "SmartStoreNET"; var e = "grandnode"; var a = CA.ToList <string>(b, c, d, e); for (int i = 0; i < a.Count; i++) { Debug.WriteLine(a[i].Length); } var input = SH.Join("\t", a); //input = "a\tb\tc"; var r = SH.TabOrSpaceNextTo(input); var vr = SH.SplitByIndexes(input, r); int i2 = 0; }
public void HasTextRightFormatTest() { FromTo requiredLength = new FromTo(1, 1); var dash = CharFormatData.Get(null, new FromTo(1, 1), AllChars.dash); var onlyNumbers = CharFormatData.GetOnlyNumbers(requiredLength); TextFormatData textFormat = new TextFormatData(false, -1, onlyNumbers, dash, onlyNumbers, dash, onlyNumbers, dash, onlyNumbers); string actual1 = " 01-1-1-1"; string actual2 = "1-1-1-1"; string actual3 = "123-1-1-1"; string actual4 = "1-1-1"; string actual5 = "1-1-1-1-1"; string actual6 = "12-1-1-1"; Assert.False(SH.HasTextRightFormat(actual1, textFormat)); Assert.True(SH.HasTextRightFormat(actual2, textFormat)); Assert.False(SH.HasTextRightFormat(actual3, textFormat)); Assert.False(SH.HasTextRightFormat(actual4, textFormat)); Assert.False(SH.HasTextRightFormat(actual5, textFormat)); Assert.False(SH.HasTextRightFormat(actual6, textFormat)); }
public static void AddXmlns(string csproj, XNamespace ns, bool add) { if (add) { XDocument xml = XDocument.Load(csproj); foreach (var element in xml.Descendants().ToList()) { element.Name = ns + element.Name.LocalName; } xml.Root.SetAttributeValue("xmlns", ns.ToString()); xml.Save(csproj); } else { var text = TF.ReadFile(csproj); var xmlns = "xmlns=\"" + ns.ToString() + "\""; text = SH.ReplaceOnce(text, xmlns, string.Empty); TF.SaveFile(text, csproj); } }
public static NetMessage Send(SpriteHandlerManager spriteHandlerManager, List <SpriteHandler> ToUpdate) { if (CustomNetworkManager.Instance._isServer == true) { return(new NetMessage()); } var TOSend = new List <SpriteHandlerIdentifier>(); foreach (var SH in ToUpdate) { TOSend.Add(new SpriteHandlerIdentifier(SH.GetMasterNetID().netId, SH.name)); } var msg = new NetMessage() { SpriteHandlerManager = spriteHandlerManager.GetComponent <NetworkIdentity>().netId, Data = JsonConvert.SerializeObject(TOSend) }; Send(msg); return(msg); }
//分页 public SH SHPage(int page, int size) { SH sh = new SH(); SqlParameter sqlParameter = new SqlParameter("@count", System.Data.SqlDbType.Int) { Direction = System.Data.ParameterDirection.Output }; SqlParameter[] sqlParameters = new SqlParameter[] { new SqlParameter("@page", page), new SqlParameter("@size", size), sqlParameter }; var dt = DBHelper.ExecuteQuery("SanHuifenye", sqlParameters, System.Data.CommandType.StoredProcedure); string str = JsonConvert.SerializeObject(dt); List <SanHui> d = JsonConvert.DeserializeObject <List <SanHui> >(str); sh.sh = d; sh.SHcount = Convert.ToInt32(sqlParameter.Value); return(sh); }
void Start() { SH shdata = new SH(); shdata.EnvHDR = EnvHDR; SHc = shdata.PrintCeoff(); for (int i = 0; i < 6; i++) { int r = i % 3; int m = (int)(i / 3); SH[i] = new Vector4(SHc[12 * m + r] * SHf[4 * m], SHc[12 * m + r + 3] * SHf[4 * m + 1], SHc[12 * m + r + 6] * SHf[4 * m + 2], SHc[12 * m + r + 9] * SHf[4 * m + 3]); } SH[6] = new Vector4(SHc[24] * SHf[8], SHc[25] * SHf[8], SHc[26] * SHf[8], 0); string ss = ""; for (int i = 0; i < SH.Length; i++) { ss += "," + SH[i].x + "," + SH[i].y + "," + SH[i].z + "," + SH[i].w; } print(ss); }
public void MultiWhitespaceLineToSingleTest() { List <string> input = SH.GetLines(@"a b c"); var excepted = SH.GetLines(@"a b c"); input = SH.GetLines(SH.MultiWhitespaceLineToSingle(input)); Assert.Equal(excepted, input); // input = SH.GetLines(@":/ Pak je pobyli, Judskeho krale si vzal primo ten Bab., mesto lehlo popelem, vetsinu odvlekly do Bab., Bab. pobyly vsechny pronarody v okoli, ale nakonec buh ukazal kdo jsou jeho vyvoleni a Izrael se zase vysvobodil, vsechno krveproliti se obratilo proti Babylonanum. //A VDV - akt.budu cist kapitolu 14, moc se ji nevenuji, viz.status.Porad jsem u toho, jak byly kazatele evangelia prohlaseni za kacire a upaleni, jak se rozsirovala potajnu bible, jak kazdy odpor byl zbytecny, protoze to byla setba.."); input = TF.GetLines(@"D:\_Test\sunamo\sunamo\Helpers\Text\SH\MultiWhitespaceLineToSingle\a.txt"); excepted = SH.GetLines(@":/ Pak je pobyli, Judskeho krale si vzal primo ten Bab., mesto lehlo popelem, vetsinu odvlekly do Bab., Bab. pobyly vsechny pronarody v okoli, ale nakonec buh ukazal kdo jsou jeho vyvoleni a Izrael se zase vysvobodil, vsechno krveproliti se obratilo proti Babylonanum. A VDV - akt.budu cist kapitolu 14, moc se ji nevenuji, viz.status.Porad jsem u toho, jak byly kazatele evangelia prohlaseni za kacire a upaleni, jak se rozsirovala potajnu bible, jak kazdy odpor byl zbytecny, protoze to byla setba.."); input = SH.GetLines(SH.MultiWhitespaceLineToSingle(input)); Assert.Equal(excepted, input); }
/// <summary> /// Performs a loop repeat action with interval between from and to values. /// </summary> public static void Loop(float interval, float from, float to, Func <float, bool> action) { ValidateTimeScale(); SH.StartCoroutine(RunLoop(interval, from, to, action)); }
/// <summary> /// Repeat the specified action with interval between from and to values. /// </summary> public static void Repeat(float interval, float from, float to, Action <float> action) { ValidateTimeScale(); SH.StartCoroutine(RunRepeat(interval, from, to, action)); }
/// <summary> /// Start the specified action in parallel. /// </summary> public static void StartEndOfFrame(Action action) { ValidateTimeScale(); SH.StartCoroutine(RunEndOfFrame(action)); }
/// <summary> /// Stop the specified coroutine. /// </summary> /// <param name="coroutine">Coroutine.</param> public static void Stop(Coroutine coroutine) { SH.StopCoroutine(coroutine); }
/// <summary> /// Start the specified action in parallel. /// <param name="delay">The deelay, in seconds, to start the action.</param> /// <param name="action">The action to be executed.</param> /// </summary> public static Coroutine Start(float delay, Action action) { ValidateTimeScale(); return(SH.StartCoroutine(Run(delay, action))); }
public static void Generate() { //AssetDatabase.StopAssetEditing(); //spriteCatalogue = AssetDatabase.LoadAssetAtPath<SpriteCatalogue>( // "Assets/Resources/ScriptableObjects/SOs singletons/SpriteCatalogueSingleton.asset"); // // DirSearch_ex3Prefab(Application.dataPath + "/Resources/Prefabs/Items"); // // AssetDatabase.StartAssetEditing(); DirSearch_ex3(Application.dataPath + "/Textures"); AssetDatabase.StopAssetEditing(); AssetDatabase.SaveAssets(); return; // TODO The following code is unreachable! Remove it or make it usable. 😣 var pathe = Application.dataPath + "/Resources/Prefabs"; var aDDll = LoadAllPrefabsOfType <SpriteHandler>(pathe); foreach (var SH in aDDll) { //foreach (var Sprite in SH.Sprites) //{ //var SO = PullOutSO(Sprite.Texture); //if (SH.SubCatalogue.Contains(SO) == false) //{ //SH.SubCatalogue.Add(SO); //} //} var SR = SH.GetComponent <SpriteRenderer>(); if (SR != null) { if (SR.sprite != null) { //SH.PresentSpriteSet = PullOutSO(SR.sprite.texture); } } try { PrefabUtility.SavePrefabAsset(GetRoot(SH.gameObject)); } catch { Logger.Log(GetRoot(SH.gameObject).name + "Not root apparently"); } } return; AssetDatabase.StartAssetEditing(); var AAA = FindAssetsByType <SpriteCatalogue>(); foreach (var a in AAA) { EditorUtility.SetDirty(a); } AssetDatabase.StopAssetEditing(); AssetDatabase.SaveAssets(); return; var DD = LoadAllPrefabsOfType <SeedPacket>(Application.dataPath + "/Resources/Prefabs/Items/Botany"); //AssetDatabase.StartAssetEditing(); /* * var DDD = LoadAllPrefabsOfType<SeedPacket>(Application.dataPath + "/Resources/Prefabs/Items/Botany"); * foreach (var d in DDD) * { * if (d == null ) continue; * if (d.plantData?.DeadSpriteSO == null && d.defaultPlantData != null) * { * * d.plantData = d.defaultPlantData.plantData; * d.plantData.DeadSpriteSO = PullOutSO(d.plantData.DeadSprite.Texture); * d.plantData.FullyGrownSpriteSO = PullOutSO(d.plantData.FullyGrownSprite.Texture); * * d.plantData.GrowthSpritesSOs.Clear(); * foreach (var TT in d.plantData.GrowthSprites) * { * d.plantData.GrowthSpritesSOs.Add(PullOutSO(TT.Texture)); * } * * foreach (var Mutates in d.plantData.MutatesInTo) * { * if (Mutates.plantData.ProduceObject == null) * { * var Seepak = FindSeedPacket(Mutates); * if (Seepak == null) * { * Seepak = GenerateDummySeedPacket(Mutates); * } * * Mutates.plantData.ProduceObject = GenerateDummyProduce(Mutates.plantData, Seepak); * } * * var foodit = Mutates.plantData.ProduceObject.GetComponent<GrownFood>(); * * * if (foodit != null) * { * var DSeepak = FindSeedPacket(Mutates); * if (DSeepak == null) * { * DSeepak = GenerateDummySeedPacket(Mutates); * } * * foodit.seedPacket = DSeepak; * PrefabUtility.SavePrefabAsset(foodit.gameObject); * } * * if (foodit != null && d.plantData.MutatesInToGameObject.Contains(foodit.seedPacket) == false) * { * d.plantData.MutatesInToGameObject.Add(Mutates.plantData.ProduceObject.GetComponent<GrownFood>().seedPacket); * } * } * * * * * PrefabUtility.SavePrefabAsset(d.gameObject); * * } * * * } * * * * * * foreach (var d in DD) * { * if (d.defaultPlantData == null) continue; * d.plantData.MutatesInToGameObject.Clear(); * d.plantData = d.defaultPlantData.plantData; * * d.plantData.DeadSpriteSO = PullOutSO(d.plantData.DeadSprite.Texture); * d.plantData.FullyGrownSpriteSO = PullOutSO(d.plantData.FullyGrownSprite.Texture); * * d.plantData.GrowthSpritesSOs.Clear(); * foreach (var TT in d.plantData.GrowthSprites) * { * d.plantData.GrowthSpritesSOs.Add(PullOutSO(TT.Texture)); * } * * * foreach (var Mutates in d.plantData.MutatesInTo) * { * if (Mutates.plantData.ProduceObject == null) * { * var Seepak = FindSeedPacket(Mutates); * if (Seepak == null) * { * Seepak = GenerateDummySeedPacket(Mutates); * } * * Mutates.plantData.ProduceObject = GenerateDummyProduce(Mutates.plantData, Seepak); * } * * var foodit = Mutates.plantData.ProduceObject.GetComponent<GrownFood>(); * * * if (foodit != null) * { * var DSeepak = FindSeedPacket(Mutates); * if (DSeepak == null) * { * DSeepak = GenerateDummySeedPacket(Mutates); * } * * foodit.seedPacket = DSeepak; * PrefabUtility.SavePrefabAsset(foodit.gameObject); * } * * if (foodit != null && d.plantData.MutatesInToGameObject.Contains(foodit.seedPacket) == false) * { * d.plantData.MutatesInToGameObject.Add(Mutates.plantData.ProduceObject.GetComponent<GrownFood>().seedPacket); * } * } * * PrefabUtility.SavePrefabAsset(d.gameObject); * } * * //AssetDatabase.StopAssetEditing(); * return; * * * foreach (var oDe in ToDel) * { * AssetDatabase.DeleteAsset(oDe); * } * * foreach (var Seve in ToSeve) * { * AssetDatabase.CreateAsset(Seve.Value, Seve.Key); * spriteCatalogue.Catalogue.Add(Seve.Value); * } */ }
/// <summary> /// Waits for the waitForCondition function returns true. /// </summary> public static void WaitFor(Func <bool> waitForCondition, Action waitEndedAction) { ValidateTimeScale(); SH.StartCoroutine(RunWaitFor(waitForCondition, waitEndedAction)); }
public static void Generate() { //AssetDatabase.StopAssetEditing(); //spriteCatalogue = AssetDatabase.LoadAssetAtPath<SpriteCatalogue>( // "Assets/Resources/ScriptableObjectsSingletons/SpriteCatalogueSingleton.asset"); // // DirSearch_ex3Prefab(Application.dataPath + "/Resources/Prefabs/Items"); // // AssetDatabase.StartAssetEditing(); AssetDatabase.ForceReserializeAssets(); //FindInGo var doors = LoadAllPrefabsOfType <DoorController>(""); foreach (var door in doors) { FindInGo(door.gameObject); EditorUtility.SetDirty(door.gameObject); } // var stuff = FindAssetsByType<PlayerSlotStoragePopulator>(); // // foreach (var PSSP in stuff) // { // bool NOID = true; // foreach (var Entry in PSSP.Entries) // { // if (Entry.NamedSlot == NamedSlot.id) // { // NOID = false; // } // // if (Entry.NamedSlot == NamedSlot.uniform) // { // Entry.ReplacementStrategy = ReplacementStrategy.DespawnOther; // } // // if (Entry.NamedSlot == NamedSlot.back) // { // Entry.ReplacementStrategy = ReplacementStrategy.DespawnOther; // } // // if (Entry.NamedSlot == NamedSlot.ear) // { // Entry.ReplacementStrategy = ReplacementStrategy.DespawnOther; // } // } // // if (NOID) // { // var ID = Spawn.GetPrefabByName("IDCardAutoInit"); // var all = new SlotPopulatorEntry(); // all.Prefab = ID; // all.NamedSlot = NamedSlot.id; // PSSP.Entries.Add(all); // } // EditorUtility.SetDirty( PSSP); // } // DirSearch_ex3(Application.dataPath + "/Textures"); AssetDatabase.StopAssetEditing(); AssetDatabase.SaveAssets(); return; // TODO The following code is unreachable! Remove it or make it usable. 😣 var pathe = Application.dataPath + "/Resources/Prefabs"; var aDDll = LoadAllPrefabsOfType <SpriteHandler>(pathe); foreach (var SH in aDDll) { //foreach (var Sprite in SH.Sprites) //{ //var SO = PullOutSO(Sprite.Texture); //if (SH.SubCatalogue.Contains(SO) == false) //{ //SH.SubCatalogue.Add(SO); //} //} var SR = SH.GetComponent <SpriteRenderer>(); if (SR != null) { if (SR.sprite != null) { //SH.PresentSpriteSet = PullOutSO(SR.sprite.texture); } } try { PrefabUtility.SavePrefabAsset(GetRoot(SH.gameObject)); } catch { Logger.Log(GetRoot(SH.gameObject).name + "Not root apparently", Category.Editor); } } return; AssetDatabase.StartAssetEditing(); var AAA = FindAssetsByType <SpriteCatalogue>(); foreach (var a in AAA) { EditorUtility.SetDirty(a); } AssetDatabase.StopAssetEditing(); AssetDatabase.SaveAssets(); return; var DD = LoadAllPrefabsOfType <SeedPacket>(Application.dataPath + "/Resources/Prefabs/Items/Botany"); //AssetDatabase.StartAssetEditing(); /* * var DDD = LoadAllPrefabsOfType<SeedPacket>(Application.dataPath + "/Resources/Prefabs/Items/Botany"); * foreach (var d in DDD) * { * if (d == null ) continue; * if (d.plantData?.DeadSpriteSO == null && d.defaultPlantData != null) * { * * d.plantData = d.defaultPlantData.plantData; * d.plantData.DeadSpriteSO = PullOutSO(d.plantData.DeadSprite.Texture); * d.plantData.FullyGrownSpriteSO = PullOutSO(d.plantData.FullyGrownSprite.Texture); * * d.plantData.GrowthSpritesSOs.Clear(); * foreach (var TT in d.plantData.GrowthSprites) * { * d.plantData.GrowthSpritesSOs.Add(PullOutSO(TT.Texture)); * } * * foreach (var Mutates in d.plantData.MutatesInTo) * { * if (Mutates.plantData.ProduceObject == null) * { * var Seepak = FindSeedPacket(Mutates); * if (Seepak == null) * { * Seepak = GenerateDummySeedPacket(Mutates); * } * * Mutates.plantData.ProduceObject = GenerateDummyProduce(Mutates.plantData, Seepak); * } * * var foodit = Mutates.plantData.ProduceObject.GetComponent<GrownFood>(); * * * if (foodit != null) * { * var DSeepak = FindSeedPacket(Mutates); * if (DSeepak == null) * { * DSeepak = GenerateDummySeedPacket(Mutates); * } * * foodit.seedPacket = DSeepak; * PrefabUtility.SavePrefabAsset(foodit.gameObject); * } * * if (foodit != null && d.plantData.MutatesInToGameObject.Contains(foodit.seedPacket) == false) * { * d.plantData.MutatesInToGameObject.Add(Mutates.plantData.ProduceObject.GetComponent<GrownFood>().seedPacket); * } * } * * * * * PrefabUtility.SavePrefabAsset(d.gameObject); * * } * * * } * * * * * * foreach (var d in DD) * { * if (d.defaultPlantData == null) continue; * d.plantData.MutatesInToGameObject.Clear(); * d.plantData = d.defaultPlantData.plantData; * * d.plantData.DeadSpriteSO = PullOutSO(d.plantData.DeadSprite.Texture); * d.plantData.FullyGrownSpriteSO = PullOutSO(d.plantData.FullyGrownSprite.Texture); * * d.plantData.GrowthSpritesSOs.Clear(); * foreach (var TT in d.plantData.GrowthSprites) * { * d.plantData.GrowthSpritesSOs.Add(PullOutSO(TT.Texture)); * } * * * foreach (var Mutates in d.plantData.MutatesInTo) * { * if (Mutates.plantData.ProduceObject == null) * { * var Seepak = FindSeedPacket(Mutates); * if (Seepak == null) * { * Seepak = GenerateDummySeedPacket(Mutates); * } * * Mutates.plantData.ProduceObject = GenerateDummyProduce(Mutates.plantData, Seepak); * } * * var foodit = Mutates.plantData.ProduceObject.GetComponent<GrownFood>(); * * * if (foodit != null) * { * var DSeepak = FindSeedPacket(Mutates); * if (DSeepak == null) * { * DSeepak = GenerateDummySeedPacket(Mutates); * } * * foodit.seedPacket = DSeepak; * PrefabUtility.SavePrefabAsset(foodit.gameObject); * } * * if (foodit != null && d.plantData.MutatesInToGameObject.Contains(foodit.seedPacket) == false) * { * d.plantData.MutatesInToGameObject.Add(Mutates.plantData.ProduceObject.GetComponent<GrownFood>().seedPacket); * } * } * * PrefabUtility.SavePrefabAsset(d.gameObject); * } * * //AssetDatabase.StopAssetEditing(); * return; * * * foreach (var oDe in ToDel) * { * AssetDatabase.DeleteAsset(oDe); * } * * foreach (var Seve in ToSeve) * { * AssetDatabase.CreateAsset(Seve.Value, Seve.Key); * spriteCatalogue.Catalogue.Add(Seve.Value); * } */ }
protected void Page_Load(object sender, EventArgs e) { Langs l = GetLang(); base.errors = errors; FillIDUsers(); var rd = this.RouteData; string song = ""; int idSong = int.MaxValue; string unLoginedUser = ""; // Dictionary to all user name used in loaded page due to avoid asking DB again with same Select Dictionary <int, string> resolvedUserNames = new Dictionary <int, string>(); if (idLoginedUser != -1) { unLoginedUser = GeneralCells.LoginOfUser(idLoginedUser); if (!resolvedUserNames.ContainsKey(idLoginedUser)) { resolvedUserNames.Add(idLoginedUser, unLoginedUser); } } #region Checking if uri-passed original and translated song is present ResultCheckWebArgument rSong = RoutePageHelper.CheckStringArgument(rd, "song", out song); if (rSong == ResultCheckWebArgument.AllOk) { idSong = MSStoredProceduresI.ci.SelectCellDataTableIntOneRow(true, Tables.Lyr_Song, "ID", "Uri", song); if (idSong == int.MaxValue) { divContent.Visible = false; Warning("Požadovaný song " + song + "nebyl v databázi nalezen. "); Include(styles, scripts, null, null); return; } } int idUserOriginal = -1; string originalLogin = ""; ResultCheckWebArgument rOriginal = RoutePageHelper.CheckStringArgument(rd, "Original", out originalLogin); if (rOriginal == ResultCheckWebArgument.AllOk) { idUserOriginal = GeneralCells.IDOfUser_Login(originalLogin); if (idUserOriginal == -1) { divContent.Visible = false; Warning("Požadovaný song byl nalezen, ale mezi originálními texty písně nebyl nalezen uživatel " + originalLogin + " specifikovaný v URI"); Include(styles, scripts, null, null); return; } else { if (!resolvedUserNames.ContainsKey(idUserOriginal)) { resolvedUserNames.Add(idUserOriginal, originalLogin); } } } int idUserTranslated = -1; string translated = ""; ResultCheckWebArgument rTranslated = RoutePageHelper.CheckStringArgument(rd, "Translated", out translated); if (rTranslated == ResultCheckWebArgument.AllOk) { idUserTranslated = GeneralCells.IDOfUser_Login(translated); if (idUserTranslated == -1) { divContent.Visible = false; Warning("Požadovaný song byl nalezen, ale mezi přeloženými texty písně nebyl nalezen uživatel " + translated + " specifikovaný v URI"); Include(styles, scripts, null, null); return; } else { if (!resolvedUserNames.ContainsKey(idUserTranslated)) { resolvedUserNames.Add(idUserTranslated, translated); } } } #endregion if (rSong == ResultCheckWebArgument.AllOk) { short idAlbum = LyricsCells.IDAlbumOfSong(idSong); string nameAlbum = LyricsCells.NameOfAlbum(idAlbum); #region Showing number of views DayViewManager.IncrementOrInsertNew(this, ViewTable.Lyr_Song, idSong); divViewCount.InnerHtml = GeneralHtmlGenerator.ViewCountOverall(this); divViewCountLast7Days.InnerHtml = GeneralHtmlGenerator.ViewCountLast7Days(LyricsCells.ViewLastWeekOfSong(idSong)); divViewsToday.InnerHtml = GeneralHtmlGenerator.ViewCountToday(this); if (idLoginedUser != 1) { MSStoredProceduresI.ci.UpdatePlusIntValue(Tables.Lyr_Song, "Views", 1, "ID", idSong); } #endregion #region Include external sources scripts.Insert(0, "ts/Lyrics/Song.js"); scripts.Insert(0, "js/jquery/jquery.actual.min.js"); scripts.Insert(0, "js/jquery/jquery.equalheights.js"); scripts.Insert(0, JavaScriptPaths.jQueryPrettySocial); styles.Add(StyleSheetPaths.AwesomeFont); styles.Add(StyleSheetPaths.PrettySocial); #endregion #region Setting <title> string header = null; int IDArtist = int.MaxValue; header = LyricsHelper.GetArtistAndTitle(idSong, out IDArtist); Title = header; CreateTitle(); #endregion string uriOfInterpret = LyricsCells.UriOfArtist(IDArtist); aInterpretPage.HRef = LyricsUri.Artist(this, uriOfInterpret); #region Add jQuery logic to play and show/hide video JavaScriptInjection.InjectFunctionOpenNewTab(this, "searchOnYouTube", SearchingOnWeb.YouTube(header)); HtmlInjection.AddOnClickParameter(searchOnYouTube, "return searchOnYouTube();"); name.InnerHtml = header; DataTable dtYTVideos = MSStoredProceduresI.ci.SelectDataTableSelective(Tables.Lyr_YoutubeVideos, "IDUser,CodeYT", "IDSong", idSong); HtmlGenerator hgYt = new HtmlGenerator(); if (dtYTVideos.Rows.Count == 0) { playOnYouTube.Visible = false; playHere.Visible = false; } else { string codeYT = ""; foreach (DataRow item in dtYTVideos.Rows) { YouTubeVideoOnPage yt = new YouTubeVideoOnPage(item.ItemArray); if (codeYT == "") { codeYT = yt.CodeYT; hfYtCode.Value = codeYT; } hgYt.WriteTagWithAttr("a", "href", "javascript:showYTVideo2(" + yt.IDUser + ", '" + yt.CodeYT + "');"); string un = ""; if (!resolvedUserNames.ContainsKey(yt.IDUser)) { un = GeneralCells.LoginOfUser(yt.IDUser); resolvedUserNames.Add(yt.IDUser, un); } else { un = resolvedUserNames[yt.IDUser]; } hgYt.WriteRaw(un); hgYt.TerminateTag("a"); if (idLoginedUser == yt.IDUser) { hgYt.WriteRaw(" [ "); hgYt.WriteTagWithAttr("a", "href", LyricsUri.ManageYtVideo(this, song, yt.CodeYT)); hgYt.WriteRaw("Spravovat"); hgYt.TerminateTag("a"); hgYt.WriteRaw(" ] "); } hgYt.WriteRaw(" | "); } JavaScriptInjection.InjectFunctionOpenNewTab(this, "playOnYouTube", YouTube.GetLinkToVideo(codeYT)); HtmlInjection.AddOnClickParameter(playHere, "return showYTVideo();"); HtmlInjection.AddOnClickParameter(playOnYouTube, "return playOnYouTube();"); } #endregion hgYt.WriteTagWithAttr("a", "href", LyricsUri.ManageYtVideo(this, song, "New")); hgYt.WriteRaw("Přidat nové YT video"); hgYt.TerminateTag("a"); otherYtVideo.InnerHtml = hgYt.ToString(); // Fetch all lyrics of song DataTable dtOriginal = MSStoredProceduresI.ci.SelectDataTableSelective(Tables.Lyr_Lyrics, "IDUser,Rating,IsTranslate", "IDSong", idSong, "Rating", SortOrder.Descending); List <LyricsWithRating> original = new List <LyricsWithRating>(); List <LyricsWithRating> translate = new List <LyricsWithRating>(); bool foundedTranslated = false; bool foundedOriginal = false; int idTranslatedForce = -1; int idOriginalForce = -1; HtmlGenerator hgOriginal = new HtmlGenerator(); HtmlGenerator hgTranslated = new HtmlGenerator(); #region Parse all of lyrics to original and translate collection foreach (DataRow item in dtOriginal.Rows) { LyricsWithRating l2 = new LyricsWithRating(item.ItemArray); if (!resolvedUserNames.ContainsKey(l2.IDUser)) { string un = GeneralCells.LoginOfUser(l2.IDUser); resolvedUserNames.Add(l2.IDUser, un); } if (l2.IsTranslate) { #region If song is translated string un = resolvedUserNames[l2.IDUser]; hgTranslated.WriteTagWithAttr("a", "href", LyricsUri.SongOriginalTranslated(this, song, originalLogin, resolvedUserNames[l2.IDUser])); hgTranslated.WriteRaw(un); hgTranslated.TerminateTag("a"); if (idUserTranslated == l2.IDUser) { foundedTranslated = true; } // If translated can be any if (translated == "") { idTranslatedForce = l2.IDUser; if (WriteToHgTranslated(song, resolvedUserNames, hgTranslated, l2)) { hgTranslated.WriteRaw(" (právě zobrazený)"); } } else if (translated == un) { #region In QS was lyrics exactly specified idTranslatedForce = l2.IDUser; if (WriteToHgTranslated(song, resolvedUserNames, hgTranslated, l2)) { hgTranslated.WriteRaw(" (právě zobrazený)"); } #endregion } hgTranslated.WriteBr(); translate.Add(l2); #endregion } else { #region If song is in original language ... string un = resolvedUserNames[l2.IDUser]; hgOriginal.WriteTagWithAttr("a", "href", LyricsUri.SongOriginalTranslated(this, song, resolvedUserNames[l2.IDUser], translated)); hgOriginal.WriteRaw(un); hgOriginal.TerminateTag("a"); if (idUserOriginal == l2.IDUser) { foundedOriginal = true; } if (originalLogin == "") { idOriginalForce = l2.IDUser; if (WriteToHgOriginal(song, resolvedUserNames, hgOriginal, l2)) { hgOriginal.WriteRaw(" (právě zobrazený)"); } } else if (originalLogin != "" && originalLogin == un) { idOriginalForce = l2.IDUser; if (WriteToHgOriginal(song, resolvedUserNames, hgOriginal, l2)) { hgOriginal.WriteRaw(" (právě zobrazený)"); } } hgOriginal.WriteBr(); original.Add(l2); #endregion } } #endregion #region If exact song lyrics wasn't enter, select first in table int idLyricsEn = int.MaxValue; if (idOriginalForce != -1) { idLyricsEn = MSStoredProceduresI.ci.SelectCellDataTableIntOneRow(true, Tables.Lyr_Lyrics, "ID", AB.Get("IDSong", idSong), AB.Get("IDUser", idOriginalForce), AB.Get("IsTranslate", false)); } int idLyricsCz = int.MaxValue; if (idTranslatedForce != -1) { idLyricsCz = MSStoredProceduresI.ci.SelectCellDataTableIntOneRow(true, Tables.Lyr_Lyrics, "ID", AB.Get("IDSong", idSong), AB.Get("IDUser", idTranslatedForce), AB.Get("IsTranslate", true)); } #endregion hgTranslated.WriteTagWithAttr("a", "href", LyricsUri.ManageLyrics(this, song, LyricsType.Translated, unLoginedUser)); hgTranslated.WriteRaw("Přidat text zde"); hgTranslated.TerminateTag("a"); hgOriginal.WriteTagWithAttr("a", "href", LyricsUri.ManageLyrics(this, song, LyricsType.Original, unLoginedUser)); hgOriginal.WriteRaw("Přidat text zde"); hgOriginal.TerminateTag("a"); var comparer = new LyricsWithRatingComparer(); original.Sort(comparer); translate.Sort(comparer); divAllEnLyrics.InnerHtml = hgOriginal.ToString(); divAllCzLyrics.InnerHtml = hgTranslated.ToString(); hfIds.Value = song.ToString(); hfBaseUri.Value = "http://" + this.Request.Url.Host + "/"; #region Write original lyrics to HTML string lyricsFirstOriginal = ""; string lyricsFirstTranslate = ""; if (original.Count == 0) { lblEN.Text = "Všechny originální texty byly smazány"; if (unLoginedUser != "") { lblEN.Text += ", chcete zde text <a href='" + LyricsUri.ManageLyrics(this, song, LyricsType.Original, unLoginedUser) + "'>přidat</a>? Pokud je song pouze instrumentální, této hlášky si nevšímejte. Web nerozlišuje mezi cizojazyčnými, českými a instrumentálními songy."; } favAreaENNonLogined.Visible = false; starRatingENNonLogined.Visible = false; favAreaEN.Visible = false; lblRatEN.Visible = false; starRatingEn.Visible = false; } else { if (idLyricsEn == int.MaxValue) { divMessageAboutDefaultTextEN.InnerHtml = "Zadaný uživatel " + originalLogin + " nebyl nalezen v textech u tohoto songu zobrazuje se song s nejvyššším hodnocením"; divEn.Visible = false; } else { object[] o = null; string columnsWhichToFetch = "Text,Rating,Added,LastEdit"; if (originalLogin != "" && foundedOriginal) { //, AB.Get("IDSong", idSong), AB.Get("IDUser", idUserOriginal), AB.Get("IsTranslate", false) o = MSStoredProceduresI.ci.SelectSelectiveOneRow(Tables.Lyr_Lyrics, "ID", idLyricsEn, columnsWhichToFetch); } else { // , AB.Get("IDSong", idSong), AB.Get("IDUser", original[0].IDUser), AB.Get("IsTranslate", false) o = MSStoredProceduresI.ci.SelectSelectiveOneRow(Tables.Lyr_Lyrics, "ID", idLyricsEn, columnsWhichToFetch); } int viewCount = int.MinValue; if (idLoginedUser == 1) { int viewCount2 = MSStoredProceduresI.ci.SelectCellDataTableIntOneRow(true, Tables.Lyr_Lyrics, "ViewCount", "ID", idLyricsEn); if (viewCount2 != int.MaxValue) { viewCount = viewCount2; } } else { viewCount = MSStoredProceduresI.ci.UpdatePlusIntValue(Tables.Lyr_Lyrics, "ViewCount", 1, "ID", idLyricsEn); } uint viewCount3 = NormalizeNumbers.NormalizeInt(viewCount); viewCountEn.InnerHtml = "Počet shlédnutí: " + viewCount3; lyricsFirstOriginal = MSTableRowParse.GetString(o, 0); lblEN.Text = LyricsHelper.GetHtmlLyrics(lyricsFirstOriginal); lblAddedEn.Text = "Přidáno: " + DTHelper.DateToString(MSTableRowParse.GetDateTime(o, 2), l); lblLastEditEn.Text = "Editováno: " + DTHelper.DateToString(MSTableRowParse.GetDateTime(o, 3), l); hfIdLyricsEN.Value = idLyricsEn.ToString(); if (idLoginedUser == -1) { favAreaEN.Visible = false; starRatingEn.Visible = false; } else { float oriRating = MSTableRowParse.GetFloat(o, 1); if (oriRating == 0) { lblRatEN.Text = LyricsStrings.GiveFirstRatingEn; } else { lblRatEN.Text = LyricsStrings.GiveRatingEn; } CheckByValue(oriRating, h1EN, h2EN, h3EN, h4EN, h5EN); string imgFavSrc = GetSrcImgFav(idLyricsEn); imgFavEn.Src = imgFavSrc; favAreaENNonLogined.Visible = false; starRatingENNonLogined.Visible = false; } } } #endregion #region Write translated lyrics to HTML if (translate.Count == 0) { lblCZ.Text = "Všechny překlady této písně byly smazány nebo nikdy neexistovali"; if (unLoginedUser != "") { lblCZ.Text += ", chcete zde text <a href='" + LyricsUri.ManageLyrics(this, song, LyricsType.Translated, unLoginedUser) + "'>přidat</a>? Pokud je song původně v češtině, této hlášky si nevšímejte. Web nerozlišuje mezi cizojazyčnými, českými a instrumentálními songy."; } favAreaCZNonLogined.Visible = false; starRatingCZNonLogined.Visible = false; lblRatCZ.Visible = false; starRatingCZ.Visible = false; favAreaCz.Visible = false; } else { if (idLyricsCz == int.MaxValue) { divMessageAboutDefaultTextCZ.InnerHtml = "Zadaný uživatel " + translated + " nebyl nalezen v textech u tohoto songu zobrazuje se song s nejvyššším hodnocením"; divCz.Visible = false; } else { object[] o = null; string columnsWhichToFetch = "Text,Rating,Added,LastEdit"; if (translated != "" && foundedTranslated) { o = MSStoredProceduresI.ci.SelectSelectiveOneRow(Tables.Lyr_Lyrics, "ID", idLyricsCz, columnsWhichToFetch); } else { o = MSStoredProceduresI.ci.SelectSelectiveOneRow(Tables.Lyr_Lyrics, "ID", idLyricsCz, columnsWhichToFetch); } int viewCount = int.MinValue; if (idLoginedUser == 1) { int viewCount2 = MSStoredProceduresI.ci.SelectCellDataTableIntOneRow(true, Tables.Lyr_Lyrics, "ViewCount", "ID", idLyricsCz); if (viewCount2 != int.MaxValue) { viewCount = viewCount2; } } else { viewCount = MSStoredProceduresI.ci.UpdatePlusIntValue(Tables.Lyr_Lyrics, "ViewCount", 1, "ID", idLyricsCz); } uint viewCount3 = NormalizeNumbers.NormalizeInt(viewCount); viewCountCz.InnerHtml = "Počet shlédnutí: " + viewCount3; lyricsFirstTranslate = MSTableRowParse.GetString(o, 0); lblCZ.Text = LyricsHelper.GetHtmlLyrics(lyricsFirstTranslate); lblAddedCz.Text = "Přidáno: " + DTHelper.DateToString(MSTableRowParse.GetDateTime(o, 2), l); lblLastEditCz.Text = "Editováno: " + DTHelper.DateToString(MSTableRowParse.GetDateTime(o, 3), l); hfIdLyricsCZ.Value = idLyricsCz.ToString(); if (idLoginedUser == -1) { favAreaCz.Visible = false; starRatingCZ.Visible = false; } else { float tranRating = MSTableRowParse.GetFloat(o, 1); if (tranRating == 0) { lblRatCZ.Text = LyricsStrings.GiveFirstRatingCz; } else { lblRatCZ.Text = LyricsStrings.GiveRatingCz; } CheckByValue(tranRating, h1CZ, h2CZ, h3CZ, h4CZ, h5CZ); string imgFavSrc = GetSrcImgFav(idLyricsCz); imgFavCz.Src = imgFavSrc; favAreaCZNonLogined.Visible = false; starRatingCZNonLogined.Visible = false; } } } #endregion #region Set meta info of page as OpenGraph, Schema.org snippets and to PrettySocial widget PageSnippet pageSnippet = null; if (YouTubeThumbnailLyrics.ci.HasAnyFile(idSong)) { int divide = 1; if (lyricsFirstTranslate != "" && lyricsFirstOriginal != "") { divide = 2; } pageSnippet = new PageSnippet { description = SH.ShortForLettersCountThreeDots(SH.TrimNewLineAndTab(lyricsFirstOriginal), 150 / divide) + " " + SH.ShortForLettersCountThreeDots(SH.TrimNewLineAndTab(lyricsFirstTranslate), 150 / divide), image = Consts.HttpWwwCzSlash + YouTubeThumbnailLyrics.ci.GetBaseUri(idSong, 1), title = Title }; } if (pageSnippet != null) { OpenGraphHelper.InsertBasicToPageHeader(this, pageSnippet, MySites.Lyrics); SchemaOrgHelper.InsertBasicToPageHeader(this, pageSnippet, MySites.Lyrics); descriptionPage = pageSnippet.description; } PrettySocialHelper.Init(this, Title, descriptionPage, google, facebook, twitter); #endregion #region Append five random songs from same artist List <int> addedYtVideosToJsArray = new List <int>(); StringBuilder fillingJavaScriptArray = new StringBuilder(); object[] oa = MSStoredProceduresI.ci.SelectSelectiveOneRow(Tables.Lyr_Artist, "ID", IDArtist, "Name,CountTags,CountSimilar"); string nameOfArtist = MSTableRowParse.GetString(oa, 0); byte countTags = MSTableRowParse.GetByte(oa, 1); byte countSimilar = MSTableRowParse.GetByte(oa, 2); int max = 10; int maxSameArtist = 5; List <int> similarSongs = new List <int>(); List <int> songsOfArtist2 = LyricsHelper.GetSongsOfArtist(IDArtist); foreach (var item3 in songsOfArtist2) { if (item3 != idSong) { similarSongs.Add(item3); if (similarSongs.Count == maxSameArtist) { break; } } } #endregion #region Fill up to 10 similar songs from other artist int[] idSimilarArtists = LyricsHelper.GetSimilarOfArtist(IDArtist, countSimilar).ToArray(); idSimilarArtists = CA.JumbleUp <int>(idSimilarArtists); foreach (var item2 in idSimilarArtists) { if (similarSongs.Count == max) { break; } List <int> songsOfArtist = LyricsHelper.GetSongsOfArtist(item2); foreach (var item3 in songsOfArtist) { if (item3 != idSong) { similarSongs.Add(item3); if (similarSongs.Count == max) { break; } } } } #endregion #region If still won't be 10 songs, fill up to 10 songs by tags short[] idTags = LyricsHelper.GetTagsOfArtist(IDArtist, countTags).ToArray(); idTags = CA.JumbleUp <short>(idTags); foreach (var item in idTags) { if (similarSongs.Count == max) { break; } int[] idArtistOfTag = MSStoredProceduresI.ci.SelectValuesOfColumnAllRowsInt(Tables.Lyr_ArtistTag, "IDArtist", new ABC(AB.Get("IDTag", item)), new ABC(AB.Get("IDArtist", IDArtist))).ToArray(); idArtistOfTag = CA.JumbleUp <int>(idArtistOfTag); foreach (var item2 in idArtistOfTag) { if (similarSongs.Count == max) { break; } List <int> songsOfArtist = LyricsHelper.GetSongsOfArtist(item2); foreach (var item3 in songsOfArtist) { if (item2 != IDArtist) { similarSongs.Add(item3); if (similarSongs.Count == max) { break; } } } } } #endregion List <string> viewCountBadgesYouCanLikeAlso = new List <string>(); List <string> idBadgesYouCanLikeAlso = new List <string>(); List <string> viewCountBadgesMostPopularOfInterpretAlbum = new List <string>(); List <string> idBadgesMostPopularOfInterpretAlbum = new List <string>(); List <string> idBadges = new List <string>(); int viewCountBadges = 0; string nameJsArray = "videos"; #region Write to output popular similar songs bool assignedImage = false; bool atLeastOneYouCanLikeAlso = false; if (similarSongs.Count != 0) { #region Add info about similar songs to collections HtmlGenerator hgYouCanLikeAlso = new HtmlGenerator(); int countSongsYouCanLikeAlso = similarSongs.Count; List <string> linksPhoto = new List <string>(countSongsYouCanLikeAlso); List <string> linksText = new List <string>(countSongsYouCanLikeAlso); List <string> innerHtmlText = new List <string>(countSongsYouCanLikeAlso); List <string> srcPhoto = new List <string>(countSongsYouCanLikeAlso); // Shuffle to make it more varied int[] ssju = CA.JumbleUp <int>(similarSongs.ToArray()); foreach (int item in ssju) { int idSong2 = item; if (idSong2 == idSong) { continue; } if (!addedYtVideosToJsArray.Contains(idSong2)) { fillingJavaScriptArray.Append(YouTubeThumbnailLyrics.ci.AllFilesRelativeUriJavascriptArray(nameJsArray, idSong2)); addedYtVideosToJsArray.Add(idSong2); } else { #region If any song will be twice in similar, I fill up to 10 with not-similar song. Still is better song in differenct stile than none idSong2 = MSStoredProceduresI.ci.RandomValueFromColumnInt(Tables.Lyr_Song, "ID"); while (addedYtVideosToJsArray.Contains(idSong2)) { idSong2 = MSStoredProceduresI.ci.RandomValueFromColumnInt(Tables.Lyr_Song, "ID"); } addedYtVideosToJsArray[addedYtVideosToJsArray.Count - 1] = idSong2; #endregion } object[] o = MSStoredProceduresI.ci.SelectSelectiveOneRow(Tables.Lyr_Song, "ID", idSong2, "Name,IDArtist,Views"); int idArtistOfSimilarSong = MSTableRowParse.GetInt(o, 1); int viewLastWeek = MSTableRowParse.GetInt(o, 2); if (!assignedImage) { if (IDArtist != int.MaxValue) { if (idArtistOfSimilarSong != IDArtist) { if (File.Exists(LyricsHelper.GetPathOfArtistImage(idArtistOfSimilarSong, 0, ImageSize.Small))) { imgYouCanLikeAlso.Attributes["style"] = CssGeneration.GetRoundedImage(34, LyricsHelper.GetUriOfArtistImage(Request, idArtistOfSimilarSong, 0, ImageSize.Small), 13); assignedImage = true; } else { imgYouCanLikeAlso.Visible = false; } } } else { assignedImage = true; imgYouCanLikeAlso.Visible = false; } } atLeastOneYouCanLikeAlso = true; string nameSong = MSTableRowParse.GetString(o, 0); srcPhoto.Add(idSong2.ToString()); string noa = LyricsCells.NameOfArtist(idArtistOfSimilarSong); string anchor = LyricsHelper.UriOfSong(this, noa, nameSong); linksPhoto.Add(anchor); linksText.Add(anchor); innerHtmlText.Add(" " + LyricsHelper.GetArtistAndTitle(noa, nameSong)); string idb = viewCountBadges.ToString(); idBadgesYouCanLikeAlso.Add(idb); viewCountBadgesYouCanLikeAlso.Add(NormalizeNumbers.NormalizeInt(viewLastWeek).ToString()); viewCountBadges++; } #endregion HtmlGenerator2.TopListWithImages(hgYouCanLikeAlso, 130, 97, web.UH.GetWebUri(this, "img/Lyrics/NoThumbnail.png"), linksPhoto, linksText, innerHtmlText, srcPhoto, idBadgesYouCanLikeAlso, nameJsArray); JavaScriptInjection.InjectInternalScript(this, JavaScriptGenerator2.JsForIosBadge("blue", idBadgesYouCanLikeAlso, viewCountBadgesYouCanLikeAlso)); if (atLeastOneYouCanLikeAlso) { innerDivYouCanLikeAlso.InnerHtml = hgYouCanLikeAlso.ToString(); } } divYouCanLikeAlso.Visible = atLeastOneYouCanLikeAlso; #endregion #region Write to output popular songs from same interpret bool atLeastOneMostPopularOfInterpret = false; int maxCountMostPopularOfInterpret = 10; int actualCountMostPopularOfInterpret = 0; if (IDArtist != int.MaxValue) { HtmlGenerator hgMostPopularOfInterpret = new HtmlGenerator(); // Get most popular of song - Views DB column DataTable dtMostPopularOfInterpret = MSStoredProceduresI.ci.SelectDataTableLimitLastRows(Tables.Lyr_Song, maxCountMostPopularOfInterpret + 1, "ID,Name,Views", "Views", AB.Get("IDArtist", IDArtist)); int countSongsMostPopularOfInterpret = dtMostPopularOfInterpret.Rows.Count; if (countSongsMostPopularOfInterpret != 0) { int viewLastWeekFirst = MSTableRowParse.GetInt(dtMostPopularOfInterpret.Rows[0].ItemArray, 2); if (viewLastWeekFirst != int.MinValue) { countSongsMostPopularOfInterpret = Math.Min(countSongsMostPopularOfInterpret, maxCountMostPopularOfInterpret); List <string> linksPhoto = new List <string>(countSongsMostPopularOfInterpret); List <string> linksText = new List <string>(countSongsMostPopularOfInterpret); List <string> innerHtmlText = new List <string>(countSongsMostPopularOfInterpret); List <string> srcPhoto = new List <string>(countSongsMostPopularOfInterpret); List <string> viewCountBadgesMostPopularOfInterpret = new List <string>(); List <string> idBadgesMostPopularOfInterpret = new List <string>(); foreach (DataRow item in dtMostPopularOfInterpret.Rows) { if (actualCountMostPopularOfInterpret == maxCountMostPopularOfInterpret) { break; } object[] o = item.ItemArray; int viewLastWeek = MSTableRowParse.GetInt(o, 2); if (viewLastWeek == int.MinValue) { break; } int idVideo = MSTableRowParse.GetInt(o, 0); if (idVideo == idSong) { continue; } actualCountMostPopularOfInterpret++; atLeastOneMostPopularOfInterpret = true; string nameSong = MSTableRowParse.GetString(o, 1); if (!addedYtVideosToJsArray.Contains(idVideo)) { fillingJavaScriptArray.Append(YouTubeThumbnailLyrics.ci.AllFilesRelativeUriJavascriptArray(nameJsArray, idVideo)); addedYtVideosToJsArray.Add(idVideo); } srcPhoto.Add(idVideo.ToString()); string odkaz = LyricsHelper.UriOfSong(this, nameOfArtist, nameSong); linksPhoto.Add(odkaz); linksText.Add(odkaz); innerHtmlText.Add(" " + LyricsHelper.GetArtistAndTitle(nameOfArtist, nameSong)); string idb = viewCountBadges.ToString(); idBadgesMostPopularOfInterpret.Add(idb); viewCountBadgesMostPopularOfInterpret.Add(NormalizeNumbers.NormalizeInt(viewLastWeek).ToString()); viewCountBadges++; } JavaScriptInjection.InjectInternalScript(this, JavaScriptGenerator2.JsForIosBadge("blue", idBadgesMostPopularOfInterpret, viewCountBadgesMostPopularOfInterpret)); HtmlGenerator2.TopListWithImages(hgMostPopularOfInterpret, 130, 97, web.UH.GetWebUri(this, "img/Lyrics/NoThumbnail.png"), linksPhoto, linksText, innerHtmlText, srcPhoto, idBadgesMostPopularOfInterpret, nameJsArray); } } if (atLeastOneMostPopularOfInterpret) { if (File.Exists(LyricsHelper.GetPathOfArtistImage(IDArtist, 0, ImageSize.Small))) { imgInterpret.Attributes["style"] = CssGeneration.GetRoundedImage(34, LyricsHelper.GetUriOfArtistImage(Request, IDArtist, 0, ImageSize.Small), 13); } else { imgInterpret.Visible = false; } innerDivMostPopularOfInterpret.InnerHtml = hgMostPopularOfInterpret.ToString(); } } divMostPopularOfInterpret.Visible = atLeastOneMostPopularOfInterpret; #endregion #region Write to output popular songs from same albums bool atLeastOneMostPopularOfInterpretAlbum = false; if (idAlbum != short.MaxValue) { aAlbumPage.InnerHtml += " " + nameAlbum; aAlbumPage.HRef = LyricsUri.Album(this, uriOfInterpret, LyricsCells.UriOfAlbum(idAlbum)); HtmlGenerator hgMostPopularOfInterpretAlbum = new HtmlGenerator(); DataTable dtMostPopularOfInterpretAlbum = MSStoredProceduresI.ci.SelectDataTableLimitLastRows(Tables.Lyr_Song, int.MaxValue, "ID,Name,Views", "Views", AB.Get("IDArtist", IDArtist), AB.Get("IDAlbum", idAlbum)); int countSongsMostPopularOfInterpretAlbum = dtMostPopularOfInterpretAlbum.Rows.Count; if (countSongsMostPopularOfInterpretAlbum != 0) { int viewLastWeekFirst = MSTableRowParse.GetInt(dtMostPopularOfInterpretAlbum.Rows[0].ItemArray, 2); if (viewLastWeekFirst != int.MinValue) { List <string> linksPhoto = new List <string>(countSongsMostPopularOfInterpretAlbum); List <string> linksText = new List <string>(countSongsMostPopularOfInterpretAlbum); List <string> innerHtmlText = new List <string>(countSongsMostPopularOfInterpretAlbum); List <string> srcPhoto = new List <string>(countSongsMostPopularOfInterpretAlbum); foreach (DataRow item in dtMostPopularOfInterpretAlbum.Rows) { object[] o = item.ItemArray; int viewLastWeek = MSTableRowParse.GetInt(o, 2); if (viewLastWeek == int.MinValue) { break; } int idVideo = MSTableRowParse.GetInt(o, 0); if (idVideo == idSong) { continue; } atLeastOneMostPopularOfInterpretAlbum = true; string nameSong = MSTableRowParse.GetString(o, 1); if (!addedYtVideosToJsArray.Contains(idVideo)) { fillingJavaScriptArray.Append(YouTubeThumbnailLyrics.ci.AllFilesRelativeUriJavascriptArray(nameJsArray, idVideo)); addedYtVideosToJsArray.Add(idVideo); } srcPhoto.Add(idVideo.ToString()); string odkaz = LyricsHelper.UriOfSong(this, nameOfArtist, nameSong); linksPhoto.Add(odkaz); linksText.Add(odkaz); innerHtmlText.Add(" " + LyricsHelper.GetArtistAndTitle(nameOfArtist, nameSong)); string idb = viewCountBadges.ToString(); idBadgesMostPopularOfInterpretAlbum.Add(idb); viewCountBadgesMostPopularOfInterpretAlbum.Add(NormalizeNumbers.NormalizeInt(viewLastWeek).ToString()); viewCountBadges++; } JavaScriptInjection.InjectInternalScript(this, JavaScriptGenerator2.JsForIosBadge("blue", idBadgesMostPopularOfInterpretAlbum, viewCountBadgesMostPopularOfInterpretAlbum)); HtmlGenerator2.TopListWithImages(hgMostPopularOfInterpretAlbum, 130, 97, web.UH.GetWebUri(this, "img/Lyrics/NoThumbnail.png"), linksPhoto, linksText, innerHtmlText, srcPhoto, idBadgesMostPopularOfInterpretAlbum, nameJsArray); } } if (atLeastOneMostPopularOfInterpretAlbum) { if (File.Exists(LyricsHelper.GetPathOfAlbumImage(idAlbum, AlbumImageSize.Small))) { imgAlbum.Attributes["style"] = CssGeneration.GetRoundedImage(34, LyricsHelper.GetUriOfAlbumImage(Request, idAlbum, AlbumImageSize.Small), 13); } else { imgAlbum.Visible = false; } innerDivMostPopularOfInterpretAlbum.InnerHtml = hgMostPopularOfInterpretAlbum.ToString(); } } else { divAlbumPage.Visible = false; } divMostPopularOfInterpretAlbum.Visible = atLeastOneMostPopularOfInterpretAlbum; #endregion if (atLeastOneMostPopularOfInterpret || atLeastOneMostPopularOfInterpretAlbum || atLeastOneYouCanLikeAlso) { JavaScriptInjection.InjectInternalScript(this, JavaScriptGenerator2.AlternatingImages(nameJsArray, nameJsArray, true)); JavaScriptInjection.InjectInternalScript(this, fillingJavaScriptArray.ToString()); } } else { NoToView(); Include(styles, scripts, null, null); return; } FillIDUsers(); Include(styles, scripts, null, null); }
/// <summary> /// Into A2 I cant pass Consts.tString, string must be validate in other way /// </summary> /// <param name="control"></param> /// <param name="type"></param> protected void RegisterForEventValidation(Control control, Type type) { string r = Request.Form[control.UniqueID]; bool b = false; if (r != null) { if (type == Consts.tString) { r = RegexHelper.rHtmlScript.Replace(r, ""); r = RegexHelper.rHtmlComment.Replace(r, ""); r = SH.ReplaceAll2(r, " ", " "); b = true; } else if (type == Consts.tInt) { int nt = 0; b = int.TryParse(r, out nt); } else if (type == Consts.tDateTime) { DateTime dt; b = DateTime.TryParse(r, out dt); } else if (type == Consts.tDouble) { double d = 0; b = double.TryParse(r, out d); } else if (type == Consts.tFloat) { float f = 0; b = float.TryParse(r, out f); } else if (type == Consts.tBool) { bool b2 = false; b = bool.TryParse(r, out b2); } else if (type == Consts.tByte) { byte by = 0; b = byte.TryParse(r, out by); } else if (type == Consts.tShort) { short sh = 0; b = short.TryParse(r, out sh); } else if (type == Consts.tLong) { long l = 0; b = long.TryParse(r, out l); } else if (type == Consts.tDecimal) { decimal d = 0; b = decimal.TryParse(r, out d); } else if (type == Consts.tSbyte) { sbyte sb = 0; b = sbyte.TryParse(r, out sb); } else if (type == Consts.tUshort) { ushort us = 0; b = ushort.TryParse(r, out us); } else if (type == Consts.tUint) { uint ui = 0; b = uint.TryParse(r, out ui); } else if (type == Consts.uUlong) { ulong ul = 0; b = ulong.TryParse(r, out ul); } } if (b) { ClientScript.RegisterForEventValidation(control.UniqueID, r); } else { ClientScript.RegisterForEventValidation(control.UniqueID, ""); } }