Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using MySql.Data.MySqlClient;
- using System.Collections.Generic;
- using System.IO;
- namespace ConsoleApplication2
- {
- public static class Program
- {
- const string connectionInfo = ("host=localhost;" + "port = '3306';" + "database='mangos';" + "UserName='root';" + "Password='mangos'");
- public static StreamWriter Log = new StreamWriter("sql_log.txt", true);
- public static bool bconnection { get; private set; }
- public static bool bgetTables { get; private set; }
- public static bool bCompare { get; private set; }
- public static UInt16 i;
- public static UInt64[] fField = new UInt64[30];
- public static UInt64[] sField = new UInt64[30];
- public static MySqlCommand fcommand;
- public static MySqlCommand scommand;
- static void Main(string[] args)
- {
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine("--------------------Programm is open!--------------------");
- ToLog("Programm is open!");
- TryCon();
- if (!bconnection)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Check your MySQL server");
- Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Press any key for exit");
- ToLog("MySQL Server not running");
- ToLog("closed.......");
- Console.ReadKey(true);
- return;
- }
- else
- {
- MySqlConnection connect = new MySqlConnection(connectionInfo);
- connect.Open();
- Console.ForegroundColor = ConsoleColor.Cyan;
- Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Connection open!");
- ToLog("Connection open");
- Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Start compare?");
- string variant = Console.ReadLine();
- if (variant == "y" || variant == "Y")
- {
- Console.WriteLine("start compare....");
- ToLog("Start compare.....");
- bgetTables = true;
- }
- else if (variant == "n" || variant == "N")
- {
- Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Press any key for exit");
- connect.Close();
- bgetTables = false;
- }
- else
- Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Neee press 'y' or 'n'");
- if (bgetTables)
- {
- string fSelect = "SELECT * FROM world.creature_template";
- string sSelect = "SELECT * FROM world.creature_template";
- fcommand = new MySqlCommand(fSelect, connect);
- scommand = new MySqlCommand(sSelect, connect);
- using (var fDBstructur = fcommand.ExecuteReader())
- {
- while (fDBstructur.Read())
- {
- //UInt64[] fField = new UInt64[30];
- fField[0] = fDBstructur[0].ToUInt32();
- fField[1] = fDBstructur[4].ToUInt32(); //kill credit 1,2
- fField[2] = fDBstructur[5].ToUInt32();
- fField[3] = fDBstructur[6].ToUInt32(); //modelid1 id 1-4
- fField[4] = fDBstructur[7].ToUInt32();
- fField[5] = fDBstructur[8].ToUInt32();
- fField[6] = fDBstructur[9].ToUInt32();
- //String IconName = fDBstructur[12].ToString();
- fField[7] = fDBstructur[23].ToUInt32(); //rank
- fField[8] = fDBstructur[34].ToUInt32(); //family
- fField[9] = fDBstructur[42].ToUInt32();//type
- fField[10] = fDBstructur[43].ToUInt32();//type flag
- fField[11] = fDBstructur[66].ToUInt32(); //movement id
- fField[12] = fDBstructur[68].ToUInt32();//health mod
- fField[13] = fDBstructur[69].ToUInt32(); //power(mana) mod
- fField[14] = fDBstructur[71].ToUInt32(); //racial leader
- fField[15] = fDBstructur[72].ToUInt32(); //quest item 1-6
- fField[16] = fDBstructur[73].ToUInt32();
- fField[17] = fDBstructur[74].ToUInt32();
- fField[18] = fDBstructur[75].ToUInt32();
- fField[19] = fDBstructur[76].ToUInt32();
- fField[20] = fDBstructur[77].ToUInt32();
- }
- }
- using (var sDBstructur = scommand.ExecuteReader())
- {
- while (sDBstructur.Read())
- {
- //UInt64[] sField = new UInt64[30];
- sField[0] = sDBstructur[0].ToUInt32();
- sField[1] = sDBstructur[4].ToUInt32(); //kill credit 1,2
- sField[2] = sDBstructur[5].ToUInt32();
- sField[3] = sDBstructur[6].ToUInt32(); //modelid1 id 1-4
- sField[4] = sDBstructur[7].ToUInt32();
- sField[5] = sDBstructur[8].ToUInt32();
- sField[6] = sDBstructur[9].ToUInt32();
- //String IconName = fDBstructur[12].ToString();
- sField[7] = sDBstructur[23].ToUInt32(); //rank
- sField[8] = sDBstructur[34].ToUInt32(); //family
- sField[9] = sDBstructur[42].ToUInt32();//type
- sField[10] = sDBstructur[43].ToUInt32();//type flag
- sField[11] = sDBstructur[66].ToUInt32(); //movement id
- sField[12] = sDBstructur[68].ToUInt32();//health mod
- sField[13] = sDBstructur[69].ToUInt32(); //power(mana) mod
- sField[14] = sDBstructur[71].ToUInt32(); //racial leader
- sField[15] = sDBstructur[72].ToUInt32(); //quest item 1-6
- sField[16] = sDBstructur[73].ToUInt32();
- sField[17] = sDBstructur[74].ToUInt32();
- sField[18] = sDBstructur[75].ToUInt32();
- sField[19] = sDBstructur[76].ToUInt32();
- sField[20] = sDBstructur[77].ToUInt32();
- }
- }
- tCompare();
- }
- }
- Console.ReadKey();
- }
- public static void ToLog(string text)
- {
- Log.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + text); Log.Flush();
- }
- public static uint ToUInt32(this object val)
- {
- uint num;
- uint.TryParse(val.ToString(), out num);
- return num;
- }
- public static void tCompare()
- {
- for (i = 1; i < 19; ++i)
- {
- Equals(fField[i], sField[i]);
- if (fField[i] != sField[i])
- {
- Console.WriteLine("ИД {0} не равен ИД {0}", fField[0], sField[0]);
- continue;
- }
- else
- {
- if (fField[i] == sField[i])
- {
- Console.WriteLine("ИД {0} равен ИД {0}", fField[0], sField[0]);
- }
- }
- }
- }
- public static void TryCon()
- {
- try
- {
- MySqlConnection connect = new MySqlConnection(connectionInfo);
- connect.Open();
- connect.Close();
- bconnection = true;
- }
- catch
- {
- bconnection = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement