/// <summary> /// 调用 <see cref="CQ_PrivateMessage"/> 方法 /// </summary> /// <param name="appEvent">目标事件信息</param> /// <param name="subType">事件类型</param> /// <param name="fromQQ">来源QQ</param> /// <param name="msg">消息内容</param> /// <param name="font">字体指针</param> /// <exception cref="ObjectDisposedException">当前对象已经被释放</exception> /// <exception cref="MissingMethodException">尝试访问未公开的函数</exception> /// <returns>返回函数处理结果</returns> public HandleType InvokeCQPrivateMessage(AppEvent appEvent, PrivateMessageType subType, int msgId, long fromQQ, string msg, IntPtr font) { if (appEvent is null) { throw new ArgumentNullException(nameof(appEvent)); } if (msg is null) { throw new ArgumentNullException(nameof(msg)); } if (appEvent.Type != AppEventType.PrivateMessage) { throw new ArgumentException($"函数信息不是 {AppEventType.PrivateMessage} 类型", nameof(appEvent)); } GCHandle msgHandle = ((string)msg).GetGCHandle(_defaultEncoding); try { return((HandleType)this.GetFunction <CQ_PrivateMessage> (appEvent.Function) ((int)subType, msgId, fromQQ, msgHandle.AddrOfPinnedObject(), font.ToInt32())); } finally { msgHandle.Free(); } }
public void Delete(IList <int> ids, PrivateMessageType type) { Trace.Assert(Context.PersonId.HasValue); if (ids == null) { return; } using (var uow = Update()) { if (type == PrivateMessageType.Income) { DeleteIncomeMesssages(ids, uow); } if (type == PrivateMessageType.Sent) { DeleteSentMessages(ids, uow); } uow.Commit(); } }
public void Delete(IList <int> id, PrivateMessageType type) { throw new NotImplementedException(); }
public PaginatedList <PrivateMessage> GetMessages(int start, int count, bool?read, PrivateMessageType type, string role, string keyword, bool?classOnly, int?acadYear) { Trace.Assert(Context.PersonId.HasValue); Trace.Assert(Context.SchoolLocalId.HasValue); Trace.Assert(Context.SchoolYearId.HasValue); DateTime?fromDate = null; DateTime?toDate = null; if (acadYear.HasValue) { var schoolYears = ServiceLocator.SchoolYearService.GetSchoolYearsByAcadYear(acadYear.Value); if (schoolYears.Count == 0) { return(new PaginatedList <PrivateMessage>(new List <PrivateMessage>(), start / count, count)); } fromDate = schoolYears.Min(x => x.StartDate); toDate = schoolYears.Max(x => x.EndDate); } PrivateMessageSecurity.EnsureMessgingPermission(Context); using (var uow = Read()) { var da = new PrivateMessageDataAccess(uow); var roles = string.IsNullOrWhiteSpace(role) ? new List <string>() : role.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); var rolesIds = roles.Select(x => CoreRoles.GetByName(x).Id).ToList(); switch (type) { case PrivateMessageType.Income: var inMsg = da.GetIncomeMessages(Context.PersonId.Value, rolesIds, keyword, read, start, count, fromDate, toDate); return(new PaginatedList <PrivateMessage>(inMsg.Select(x => x), inMsg.PageIndex, inMsg.PageSize, inMsg.TotalCount)); case PrivateMessageType.Sent: var sentMsg = da.GetSentMessages(Context.PersonId.Value, rolesIds, keyword, start, count, classOnly, fromDate, toDate); return(new PaginatedList <PrivateMessage>(sentMsg.Select(x => x), sentMsg.PageIndex, sentMsg.PageSize, sentMsg.TotalCount)); default: throw new ChalkableException(ChlkResources.ERR_PRIVATE_MESSAGE_INVALID_TYPE); } } }
PaginatedList <PrivateMessage> IPrivateMessageService.GetMessages(int start, int count, bool?read, PrivateMessageType type, string role, string keyword, bool?classOnly, int?acadYear) { throw new NotImplementedException(); }