Update Happiness Task

This commit is contained in:
Chris Chen
2022-10-02 09:50:42 -07:00
parent b33c0d8286
commit f9a5dc5e34
43 changed files with 4904 additions and 623 deletions
+14 -6
View File
@@ -13,6 +13,7 @@ using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Processing;
using WebAPI.Logics;
using WebAPI.Logics.Interface;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@@ -24,19 +25,19 @@ namespace WebAPI.Controllers
public class BestController : ApiControllerBase<HappinessBEST>
{
private readonly ICrudLogic<HappinessBEST> logic;
private readonly ICrudLogic<HappinessGroup> groupLogic;
private readonly ICrudLogic<HappinessWeek> weekLogic;
private readonly PastoralDomainLogic cellGroupLogic;
public BestController(
ICrudLogic<HappinessBEST> logic,
ICrudLogic<HappinessGroup> groupLogic,
ICrudLogic<HappinessWeek> weekLogic
ICrudLogic<HappinessWeek> weekLogic,
PastoralDomainLogic cellGroupLogic
) : base(logic)
{
this.logic = logic;
this.groupLogic = groupLogic;
this.weekLogic = weekLogic;
this.cellGroupLogic = cellGroupLogic;
}
// GET api/<BestController>/5
@@ -49,8 +50,8 @@ namespace WebAPI.Controllers
{
return Task<HappinessBEST>.Run(() => {
var best = logic.GetById(id);
best.HappinessGroup = groupLogic.GetById(best.GroupId);
best.HappinessGroup.Weeks = weekLogic.GetAll(w => w.GroupId == best.GroupId).OrderBy(w=>w.SEQ).ToList();
best.HappinessGroup = cellGroupLogic.GetById(best.GroupId);
best.HappinessGroup.HappinessWeeks = weekLogic.GetAll(w => w.GroupId == best.GroupId).OrderBy(w=>w.SEQ).ToList();
return best;
});
}
@@ -91,6 +92,13 @@ namespace WebAPI.Controllers
return this.NotFound();
}
[HttpPost]
public int UpdateBestWeek(HappinessWeek week)
{
return weekLogic.CreateOrUpdate(week,out string id);
}
private Font arialFont;
[NonAction]
public Image Superimpose(string bestName, Image largeBmp, Image smallBmp, int? x = null, int? y = null)
@@ -18,12 +18,12 @@ namespace WebAPI.Controllers
[ApiController]
public class CellGroupRoutineEventsController : ApiControllerBase<CellGroupRoutineEvent>
{
private readonly CellGroupLogic logic;
private readonly PastoralDomainLogic logic;
private readonly ICombinedKeyCrudLogic<CellGroupRoutineEventPrayer> prayerLogic;
private readonly ICombinedKeyCrudLogic<CellGroupRoutineEventAttendee> dinnerLogic;
public CellGroupRoutineEventsController(
CellGroupLogic logic,
PastoralDomainLogic logic,
ICrudLogic<CellGroupRoutineEvent> crudLogic,
ICombinedKeyCrudLogic<CellGroupRoutineEventPrayer> prayerLogic,
ICombinedKeyCrudLogic<CellGroupRoutineEventAttendee> dinnerLogic
@@ -1,44 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Church.Net.DAL.EF;
using Church.Net.Entity;
using Church.Net.Utility;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using WebAPI.Logics;
using WebAPI.Logics.Interface;
namespace WebAPI.Controllers
{
[ApiController]
[Route("[controller]/[action]")]
public class HappinessGroupController : ApiControllerBase<HappinessGroup>
{
private readonly HappinessGroupLogic logic;
public HappinessGroupController(
ICrudLogic<HappinessGroup> crudLogic,
HappinessGroupLogic logic
):base(crudLogic)
{
this.logic = logic;
}
[HttpGet]
public override async Task<IEnumerable<HappinessGroup>> GetAll()
{
return await Task.Run(() => { return logic.GetAllGroups(); });
}
[HttpPost]
public virtual async Task<int> UpdateBestWeek(HappinessWeek entity)
{
return await Task.Run(() => {
return logic.UpdateWeekInfo(entity);
});
}
}
}
@@ -0,0 +1,23 @@
using Church.Net.Entity;
using Church.Net.Entity.Messenger;
using LineMessaging;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading.Tasks;
using WebAPI.Logics;
using WebAPI.Logics.Interface;
namespace WebAPI.Controllers
{
[Route("[controller]/[action]")]
[ApiController]
public class HappinessWeekTaskController : ApiControllerBase<HappinessTask>
{
public HappinessWeekTaskController(ICrudLogic<HappinessTask> logic) : base(logic)
{
}
}
}
+18 -13
View File
@@ -22,6 +22,8 @@ using System.Text;
using WebAPI.Services;
using Jint.Native;
using WebAPI.Services.Interfaces;
using Church.Net.DAL.EFCoreDBF.Migrations;
using Church.Net.DAL.EFCoreDBF;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace WebAPI.Controllers
@@ -33,15 +35,17 @@ namespace WebAPI.Controllers
{
private readonly LineAutoBotService lineAutoBotService;
private readonly ILoggingService loggingService;
private readonly ICrudDAL<LineMessagingAccount> crudDAL;
public LineMessageController(
LineAutoBotService lineAutoBotService,
ILoggingService loggingService
ILoggingService loggingService,
ICrudDAL<LineMessagingAccount> crudDAL
)
{
this.lineAutoBotService = lineAutoBotService;
this.loggingService = loggingService;
this.crudDAL = crudDAL;
}
//private ChurchNetContext dbContext = new ChurchNetContext();
//// GET: api/<BestController>
@@ -65,20 +69,21 @@ namespace WebAPI.Controllers
// POST api/<BestController>
[HttpPost]
//[Route("[controller]/[action]")]
//[Route("[controller]/[action]/{id?}")]
public async Task PostFromLine(string id, [FromBody] object jsonData)
public async Task PostFromLine(int seq, [FromBody] object jsonData)
{
//string txtPath = ServerUtils.MapPath("App_Data/LinePostRawLog.txt");
//System.IO.File.AppendAllText(txtPath, JsonConvert.SerializeObject(jsonData.ToString(), Formatting.Indented));
try
{
LineMessagingAccount lineAccount = crudDAL.GetAll(l => l.Seq == seq).FirstOrDefault();
if (lineAccount != null)
{
LineWebhookContent content = JsonConvert.DeserializeObject<LineWebhookContent>(jsonData.ToString());
LineWebhookContent content = JsonConvert.DeserializeObject<LineWebhookContent>(jsonData.ToString());
await lineAutoBotService.AutoReply(lineAccount,content);
}
//this.loggingService.Log("PostFromLine");
await lineAutoBotService.AutoReply(content);
}
catch (Exception ex)
{
@@ -104,11 +109,11 @@ namespace WebAPI.Controllers
}
[HttpGet]
public Task PushCommandMessage(string groupToken, string command)
{
return lineAutoBotService.PushCommandMessage(EnumHelper.GetEnumValueFromDescription<LineGroup>(groupToken), "#" + command);
}
//[HttpGet]
//public Task PushCommandMessage(string groupToken, string command)
//{
// return lineAutoBotService.PushCommandMessage(EnumHelper.GetEnumValueFromDescription<LineGroup>(groupToken), "#" + command);
//}
}
@@ -1,4 +1,5 @@
using Church.Net.Entity;
using Church.Net.Entity.Messenger;
using LineMessaging;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
@@ -32,4 +33,16 @@ namespace WebAPI.Controllers
}
}
}
[Route("[controller]/[action]")]
[ApiController]
public class LineClientController : ApiControllerBase<LineMessageClient>
{
public LineClientController(ICrudLogic<LineMessageClient> logic) : base(logic)
{
}
}
}
@@ -16,7 +16,7 @@ namespace WebAPI.Controllers
[ApiController]
public class PastoralDomainController : ApiControllerBase<PastoralDomain>
{
public PastoralDomainController(ICrudLogic<PastoralDomain> logic) : base(logic)
public PastoralDomainController(PastoralDomainLogic logic) : base(logic)
{
}
+5 -44
View File
@@ -16,6 +16,7 @@ using WebAPI.Logics;
using WebAPI.Services;
using static System.Net.Mime.MediaTypeNames;
using WebAPI.Services.Interfaces;
using WebAPI.Logics.Interface;
namespace WebAPI.Controllers
{
@@ -24,9 +25,12 @@ namespace WebAPI.Controllers
public class PingController : ControllerBase
{
private readonly IEnumerable<IAutoReplyCommand> autoReplyCommands;
private readonly PastoralDomainLogic pastoralDomainLogic;
private readonly LineAutoBotService lineAutoBotService;
public PingController(VideoDownloadLogic videoDownloadLogic,
IEnumerable<IAutoReplyCommand> autoReplyCommands)
IEnumerable<IAutoReplyCommand> autoReplyCommands
)
{
VideoDownloadLogic = videoDownloadLogic;
this.autoReplyCommands = autoReplyCommands;
@@ -129,41 +133,6 @@ namespace WebAPI.Controllers
}
[HttpGet]
public async void TestAutoReply(string command)
{
//\\ArkNAS\Church\WorshipVideo
//this.VideoDownloadLogic.Download(@"https://www.youtube.com/watch?v=K2bdSYim7uI", @"\\ArkNAS\home\Test.mp4");
if (!String.IsNullOrWhiteSpace(command))
{
string text = command;
var group = LineGroup.Chris;
var autoReply = autoReplyCommands.Where(ar => ar.SupportGroups.Contains(group) && ar.Commands.Contains(text)).FirstOrDefault();
if (autoReply != null)
{
if (autoReply.LineMessage != null)
{
ReplyLineMessage(group.EnumToDescriptionString(), autoReply.LineMessage);
}
else
{
// ReplyTextMessage(replyToken, autoReply.ReplyMessage);
}
return;
}
};
}
[HttpGet]
public string[] GetFiles(string path)
@@ -193,14 +162,6 @@ namespace WebAPI.Controllers
}
private async void ReplyLineMessage(string replyToken, IEnumerable<ILineMessage> lineMessages)
{
var test = new LineMessagingClient();
var replyMessage = new LinePushMessage() { To = replyToken };
replyMessage.Messages = lineMessages;
await test.PushMessage(replyMessage);
}
}
}