/// <summary> /// 删除所选通知 /// </summary> /// <param name="ids"></param> /// <param name="type"></param> /// <returns></returns> public static OpResult DeleteByIds(long[] ids) { var re = new OpResult(); try { List <Notice> noticeList = new List <Notice>(); foreach (var id in ids) { var notice = CurrentRepository.QueryEntity.FirstOrDefault(n => n.Id == id); if (notice != null) { noticeList.Add(notice); } } if (CurrentRepository.RemoveRange(noticeList, true)) { re.Successed = true; } #region 写入日志 string msg = "成功删除公告!"; var module = Pharos.Sys.LogModule.通知公告; if (re.Successed) { for (int i = 0; i < noticeList.Count(); i++) { var noticeTemp = noticeList[i]; var TypeName = (noticeTemp.Type == 1 ? "公告" : "活动"); msg += "<br />Id=" + noticeTemp.Id + ",<br />类型=" + TypeName + ",状态=" + Enum.GetName(typeof(NoticeState), noticeTemp.State) + ",主题=" + noticeTemp.Theme + ",开始日期=" + noticeTemp.BeginDate.ToString("yyyy-MM-dd") + ",截止日期=" + noticeTemp.ExpirationDate.ToString("yyyy-MM-dd") + "。"; log.WriteDelete(msg, module); msg = "成功删除公告!"; } } else { msg = "删除公告失败!"; log.WriteDelete(msg, module); } #endregion } catch (Exception ex) { re.Message = ex.Message; Log.WriteError(ex); } return(re); }