Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. using System.Diagnostics;
  10.  
  11. namespace KLauncher
  12. {
  13.     class CacheCheck
  14.     {
  15.        
  16.         public static long lCacheSize;
  17.         public static string strCurrentMD5;
  18.         public static string strKuretarMD5;
  19.  
  20.         public static void DownloadCache()
  21.         {
  22.             WebClient p = new WebClient();
  23.             Uri url = new Uri("http://kuretarhost.fr/cache/DBCache.bin");
  24.  
  25.             p.DownloadFileAsync(url, Utils.GetAssemblyDirectory + @"\Data\data\cachebckp\DBCache.bin");
  26.  
  27.         }
  28.  
  29.         public static void CacheBackupIntegrity(string file)
  30.         {
  31.             if (!File.Exists(file))
  32.                 DownloadCache();
  33.             else
  34.             {
  35.                 // Server Cache & Client Cache.
  36.                 strKuretarMD5 = MySql.QueryGetSrvCacheMd5(); // server
  37.                 strCurrentMD5 = Utils.CalculateMD5(file); // client
  38.  
  39.                 if (strCurrentMD5 != strKuretarMD5)
  40.                 {
  41.                     MessageBox.Show("La sauvegarde du cache est incomplète et ne correspond pas au fichier présent sur nos serveurs. Téléchargement de la nouvelle version . . .", "Intégrité du cache", MessageBoxButtons.OK, MessageBoxIcon.Information);
  42.                     DownloadCache();
  43.                 }
  44.                
  45.             }
  46.  
  47.         }
  48.  
  49.         public static void CacheClientCheck(string file)
  50.         {
  51.             FileInfo fInfo = new FileInfo(file);
  52.             lCacheSize = fInfo.Length;
  53.  
  54.             double InMegaBit = Utils.BitConversion(lCacheSize, "mb");
  55.  
  56.             if (InMegaBit >= 500)
  57.             {
  58.                 MessageBox.Show("Votre cache est beaucoup trop lourd, un cache d'une trop grande taille risque de provoquer de lourd ralentissement au long terme. Copie du cache backup . . .", "Cache trop lourd !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  59.                 DownloadCache();
  60.             }    
  61.         }
  62.  
  63.         public static void CacheFix(string bckpPath, string cachePath)
  64.         {
  65.             // Before, check if wow is started
  66.             Process[] pName = Process.GetProcessesByName("Wow");
  67.             if (pName.Length != 0)
  68.                 MessageBox.Show("Impossible de corriger le cache alors que World of Warcraft est ouvert. Veuillez fermer le jeu avant de procéder.", "WoW est ouvert", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  69.             else
  70.             {
  71.                 File.Copy(bckpPath, cachePath);
  72.                 MessageBox.Show("Cache corrigée avec succès. Vous pouvez désormais vous connecter.", "Cache à jour", MessageBoxButtons.OK, MessageBoxIcon.Information);
  73.             }
  74.            
  75.         }
  76.  
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement