Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.03 KB | None | 0 0
  1. using System;
  2. using MySql.Data.MySqlClient;
  3. using System.Collections.Generic;
  4. using System.IO;
  5.  
  6. namespace ConsoleApplication2
  7. {
  8.     public static class Program
  9.     {
  10.         const string connectionInfo = ("host=localhost;" + "port = '3306';" + "database='mangos';" + "UserName='root';" + "Password='mangos'");
  11.         public static StreamWriter Log = new StreamWriter("sql_log.txt", true);
  12.         public static bool bconnection { get; private set; }
  13.         public static bool bgetTables { get; private set; }
  14.         public static UInt16 i;
  15.         public static UInt16 entry;
  16.         public static double[] fField = new double[30];
  17.         public static double[] sField = new double[30];
  18.         public static MySqlCommand fcommand;
  19.         public static MySqlCommand scommand;
  20.  
  21.         static void Main(string[] args)
  22.         {
  23.             Console.ForegroundColor = ConsoleColor.Yellow;
  24.             Console.WriteLine("--------------------Programm is open!--------------------");
  25.             ToLog("Programm is open!");
  26.             TryCon();
  27.             if (!bconnection)
  28.             {
  29.                 Console.ForegroundColor = ConsoleColor.Red;
  30.                 Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Check your MySQL server");
  31.                 Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Press any key for exit");
  32.                 ToLog("MySQL Server not running");
  33.                 ToLog("closed.......");
  34.                 Console.ReadKey(true);
  35.                 return;
  36.             }
  37.             else
  38.             {
  39.                 MySqlConnection connect = new MySqlConnection(connectionInfo);
  40.                 connect.Open();
  41.                 Console.ForegroundColor = ConsoleColor.Cyan;
  42.                 Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Connection open!");
  43.                 ToLog("Connection open");
  44.                 Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Start compare?");
  45.                 string variant = Console.ReadLine();
  46.                 if (variant == "y" || variant == "Y")
  47.                 {
  48.                     Console.WriteLine("start compare....");
  49.                     ToLog("Start compare.....");
  50.                     bgetTables = true;
  51.                 }
  52.                 else if (variant == "n" || variant == "N")
  53.                 {
  54.                     Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Press any key for exit");
  55.                     connect.Close();
  56.                     bgetTables = false;
  57.                 }
  58.                 else
  59.                     Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Neee press 'y' or 'n'");
  60.  
  61.                 if (bgetTables)
  62.                 {
  63.                     string fSelect = "SELECT * FROM world.creature_template";
  64.                     string sSelect = "SELECT * FROM world.creature_template";
  65.  
  66.                     fcommand = new MySqlCommand(fSelect, connect);
  67.                     scommand = new MySqlCommand(sSelect, connect);
  68.                     using (var fDBstructur = fcommand.ExecuteReader())
  69.                     {
  70.                         while (fDBstructur.Read())
  71.                         {
  72.                             //UInt64[] fField = new UInt64[30];
  73.                             fField[0] = fDBstructur[0].ToUInt32();
  74.                             fField[1] = fDBstructur[4].ToUInt32(); //kill credit 1,2
  75.                             fField[2] = fDBstructur[5].ToUInt32();
  76.                             fField[3] = fDBstructur[6].ToUInt32(); //modelid1 id 1-4
  77.                             fField[4] = fDBstructur[7].ToUInt32();
  78.                             fField[5] = fDBstructur[8].ToUInt32();
  79.                             fField[6] = fDBstructur[9].ToUInt32();
  80.                             //String IconName = fDBstructur[12].ToString();
  81.                             fField[7] = fDBstructur[23].ToUInt32(); //rank
  82.                             fField[8] = fDBstructur[34].ToUInt32(); //family
  83.                             fField[9] = fDBstructur[42].ToUInt32();//type
  84.                             fField[10] = fDBstructur[43].ToUInt32();//type flag
  85.                             fField[11] = fDBstructur[66].ToUInt32(); //movement id
  86.                             fField[12] = fDBstructur[68].ToUInt32();//health mod
  87.                             fField[13] = fDBstructur[69].ToUInt32(); //power(mana) mod
  88.                             fField[14] = fDBstructur[71].ToUInt32(); //racial leader
  89.                             fField[15] = fDBstructur[72].ToUInt32(); //quest item 1-6
  90.                             fField[16] = fDBstructur[73].ToUInt32();
  91.                             fField[17] = fDBstructur[74].ToUInt32();
  92.                             fField[18] = fDBstructur[75].ToUInt32();
  93.                             fField[19] = fDBstructur[76].ToUInt32();
  94.                             fField[20] = fDBstructur[77].ToUInt32();
  95.                         }
  96.                     }
  97.                     using (var sDBstructur = scommand.ExecuteReader())
  98.                     {
  99.                         while (sDBstructur.Read())
  100.                         {
  101.                             //UInt64[] sField = new UInt64[30];
  102.                             sField[0]  = sDBstructur[0].ToUInt32();
  103.                             sField[1]  = sDBstructur[4].ToUInt32(); //kill credit 1,2
  104.                             sField[2]  = sDBstructur[5].ToUInt32();
  105.                             sField[3]  = sDBstructur[6].ToUInt32(); //modelid1 id 1-4
  106.                             sField[4]  = sDBstructur[7].ToUInt32();
  107.                             sField[5]  = sDBstructur[8].ToUInt32();
  108.                             sField[6]  = sDBstructur[9].ToUInt32();
  109.                             //String IconName = fDBstructur[12].ToString();
  110.                             sField[7]  = sDBstructur[23].ToUInt32(); //rank
  111.                             sField[8]  = sDBstructur[34].ToUInt32(); //family
  112.                             sField[9]  = sDBstructur[42].ToUInt32();//type
  113.                             sField[10] = sDBstructur[43].ToUInt32();//type flag
  114.                             sField[11] = sDBstructur[66].ToUInt32(); //movement id
  115.                             sField[12] = sDBstructur[68].ToUInt32();//health mod
  116.                             sField[13] = sDBstructur[69].ToUInt32(); //power(mana) mod
  117.                             sField[14] = sDBstructur[71].ToUInt32(); //racial leader
  118.                             sField[15] = sDBstructur[72].ToUInt32(); //quest item 1-6
  119.                             sField[16] = sDBstructur[73].ToUInt32();
  120.                             sField[17] = sDBstructur[74].ToUInt32();
  121.                             sField[18] = sDBstructur[75].ToUInt32();
  122.                             sField[19] = sDBstructur[76].ToUInt32();
  123.                             sField[20] = sDBstructur[77].ToUInt32();
  124.                         }
  125.                     }
  126.                     tCompare();
  127.                 }
  128.             }
  129.             Console.ReadKey();
  130.         }
  131.  
  132.         public static void ToLog(string text)
  133.         {
  134.             Log.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + text); Log.Flush();
  135.         }
  136.  
  137.         public static uint ToUInt32(this object val)
  138.         {
  139.             uint num;
  140.             uint.TryParse(val.ToString(), out num);
  141.             return num;
  142.         }
  143.  
  144.         public static void tCompare()
  145.         {
  146.             for (fField[0] = 1; fField[0] < 40001; ++fField[0])
  147.             {
  148.                 for (i = 1; i < 20; ++i)
  149.                 {
  150.                     Equals(fField[i], sField[i]);
  151.  
  152.                     if (fField[i] != sField[i] && i == 19)
  153.                     {
  154.                         Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "ИД {0} не равен ИД {0}", fField[0], sField[0]);
  155.                         Log.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "ID {0} != ID {0}", fField[0], sField[0]);
  156.                     }
  157.                     else
  158.                     {
  159.                         if (fField[i] == sField[i] && i == 19)
  160.                         {
  161.                             Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "ИД {0} равен ИД {0}", fField[0], sField[0]);
  162.                             Log.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "ID {0} == ID {0}", fField[0], sField[0]);
  163.                         }
  164.                     }
  165.                 }
  166.                 if (fField[0] > 39999)
  167.                 {
  168.                     Console.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Сравнение удачно завершено!");
  169.                     Log.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + "Compare successfully compete!");
  170.                 }
  171.             }
  172.         }
  173.  
  174.         public static void TryCon()
  175.         {
  176.             try
  177.             {
  178.                 MySqlConnection connect = new MySqlConnection(connectionInfo);
  179.                 connect.Open();
  180.                 connect.Close();
  181.                 bconnection = true;
  182.             }
  183.             catch
  184.             {
  185.                 bconnection = false;
  186.             }
  187.         }
  188.     }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement