From 79fe8dab1bcb8e8d92d9058ca2540cd4e8f9ecf9 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期五, 27 十一月 2020 14:05:32 +0800
Subject: [PATCH] 20201127 合并嘉乐代码
---
HDL_ON/DAL/FileUtils.cs | 229 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 112 insertions(+), 117 deletions(-)
diff --git a/HDL_ON/DAL/FileUtils.cs b/HDL_ON/DAL/FileUtils.cs
index 4f114b6..821be14 100644
--- a/HDL_ON/DAL/FileUtils.cs
+++ b/HDL_ON/DAL/FileUtils.cs
@@ -1,13 +1,7 @@
锘縰sing System;
using System.IO;
using System.Collections.Generic;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
using Shared;
-//using HDL_ON.UI;
-using HDL_ON.DAL.Net;
-using HDL_ON.DAL;
-using HDL_ON.Entity;
namespace HDL_ON
{
@@ -15,6 +9,17 @@
{
public static string RootPath = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/";
+ /// <summary>
+ /// 鏄惁瀛樺湪鏂囦欢澶�
+ /// </summary>
+ /// <returns></returns>
+ public static bool IsExisFolder(string folderName)
+ {
+ bool result = false;
+ var path = Path.Combine(RootPath, folderName);
+ result = Directory.Exists(path);
+ return result;
+ }
/// <summary>
/// 鍒涘缓涓�涓綇瀹呯殑澶囦唤鏂囦欢澶�
/// </summary>
@@ -45,7 +50,6 @@
foreach (var fileName in ReadRegionFiles(path))
{
File.Delete(Path.Combine(path, fileName));
- MainPage.Log("Del region file :" + fileName);
}
}
@@ -79,7 +83,7 @@
{
continue;
}
- if (NextFile.Name == "null" || NextFile.Name == "UserConfig" || NextFile.Name == "Register_File" || NextFile.Name == "AccountListDB")
+ if (NextFile.Name == "null" || NextFile.Name == "UserConfig" || NextFile.Name == "UserInfo_File" || NextFile.Name == "AccountListDB")
{
continue;
}
@@ -95,7 +99,7 @@
/// <summary>
/// 閬嶅巻鏂囦欢
/// </summary>
- public static List<string> ReadFiles(bool reInit = true)
+ public static List<string> ReadFiles()
{
List<string> listFiles = new List<string>();
DirectoryInfo TheFolder = new DirectoryInfo(RootPath);
@@ -103,14 +107,6 @@
{
listFiles.Add(NextFile.Name);
}
- try
- {
- if (reInit)
- {
- MainPage.LocationFiles = listFiles;
- }
- }
- catch { }
return listFiles;
}
@@ -215,10 +211,9 @@
for (int j = 0; j < filesList.Count; j++)
{
var f = filesList[j];
- if (f == "linphonerc" || f == "AccountListDB" || f == "Register_File")
+ if (f == "linphonerc" || f == "AccountListDB" || f == "UserInfo_File")
continue;
DeleteFile(f);
- MainPage.Log($"Del file :{f}");
}
}
@@ -411,108 +406,108 @@
}
}
- /// <summary>
- /// 涓嬭浇鐢靛彴銆侀煶涔愩�丏LNA绛夌瓑缃戠粶鍥剧墖
- /// </summary>
- /// <param name="fileName"></param>
- /// <param name="url"></param>
- public static void DownLoadImage(string fileName, string url)
- {
- #region 濡傛灉褰撳墠鐩綍涓嶅瓨鍦紝灏卞垵濮嬪寲
- string directioryPath = null;
- if (Shared.Application.IsPad)
- {
- directioryPath = "Pad/" + "MusicImage";
- }
- else
- {
- directioryPath = "Phone/" + "MusicImage";
- }
- directioryPath = Path.Combine(RootPath, directioryPath);
- if (!Directory.Exists(directioryPath))
- {
- Directory.CreateDirectory(directioryPath);
- }
- #endregion
+ ///// <summary>
+ ///// 涓嬭浇鐢靛彴銆侀煶涔愩�丏LNA绛夌瓑缃戠粶鍥剧墖
+ ///// </summary>
+ ///// <param name="fileName"></param>
+ ///// <param name="url"></param>
+ //public static void DownLoadImage(string fileName, string url)
+ //{
+ // #region 濡傛灉褰撳墠鐩綍涓嶅瓨鍦紝灏卞垵濮嬪寲
+ // string directioryPath = null;
+ // if (Shared.Application.IsPad)
+ // {
+ // directioryPath = "Pad/" + "MusicImage";
+ // }
+ // else
+ // {
+ // directioryPath = "Phone/" + "MusicImage";
+ // }
+ // directioryPath = Path.Combine(RootPath, directioryPath);
+ // if (!Directory.Exists(directioryPath))
+ // {
+ // Directory.CreateDirectory(directioryPath);
+ // }
+ // #endregion
- if (!File.Exists(fileName))
- {
- System.Threading.Tasks.Task.Run(() =>
- {
- FileStream fs = null;
- try
- {
- HDL_ON.DAL.Net.MyWebClient webClient = new HDL_ON.DAL.Net.MyWebClient();
- byte[] recevieBytes = webClient.DownloadData(new Uri(url));
- fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
- fs.Write(recevieBytes, 0, recevieBytes.Length);
- fs.Flush();
- }
- catch { }
- finally
- {
- if (fs != null)
- {
- fs.Close();
- }
- }
- });
- }
- }
+ // if (!File.Exists(fileName))
+ // {
+ // System.Threading.Tasks.Task.Run(() =>
+ // {
+ // FileStream fs = null;
+ // try
+ // {
+ // MyWebClient webClient = new MyWebClient();
+ // byte[] recevieBytes = webClient.DownloadData(new Uri(url));
+ // fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
+ // fs.Write(recevieBytes, 0, recevieBytes.Length);
+ // fs.Flush();
+ // }
+ // catch { }
+ // finally
+ // {
+ // if (fs != null)
+ // {
+ // fs.Close();
+ // }
+ // }
+ // });
+ // }
+ //}
- /// <summary>
- /// 涓嬭浇鐢靛彴銆侀煶涔愩�丏LNA绛夌瓑缃戠粶鍥剧墖
- /// </summary>
- /// <param name="fileName"></param>
- /// <param name="url"></param>
- public static string DownLoadImageFormBaidu(string album, string artist)
- {
- var url = "http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.search.catalogSug&format=json&query=" + artist;
- string directioryPath = "MusicImage";
- directioryPath = Path.Combine(RootPath, directioryPath);
- if (!Directory.Exists(directioryPath))
- {
- Directory.CreateDirectory(directioryPath);
- }
- try
- {
- var song = Newtonsoft.Json.JsonConvert.DeserializeObject<Song>(new HDL_ON.DAL.Net.MyWebClient().DownloadString(new Uri(url)));
- if (song == null)
- {
- return null;
- }
- foreach (var tempAlbum in song.album)
- {
- if (tempAlbum.albumname == album && artist == tempAlbum.artistname)
- {
- var bytes = new HDL_ON.DAL.Net.MyWebClient().DownloadData(new Uri(tempAlbum.artistpic.Split('@')[0] + "@s_1,w_160,h_160"));
- var filePath = Path.Combine(directioryPath, "AlbumArtistImage_" + album);
- var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
- fs.Write(bytes, 0, bytes.Length);
- fs.Flush();
- fs.Close();
- return filePath;
- }
- }
+ ///// <summary>
+ ///// 涓嬭浇鐢靛彴銆侀煶涔愩�丏LNA绛夌瓑缃戠粶鍥剧墖
+ ///// </summary>
+ ///// <param name="fileName"></param>
+ ///// <param name="url"></param>
+ //public static string DownLoadImageFormBaidu(string album, string artist)
+ //{
+ // var url = "http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.search.catalogSug&format=json&query=" + artist;
+ // string directioryPath = "MusicImage";
+ // directioryPath = Path.Combine(RootPath, directioryPath);
+ // if (!Directory.Exists(directioryPath))
+ // {
+ // Directory.CreateDirectory(directioryPath);
+ // }
+ // try
+ // {
+ // var song = Newtonsoft.Json.JsonConvert.DeserializeObject<Song>(new HDL_ON.DAL.Net.MyWebClient().DownloadString(new Uri(url)));
+ // if (song == null)
+ // {
+ // return null;
+ // }
+ // foreach (var tempAlbum in song.album)
+ // {
+ // if (tempAlbum.albumname == album && artist == tempAlbum.artistname)
+ // {
+ // var bytes = new HDL_ON.DAL.Net.MyWebClient().DownloadData(new Uri(tempAlbum.artistpic.Split('@')[0] + "@s_1,w_160,h_160"));
+ // var filePath = Path.Combine(directioryPath, "AlbumArtistImage_" + album);
+ // var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
+ // fs.Write(bytes, 0, bytes.Length);
+ // fs.Flush();
+ // fs.Close();
+ // return filePath;
+ // }
+ // }
- foreach (var tempArtist in song.artist)
- {
- if (artist == tempArtist.artistname)
- {
- var bytes = new HDL_ON.DAL.Net.MyWebClient().DownloadData(new Uri(tempArtist.artistpic.Split('@')[0] + "@s_1,w_160,h_160"));
- var filePath = Path.Combine(directioryPath, "AlbumArtistImage_" + artist);
- var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
- fs.Write(bytes, 0, bytes.Length);
- fs.Flush();
- fs.Close();
- return filePath;
- }
- }
+ // foreach (var tempArtist in song.artist)
+ // {
+ // if (artist == tempArtist.artistname)
+ // {
+ // var bytes = new HDL_ON.DAL.Net.MyWebClient().DownloadData(new Uri(tempArtist.artistpic.Split('@')[0] + "@s_1,w_160,h_160"));
+ // var filePath = Path.Combine(directioryPath, "AlbumArtistImage_" + artist);
+ // var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
+ // fs.Write(bytes, 0, bytes.Length);
+ // fs.Flush();
+ // fs.Close();
+ // return filePath;
+ // }
+ // }
- }
- catch { }
- return null;
- }
+ // }
+ // catch { }
+ // return null;
+ //}
}
[System.Serializable]
--
Gitblit v1.8.0