@@ -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<Root>(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<NewsEntity>().Count();
}
public Dictionary<int,int> GetNewMonthSum()
public Dictionary<int, int> GetNewMonthSum()
{
var dt = new DateTime(DateTime.Now.Year, 1, 1);
var ls = this.BaseRepository().FindList<NewsEntity>(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<NewsEntity>(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;
}
}