using PMS.BusinessModels.Account; using PMS.BusinessModels.Problem; using PMS.DBService.MessageManage; using PMS.Interface.MessageManage; using QWPlatform.IService; using QWPlatform.SystemLibrary; using QWPlatform.SystemLibrary.Utils; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using PMS.EntityModels.NoticeManager; using PMS.Plugins.Common; using PMS.Plugins.WeChart; using PMS.Plugins.PluginsModels; using PMS.BusinessModels.SMS; namespace PMS.BusinessService.MessageManag { public class MessageManageBLL: IMessageManage { private MessageManageServe Message_Service = DataServiceBase.Instance(); public bool AddMessage(MessageManageModel model,UserInfo user,string ID) { if(user.PersonProperty!=1) { return Message_Service.AddMessageByQD(model, user,ID); } return Message_Service.AddMessageByBB(model,ID); } public bool DeleteMessage(MessageManageModel model) { return Message_Service.DeleteMessage(model); } public string SelecteMessageById(string id) { return Message_Service.SelecteMessageById(id).ToJson(); } //公告信息绑定 public string DataBind(int page, int rows, string query,UserInfo user) { int defaultrow = 10; int startnumber = Startnumber(page, rows, defaultrow); int endnumber = Endnumbers(page, rows, defaultrow); return Message_Service.DataBind(startnumber,endnumber,query, user); } public string GetHome(UserInfo user) { return Message_Service.GetHome(user).ToJson(); } //首页获取公告列表 public string HomeGetList(int page, int rows, UserInfo user) { var total = 0; var dt = Message_Service.HomeGetList(page, rows, user, out total); return QWPlatform.SystemLibrary.Utils.Strings.ObjectToJson( new { total = total, rows = dt }); } //首页获取通知列表 public string HomeGetNotice(int page, int rows, UserInfo user) { var total = 0; var dt = Message_Service.HomeGetNotice(page, rows, user, out total); return QWPlatform.SystemLibrary.Utils.Strings.ObjectToJson( new { total = total, rows = dt }); } //结束行 private int Endnumbers(int page, int row, int defaultrow) { if (page == 0 && row == 0) { row = defaultrow; page = 1; } return (page) * row; } //起始行 private int Startnumber(int page, int row, int defaultrow) { if (page == 0 && row == 0) { row = defaultrow; page = 1; } return (page - 1) * row + 1; } /// /// 通知类型 /// /// public string NoticeType() { return Message_Service.NoticeType().ToJson(); } /// /// 通知优先级 /// /// public string NoticeOrder() { return Message_Service.NoticeOrder().ToJson(); } /// /// 通知对象 /// /// public string NoticePerson(int PersonProperty) { return Message_Service.NoticePerson(PersonProperty).ToJson(); } /// /// 根据ID获取通知信息 /// /// /// /// public string GetNoticeByID(string id) { return Message_Service.GetNoticeByID(id).ToJson(); } /// /// 根据公告ID获取通知对象 /// /// /// /// public string GetNatureByID(string id) { return Message_Service.GetNatureByID(id).ToJson(); } /// /// 修改操作 /// /// /// public bool Edit_Notice(MessageManageModel model) { return Message_Service.Edit_Notice(model)!=0; } /// /// 获取渠道 /// /// /// public string GetChannelByNature(UserInfo user) { return Message_Service.GetChannelByNature(user).ToJson(); } public string ShowNotice(UserInfo user) { return Message_Service.ShowNotice(user).ToJson(); } /// /// 显示总部和渠道的最新公告通知 /// /// /// public string GetMessageOnIndex(UserInfo user) { return Message_Service.GetMessageOnIndexChannel(user).ToJson(); } /// /// 查询通知数量 /// /// /// public int GetCount(UserInfo user) { return Message_Service.GetCount(user); } /// /// 判断是否显示 /// /// /// public Mssage_config PanDuanIsShow(UserInfo userInfo) { return Message_Service.PanDuanIsShow(userInfo); } //保存单个公告显示配置 public bool SaveNoticeConfig(string PersonId, string NoticeId, bool IsOpen) { return Message_Service.SaveNoticeConfig(PersonId, NoticeId, IsOpen); } //是否启用 public int NoticeStatus(string id) { return Message_Service.NoticeStatus(id); } public int AppNoticeStatus(string id) { return Message_Service.AppNoticeStatus(id); } /// /// APP公告获取 /// public string APPDataBind(int page, int rows) { var total = 0; int startnumber = Startnumber(page, rows,10); int endnumber = Endnumbers(page, rows,10); DataTable dt= Message_Service.APPDataBind(startnumber, endnumber,out total); return Strings.ObjectToJson(new { total = total, rows = dt, }); } public string Add_AppPush(AppPush_Model model) { return Message_Service.Add_AppPush(model); } /// /// 修改App图片公告 /// /// public int Edit_AppNotice(AppPush_Model model) { return Message_Service.Edit_AppImg(model); } public int Del_AppNotice(string id) { return Message_Service.Del_AppNotice(id); } //获取启用的app公告 public string GetWorkNotice() { return Message_Service.GetWorkNotice().ToJson(); } public string GetWorkNotiveById(string id) { return Message_Service.GetWorkNotiveById(id).ToJson(); } public int Edit_NoticeFJ(string v, string ID) { return Message_Service.Edit_NoticeFJ(v,ID); } public int DeleteFJ(string id) { return Message_Service.DeleteFJ(id); } public string ConvertWeChatTemp(int type, string TemplateID, Dictionary TempParame, string sign_name) { return Message_Service.ConvertWeChatTemp(type, TemplateID, TempParame, sign_name); } /// /// 发送微信消息 /// /// /// public string SendWeChartTempletMessge(NotificationDto notificationDto) { string strReturn = string.Empty; try { foreach (var items in notificationDto.record_items) { WxMessgPush wxMessgPush = new WxMessgPush(); wxMessgPush.wx_openid = items.接收人id; wxMessgPush.url = notificationDto.url; wxMessgPush.template_id = notificationDto.template_code; wxMessgPush.data = notificationDto.template_value; strReturn = WeChartMessage.SendWeChartTempletMessge(wxMessgPush); } } catch (Exception ex) { strReturn = ex.Message; } return strReturn; } } }