Guest User

Untitled

a guest
Jan 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Excel = Microsoft.Office.Interop.Excel;
  9.  
  10. namespace ConsoleApplication2
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16. string connectionString = "server=localhost;database=IGP;pooling=false;Connect Timeout=60;Integrated Security=SSPI;";
  17. Excel.Application xlApp = new Excel.Application();
  18. Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"C:\Users\dominikb.CT\Desktop\Templates.ods");
  19. Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
  20. Excel.Range xlRange = xlWorksheet.UsedRange;
  21. #region Games
  22. //List<string> ExternalGameId = new List<string>
  23. //{
  24. // "blackjack3_mobile_html_sw",
  25. // "blackjack3-1h_mobile_html_sw",
  26. // "blackjack3_not_mobile_sw",
  27. // "bloodsuckers_mobile_html_sw",
  28. // "bloodsuckers_not_mobile_sw",
  29. // "dazzle_not_mobile_sw",
  30. // "deadoralive_not_mobile_sw",
  31. // "deadoralive_mobile_html_sw",
  32. // "dracula_sw",
  33. // "multipliermayhem_not_mobile_sw",
  34. // "elements_sw",
  35. // "europeanroulette3_sw",
  36. // "fairyred_not_mobile_sw",
  37. // "fairyred_mobile_html_sw",
  38. // "flowers_not_mobile_sw",
  39. // "football_not_mobile_sw",
  40. // "fruitshop_not_mobile_sw",
  41. // "glow_mobile_html_sw",
  42. // "eldorado_not_mobile_sw",
  43. // "gunsnroses_not_mobile_sw",
  44. // "hooksheroes_not_mobile_sw",
  45. // "jackhammer2_not_mobile_sw",
  46. // "jackhammer2_mobile_html_sw",
  47. // "jackhammer_mobile_html_sw",
  48. // "jackhammer_not_mobile_sw",
  49. // "jimihendrix_not_mobile_sw",
  50. // "jokerpro_mobile_html_sw",
  51. // "jokerpro_not_mobile_sw",
  52. // "junglespirit_not_mobile_sw",
  53. // "koiprincess_mobile_html_sw",
  54. // "koiprincess_not_mobile_sw",
  55. // "fireflies_not_mobile_sw",
  56. // "luckyangler_not_mobile_sw",
  57. // "magicportals_not_mobile_sw",
  58. // "magicportals_mobile_html_sw",
  59. // "motorhead_not_mobile_sw",
  60. // "mythicmaiden_mobile_html_sw",
  61. // "mythicmaiden_not_mobile_sw",
  62. // "neonstaxx_not_mobile_sw",
  63. // "piggyriches_mobile_html_sw",
  64. // "piggyriches_not_mobile_sw",
  65. // "pyramid_not_mobile_sw",
  66. // "reelrush_mobile_html_sw",
  67. // "reelrush_not_mobile_sw",
  68. // "scruffyduck_not_mobile_sw",
  69. // "highlights_mobile_html_sw",
  70. // "highlights_not_mobile_sw",
  71. // "secretsofchristmas_not_mobile_sw",
  72. // "secretsofchristmas_mobile_html_sw",
  73. // "sparks_mobile_html_sw",
  74. // "sparks_not_mobile_sw",
  75. // "colossalpinatas_not_mobile_sw",
  76. // "colossalpinatas_mobile_html_sw",
  77. // "starburst_not_mobile_sw",
  78. // "stickers_mobile_html_sw",
  79. // "stickers_not_mobile_sw",
  80. // "invisibleman_not_mobile_sw",
  81. // "invisibleman_mobile_html_sw",
  82. // "shangrila_not_mobile_sw",
  83. // "themepark_not_mobile_sw",
  84. // "twinspin_not_mobile_sw",
  85. // "victorious_mobile_html_sw",
  86. // "victorious_not_mobile_sw",
  87. // "warlords_not_mobile_sw",
  88. // "warlords_mobile_html_sw",
  89. // "wildwater_not_mobile_sw",
  90. // "wildwildwest_mobile_html_sw",
  91. // "wildwildwest_not_mobile_sw",
  92. // "wolfcub_not_mobile_sw"
  93. //};
  94.  
  95. //List<string> MobileGameIds = new List<string>()
  96. //{
  97. // "blackjack3_mobile_html_sw",
  98. // "bloodsuckers_mobile_html_sw",
  99. // "deadoralive_mobile_html_sw",
  100. // "fairyred_mobile_html_sw",
  101. // "glow_mobile_html_sw",
  102. // "jackhammer2_mobile_html_sw",
  103. // "jackhammer_mobile_html_sw",
  104. // "jokerpro_mobile_html_sw",
  105. // "koiprincess_mobile_html_sw",
  106. // "magicportals_mobile_html_sw",
  107. // "mythicmaiden_mobile_html_sw",
  108. // "piggyriches_mobile_html_sw",
  109. // "reelrush_mobile_html_sw",
  110. // "highlights_mobile_html_sw",
  111. // "secretsofchristmas_mobile_html_sw",
  112. // "sparks_mobile_html_sw",
  113. // "colossalpinatas_mobile_html_sw",
  114. // "stickers_mobile_html_sw",
  115. // "invisibleman_mobile_html_sw",
  116. // "victorious_mobile_html_sw",
  117. // "warlords_mobile_html_sw",
  118. // "wildwildwest_mobile_html_sw",
  119. // "blackjack3-1h_mobile_html_sw"
  120. //};
  121.  
  122. //List<string> NonTmMobileGames = new List<string>()
  123. //{
  124. // "BlackJack Classic TouchT",
  125. // "Blackjack Touch - Single DeckT",
  126. // "BlackJackT",
  127. // "Blood Suckers TouchT",
  128. // "Blood SuckersT",
  129. // "Dazzle MeT",
  130. // "Dead or AliveT",
  131. // "Dead or Alive TouchT",
  132. // "DraculaT",
  133. // "Drive: Multiplayer MayhemT",
  134. // "Elements: The AwakeningT",
  135. // "European Roulette 3T",
  136. // "Fairytale Legends: Red Riding HoodT",
  137. // "Fairytale Legends: Red Riding Hood TouchT",
  138. // "FlowersT",
  139. // "Football Champions CupT",
  140. // "Fruit ShopT",
  141. // "Glow (only Touch)",
  142. // "Gonzo's QuestT",
  143. // "Guns N' RosesT",
  144. // "Hook's HeroesT",
  145. // "Jack Hammer 2T",
  146. // "Jack Hammer Touch 2T",
  147. // "Jack Hammer TouchT",
  148. // "Jack HammerT",
  149. // "Jimi HendrixT",
  150. // "Joker Pro TouchT",
  151. // "Joker ProT",
  152. // "Jungle SpiritT",
  153. // "Koi Princess TouchT",
  154. // "Koi PrincessT",
  155. // "LightsT",
  156. // "Lucky AnglerT",
  157. // "Magic PortalsT",
  158. // "Magic Portals TouchT",
  159. // "MotorheadT",
  160. // "Mythic Maiden TouchT",
  161. // "Mythic MaidenT",
  162. // "Neon StaxxT",
  163. // "Piggy Riches TouchT",
  164. // "Piggy RichesT",
  165. // "Pyramid: Quest for ImmortalityT",
  166. // "Reel Rush TouchT",
  167. // "Reel RushT",
  168. // "Scruffy DuckT",
  169. // "Secrets of Atlantis TouchT",
  170. // "Secrets of AtlantisT",
  171. // "Secrets of ChristmasT",
  172. // "Secrets of Christmas TouchT",
  173. // "Sparks TouchT",
  174. // "SparksT",
  175. // "Spinata GrandeT",
  176. // "Spinata Grande TouchT",
  177. // "StarburstT",
  178. // "Stickers TouchT",
  179. // "StickersT",
  180. // "The InvisibleManT",
  181. // "The InvisibleManTouchT",
  182. // "The Legend of Shangri-La: CLuster PaysT",
  183. // "Theme ParkT",
  184. // "Twin SpinT",
  185. // "Victorious TouchT",
  186. // "VictoriousT",
  187. // "Warlords-Crystals of PowerT",
  188. // "Warlords-Crystals of Power TouchT",
  189. // "Wild WaterT",
  190. // "Wild Wild West: The Great Train Heist TouchT",
  191. // "Wild Wild West: The Great Train HeistT",
  192. // "Wolf ClubT",
  193. // "FairyTale Legends: Red Riding HoodT",
  194. // "Blackjack Classic TouchT",
  195. // "Glow TouchT",
  196. // "Gonzo''s QuestT",
  197. // "Guns N'' Roses Video SlotsT",
  198. // "Guns N'' RosesT",
  199. // "NetEntT",
  200. // "Hook''s HeroesT",
  201. // "Jack Hammer 2 TouchT",
  202. // "Sticky WinT",
  203. // "Jimi Hendrix Online SlotT",
  204. // "Jungle Spirit: Call of the WildT",
  205. // "Lucky Angler: A Snowy CatchT",
  206. // "Motörhead Video SlotT",
  207. // "Spiñata GrandeT",
  208. // "Spiñata Grande TouchT",
  209. // "The Invisible ManT",
  210. // "Shangri-La: Cluster PaysT",
  211. // "Theme Park: Tickets of FortuneT",
  212. // "Warlords - Crystals of PowerT",
  213. // "Warlords - Crystals of Power TouchT",
  214. // "Wolf CubT",
  215. // "Drive: Multiplier MayhemT",
  216. // "MotörheadT",
  217. // "Bloodsuckers TouchT",
  218. // "AvalancheT",
  219. // "FairyTale Legends: Red Riding Hood TouchT",
  220. // "Football: Champions CupT",
  221. // "Sticky WinsT",
  222. // "Smart RangeT",
  223. // "Netent RocksT",
  224. // "SuperStaxxT",
  225. // "TouchT",
  226. // "The Invisible Man TouchT",
  227. // "Cluster PaysT"
  228. //};
  229. //List<string> Long_Description = new List<string>();
  230. //for (int i = 2; i <= 70; i++)
  231. //{
  232. // try
  233. // {
  234. // Long_Description.Add(xlRange.Cells[i, 2].Value2);
  235. // }
  236. // catch
  237. // {
  238. // Console.WriteLine("Error:{0}", i.ToString());
  239. // }
  240. //}
  241.  
  242. //string text = File.ReadAllText(@"C:\Users\dominikb.CT\Desktop\gamestm.txt");
  243. ////string[] words = text.Split(' ');
  244. //foreach(string item in NonTmMobileGames)
  245. //{
  246. // text = text.Replace(item, item + "@@TMPLACEHOLDER@@");
  247. // File.WriteAllText(@"C:\Users\dominikb.CT\Desktop\gamestm1.txt", text);
  248. //}
  249. //Console.WriteLine("Finished");
  250. //for (int i = 0; i < words.Length; i++)
  251. // if (words[i] != "INSERT" || !string.IsNullOrEmpty(words[i]))
  252. // {
  253. // if (words[i].EndsWith("T"))
  254. // {
  255. // Console.WriteLine(words[i]);
  256. // words[i] = words[i].Replace('T', '™');
  257. // }
  258. // }
  259. //text = text.Replace(item, item+"@@TMPLACEHOLDER@@");
  260. //File.WriteAllText(@"C:\Users\dominikb.CT\Desktop\gamestm1.txt", text);
  261. //Console.WriteLine("Finished");
  262. //for (int i = 1; i < 70; i++)
  263. //{
  264. // if (MobileGameIds.Contains(ExternalGameId[i - 1]))
  265. // {
  266. // Console.WriteLine("SELECT @GameId = [Id] FROM [IGP].[ProdGameManagement].[Game] WHERE [ExternalGameId] = '{0}'", ExternalGameId[i - 1]);
  267. // Console.WriteLine("INSERT INTO [Globalization].[Translation] ([LanguageId],[Key],[Value]) VALUES");
  268. // Console.WriteLine(@"(83, 'PGM_GAME_LD_' + CONVERT(VARCHAR(100), @GameId) + '_2' , '{0}')", Long_Description[i - 1]);
  269. // Console.WriteLine();
  270. // }
  271. // else
  272. // {
  273. // Console.WriteLine("SELECT @GameId = [Id] FROM [IGP].[ProdGameManagement].[Game] WHERE [ExternalGameId] = '{0}'", ExternalGameId[i - 1]);
  274. // Console.WriteLine("INSERT INTO [Globalization].[Translation] ([LanguageId],[Key],[Value]) VALUES");
  275. // Console.WriteLine(@"(83, 'PGM_GAME_LD_' + CONVERT(VARCHAR(100), @GameId) + '_1' , '{0}')", Long_Description[i - 1]);
  276. // Console.WriteLine();
  277. // }
  278. //}
  279. #endregion
  280.  
  281.  
  282. using (SqlConnection connection = new SqlConnection(connectionString))
  283. {
  284. SqlCommand SqlCmd = new SqlCommand();
  285. connection.Open();
  286. SqlCmd = connection.CreateCommand();
  287.  
  288. SqlCmd.CommandText = "SELECT TOP 1000 t.Id, t.Body FROM[IGP].[NotificationManagement].[NotificationSubTypeConfiguration] INNER JOIN [TemplatesManagement].Templates t ON EmailTemplateId = t.Id WHERE[SendAsEmail] = 1 AND t.LanguageId = 83 AND t.Id > 321 OR t.Id = 259 OR t.Id = 251";
  289. //SqlCmd.CommandText = "SELECT * FROM [IGP].[UserManagement].[Users]";
  290. SqlDataReader SqlDr = SqlCmd.ExecuteReader();
  291.  
  292. using (System.IO.StreamWriter file =
  293. new System.IO.StreamWriter(@"C:\Users\dominikb.CT\Desktop\clean.sql", true))
  294. {
  295. while (SqlDr.Read())
  296. {
  297. file.WriteLine();
  298. file.WriteLine("({0}, N'ro-RO', N'{1}'),", SqlDr.GetValue(0), SqlDr.GetValue(1));
  299. file.WriteLine();
  300. }
  301. }
  302. }
  303.  
  304. using (System.IO.StreamWriter file =
  305. new System.IO.StreamWriter(@"C:\Users\dominikb.CT\Desktop\test.sql", true))
  306. {
  307. file.WriteLine("PRINT N'STARTING TemplatesManagement.Data.ICBA-967';");
  308. for (int i = 3; i <= 23; i++)
  309. {
  310. if (xlRange.Cells[i, 1].Value2 != null)
  311. {
  312. if (i == 21)
  313. {
  314. continue;
  315. }
  316. //file.WriteLine();
  317. //file.WriteLine("UPDATE [TemplatesManagement].[Templates]");
  318. //file.WriteLine("SET [Body] = N'{0}'", xlRange.Cells[i, 6].Value2);
  319. //file.WriteLine("WHERE [Name] = '{0}'", xlRange.Cells[i, 1].Value2);
  320. //file.WriteLine();
  321. //file.WriteLine();
  322. //Console.WriteLine("Declare @Test{0} INT", i.ToString());
  323. //Console.WriteLine("SELECT Test{0} = [Body] FROM [TemplatesManagement].[Templates]", i.ToString());
  324. //Console.WriteLine("Where [Name] = '{0}'", xlRange.Cells[i, 1].Value2);
  325. //Console.WriteLine("PRINT @Test{0}", i.ToString());
  326. //Console.WriteLine();
  327. //Console.WriteLine();
  328. //Console.WriteLine("({0}, N'ro-RO', N'')", xlRange.Cells[i, 6].Value2);
  329. //Console.WriteLine();
  330. }
  331. }
  332. file.WriteLine("PRINT N'FINISHED TemplatesManagement.Data.ICBA-967';");
  333. }
  334. Console.WriteLine("Finished");
  335.  
  336. Console.Read();
  337. }
  338. }
  339. }
Add Comment
Please, Sign In to add comment