using System; using System.Collections.Generic; using System.Data.Entity.Core.Metadata.Edm; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Web; using System.Web.Http; using Common.Logging; using Learun.Application.Base.SystemModule; using Learun.Application.Organization; using Learun.Application.TwoDevelopment.ZZDT_EC; using Learun.Loger; using Learun.Util; using Learun.Util.Operat; using Learun.Util.SqlSugar; using log4net.Config; using Pipelines.Sockets.Unofficial.Arenas; namespace Learun.Application.Web.AppApi { /// /// 通知消息的接口(By YuXH) /// [RoutePrefix("api/NotificationApi")] [HandlerApiLogin(FilterMode.Ignore)] public class NotificationApiController : WebApiControllerBase { #region 图纸消息 /// /// 为图纸最新的一个检入记录发起通知 /// /// /// 用户之间逗号分开 /// /// [HttpGet] [HandlerApiLogin(FilterMode.Enforce)] public IHttpActionResult Add(string ProjectId, string Users, string DrawingID) { var synRecord = new ec_drawing_synBLL().GetList("{DrawingFileID:\"" + DrawingID + "\",ProjectId:\"" + ProjectId + "\"}"); var LatestSyn = synRecord.OrderByDescending(x => x.CreateTime).FirstOrDefault(); if (LatestSyn != null) { foreach (var userName in Users.Replace("|", ",").Replace(",", ",").Split(',')) { ec_notificationEntity ec_NotificationEntity = new ec_notificationEntity { SenderUserID = LoginUserInfo.Get().realName, RetrieveUserID = userName, DrawingSynID = LatestSyn.DrawingSynID, CheckFLG = 0 }; new ec_notificationBLL().SaveEntity("", ec_NotificationEntity, ProjectId); } } return Success("OK"); } /// /// 获取某一个用户所有的未读通知 /// /// /// 当前用户 /// 0接收到的信息,1发出去的信息 /// [HttpGet] [HandlerApiLogin(FilterMode.Ignore)] public IHttpActionResult GetUserAllNotification(string ProjectId, string User, int mode = 0) { if (mode == 0) { var res = new ec_notificationBLL().GetUserAllNotification(ProjectId, User); return Success(res); } else { var res = new ec_notificationBLL().GetUserSendOutNotification(ProjectId, User); return Success(res); } } /// /// 批量确认消息 /// /// /// 多个主键,逗号隔开 /// [HttpGet] [HandlerApiLogin(FilterMode.Enforce)] public IHttpActionResult ApproveNofity(string ProjectId, string IDs) { IDs = WebHelper.UrlDecode(IDs); new ec_notificationBLL().Approve(IDs, ProjectId); return Success("OK"); } #endregion #region 捡入消息(需要生产确认的) /// /// 获取所有图纸,需要生产确认的检入记录 /// /// 项目ID /// 图纸文件ID /// [HttpGet] public IHttpActionResult GetCheckInLogNeedApprove(string projectId) { try { string queryJson = "{\"IsProcess\":\"" + "1" + "\",\"ProjectId\":\"" + projectId + "\"}"; var listDrawingSyn = new ec_drawing_synBLL().GetList(queryJson); return Success(listDrawingSyn.GroupBy(x => x.DrawingFileID).ToList()); } catch (Exception ex) { return Fail(ex.Message); } } /// /// 批量确认捡入记录里需要生产主管确认的 /// /// /// 主管人的用户id /// DrawingSynID,逗号隔开 /// [HttpGet] [HandlerApiLogin(FilterMode.Enforce)] public IHttpActionResult ApproveCheckInLog(string ProjectId, string userId, string IDs) { var tbName = ProjectSugar.TableName(ProjectId); SqlSugarHelper.Db.Updateable().AS(tbName) .SetColumns(x => x.ApproveByAdmin == 1) .SetColumns(x => x.UpdateUserID == userId) .Where(x => IDs.Split(',').Contains(x.DrawingSynID)) .ExecuteCommand(); return Success("OK"); } #endregion } }