Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- using System.Diagnostics;
- namespace KLauncher
- {
- class CacheCheck
- {
- public static long lCacheSize;
- public static string strCurrentMD5;
- public static string strKuretarMD5;
- public static void DownloadCache()
- {
- WebClient p = new WebClient();
- Uri url = new Uri("http://kuretarhost.fr/cache/DBCache.bin");
- p.DownloadFileAsync(url, Utils.GetAssemblyDirectory + @"\Data\data\cachebckp\DBCache.bin");
- }
- public static void CacheBackupIntegrity(string file)
- {
- if (!File.Exists(file))
- DownloadCache();
- else
- {
- // Server Cache & Client Cache.
- strKuretarMD5 = MySql.QueryGetSrvCacheMd5(); // server
- strCurrentMD5 = Utils.CalculateMD5(file); // client
- if (strCurrentMD5 != strKuretarMD5)
- {
- 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);
- DownloadCache();
- }
- }
- }
- public static void CacheClientCheck(string file)
- {
- FileInfo fInfo = new FileInfo(file);
- lCacheSize = fInfo.Length;
- double InMegaBit = Utils.BitConversion(lCacheSize, "mb");
- if (InMegaBit >= 500)
- {
- 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);
- DownloadCache();
- }
- }
- public static void CacheFix(string bckpPath, string cachePath)
- {
- // Before, check if wow is started
- Process[] pName = Process.GetProcessesByName("Wow");
- if (pName.Length != 0)
- 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);
- else
- {
- File.Copy(bckpPath, cachePath);
- MessageBox.Show("Cache corrigée avec succès. Vous pouvez désormais vous connecter.", "Cache à jour", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement