Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.26 KB | None | 0 0
  1. using System;
  2. using MySql.Data.MySqlClient;
  3. using System.IO;
  4. using System.Data;
  5. using System.Collections.Generic;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9.     class Program
  10.     {
  11.         const string connectionInfo = ("host=localhost;" + "port = '3306';" + "database='mangos';" + "UserName='root';" + "Password='mangos'");
  12.         public static StreamWriter Log = new StreamWriter("sql_log.txt", true);
  13.         public static bool bconnection { get; private set; }
  14.         public static bool bcompare { get; private set; }
  15.         public static MySqlCommand fcommand;
  16.         public static MySqlCommand scommand;
  17.  
  18.         static void Main(string[] args)
  19.         {
  20.             Console.WriteLine("--------------------Programm is open!--------------------");
  21.             ToLog("Programm is open!");
  22.             TryCon();
  23.             if (!bconnection)
  24.             {
  25.                 Console.WriteLine("-------------Check your MySQL server-------------");
  26.                 Console.WriteLine("-------------Press any key for exit-------------");
  27.                 ToLog("MySQL Server not running");
  28.                 Console.ReadKey(true);
  29.                 return;
  30.             }
  31.             else
  32.             {
  33.                 MySqlConnection connect = new MySqlConnection(connectionInfo);
  34.                 connect.Open();
  35.                 Console.WriteLine("-------------Connection open-------------");
  36.                 ToLog("Connection open");
  37.                 Console.WriteLine("Start compare?");
  38.                 string variant = Console.ReadLine();
  39.                 if (variant == "y" || variant == "Y")
  40.                 {
  41.                     Console.WriteLine("start compare....");
  42.                     ToLog("Start compare.....");
  43.                     bcompare = true;
  44.                 }
  45.                 else if (variant == "n" || variant == "N")
  46.                 {
  47.                     Console.WriteLine("Press any key for exit");
  48.                     connect.Close();
  49.                     bcompare = false;
  50.                 }
  51.                 else
  52.                     Console.WriteLine("Neee press 'y' or 'n'");
  53.  
  54.                 if (bcompare)
  55.                 {
  56.                     string fSelect = "SELECT * FROM world.creature_template";
  57.                     string sSelect = "SELECT * FROM world.creature_template_cache";
  58.  
  59.                     fcommand = new MySqlCommand(fSelect, connect);
  60.                     scommand = new MySqlCommand(sSelect, connect);
  61.                     var fDBstructur = fcommand.ExecuteReader();
  62.                     var sDBstructur = scommand.ExecuteReader();
  63.  
  64.                     while (fDBstructur.Read())
  65.                     {
  66.                     }
  67.                 }
  68.             }
  69.             Console.ReadKey();
  70.         }
  71.  
  72.         public static void ToLog(string text)
  73.         {
  74.             Log.WriteLine(DateTime.Now.ToString("[HH:mm:ss]") + text); Log.Flush();
  75.         }
  76.  
  77.         public static void TryCon()
  78.         {
  79.             try
  80.             {
  81.                 MySqlConnection connect = new MySqlConnection(connectionInfo);
  82.                 connect.Open();
  83.                 connect.Close();
  84.                 bconnection = true;
  85.             }
  86.             catch
  87.             {
  88.                 bconnection = false;
  89.             }
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement