From 769fcb3a22019a76fd12c13f549610e70f1ad452 Mon Sep 17 00:00:00 2001 From: YL <YL@LAPTOP-SE03PLUR> Date: 星期日, 05 九月 2021 16:17:01 +0800 Subject: [PATCH] nothing --- CLOUDWEB/CLOUDWEB.csproj | 1 CLOUDWEB/LogService.cs | 57 ++++++++++++++++++++++++++++ CLOUDWEB/WebService1.asmx.cs | 13 ++++++ 3 files changed, 70 insertions(+), 1 deletions(-) diff --git a/CLOUDWEB/CLOUDWEB.csproj b/CLOUDWEB/CLOUDWEB.csproj index fc2de38..28b38da 100644 --- a/CLOUDWEB/CLOUDWEB.csproj +++ b/CLOUDWEB/CLOUDWEB.csproj @@ -317,6 +317,7 @@ <Compile Include="Global.asax.cs"> <DependentUpon>Global.asax</DependentUpon> </Compile> + <Compile Include="LogService.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Site.Master.cs"> <DependentUpon>Site.Master</DependentUpon> diff --git a/CLOUDWEB/LogService.cs b/CLOUDWEB/LogService.cs new file mode 100644 index 0000000..673d91e --- /dev/null +++ b/CLOUDWEB/LogService.cs @@ -0,0 +1,57 @@ +锘縰sing Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CLOUDWEB +{ + public class LogService + { + private static readonly object lockObj = new object(); + + #region 鏃ュ織 + public static void Write(object obj, string filePath = "Vlog", bool isAppend = true) + { + try + { + lock (lockObj) + { + filePath = $@"{filePath}\webapi{DateTime.Now.ToString("yyyyMMdd")}.txt"; + + filePath = AppDomain.CurrentDomain.BaseDirectory + filePath; + + if (!System.IO.Directory.Exists(Path.GetDirectoryName(filePath))) + { + System.IO.Directory.CreateDirectory(Path.GetDirectoryName(filePath)); + } + + bool fileExists = System.IO.File.Exists(filePath); + //涓嶅瓨鍦� 鍒欏垱寤鸿鏂囦欢 + if (!fileExists) + { + System.IO.File.Create(filePath).Close(); + } + + using (StreamWriter writer = new StreamWriter(filePath, isAppend)) + { + //瀛樺湪鐨勬椂鍊欐墠鍐欎竴琛� + if (fileExists && isAppend) + { + writer.WriteLine(); + } + + var content = obj is string ? obj : JsonConvert.SerializeObject(obj); + writer.WriteLine($"{DateTime.Now} {content}"); + } + } + } + catch (Exception ex) + { + } + } + #endregion + } +} diff --git a/CLOUDWEB/WebService1.asmx.cs b/CLOUDWEB/WebService1.asmx.cs index dc17623..bb111e1 100644 --- a/CLOUDWEB/WebService1.asmx.cs +++ b/CLOUDWEB/WebService1.asmx.cs @@ -5292,6 +5292,16 @@ string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117 bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052); string msgReport = dbId + ';' + sCLOUDUseName + ';' + sCLOUDPsd + ';' + 2052; + + + LogService.Write($"{Pub_Class.ClsPub.sCLOUDUrl}銆亄dbId}銆亄sCLOUDUseName}銆亄sCLOUDPsd}"); + + LogService.Write(sJson); + + + + + if (bLogin) { var result = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save", @@ -5308,7 +5318,8 @@ new object[] { "PRD_MORPT", sJson3 }); //瀹℃牳鍗曟嵁 HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString(); - + LogService.Write(sJson2); + LogService.Write(sJson3); } else { -- Gitblit v1.9.1