From a9fbea8ae70eb4d2598917d616065331a21ad67d Mon Sep 17 00:00:00 2001 From: dyy <807692433@qq.com> Date: Thu, 9 Jan 2025 14:36:24 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E6=96=B0?= =?UTF-8?q?=E9=97=BB=E5=85=AC=E5=91=8A=E4=B8=8B=E5=8F=91=EF=BC=8C=E4=B8=8B?= =?UTF-8?q?=E5=8F=91=E5=AE=98=E7=BD=91=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XmlConfig/database.config | 4 +- .../XmlConfig/system.config | 6 +-- .../Learun.Application.OA/News/NewsService.cs | 39 ++++++++++--------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config index fcac9f60a..a813cc226 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config @@ -1,7 +1,7 @@  - - + + \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config index f1ede9b8d..2baf08745 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config @@ -191,9 +191,9 @@ - + - + - + \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs index 62e52d7e1..90f800805 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs @@ -202,20 +202,25 @@ namespace Learun.Application.OA { newEntity.F_Status = "0"; } - } - this.BaseRepository().Update(newEntity); + this.BaseRepository().Update(newEntity); - if (newEntity.IsSend == "1" && status == 2) - { - BaseRepository() - .ExecuteBySql("insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson) VALUES (newid(),2222,'准备开始run task') "); - Task.Run(async () => { sendNew(newEntity); }); + if (newEntity.IsSend == "1" && status == 2) + { + BaseRepository().ExecuteBySql($"insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson,F_Module,F_OperateTime) VALUES (newid(),2222,'准备开始run task','{newEntity.F_NewsId}','{DateTime.Now}') "); + try + { + Task.Run(async () => { sendNew(newEntity); }); + } + catch (Exception ex) + { + BaseRepository().ExecuteBySql($"insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson,F_Module,F_OperateTime) VALUES (newid(),2222,'run task 报错:{ex.Message}','{newEntity.F_NewsId}','{DateTime.Now}') "); + } + } } + } catch (Exception ex) { - BaseRepository() - .ExecuteBySql("insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson) VALUES (newid(),2222,'run task 报错"+ex.Message+"') "); if (ex is ExceptionEx) { throw; @@ -242,8 +247,7 @@ namespace Learun.Application.OA string ports = ConfigurationManager.AppSettings["Ports"]; #endregion - BaseRepository() - .ExecuteBySql("insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson) VALUES (newid(),2222,'准备开始组装实体') "); + BaseRepository().ExecuteBySql($"insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson,F_Module,F_OperateTime) VALUES (newid(),2222,'准备开始组装实体','{newEntity.F_NewsId}','{DateTime.Now}') "); SemdNewList SendNew = new SemdNewList { Title = newEntity.F_FullHead, @@ -259,12 +263,10 @@ namespace Learun.Application.OA { { "X-SS-API-KEY", ApiKey } }; - BaseRepository() - .ExecuteBySql("insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson) VALUES (newid(),2222,'准备开始post cms') "); + BaseRepository().ExecuteBySql($"insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson,F_Module,F_OperateTime) VALUES (newid(),2222,'准备开始post cms','{newEntity.F_NewsId}','{DateTime.Now}') "); string responses = HttpMethods.HttpPosts("http://" + ports + "/api/v1/contents/" + siteId + "/" + channelId, SendNew.ToJson(), ApiId); - BaseRepository() - .ExecuteBySql("insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson) VALUES (newid(),2222,'"+HttpUtility.UrlEncode(responses)+"') "); + BaseRepository().ExecuteBySql($"insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson,F_Module,F_OperateTime) VALUES (newid(),2222,'post cms响应结果:{HttpUtility.UrlEncode(responses)}','{newEntity.F_NewsId}','{DateTime.Now}') "); //#region 修改审核状态 //string Nid = JsonConvert.DeserializeObject(responses).value.id; @@ -287,8 +289,7 @@ namespace Learun.Application.OA } catch (Exception ex) { - BaseRepository() - .ExecuteBySql("insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson) VALUES (newid(),2222,'"+ex.Message + "') "); + BaseRepository().ExecuteBySql($"insert INTO LR_Base_Log(F_LogId,F_CategoryId,F_SourceContentJson,F_Module,F_OperateTime) VALUES (newid(),2222,'下发官网异常:{ex.Message}','{newEntity.F_NewsId}','{DateTime.Now}') "); } } @@ -298,10 +299,10 @@ namespace Learun.Application.OA return this.BaseRepository().FindList().Count(); } - public Dictionary GetNewMonthSum() + public Dictionary GetNewMonthSum() { var dt = new DateTime(DateTime.Now.Year, 1, 1); - var ls = this.BaseRepository().FindList(x=>x.F_CreateDate>=dt).Select(x => new { Year = x.F_CreateDate.Value.Year, Month = x.F_CreateDate.Value.Month }).GroupBy(x => new { x.Year, x.Month }).ToDictionary(x => x.Key.Month, a => a.Count()); + var ls = this.BaseRepository().FindList(x => x.F_CreateDate >= dt).Select(x => new { Year = x.F_CreateDate.Value.Year, Month = x.F_CreateDate.Value.Month }).GroupBy(x => new { x.Year, x.Month }).ToDictionary(x => x.Key.Month, a => a.Count()); return ls; } }