From fb172d3848dc66f676af32754834ec6cd94c45da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=BD=87=E9=98=B3?= Date: Fri, 28 Jun 2024 14:09:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=AD=E9=9F=B3=E6=92=AD?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF_Cef/Common/ChunkedUpload.cs | 28 ++++++++++++++ CPF_Cef/FrmMain.cs | 4 +- CPF_Cef/MainModel.cs | 68 ++++++++++++++------------------- 3 files changed, 59 insertions(+), 41 deletions(-) diff --git a/CPF_Cef/Common/ChunkedUpload.cs b/CPF_Cef/Common/ChunkedUpload.cs index e169a8e..7044e8a 100644 --- a/CPF_Cef/Common/ChunkedUpload.cs +++ b/CPF_Cef/Common/ChunkedUpload.cs @@ -9,6 +9,7 @@ using System.Globalization; using System.IO; using System.Net; using System.Net.Http; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace AksWebBrowser.Common @@ -761,5 +762,32 @@ namespace AksWebBrowser.Common ServicePointManager.DefaultConnectionLimit = 1000; ServicePointManager.Expect100Continue = false; } + + public static string NumberToChinese(int number) + { + string[] chineseNumbers = new string[] { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" }; + string[] chineseUnits = new string[] { "", "十", "百", "千", "万" }; + + string result = ""; + int unitPlace = 0; + + if (number == 0) + { + return chineseNumbers[0]; + } + + while (number > 0) + { + int part = number % 10; + if (part != 0 || (part == 0 && result.Length > 0 && result[0] != '零')) + { + result = string.Format("{0}{1}{2}", chineseNumbers[part], chineseUnits[unitPlace], result); + } + number /= 10; + unitPlace++; + } + + return result; + } } } diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs index fe57627..823a436 100644 --- a/CPF_Cef/FrmMain.cs +++ b/CPF_Cef/FrmMain.cs @@ -81,9 +81,9 @@ namespace AksWebBrowser //浏览器大小 Parame.webBrowser.Width = w; Parame.webBrowser.Height = h; - Parame.webBrowser.Url = "http://127.0.0.1:8096/#/main-out"; + //Parame.webBrowser.Url = "http://127.0.0.1:8096/#/main-out"; //Parame.webBrowser.Url = "http://192.168.0.232:8848/html/index.html"; - //Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out"; + Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out"; //Parame.webBrowser.Url = Application.StartupPath + @"\html\index.html"; //开发者工具暂时只能支持Windows //webBrowser.ShowDev(); diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index 43984c7..1f43fec 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -401,10 +401,7 @@ namespace AksWebBrowser { if (ispaye) { - Task.Run(() => - { - Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); }); - }); + Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); }); string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}"; SubmitLogs(result, "payleText"); return result; @@ -451,7 +448,7 @@ namespace AksWebBrowser } else { - Task.Run(() => { string command = $"sox {tempFile} -d"; ShllCommad(command); }); + Task.Run(() => { string command = $"sox {tempFile} -d"; ShllCommad(command); }); result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "开始播放" + "\"}"; } @@ -1012,10 +1009,7 @@ namespace AksWebBrowser { if (ispaly) { - Task.Run(() => - { - Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); }); - }); + Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); }); string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}"; SubmitLogs(result, "PalyFile"); return result; @@ -1024,37 +1018,33 @@ namespace AksWebBrowser { Task.Run(() => { - Task.Run(() => - { - Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); }); - }); - Uri uri = new Uri(url); - //返回 123.xlsx - var filename = HttpUtility.UrlDecode(uri.Segments.Last()); - //获取文件后缀 - string ext = System.IO.Path.GetExtension(filename); - DateTime dateTime = DateTime.Now; - string time = DateTime.Now.ToString( - "yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - string dirpath = Utils.getSystemPaht() + @"/wwwroot/WaveOutFile"; - if (!Directory.Exists(dirpath)) - { - Directory.CreateDirectory(dirpath); - } - string path = dirpath + @"/" + time + ext; - WebRequest request = WebRequest.Create(url); - WebResponse response = request.GetResponse(); - using (Stream stream = response.GetResponseStream()) - { - using (FileStream fileStream = new FileStream(path, FileMode.Create)) - { - stream.CopyTo(fileStream); - } - } - response.Close(); - + string command = $"pkill sox"; ShllCommad(command); + //Uri uri = new Uri(url); + ////返回 123.xlsx + //var filename = HttpUtility.UrlDecode(uri.Segments.Last()); + ////获取文件后缀 + //string ext = System.IO.Path.GetExtension(filename); + //DateTime dateTime = DateTime.Now; + //string time = DateTime.Now.ToString( + // "yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); + //string dirpath = Utils.getSystemPaht() + @"/wwwroot/WaveOutFile"; + //if (!Directory.Exists(dirpath)) + //{ + // Directory.CreateDirectory(dirpath); + //} + //string path = dirpath + @"/" + time + ext; + //WebRequest request = WebRequest.Create(url); + //WebResponse response = request.GetResponse(); + //using (Stream stream = response.GetResponseStream()) + //{ + // using (FileStream fileStream = new FileStream(path, FileMode.Create)) + // { + // stream.CopyTo(fileStream); + // } + //} + //response.Close(); //开始播放 - string command = $"sox {path} -d"; + command = $"sox {url} -d"; ShllCommad(command); //AutoAudio(ispaly, path); });