Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.43 KB | None | 0 0
  1. public static void InsertPlayer(uint ID, string character)
  2. {
  3. using (MySqlConnection conn = new MySqlConnection(Database.ConnectionString))
  4. {
  5. conn.Open();
  6. MySqlCommand cmd = new MySqlCommand("INSERT INTO `numberlottery` VALUES (" + ID + ",'" + character + "')", conn);
  7. cmd.ExecuteNonQuery();
  8. }
  9. }
  10.  
  11. ------------------------------------------------------------------------------------------
  12. public static int IsParticipant(uint ID)
  13. {
  14. int number = -1;
  15. using (MySqlConnection conn = new MySqlConnection(Database.ConnectionString))
  16. {
  17. conn.Open();
  18. MySqlCommand cmd = new MySqlCommand("SELECT * FROM `numberlottery` WHERE PlayerID = " + ID, conn);
  19. MySqlDataReader rdr = cmd.ExecuteReader();
  20. if (rdr.Read())
  21. {
  22. number = 1;
  23. }
  24. }
  25. return number;
  26. }
  27. ------------------------------------------------------------------------------------------
  28. public class Database
  29. {
  30. public static string mysqlUser = "";
  31. public static string mysqlPassword = "";
  32. public static string mysqlDatabase = "";
  33. public static string ConnectionString;
  34. public static void OpenDatabases()
  35. {
  36. ConnectionString = "Server='localhost';Database='" + mysqlDatabase + "';Username='" + mysqlUser + "';Password='" + mysqlPassword + "';Pooling=true;Min Pool Size=5;Max Pool Size=40; Connection Timeout=5900;";
  37.  
  38. }
  39. public static int GetVoteCount(string account)
  40. {
  41. string ConnectionString = "Server='';Database='';Username='';Password='';Pooling=false;";
  42. int count = 0;
  43. using (MySqlConnection conn = new MySqlConnection(ConnectionString))
  44. {
  45. conn.Open();
  46. MySqlDataAdapter DataAdapter = null;
  47. DataSet DSet = new DataSet();
  48.  
  49. DataAdapter = new MySqlDataAdapter("SELECT * FROM `co_vote` WHERE AccountID ='" + account + "'", conn);//read
  50. DataAdapter.Fill(DSet, "table");
  51. if (DSet != null && DSet.Tables["table"].Rows.Count > 0)
  52. {
  53. DataRow DR = DSet.Tables["table"].Rows[0];
  54. count = Convert.ToInt32(DR["Points"]);
  55. }
  56. }
  57. return count;
  58. }
  59.  
  60. ------------------------------------------------------------------------------------------
  61. /*
  62. public static string mysqlUser = "";
  63. public static string mysqlPassword = "";
  64. public static string mysqlDatabase = "";
  65. public const string SERVER = "localhost";
  66. static MySqlConnection conn = new MySqlConnection("Server=" + SERVER + ";Database='" + mysqlDatabase + "';Username='" + mysqlUser + "';Password='" + mysqlPassword + "';");
  67. static bool did = false;
  68. public static MySqlConnection Connection
  69. {
  70. get
  71. {
  72. if (!did)
  73. { conn.Open(); did = true; conn.StateChange += new System.Data.StateChangeEventHandler(conn_StateChange); }
  74. return conn;
  75. }
  76. }
  77. static void conn_StateChange(object sender, System.Data.StateChangeEventArgs e)
  78. {
  79. if (e.CurrentState == System.Data.ConnectionState.Closed || e.CurrentState == System.Data.ConnectionState.Broken)
  80. {
  81. conn.Dispose();
  82. conn = new MySqlConnection("Server=" + SERVER + ";Database='" + mysqlDatabase + "';Username='" + mysqlUser + "';Password='" + mysqlPassword + "';");
  83. conn.Open();
  84. conn.StateChange +=new System.Data.StateChangeEventHandler(conn_StateChange);
  85. }
  86. }*/
  87. ------------------------------------------------------------------------------------------
  88. public static Main.AuthWorker.AuthInfo Authenticate(string User, string Password)
  89. {
  90. using (MySqlConnection conn = new MySqlConnection(ConnectionString))
  91. {
  92. conn.Open();
  93. Main.AuthWorker.AuthInfo Info = new ConquerSx.Main.AuthWorker.AuthInfo();
  94. Info.Account = User;
  95. try
  96. {
  97. MySqlDataAdapter DataAdapter = null;
  98. DataAdapter = new MySqlDataAdapter("SELECT * FROM `Accounts` WHERE `AccountID` = '" + User + "'", conn);//read
  99. DataSet DSet = new DataSet();
  100.  
  101. DataAdapter.Fill(DSet, "Account");
  102.  
  103. if (DSet != null && DSet.Tables["Account"].Rows.Count > 0)
  104. {
  105. DataRow DR = DSet.Tables["Account"].Rows[0];
  106.  
  107. string RealAccount = (string)DR["AccountID"];
  108. if (User == RealAccount)
  109. {
  110. string RealPassword = (string)DR["Password"];
  111.  
  112. if (Main.PassCrypto.EncryptPassword(RealPassword) == Password)
  113. {
  114. int status = 0;
  115. if (!int.TryParse((string)DR["Status"], out status))
  116. Info.Status = (string)DR["Status"];
  117. else
  118. Info.Status = "[" + ((AccountStatus)status).ToString() + "]";
  119.  
  120. Info.Character = (string)DR["Character"];
  121. if (Info.Character == "")
  122. Info.LogonType = 2;
  123. else
  124. Info.LogonType = 1;
  125. }
  126. else
  127. {
  128. Info.LogonType = 255;
  129. }
  130. }
  131. else
  132. {
  133. Info.LogonType = 255;
  134. }
  135. }
  136. else
  137. {
  138. Info.LogonType = 255;
  139. }
  140. }
  141. catch (Exception Exc) { Program.WriteLine(Exc); }
  142. return Info;
  143. }
  144. }
  145. ------------------------------------------------------------------------------------------
  146. public static void TopGuildReset()
  147. {
  148. using (MySqlConnection conn = new MySqlConnection(ConnectionString))
  149. {
  150. conn.Open();
  151. foreach (Game.Character Chaar in Game.World.H_Chars.Values)
  152. {
  153. {
  154. Chaar.StatEff.Remove(ConquerSx.Game.StatusEffectEn.TopDeputyLeader);
  155. Chaar.StatEff.Remove(ConquerSx.Game.StatusEffectEn.TopGuildLeader);
  156. Chaar.TopDeputyLeader = 0;
  157. Chaar.TopGuildLeader = 0;
  158. }
  159. }
  160. MySqlCommand cmd = new MySqlCommand("UPDATE `characters` SET `TopGuildLeader` = 0 ,`TopDeputyLeader` = 0 WHERE EntityID > 0", conn);//write
  161. cmd.ExecuteNonQuery();
  162. }
  163. }
  164. ------------------------------------------------------------------------------------------
  165.  
  166.  
  167. ctrl+f:
  168.  
  169. //read
  170. and
  171. //write
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement