Advertisement
Guest User

Untitled

a guest
May 10th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using MySql.Data.MySqlClient;//MySql Connector
  6. using System.Data;
  7. using System.IO;
  8.  
  9. namespace Items_SpellID_Checker
  10. {
  11.     class Program
  12.     {
  13.         const int advance = 100;
  14.         const string DBCselect = "SELECT Id FROM dbc_spell WHERE Id = '";
  15.         static string username = "";
  16.         static string password = "";
  17.         static string world_db = "";
  18.         static string spell_db = "";
  19.         static string LOG_FILE = "bugged items.txt";
  20.         static string[] names = { "spellid_1", "spellid_2", "spellid_3", "spellid_4", "spellid_5" };
  21.         static void Main(string[] args)
  22.         {
  23.            
  24.             MySqlConnection ItConn = new MySqlConnection("Server=localhost;UserId="+username+";Password="+password+";Database="+world_db);
  25.             ItConn.Open();
  26.             MySqlCommand ItCommand = ItConn.CreateCommand();
  27.             MySqlDataAdapter ItDAdap = new MySqlDataAdapter();
  28.             DataSet ItDSet = new DataSet();
  29.             ItDAdap.SelectCommand = ItCommand;
  30.             MySqlConnection DBCConn = new MySqlConnection("Server=localhost;UserId=" + username + ";Password=" + password + ";Database=" + spell_db);
  31.             DBCConn.Open();
  32.             MySqlCommand DBCCommand = DBCConn.CreateCommand();
  33.             MySqlDataAdapter DBCDAdap = new MySqlDataAdapter();
  34.             DBCDAdap.SelectCommand = DBCCommand;
  35.             DataSet DBCDSet = new DataSet();
  36.             for (int i = 0; i < names.Length; i++)
  37.             {
  38.                 int counter = 0;
  39.                 Log("Checking " + names[i]);
  40.                 for (; ; )
  41.                 {
  42.                     ItCommand.CommandText = "SELECT entry, " + names[i] + " FROM items " +
  43.                         "WHERE " + names[i] + " != '0' " +
  44.                         " ORDER BY entry " +
  45.                         "LIMIT " + counter + "," + advance + ";";
  46.  
  47.                     ItDSet.Clear();
  48.                     ItDAdap.Fill(ItDSet);
  49.                     if (ItDSet.Tables[0].Rows.Count == 0)
  50.                         break;
  51.  
  52.                     foreach (DataRow item in ItDSet.Tables[0].Rows)
  53.                     {
  54.                         DBCCommand.CommandText = DBCselect + item[i+1] + "';";
  55.                         DBCDSet.Clear();
  56.                         DBCDAdap.Fill(DBCDSet);
  57.                         if (DBCDSet.Tables[0].Rows.Count == 0)
  58.                         {
  59.                             Log("ItemID = " + item[0] + " has an inexistent " + names[i] + " = " + item[i+1]);
  60.                         }
  61.                     }
  62.                     counter += advance;
  63.                 }
  64.                 Log("");
  65.             }
  66.             Console.WriteLine("Finished");
  67.             ItConn.Close();
  68.             DBCConn.Close();
  69.             Console.Read();
  70.         }
  71.         public static void Log(String s)
  72.         {
  73.             StreamWriter log;
  74.             try
  75.             {
  76.                 if (!File.Exists(LOG_FILE))
  77.                     log = File.CreateText(LOG_FILE);
  78.                 else
  79.                 {
  80.                     log = File.AppendText(LOG_FILE);
  81.                     log.Write("\n");
  82.                 }
  83.                 log.Write(s);
  84.                 log.Close();
  85.                 Console.WriteLine(s);
  86.             }
  87.             catch (Exception e)
  88.             {
  89.                 Console.WriteLine(e.Message);
  90.             }
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement