public static void SaveLocaSettings() { File.WriteAllText(USettings.CachePath + "Data.st", TextHelper.TextEncrypt(Convert.ToBase64String(Encoding.Default.GetBytes(TextHelper.JSON.ToJSON(LSettings))), TextHelper.MD5.EncryptToMD5string("Data.st"))); }
public static void LoadUSettings(string qq) { USettings = new UserSettings(); if (File.Exists(USettings.CachePath + qq + ".st")) { string data = Encoding.UTF8.GetString(Convert.FromBase64String(TextHelper.TextDecrypt(File.ReadAllText(USettings.CachePath + qq + ".st"), TextHelper.MD5.EncryptToMD5string(qq + ".st")))); JObject o = JObject.Parse(data); USettings.LemonAreeunIts = o["LemonAreeunIts"].ToString(); USettings.UserImage = o["UserImage"].ToString(); USettings.UserName = o["UserName"].ToString(); USettings.Playing.GC = o["Playing"]["GC"].ToString(); USettings.Playing.ImageUrl = o["Playing"]["ImageUrl"].ToString(); USettings.Playing.MusicID = o["Playing"]["MusicID"].ToString(); USettings.Playing.MusicName = o["Playing"]["MusicName"].ToString(); USettings.Playing.Singer = o["Playing"]["Singer"].ToString(); USettings.jd = Double.Parse(o["jd"].ToString()); USettings.alljd = Double.Parse(o["alljd"].ToString()); foreach (var jx in o["MusicLike"].ToArray()) { foreach (var jm in jx) { if (!USettings.MusicLike.ContainsKey(jm["MusicID"].ToString())) { USettings.MusicLike.Add(jm["MusicID"].ToString(), new Music() { GC = jm["GC"].ToString(), MusicID = jm["MusicID"].ToString(), Singer = jm["Singer"].ToString(), ImageUrl = jm["ImageUrl"].ToString(), MusicName = jm["MusicName"].ToString() }); } } } foreach (var jcm in o["MusicGD"]) { foreach (var jm in jcm) { if (!USettings.MusicGD.ContainsKey(jm["id"].ToString())) { var datae = new List <Music>(); foreach (var dt in jm["Data"]) { datae.Add(new Music() { GC = dt["GC"].ToString(), Singer = dt["Singer"].ToString(), ImageUrl = dt["ImageUrl"].ToString(), MusicID = dt["MusicID"].ToString(), MusicName = dt["MusicName"].ToString() }); } USettings.MusicGD.Add(jm["id"].ToString(), new MusicGData() { id = jm["id"].ToString(), name = jm["name"].ToString(), pic = jm["pic"].ToString(), Data = datae }); } } } if (data.Contains("Skin_Path")) { USettings.Skin_Path = o["Skin_Path"].ToString(); USettings.Skin_txt = o["Skin_txt"].ToString(); USettings.Skin_Theme_R = o["Skin_Theme_R"].ToString(); USettings.Skin_Theme_G = o["Skin_Theme_G"].ToString(); USettings.Skin_Theme_B = o["Skin_Theme_B"].ToString(); } if (data.Contains("CachePath")) { USettings.CachePath = o["CachePath"].ToString(); USettings.DownloadPath = o["DownloadPath"].ToString(); } else { USettings.CachePath = Environment.ExpandEnvironmentVariables(@"%AppData%\LemonApp\Cache\"); USettings.DownloadPath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + "\\LemonApp\\"; } } else { SaveSettings(qq); } }
public static void LoadUSettings(string qq) { USettings = new UserSettings(); if (File.Exists(USettings.CachePath + qq + ".st")) { string data = Encoding.UTF8.GetString(Convert.FromBase64String(TextHelper.TextDecrypt(File.ReadAllText(USettings.CachePath + qq + ".st"), TextHelper.MD5.EncryptToMD5string(qq + ".st")))); Console.WriteLine(data); JObject o = JObject.Parse(data); USettings.LemonAreeunIts = o["LemonAreeunIts"].ToString(); USettings.UserImage = o["UserImage"].ToString(); USettings.UserName = o["UserName"].ToString(); USettings.Cookie = o["Cookie"].ToString(); USettings.g_tk = o["g_tk"].ToString(); USettings.Playing.ImageUrl = o["Playing"]["ImageUrl"].ToString(); USettings.Playing.MusicID = o["Playing"]["MusicID"].ToString(); USettings.Playing.MusicName = o["Playing"]["MusicName"].ToString(); USettings.Playing.SingerText = o["Playing"]["SingerText"].ToString(); foreach (var xs in o["Playing"]["Singer"]) { USettings.Playing.Singer.Add(new MusicSinger() { Name = xs["Name"].ToString(), Mid = xs["Mid"].ToString() }); } foreach (var jx in o["MusicLike"].ToArray()) { foreach (var jm in jx) { if (!USettings.MusicLike.ContainsKey(jm["MusicID"].ToString())) { List <MusicSinger> lm = new List <MusicSinger>(); foreach (var xs in jm["Singer"]) { lm.Add(new MusicSinger() { Name = xs["Name"].ToString(), Mid = xs["Mid"].ToString() }); } USettings.MusicLike.Add(jm["MusicID"].ToString(), new Music() { MusicID = jm["MusicID"].ToString(), SingerText = jm["SingerText"].ToString(), Singer = lm, ImageUrl = jm["ImageUrl"].ToString(), MusicName = jm["MusicName"].ToString() }); } } } if (data.Contains("IsRoundMusicImage")) { USettings.IsRoundMusicImage = int.Parse(o["IsRoundMusicImage"].ToString()); } if (data.Contains("DownloadName")) { USettings.DownloadName = o["DownloadName"].ToString(); } if (data.Contains("DownloadWithLyric")) { USettings.DownloadWithLyric = bool.Parse(o["DownloadWithLyric"].ToString()); } if (data.Contains("Skin_Path")) { USettings.Skin_Path = o["Skin_Path"].ToString(); USettings.Skin_txt = o["Skin_txt"].ToString(); USettings.Skin_Theme_R = o["Skin_Theme_R"].ToString(); USettings.Skin_Theme_G = o["Skin_Theme_G"].ToString(); USettings.Skin_Theme_B = o["Skin_Theme_B"].ToString(); } if (data.Contains("CachePath")) { USettings.CachePath = o["CachePath"].ToString(); USettings.DownloadPath = o["DownloadPath"].ToString(); } else { USettings.CachePath = Environment.ExpandEnvironmentVariables(@"%AppData%\LemonApp\Cache\"); USettings.DownloadPath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + "\\LemonApp\\"; } } else { SaveSettings(qq); } }